akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll dp [50*50+1][51];
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int N, A; cin >> N >> A;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	sort(arr.begin(), arr.end());
	dp[arr[0]][1] = 1;
	dp[0][0] = 1;

	FOR(i, 1, N) {
		R0F(c, N) {
			R0F(s, 50 * 50 + 1) {
				// if (s + arr[i] == 24) print("ADDING", i, c, dp[s][c]);
				if (s + arr[i] <= 50 * 50) dp[s + arr[i]][c+1] += dp[s][c];
			}
		}
	}

	ll ans = 0;
	FOR(i, 1, N+1) {
		// print(i, dp[A*i][i]);
		ans += dp[A*i][i];
	}
	print(ans);
	// print(dp[24-9]);
	// print(dp[24]);
}

Measured memory_bytes: 1280
# include <bits/stdc++.h>
# include <atcoder/all>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

int main() {
    ll K; cin >> K;
    rep(i, K) cout << "ACL";
    cout << endl;
}


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

int main(){
  int N,A;
  cin >> N;
  A=N%10;
  if(A==3){
    cout << "bon" << endl;
  }
  else if(A==0 || A==1 || A==6 || A==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}
  

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <queue>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

bool voyage(vector<vector<int>> boat, int N) {
  std::queue<int> q;

  rep(i, boat[0].size()) {
    q.push(boat[0][i]);
  }

  while(q.size() > 0) {
    int now = q.front();
    q.pop();

    rep(j, boat[now].size()) {
      if (boat[now][j] == N-1) return true;
    }
  }

  return false;
}

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> boat(N);
  int a, b;
  rep(i, M) {
    cin >> a >> b;
    a--;
    b--;
    boat[a].push_back(b);
    boat[b].push_back(a);
  }

  bool ok = voyage(boat, N);
  if (ok) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}


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

int main(void) {
	long long n, a, b, c, d, e;
	long long tran[7] = { 0 };
	long long min=LLONG_MAX;
	scanf("%lld %lld %lld %lld %lld %lld", 
		&n,&tran[1], &tran[2], &tran[3], &tran[4], &tran[5]);
	
	for (int i = 1; i <= 5; i++) {
		if (min > tran[i])min = tran[i];
	}
	long long ans = 4 + (long long)ceil((long double)n / (long double)min);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long lcm = 1;
		for (int i = 0; i < n; i++) {
			lcm = lcm(lcm, a[i] / 2);
			if (lcm > m) {
				System.out.println(0);
				return;
			}
		}

		for (int i = 0; i < n; i++) {
			if (lcm % a[i] == 0) {
				System.out.println(0);
				return;
			}
		}
		System.out.println(m / lcm - m / 2 / lcm);
	}

	static long lcm(long a, long b) {
		BigInteger ba = BigInteger.valueOf(a);
		BigInteger bb = BigInteger.valueOf(b);
		return ba.multiply(bb).divide(ba.gcd(bb)).longValue();
	}
}


Measured memory_bytes: 59540
n = gets.to_i
a = gets.split.map(&:to_i)
c = Array.new(100010, 0)
geta = 1
a.each do |x|
    c[x+geta] += 1
    c[x-1+geta] += 1
    c[x + 1+geta] += 1
end

ans = 0
100010.times do |i|
    ans = [ans, c[i]].max
end
p ans

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll a;
  cin>>a;
  cout<<(a+a*a+a*a*a)<<endl;

}

Measured memory_bytes: 3592
#include <stdio.h>
int main(void)
{
    int i,x,y;
    for(i=1;i<=3000;i++)
    {
        scanf("%d%d",&x,&y);
        if(x>=0&&x<=10000&&y>=0&&y<=10000)
        {
        if(x==0&&y==0)
        {
            break;
        }
        }
            if(x<=y)
            {
                printf("%d %d\n",x,y);
            }
            else if(x>=y)
            {
                printf("%d %d\n",y,x);
            }
    }
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fcout cout << fixed << setprecision(10)

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

  double R; cin >> R;
  
  fcout << (2.0 * R * 3.14159265358) << '\n';
  return 0;
}

Measured memory_bytes: 3804
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();

        Console.WriteLine(3*N*N);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
int main() { 
	cin >> N;
	string ans = "";
	ll M = N;
	ll C = 0;
	M = N - 1;
	if (N == 1) {
		cout << 'a';
		exit(0);
	}
	while (M > 0) {
		M /= pow(26, C+1);
		C++;
		if (M > 0) {
			N -= pow(26, C);
			M = N - 1;
			if (M == 0) {
				C++;
				break;
			}
		}
	}
	N--;
	while (C>0) {
		char key = 'a' + (N % 26);
		ans += key;
		N /= 26;
		C--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 2000;
  rep(i, s.size()-t.size()+1) {
    int x = 0;
    rep(j, t.size()) {
      if (s.at(i+j) != t.at(j)) x++;
    }
    if (ans > x) ans = x;
  }
  cout << ans << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
double dd,cc;
ll A[101010];
ll i, j, k,l;
vector<pll> cbv;
ll ans;


int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    sort(A, A + N);
    fornum(i,0,M){
        ll b, c;
        scanf("%lld%lld", &b, &c);
        cbv.push_back({c, b});
    }
    sort(cbv.begin(), cbv.end(),greater<pll>());
    j = 0;
    fornum(i,0,M){
        ll b = cbv[i].second;
        ll c = cbv[i].first;
        while(b>0&&j<N&&A[j]<c){
            A[j++] = c;
            b--;
        }
    }
    fornum(i,0,N){
        ans += A[i];
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3188
/* ****_hela**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,k;
		cin>>n>>k;
		cout<<min(n%k,abs(k-(n%k)));		
	}
	return 0;
}

Measured memory_bytes: 256
n,y = map(int, input().split())
for a in range(n+1):
  for b in range(n+1-a):
    if a*10000+b*5000+(n-a-b)*1000==y:
      print(str(a)+" "+str(b)+" "+ str(n-a-b))
      exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N, A, B; cin >> N >> A >> B;
	if (abs(A - B) % 2 == 0)cout << "Alice" << endl;
	else cout << "Borys" << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < N-1; i++) {
    if (p[i-1] < p[i] && p[i] < p[i+1]) ans++;
    else if (p[i-1] > p[i] && p[i] > p[i+1]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N;
	cin >> N;

	int ans = 0;
	for (int n = 1; n <= N; ++n){
		if (n%2==0) continue;
		int cnt = 0;
	    for (ll ii = 1; ii*ii <= n; ++ii){
	        if (n % ii == 0){
	        	cnt++;
	            if (n / ii != ii){
	            	cnt++;
	            }
	        }
	    }
	    if (cnt == 8){
	    	ans++;
	    }
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int64_t X;
  cin >> X;
  int cnt1 = 0;
  int cnt2 = 0;
  if (X >= 500) {
    cnt1 = X/500;
    X = X - cnt1 * 500;
  }
  cnt2 = X/5;
  int64_t res = 1000 * cnt1 + 5 * cnt2;
  cout << res << endl;


  return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

    vector<int> x(N),y(N),h(N);
    rep(i,0,N) cin >> x[i] >> y[i] >> h[i];
    
    vector<int> hs;
    rep(i,-400,400) hs.push_back(h[0]+i);

    rep(cx,0,101) rep(cy,0,101) for(int ch:hs){
        bool valid=true;
        rep(i,0,N){
            if(max(ch-abs(x[i]-cx)-abs(y[i]-cy),(i64)0)!=h[i]){
                valid=false;
                break;
            }
        }
        if(valid){
            cout << cx << " " << cy << " " << ch << endl;
            return;
        }
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using ll = long long;

using namespace std;
#define int ll

// 0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
// a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
// a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
// a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)                                                              \
	sort(all(v));                                                              \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x)                                                           \
	type x;                                                                    \
	cin >> x
#define YES(f)                                                                 \
	if ((f)) {                                                                 \
		cout << "YES" << endl;                                                 \
	} else {                                                                   \
		cout << "NO" << endl;                                                  \
	}
#define Yes(f)                                                                 \
	if ((f)) {                                                                 \
		cout << "Yes" << endl;                                                 \
	} else {                                                                   \
		cout << "No" << endl;                                                  \
	}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define P(x) ((x) * (x))

signed main()
{
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	fcout << sqrt(P(a - c) + P(b - d)) << endl;
}



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

int main(){
    int r,c,a[101][101];
    cin >> r >> c ;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> a[i][j] ;
        }
    }
    for(int i=0;i<=r;i++)a[i][c]=0;
    for(int j=0;j<=c;j++)a[r][j]=0;
    
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][c]+=a[i][j];
        }
    }
    
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j)cout << " ";
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
//290 C div 2
//https://codeforces.com/problemset/problem/510/C
using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,b) for(int i=0;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 10005
#define input(v) for(int i=0;i<n;i++) cin>>v[i];
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
int mod=1e9+7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

//variables
int n;


int32_t main() {
    faster;

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

    double ans=(double)sum/(double)(m*4);

    sort(a,a+n,greater<int>());
    for(int i=0;i<m;i++){
        if(a[i]>=ans){
            continue;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int n;
	string s;
	cin>>n;
	cin>>s;
	int ans = 0;
	rep(i,n-1){
		bool aru[26];
		rep(j,26){
			aru[j] = false;
		}
		rep(j,i+1){
			aru[s[j]-'a'] = true;
		}
		int memo=0;
		for(int j=i+1; j<n;j++){
			if(aru[s[j]-'a']){
				memo++;
				aru[s[j] - 'a'] = false;
			}
		}
		ans=max(ans,memo);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define endl ("\n")
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,s,n)        for(int i=s;i<n;i++)
int si= 2000005;
void io()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

}
int dp[200005];
int a[200005];
int abc(int n)
{
    dp[1]=abs(a[1]-a[0]);
    dp[2]=min(abs(a[0]-a[2]),dp[1]+abs(a[2]-a[1]));
    for(int i=3;i<n;i++)
    {
             dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
    }
    return dp[n-1];
}
void solve()
{
  int n;
  cin>>n;
  f(i,0,n)
  cin>>a[i];
  memset(dp,0,sizeof(dp));
  cout<<abc(n)<<endl;
}
int32_t main()
{
    io();
    solve();
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int n_change = 0;

    for (int i=0; i<S.length()/2; i++) {
        if (S[i] != S[S.length()-1-i]) {
            n_change += 1;
        }
    }
    cout << n_change << endl;

    return(0);
}


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

int main(){

    int n,ans;

    string a,b;
    cin >> a >> b;
    n = a.size();
    ans = n;

    for(int i = 0; i < n; i++){
        if(a.at(i) == b.at(i))ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3860
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# [a, b].min が遅いので
def min(a, b)
  return a < b ? a : b
end

# [a, b].max が遅いので
def max(a, b)
  return a > b ? a : b
end

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i).sort
end
N, l_list = gets_n_and_i_list

total = 0
1.upto(N-1) do |i|
  a = l_list[i]
  k = i + 1
  num = 0
  i.times do |j|
    b = l_list[j]
    while k < N
      c = l_list[k]
      if c < a + b
        num += 1
      else
        break
      end
      k += 1
    end
    total += num
  end
end

puts total

Measured memory_bytes: 2172
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val AB = Array.fill(N)(sc.nextLong, sc.nextLong)
      .map(ab => (ab._1, ab._2, ab._1 + ab._2))
      .sortBy(_._3).reverse

    val Asum = (for (i <- 0 until N by 2) yield AB(i)._1).sum
    val Bsum = (for (i <- 1 until N by 2) yield AB(i)._2).sum
    (Asum - Bsum).toString
  }
}


Measured memory_bytes: 82096
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;



int main()
{
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n-1]<<endl;
	for (int i = 1; i <= n - 1; i++) {
		int v = a[i];
		int j = i-1;
		while (j >= 0 && a[j]>v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int i = 0; i < n-1; i++) {
			cout << a[i] << " ";
		}
		cout << a[n-1]<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
    int K,i,j;
    char S[100];
    scanf("%d\n",&K);
    scanf("%s",S);
    for(i=0;S[i]!='\0';i++);
    if(K>=i){
       printf("%s\n",S);
    }else{
        for(j=0;j<K;j++){
            printf("%c",S[j]);
        }
        printf("...\n");
    }

    return 0;
}

Measured memory_bytes: 1640
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string x; cin >> x;
	int q; cin >> q;
	using P = pair<int, int>;
	enum { LEFT, RIGHT };
	//??£?¶?????????????????????????
	set<P> st; //??????, ?????? ??????
	/*

	a < l <= b <= r < c

	x: 1
	b ??????????????????
	a ????????????????????? (l, LEFT) ????????\
	c ????????????????????? (r, RIGHT) ????????\

	x: 0
	b ??????????????????
	a ????????????????????? (l, RIGHT) ????????\
	c ????????????????????? (r, LEFT) ????????\

	*/
	if (x.front() == '1')st.emplace(0, LEFT);
	rep(i, 1, n) {
		if (x[i - 1] == x[i])continue;
		st.emplace(i, x[i] == '0');
	}
	if (x.back() == '1')st.emplace(n, RIGHT);
	dump(st);
	rep(i, 0, q) {
		int l, r, b; cin >> l >> r >> b; l--;
		P pl(l, LEFT), pr(r, RIGHT);
		while (true) {
			auto p = st.lower_bound(pl);
			if (p == st.end())
				break;
			if (*p <= pr)
				st.erase(p);
			else
				break;
		}
		if (b == 1) {
			auto a = st.lower_bound(pl);
			if (a != st.begin()) {
				a--;
				if ((*a).second == RIGHT)
					st.emplace(l, LEFT);
			}
			else {
				st.emplace(l, LEFT);
			}
			auto b = st.upper_bound(pr);
			if (b != st.end()) {
				if ((*b).second == LEFT)
					st.emplace(r, RIGHT);
			}
			else {
				st.emplace(r, RIGHT);
			}
		}
		else {
			auto a = st.lower_bound(pl);
			if (a != st.begin()) {
				a--;
				if ((*a).second == LEFT)
					st.emplace(l, RIGHT);
			}
			auto b = st.upper_bound(pr);
			if (b != st.end()) {
				if ((*b).second == RIGHT)
					st.emplace(r, LEFT);
			}
		}
		dump(st);
		cout << st.size() / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 5576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int X;
		Scanner sc = new Scanner(System.in);
		X = Integer.parseInt(sc.next());
		int mod = 0;
		int c_500 = X / 500;
		mod = X % 500;
		int c_5 = mod / 5;
		System.out.println(c_500 * 1000 + c_5 * 5);

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     100000007
#define PI                      2*acos(0.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     100005

using namespace std;

int main()
{
//    READ;
//    WRITE;
    int a,b;
    scanf("%d %d",&a,&b);
    if(b*2>=a)cout<<0<<endl;
    else
    {
        cout<<(a-b*2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a;
    cin >> a;
    n -= a;
  }
  if (n >= 0) cout << n << endl;
  else cout << -1 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int h, w;
  cin >> h >> w;
  string s[h + 1];

  rep(i, h) cin >> s[i];
  if (h == w && h == 1) {
    puts("No");
    return 0;
  }

  rep(i, h) rep(j, w) {
    if (s[i][j] == '#')
      if (!((j - 1 >= 0 && s[i][j - 1] == '#') ||
            (j + 1 <= w && s[i][j + 1] == '#') ||
            (i - 1 >= 0 && s[i - 1][j] == '#') ||
            (i + 1 <= h && s[i + 1][j] == '#'))) {
        puts("No");
        return 0;
      }
  }
  puts("Yes");
  return 0;
}


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

const int mod=1000000007;
int n,f[1<<16|3],m,ans,jc[1<<16|3],inv[1<<16|3],a[21];

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int C(int a,int b) {return 1ll*jc[a]*inv[b]%mod*inv[a-b]%mod;}

int main()
{
	scanf("%d%d",&n,&m),jc[0]=1;
	for (int i=1; i<=(1<<n); i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[1<<n]=quickmi(jc[1<<n],mod-2);
	for (int i=(1<<n); i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	for (int i=1; i<=m; i++) scanf("%d",&a[i]);
	sort(a+1,a+1+m),f[0]=1;
	for (int i=m; i; i--)
		for (int j=(1<<n)-2; j>=0; j--)
		{
			int nw=0;
			for (int k=0; k<n; k++) if (j>>k&1) nw+=(1<<k);
			for (int k=0; k<n; k++)
				if (!(j>>k&1)&&(1<<k)+nw<=(1<<n)-a[i]+1) 
					f[j|(1<<k)]=(f[j|(1<<k)]+1ll*f[j]*C((1<<n)-a[i]-nw,(1<<k)-1)%mod*jc[1<<k])%mod;
		}
	ans=jc[(1<<n)-1];
	for (int i=1; i<(1<<n); i++)
	{
		int nw=0,cnt=0;
		for (int j=0; j<n; j++) if (i>>j&1) nw+=(1<<j),cnt++;
		if (cnt&1) ans=(ans+1ll*jc[(1<<n)-1-nw]*(mod-f[i]))%mod;
		else ans=(ans+1ll*jc[(1<<n)-1-nw]*f[i])%mod;
	}
	printf("%d\n",(1ll<<n)*ans%mod);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
LL A[100005]={};
int main()
{
int a;
while(cin>>a){
    for(int i=0;i<a;i++){
        cin>>A[i];
    }
    sort(A,A+a);
    int ans=a;
    LL now=0;
    int l=0;
    for(int r=0;r<a-1;r++){
   now+=A[r];
   if(now*2<A[r+1]){
    ans-=(r-l+1);
    l=r+1;
   }
    }
    cout<<ans<<endl;
}

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;

int main(){
	IOS;
	ll a, b;
	cin >> a >> b;
	cout << a * b ;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */
int main(){
	int N,Q;
	cin >> N >> Q;
	vector<pair<int,PII> >Event;
	REP(i,N){
	    int s,t,x;
	    cin >> s >> t >> x;
	    Event.PB(MP(s-x,MP(1,x)));
		Event.PB(MP(t-x,MP(-1,x)));
	}

	Event.PB(MP(1e9,MP(0,0)));
	sort(ALL(Event));

	set<int> ng;
	vector<int> Que;

	REP(i,Q){
	    int q; cin >> q;
	    Que.PB(q);
	}

	int stindex = 0;
	int q = 0;

	while(q < Q){
		int now = Que[q];
		if (now < Event[stindex].fst){
			if (ng.empty()){
				Que[q] = -1;
				q++;
				continue;
			}
			auto it = ng.begin();
			Que[q] = *it;
			q++;
		}else{
			if (Event[stindex].snd.fst == 1){
				ng.insert(Event[stindex].snd.snd);
			}else{
				ng.erase(Event[stindex].snd.snd);
			}
			stindex++;
		}

	}

	REP(i,Q){
	    cout << Que[i] << "\n";
	}





}

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

int main() {
    int k,s;
    cin >> k >> s;
    int counter=0;
    for(int x=0; x <= k; x++){
        for(int y=0; y <= k; y++){
            int z = s - x - y;
            if(0 <= z && z <= k){
                counter++;
            }
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

N,p=map(int, input().split(" "))
tmp=prime_factors(p)

d={}
count=1
#result=[]
if N==1:
    print(p)
else:
    for i in tmp:
        if i in d:
            if d[i]==N-1:
                d[i]=0
                #result.append(i)
                count*=i
            else:
                d[i]+=1
        else:
            d[i]=1
    print(count)


Measured memory_bytes: 3064
require 'date'
s1, s2, s3= gets.split('/')
d = Date.new(s1.to_i, s2.to_i, s3.to_i)

sakaime = Date.new(2019, 4, 30)

if d > sakaime
  puts 'TBD'
else
  puts 'Heisei'
end


Measured memory_bytes: 2040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int h, w;
        String input[] = new String[2];
        while (true) {
            try {
                input = br.readLine().split(" ");
                if (input[0].equals("0") && input[1].equals("0"))
                    return;
                h = Integer.parseInt(input[0]);
                w = Integer.parseInt(input[1]);

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if ((i + j) % 2 == 0)
                            sb.append("#");
                        else
                            sb.append(".");
                    }
                    sb.append("\n");
                }
                System.out.println(sb.toString());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}


Measured memory_bytes: 25660
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
long long int a[200010];
long long int sum[200010];
long long int n,i;
long long int ans;
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum[a[i]]++;
	}
     for(i=1;i<=n;i++)
     {
		if(sum[i])
		{
			ans+=(sum[i])*(sum[i]-1)/2;
		}
     }
	for(i=1;i<=n;i++)
	{
		printf("%lld\n",ans-sum[a[i]]+1);	
	}
    
} 

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

int main(void)
{
	long long x;

	while (EOF!= scanf("%lld", &x)){
		long long fh= x/500;
		long long f= (x%500)/5;

		printf("%lld\n", fh*1000+5*f);
	}
	return 0;
}

Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

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

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e5 + 5;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
}

void solve()
{
    std::sort(A + 1, A + N + 1);

    int v = 0;
    for (int i = 1; i < N; ++i) {
        int d = N - i;
        if (A[i] - d - 1 >= 0) {
            puts(((A[i] - d - 1) & 1) ^ v ? "First" : "Second");
            return;
        }
        if (v == 0 && !((A[i + 1] - A[i]) & 1) && A[i] == d) {
            puts("First");
            return;
        }
        v = (A[i] == A[i + 1] ? v ^ 1 : 0);
    }
    puts(((A[N] - 1) & 1) ^ v ? "First" : "Second");
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 搴帷拜母河梁去，白发愁看泪眼枯。
//     -- 黄景仁《别老母》


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
 
int main()
{
    int i=0 ,j=0 ;
    int lens=0 ,lenp=0 ;
    int flg=0 ;
    char mem='\0' ;
    char s[101] = {0} ;
    char p[101] = {0} ;
 
    scanf("%s %s",s ,p) ;
 
    lens=strlen(s) ;
    lenp=strlen(p) ;
    for (i=0 ;i<lens ;i++)
    {
        if (strncmp(s ,p ,lenp) == 0)
        {
            flg++ ;
            break ;
        }
        else
        {
            mem=s[0] ;
            for (j=0 ;j<lens ;j++)
            {
                s[j]=s[j+1] ;
            }
            s[lens-1]=mem ;
        }
    }
 
    if (flg)
    {
        printf("Yes\n") ;
    }
    else
    {
        printf("No\n") ;
    }
 
    return 0;
}

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

int n,m,r=0;
vector<vector<int>> path1;
vector<vector<int>> path2;

void cal(int b,vector<int> count){
    count.push_back(b);
    for(int i=0;i<path1.at(b).size();i++){
        for(int j=0;j<count.size();j++){
            if (count.at(j) == path1.at(b).at(i)){
                goto label;
            }
        }
        cal(path1.at(b).at(i), count);
        label:;
    }
    for(int i=0;i<path2.at(b).size();i++){
        for(int j=0;j<count.size();j++){
            if (count.at(j) == path2.at(b).at(i)){
                goto label2;
            }
        }
        cal(path2.at(b).at(i), count);
        label2:;
    }

    if (count.size() == n){
        r++;
        return;
    }
    return;
}

int main() {
    cin >> n >> m;
    path1.resize(n);
    path2.resize(n);
    vector<vector<int>> path_tmp(m);
    for(int i=0;i<m;i++){
        for(int j=0;j<2;j++){
            int tmp;
            cin >> tmp;
            path_tmp.at(i).push_back(tmp-1);
        }
    }

    for(int i=0;i<m;i++){
        path1.at(path_tmp.at(i).at(0)).push_back(path_tmp.at(i).at(1));
        path2.at(path_tmp.at(i).at(1)).push_back(path_tmp.at(i).at(0));
    }

    vector<int> count;
    cal(0,count);
    printf("%d\n",r);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        long numOfT = 1;
        long numOfA = 1;
        for (int i = 0; i < n; i++) {
            long t = sc.nextLong();
            long a = sc.nextLong();

            long xt = numOfT % t == 0 ? numOfT / t : numOfT / t + 1;
            long xa = numOfA % a == 0 ? numOfA / a : numOfA / a + 1;
            long x = Math.max(xt, xa);
            numOfT = t * x;
            numOfA = a * x;
        }
        System.out.println(numOfT + numOfA);
    }
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n - 1];
    for (int &i : a)
        cin >> i;
    int sub[n + 1] = {};
    for (int i : a)
        sub[i]++;
    for (int i = 1; i <= n; i++)
        cout << sub[i] << endl;
}

Measured memory_bytes: 5188
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
int main()
{
	char s[100000];
	cin>>s;
	int len;
	len=strlen(s);
	for(int i=0;i<len;i+=2)
	{
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int K;
	cin >> K;
	string s = "1";
	while(--K){
		if(s == string(s.size(),'9')){
			s = '1' + string(s.size(),'0');
		}else{
			int idx = s.size() - 1;
			RREP(i,s.size() - 1){
				if(s[i + 1] - s[i] != 1 && !(s[i + 1] == '9' && s[i] == '9'))break;
				--idx;
			}
			++s[idx];
			FOR(i,idx + 1,s.size()){
				s[i] = max('0',char(s[i - 1] - 1));
			}
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

long a[100000] = {};

int main()
{
	long n;
	long x = 0, y = 0, z = 0;
	scanf("%ld", &n);
	for (long i = 0; i < n; i++)
	{
		scanf("%ld", &a[i]);
	}
	for (long i = 0; i < n; i++)
	{
		if (a[i] % 4 == 0)
		{
			x++;
		}
		else if (a[i] % 2 == 0)
		{
			y = 1;
		}
		else
		{
			z++;
		}
	}
	if ((x + 1) >= (z + y))
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 896