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

using namespace std;

#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)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	vector<int> r(n + 1), g(n + 1), b(n + 1);
	rep (i, n) {
	  if (s[i] == 'R') r[i]++;
	  else if (s[i] == 'G') g[i]++;
	  else b[i]++;
	}
	rep (i, n) {
	  r[i + 1] += r[i];
	  g[i + 1] += g[i];
	  b[i + 1] += b[i];
	}
	
	ll res = 0;
	rep (i, n) {
	  FOR (j, i + 1, n) {
		if (s[i] == s[j]) continue;
		int k = 2 * j - i;
		if (s[i] == 'R') {
		  if (s[j] == 'G') {
			res += b[n] - b[j];
			if (k < n && s[k] == 'B') res--;
		  } else if (s[j] == 'B') {
			res += g[n] - g[j];
			if (k < n && s[k] == 'G') res--;
		  }
		} else if (s[i] == 'G') {
		  if (s[j] == 'B') {
			res += r[n] - r[j];
			if (k < n && s[k] == 'R') res--;
		  } else if (s[j] == 'R') {
			res += b[n] - b[j];
			if (k < n && s[k] == 'B') res--;
		  }
		} else {
		  if (s[j] == 'G') {
			res += r[n] - r[j];
			if (k < n && s[k] == 'R') res--;
		  } else if (s[j] == 'R') {
			res += g[n] - g[j];
			if (k < n && s[k] == 'G') res--;
		  }
		}
	  }
	}
	cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3716
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=500005,md=1000000007;
struct node
{
	int k,b;
}a[N];
struct mode
{
	int id,num;
}b[N];
struct ode
{
	int lt,rt;
}c[N];
int n,i,j,k,l,mx[N*5],mn[N*5],sum[N*5],lt[N],rt[N],x,y,ans;
inline void Read(int &x)
{
	char c;
	int t=1;
	while(((c=getchar())<'0'||c>'9')&&c!='-');
	if(c=='-')
		x=0,t=-1;
	else
		x=c-'0';
	while((c=getchar())>='0'&&c<='9')
		x=x*10+c-'0';
	x*=t;
}
bool cmp(node a,node b)
{
	if(a.k!=b.k)
		return a.k<b.k;
	return a.b<b.b;
}
bool cmq(mode a,mode b)
{
	return a.num<b.num;
}
bool cmr(ode a,ode b)
{
	if(a.rt!=b.rt)
	return a.rt<b.rt;
	return a.lt<b.lt;
}
void update1(int o,int l,int r)
{
	if(l==r)
	{
		mn[o]=min(mn[o],y);
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)
		update1(o<<1,l,mid);
	else
		update1(o<<1|1,mid+1,r);
	mn[o]=min(mn[o<<1],mn[o<<1|1]);
}
int query1(int o,int l,int r)
{
	if(l>=x&&r<=y)
		return mn[o];
	int mid=l+r>>1,rtn=1<<30;
	if(x<=mid)
		rtn=query1(o<<1,l,mid);
	if(y>mid)
		rtn=min(rtn,query1(o<<1|1,mid+1,r));
	return rtn;
}
void update2(int o,int l,int r)
{
	if(l==r)
	{
		mx[o]=max(mx[o],y);
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)
		update2(o<<1,l,mid);
	else
		update2(o<<1|1,mid+1,r);
	mx[o]=max(mx[o<<1],mx[o<<1|1]);
}
int query2(int o,int l,int r)
{
	if(l>=x&&r<=y)
		return mx[o];
	int mid=l+r>>1,rtn=0;
	if(x<=mid)
		rtn=query2(o<<1,l,mid);
	if(y>mid)
		rtn=max(rtn,query2(o<<1|1,mid+1,r));
	return rtn;
}
void update(int o,int l,int r)
{
	if(l==r)
	{
		sum[o]=(sum[o]+y)%md;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)
		update(o<<1,l,mid);
	else
		update(o<<1|1,mid+1,r);
	sum[o]=(sum[o<<1]+sum[o<<1|1])%md;
}
int query(int o,int l,int r)
{
	if(l>=x&&r<=y)
		return sum[o];
	int mid=l+r>>1,rtn=0;
	if(x<=mid)
		rtn=query(o<<1,l,mid);
	if(y>mid)
		rtn=(rtn+query(o<<1|1,mid+1,r))%md;
	return rtn;
}
int main()
{
	Read(n);
	for(i=1;i<=n;++i)
	{
		Read(a[i].b);
		Read(a[i].k);
		b[i]=(mode){i,a[i].b};
	}
	sort(b+1,b+1+n,cmq);
	for(i=1,l=0;i<=n;i=j)
	{
		++l;
		for(j=i;j<=n&&b[i].num==b[j].num;++j)
			a[b[i].id].b=l;
	}
	sort(a+1,a+1+n,cmp);
	for(i=0;i<n*5;++i)
		mn[i]=1<<30;
	for(i=1;i<=n;++i)
	{
		x=a[i].b,y=i;
		update1(1,1,l);
		x=a[i].b,y=l;
		c[i].lt=query1(1,1,l);
	}
	for(i=n;i>=1;--i)
	{
		x=a[i].b,y=i;
		update2(1,1,l);
		x=1,y=a[i].b;
		c[i].rt=query2(1,1,l);
	}
	//for(i=1;i<=n;++i)
	//	printf("%d %d  %d %d\n",a[i].k,a[i].b,c[i].lt,c[i].rt);
	x=0,y=1;
	update(1,0,n);
	sort(c+1,c+1+n,cmr);
	for(i=1;i<=n;++i)
	{
		x=c[i].lt-1,y=c[i].rt;
		y=query(1,0,n);
		x=c[i].rt;
		update(1,0,n);
		if(c[i].rt==n)
			ans=(ans+y)%md;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 20608
#include<cstdio>
long long n,mod,ans,p[4001][4001],f[8001],x[200001],y[200001];
long long mi(long long k,long long p)
{
	if (!p)return 1;
	long long s=mi(k,p/2);
	s=s*s%mod;
	if (p%2)s=s*k%mod;
	return s;
}
long long c(long long n,long long m)
{
	return f[n]*mi(f[m],mod-2)%mod*mi(f[n-m],mod-2)%mod;
}
int main()
{
	mod=1000000007;
	f[1]=1;
	for (int i=2;i<=8000;i++)f[i]=f[i-1]*i%mod;
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x[i],&y[i]);
		p[2000-x[i]][2000-y[i]]++;
		ans=(ans+c(2*x[i]+2*y[i],2*y[i]))%mod;
	}
	ans=mod-ans;
	for (int i=0;i<=4000;i++)
		for (int j=0;j<=4000;j++)
		{
			if (i)p[i][j]=(p[i][j]+p[i-1][j])%mod;
			if (j)p[i][j]=(p[i][j]+p[i][j-1])%mod;
		}
	for (int i=1;i<=n;i++)ans=(ans+p[2000+x[i]][2000+y[i]])%mod;
	printf("%lld",ans*mi(2,mod-2)%mod);
}

Measured memory_bytes: 128384
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_string(S),
    write("2018/01/"),
    string_code(9, S, X),
    char_code(X2, X),
    write(X2),
    string_code(10, S, Y),
    char_code(Y2, Y),
    writeln(Y2).



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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 100;
ll N;
ll F[MAX_N][10];
ll P[MAX_N][11];
int main(){
   cin >> N;
   REP(i, N) REP(j, 10) cin >> F[i][j];
   REP(i, N) REP(j, 11) cin >> P[i][j];

   ll profit = -INF;

   REP(s, (1ll << 10)){
      if(s == 0) continue;
      ll temp = 0;
      REP(i, N){
         ll c = 0;
         REP(j, 10){
            if (F[i][j] & (s >> j)) c++;
         }
         temp += P[i][c];
      }
      chmax(profit, temp);
   }
   cout << profit << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define INF 2000000000

int main() {
    int n, t;
    scanf("%d %d", &n, &t);
    int ans = INF;
    rep(i,n) {
        int cost, time;
        scanf("%d %d", &cost, &time);
        if (time <= t) {
            ans = min(ans, cost);
        }
    }
    if (ans == INF) printf("TLE\n");
    else printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define N 4001
using namespace std;
int n,m,dp[N][N],ans;
int main(){
  string A,B;
  while(cin>>A>>B){
    n=A.size();
    m=B.size();
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) dp[i][j]=0;
    ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(A[i]==B[j]) dp[i+1][j+1]=dp[i][j]+1;
	ans=max(ans,dp[i+1][j+1]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
	int A[101][101],b[101],n,m,c;
	cin >> n >> m;

	for(int i=0;i<n; i++){
		for(int j=0;j<m;j++){
			cin >> A[i][j];
		}
	}


	for(int j=0;j<m;j++){
		cin >> b[j];
	}


	for(int i=0;i<n; i++){
		c=0;
		for(int j=0;j<m;j++){
			c += A[i][j]*b[j];
		}
		cout << c << "\n";
	}

	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(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; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while(first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if(last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}

ll A, B, Q;
VL s, t;

int main() {
    cin >> A >> B >> Q;
    s.resize(A);
    t.resize(B);
    VECCIN(s);
    VECCIN(t);
    sort(All(s));
    sort(All(t));
    REP(i, Q) {
        LCIN(x);
        ll sidx = lower_bound(All(s), x) - s.begin();
        ll tidx = lower_bound(All(t), x) - t.begin();
        ll res1 = LINF, res2 = LINF, res3 = LINF, res4 = LINF;
        if(sidx != A && tidx != B) {
            res1 = max(abs(x - s[sidx]), abs(x - t[tidx]));
        }
        if(sidx - 1 >= 0 && tidx != B) {
            res2 = abs(x - s[sidx - 1]) + abs(x - t[tidx]) +
                   min(abs(x - s[sidx - 1]), abs(x - t[tidx]));
        }
        if(sidx != A && tidx - 1 >= 0) {
            res3 = abs(x - s[sidx]) + abs(x - t[tidx - 1]) +
                   min(abs(x - s[sidx]), abs(x - t[tidx - 1]));
        }
        if(sidx - 1 >= 0 && tidx - 1 >= 0) {
            res4 = max(abs(x - s[sidx - 1]), abs(x - t[tidx - 1]));
        }
        cout << min({res1, res2, res3, res4}) << "\n";
    }
    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 10001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int n, k;
  scanf("%d %d", &n, &k);

  int m = 0;
  int edge[MAX][2] = {0};

  // グラフを作成不可能
  int max = (n - 1) * (n - 2) / 2;
  if (k > max)
  {
    printf("-1\n");
    return 0;
  }

  // 連結グラフ(スター)を作成(頂点距離が2である個数が(n-1)(n-2)/2個)
  rep(i, n - 1)
  {
    edge[i][0] = 1;
    edge[i][1] = i + 2;
    m++;
  }

  // 頂点距離が2である個数をK個に合わせる
  int count = max - k;
  for (int from = 2; from <= n; from++)
  {
    for (int to = from + 1; to <= n; to++)
    {
      if (count <= 0)
        goto exit;
      edge[m][0] = from;
      edge[m][1] = to;
      m++;
      count--;
    }
  }

exit:
  printf("%d\n", m);
  rep(i, m)
  {
    printf("%d %d\n", edge[i][0], edge[i][1]);
  }
  return 0;
}


Measured memory_bytes: 256
class tree:
    def __init__(self, parts):
        self.num_parts = len(parts)
        self.nodes = []
        for i in range(self.num_parts):
            self.nodes.append(node(parts[i][0],parts[i][1],parts[i][2]))

    def set_parents(self):
        for i in range(self.num_parts):
            for child_id in self.nodes[i].children_id:
                self.nodes[child_id].set_parent(i)

    def set_type(self):
        for i in range(self.num_parts):
            self.nodes[i].check_type()
    def set_depth(self):
        for i in range(self.num_parts):
            if self.nodes[i].type == "root":
                parents = [self.nodes[i]]
                depth = 0
                self.nodes[i].set_depth(depth)
                for j in range(20):
                    depth += 1
                    children = []
                    for parent in parents:
                        for child_id in parent.children_id:
                            self.nodes[child_id].set_depth(depth)
                            children.append(self.nodes[child_id])
                    parents = children
                        
class node:
    def __init__(self, id, k, children):
        self.id = id
        self.k = k
        self.children_id = children
        self.depth = -1
        self.parent_id = -1
        self.type = "leaf"
        
    def set_parent(self,parent_id):
        self.parent_id = parent_id

    def check_type(self):
        if self.parent_id == -1:
            self.type = "root"
        elif self.children_id == []:
            self.type = "leaf"
        else:
            self.type = "internal node"
            
    def set_depth(self,depth):
        self.depth = depth
        
n = int(input())
obj = [[0,0,[]] for i in range(n)]
for i in range(n):
    inp = list(map(int, input().split()))
    obj[inp[0]][0] = inp[0]
    obj[inp[0]][1] = inp[1]
    if inp[1]>0:
        obj[inp[0]][2] = inp[2:]

new_tree = tree(obj)
new_tree.set_parents()
new_tree.set_type()
new_tree.set_depth()

for i in range(n):
    print("node {}: parent = {}, depth = {}, {}, {}".format(i, new_tree.nodes[i].parent_id, new_tree.nodes[i].depth, new_tree.nodes[i].type, new_tree.nodes[i].children_id))


Measured memory_bytes: 52504
# coding: utf-8
# Your code here!

import math

N, D = map(int, input().split())
x_arr = [list(map(int, input().split())) for i in range(N)]
num = 0
ctr = 0


for i in range(N):
    for j in range(i + 1, N):
        for k in range(D):
            num += pow(x_arr[j][k] - x_arr[i][k],2)
        dist = math.sqrt(num)
        if dist.is_integer():
            ctr += 1
        num = 0
print(ctr)

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long S = inputArray[0];

			if (S <3) {
				Console.WriteLine(0);
				return;
			}

			var combinationList = new List<long>();

			var n = 1;
			while (S-n*3 >=0 ) {
				var amari = S - n * 3;
				var c = combination(amari + (n - 1), n - 1);
				combinationList.Add(c);
				n++;
			}
			long ans = 0;

			foreach (var combi in combinationList) {
				ans += combi;
				ans %= _mod;
			}

			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}

		private static long _mod = 1000000000 + 7;

		/// <summary>
		/// x^n のmod　を繰り返し二乗法で求める
		/// </summary>
		/// <param name="x"></param>
		/// <param name="n"></param>
		/// <returns></returns>
		private static long repeatPow(long x, long n) {
			if (n == 0) {
				return 1;
			}
			if (n == 1) {
				return x;
			}

			if (n % 2 == 1) {
				var a = repeatPow(x, n / 2);
				var b = a * x % _mod;
				return (a * b) % _mod;
			}
			else {
				var a = repeatPow(x, n / 2);
				return (a * a) % _mod;
			}
		}

		/// <summary>
		/// nこからrこを選ぶ組み合わせの数
		/// </summary>
		/// <param name="n"></param>
		/// <param name="r"></param>
		/// <returns></returns>
		private static long combination(long n, long r) {

			long bunshi = 1;
			for (int i = 1; i <= r; i++) {
				bunshi = bunshi * (n - r + i) % _mod;
			}

			long bunbo = 1;
			for (int i = 1; i <= r; i++) {
				bunbo = bunbo * (i) % _mod;
			}
			//逆元を使って、組み合わせの数を求める	
			return (bunshi * repeatPow(bunbo, _mod - 2)) % _mod;

		}

	}
}



Measured memory_bytes: 28260
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int a[100]={},N,cnt=0;
  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i];
  sort(&a[0],&a[N]);
  for(int i=1;i<N;i++)if(a[i-1]!=a[i])cnt++;
  cout<<cnt+1<<endl;

  return 0;
}

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

using namespace std;

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

    int64_t flag = 1000000000000000000;
    int64_t answer = 1;

    for(int i=0;i<N;i++){
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

        for(int i=0;i<N;i++){
            if((double)(flag / answer) < a[i]){
                cout << -1 << endl;
                return 0;
            }
            answer = answer * a[i];
        }

    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    rep(i, 0, N) cin >> T[i];
    sort(all(T));

    int ans = 0;
    int t = -1;
    int passengers = 0;
    rep(i, 0, N)
    {
        if (t == -1)
        {
            t = T[i];
            ++passengers;
        }
        else if (T[i] <= t + K)
        {
            ++passengers;
        }
        else
        {
            ++ans;
            t = T[i];
            passengers = 1;
        }

        if (passengers >= C)
        {
            ++ans;
            t = -1;
            passengers = 0;
        }
    }
    if (passengers > 0)
    {
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>

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

int main(int argc, char* argv[]) {
  int n, q;
  cin >> n >> q;

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

  vector<int> ops(n + 1, 0);
  for (int i = 0; i < q; ++i) {
    int p, x;
    cin >> p >> x;
    ops[p] += x;
  }

  vector<int> cs(n + 1, 0);
  vector<bool> visited(n + 1, false);

  queue<int> nodes;
  nodes.push(1);
  visited[1] = true;
  cs[1] = 0;
  while (!nodes.empty()) {
    auto i = nodes.front();
    nodes.pop();
    cs[i] += ops[i];
    for (auto b : es[i]) {
      if (visited[b]) {
        continue;
      }
      visited[b] = true;
      cs[b] = cs[i];
      nodes.push(b);
    }
  }

  cout << cs[1];
  for (int i = 2; i <=n; ++i) {
    cout << " " << cs[i];
  }
  cout << endl;

  return 0;
}


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

int main() {
  int N ;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0 ; i < N ; i ++ ){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(),vec.end());
  
  int Alice, Bob;
  Alice = 0;
  Bob = 0;
  for (int i = 0 ; i < N ; i ++ ){
    if (i % 2 == 0){
      Alice += vec.at(i);
    }
    else {
      Bob += vec.at(i);
    }
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int x, s, xx;
	cin >> x;
	s = 0;
	xx = x;
	while (xx > 0) {
		s += xx % 10;
		xx /= 10;
	}
	if (x % s == 0) cout << "Yes\n";
	else cout << "No\n";
		

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		String str =scan.nextLine();
		char[] s = new char[20];
		char[] t = new char[20];
		s=str.toCharArray();
		for(int i=0;i<s.length;i++){
			t[t.length-1-i]=s[i];
		}
		str=String.valueOf(t);
		System.out.println(str);
	}

}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;double p[N],DP[N+1][N+1],sum=0;
  for(int i=0;i<N;i++)cin>>p[i];DP[0][0]=1;
  for(int i=1;i<=N;i++){
    DP[i][0]=DP[i-1][0]*(1-p[i-1]);DP[i][i]=DP[i-1][i-1]*p[i-1];
    for(int j=1;j<i;j++)DP[i][j]=DP[i-1][j-1]*p[i-1]+DP[i-1][j]*(1-p[i-1]);
  }
  for(int i=(N+1)/2;i<=N;i++)sum+=DP[N][i];
  printf("%.10lf\n",sum);
}

Measured memory_bytes: 70400
#include<iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

int main() {
	int N;
	std::cin >> N;
	std::vector<int> v(N);
	for (int i = 0; i < N; ++i) std::cin >> v[i];
	std::sort(v.begin(), v.end());
	double max = static_cast<double>(v.back());
	double min = max / 2.0;
	int target;
	for (int i = 0; i < N - 1; ++i) {
		double diff = fabs(max / 2.0 - static_cast<double>(v[i]));
		if (diff <= min) {
			min = diff;
			target = i;
		}
	}
	std::cout << v.back() << " " << v[target] << "\n";
}

Measured memory_bytes: 640
#include <stdio.h>

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

Measured memory_bytes: 128
import java.util.*;

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

        int N = sc.nextInt();
        int D = sc.nextInt();
        sc.close();

        if ((N % (2*D+1)) != 0)
            System.out.println((N / (2*D+1))+1);
        else
            System.out.println((N / (2*D+1)));
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

string st[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
  string s;
  cin >> s;
  reverse(ALL(s));
  REP(i,4) reverse(ALL(st[i]));
  for(int pos=0; pos<s.size();){
    bool flag = true;
    REP(i,4){
      if(s.substr(pos,st[i].size())==st[i]){
        pos += st[i].size();
        flag = false;
        break;
      }
    }
    if(flag){
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    
    double s,r,l;
    
    
    scanf("%lf",&r);
    
    s = (double)r*r*M_PI;
    l = (double)2*r*M_PI;
    
    printf("%f %f\n",s,l);
    
    return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int a;cin>>a;
    double ans;
    int b=(a+1)/2;
    ans=(double)b/a;
    cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

int main() {
  int x,t; cin>>x>>t;
  cout << max(x-t,0) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
const LL MOD=1000000007ll;
const int MAX=510000;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long C(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}
 
	

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    LL ans = power(2,n);
    ans--;
    ans-=C(n,a);
    ans-=C(n,b);
    cout << (ans%MOD+MOD)%MOD << endl;
}


Measured memory_bytes: 256
import java.util.*;

// ARC 83-C
// http://arc079.contest.atcoder.jp/tasks/arc079_b

public class Main {
	
	static int A;
	static int B;
	static int C;
	static int D;
	static int E;
	static int F;
	
	static double concentration = 0;
	static int answerW = 0;
	static int answerS = 0;
	
	static int[][] dp;
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		A = in.nextInt();
		B = in.nextInt();
		C = in.nextInt();
		D = in.nextInt();
		E = in.nextInt();
		F = in.nextInt();
		
		dp = new int[F + 1][F * E / 100 + 1];
		
		answerW = 100 * A;
		
		solve(0, 0);
		
		System.out.printf("%d %d\n", answerW + answerS, answerS);
	}
	
	public static void solve(int water, int sugar) {
		if (water + sugar > F || water > F || sugar > F * E / 100) {
			return;
		}
		if (dp[water][sugar] == 1) {
			return;
		}
		
		boolean isSugarDissolved = isSugarDissolved(water, sugar);
		if (isSugarDissolved) {
			double conc = calculateConcentration(water, sugar);
			if (conc > concentration) {
				concentration = conc;
				answerW = water;
				answerS = sugar;
			}
		}

		dp[water][sugar] = 1;
				
		// Operation 1
		solve(water + 100 * A, sugar);
		// Operation 2
		solve(water + 100 * B, sugar);
		
		// Only sugar is dissolved, check adding sugar
		if (isSugarDissolved) {
			// Operation 3
			solve(water, sugar + C);
			// Operation 4
			solve(water, sugar + D);
		}
	}
	
	public static double calculateConcentration(int water, int sugar) {
		return (100.0 * sugar) / (water + sugar);
	}
	
	public static boolean isSugarDissolved(int water, int sugar) {
		return sugar <= water * E / 100;
	}
}


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

int main(){
    bool finished = true;
    while(finished){
        int n, x;
        cin >> n >> x;
        int c = 0;
        
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                for(int k = j + 1; k < n; k++){
                    if(i + j + k == x - 3){
                        c++;
                    }
                }
            }
        }
        
        if(n == 0 && x == 0){
            finished = false;
        }
        else{
        cout << c << endl;
        }

    }
}


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

int main(){
    long long n;
    long long sum = 0;
    cin >> n;
    for(long long i=1;i<=n;i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int x;
	cin >> x;
	cout << 1 - x << endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/04  Problem: 071_arc_c / Link: https://arc071.contest.atcoder.jp/tasks/arc071_c?lang=en  ----- */
/* ------問題------

A, B からなる文字列に対して、次の操作を考えます。
文字列中の 1 文字を選ぶ。それが A なら BB で、 B なら AA で置き換える。
AAA か BBB であるような部分文字列を選び、消す。
例えば、ABA という文字列で 1 番目の操作を 1 文字目に対して行うと、 BBBA となります。 また、BBBAAAA に対して 2 番目の操作を 4 文字目から 6 文字目に対して行うと、 BBBA となります。
これらの操作を何回でも好きな順で行うことができます。
文字列 S,T と q 個のクエリ ai,bi,ci,di が与えられます。 各クエリに対して、 S の部分文字列 SaiSai+1…Sbi を T の部分文字列 TciTci+1…Tdi にすることができるか判定してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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


	string s, t; cin >> s >> t;
	VI sums(SZ(s) + 1, 0);
	VI sumt(SZ(t) + 1, 0);
	FOR(i, 0, SZ(s)) {
		sums[i + 1] = sums[i] + (s[i] == 'A' ? 1 : 2);
	}
	FOR(i, 0, SZ(t)) {
		sumt[i + 1] = sumt[i] + (t[i] == 'A' ? 1 : 2);
	}

	int Q; cin >> Q;
	FOR(i, 0, Q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d; // [a,b] ? [c,d]
		int vals = (sums[b] - sums[a-1])%3;
		int valt = (sumt[d] - sumt[c-1])%3;
		if (vals == valt) {
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1744
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

ans = [str(0) for _ in range(n)]

odd_total = sum(a[:-2:2])
even_total = sum(a[1::2])
ans[0] = str(a[-1] + odd_total - even_total)
for i in range(n - 1):
    ans[i + 1] = str(2 * a[i] - int(ans[i]))

print(' '.join(ans))

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

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

    int A, B, C;
    cin >> A >> B >> C;
    if ((A < C && C < B) || (B < C && C < A))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

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

    bool ok = false;
    for (int i = X / 105; i <= X / 100; ++i) {
        if (100 * i <= X and X <= 105 * i) {
            ok = true;
            break;
        }
    }

    if (ok) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

int main()
{
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
R, G, B, N = map(int,input().split())
Rm = N // R
cnt = 0
for r in range(Rm+1):
  x = N - r * R
  Gm = x // G
  for g in range(Gm+1):
    Bb = N - r * R - G * g
    if Bb % B == 0:
      cnt += 1
print(cnt)

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

// 再帰関数による最大公約数
int gcd(int x, int y) {
  return y ? gcd(y, x % y) : x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  int maximum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    maximum = max(maximum, a.at(i));
    if (a.at(i) == k) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  
  if (maximum < k) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }
  
  int keep = 0;
  for (int i = 0; i < n; i++) keep = gcd(keep, a.at(i));
  
  if (k % keep == 0) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
  return 0;
}

Measured memory_bytes: 640
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(A,B);
    cout << 1 + 2 + 3 -A-B << nn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N, M;
vector<pair<int, int> > h;

string conv(int k){
  string p = to_string(k);
  int j = p.length();
  string pp = "";
  while(j < 6){
      pp += '0';
      ++j;
  }
  p = pp + p;
  return p;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M;
  h.resize(M);
  for(int i=0; i<M; ++i) cin >> h[i].first >> h[i].second;
  int id[M];
  iota(id, id+M, 0);
  sort(id, id+M, [&](int a, int b){
      if(h[a].first == h[b].first)
        return h[a].second < h[b].second;
      return h[a].first < h[b].first;
   });
  int x[N+5];
  memset(x, 0, sizeof(x));
  vector<string> res[M];
  for(int i=0; i<M; ++i){
    int f = h[id[i]].first;
    int l = x[h[id[i]].first] + 1;
    ++x[h[id[i]].first];
    res[id[i]].push_back(conv(f) + conv(l));
  }
  for(int i = 0; i<M; ++i){
    for(int j = 0; j < (int)res[i].size(); ++j){
      cout << res[i][j];
    }
    cout << "\n";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 14336
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *P = map(int, read().split())

    P.sort()
    ans = sum(P[:-1]) + P[-1] // 2
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
/*
      author : nishi5451
      created: 11.08.2020 00:28:57
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <algorithm>
/*
?????????
*/

constexpr int NUM = 300;
int w[NUM] = { 0 };
bool dp[NUM][NUM] = { {false} };
int ddp[NUM+1] = { 0 };

//a~a+1??¨a+2~b?????\??\??\???a~d??¨d+1~r?????\??\??\???a~b-2??¨b-1~b????????????????????¨???????????????
bool isDroped(int a, int b) {
	if (b - a <= 1) return false;
	for (int i = a + 1; i < b; i += 2) {
		if (dp[a][i] && dp[i + 1][b]) return true;
	}
	return false;
}

int main() {
	int n;
	while (std::cin >> n && n) {
		std::memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) std::cin >> w[i];

		for (int d = 1; d < n; d += 2) { //?????¨?????????
			for (int i = 0; i < n - d; i++) { //?????¨?????´???
				if ((d == 1 || dp[i + 1][i + d - 1]) && std::abs(w[i] - w[i + d]) <= 1){
					dp[i][i + d] = true; //???????????????????????¨????????¨??????
				}
				if (isDroped(i, i + d)) {
					dp[i][i + d] = true;
				}
			}
		}
		std::memset(ddp, 0, sizeof(ddp));
		for (int i = 0; i < n; ++i) {
			ddp[i + 1] = std::max(ddp[i + 1], ddp[i]);
			for (int j = i + 1; j < n; j += 2) {
				if (dp[i][j]) {
					ddp[j + 1] = std::max(ddp[j + 1], ddp[i] + j - i + 1);
				}
			}
		}
		std::cout << ddp[n] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vector<int> a(N);
    cin >> a;
    int cnt = 0;
    int m = 1000;
    int prev;
    if (a[0] < a[1]) {
        prev = 1;
        cnt += m / a[0];
        m %= a[0];
    } else {
        prev = 0;
    }
    REPS(i, N - 2) {
        dump(m, cnt);
        int now;
        if (a[i] == a[i + 1])
            continue;
        if (a[i] < a[i + 1]) {
            now = 1;
        } else {
            now = 0;
        }
        if (prev == now) {
            continue;
        } else {
            if (now) {
                cnt += m / a[i];
                m %= a[i];
            } else {
                m += cnt * a[i];
                cnt = 0;
            }
        }
        prev = now;
    }
    m += cnt * a[N - 1];
    cnt = 0;
    cout << m << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  double v[n];
  rep(i, n){
    cin >> v[i];
  }
  sort(v, v + n);
  double ans = (v[0] + v[1]) / 2;
  for(int i = 2; i < n; i++){
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
  
}

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

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    if a < c && c < b || a > c && c > b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

using namespace std;

typedef long long ll;

const int MAXN = 100000 + 5;

int t;

ll n, m, v, p;
ll a[MAXN];

bool cmp(const int aa, const int bb)
{
	return aa > bb;
}

bool isValid(int k) 
{
	ll sum = m * v;
	int tmp = a[k] + m;
	sum -= (n - k)*m;
	sum -= (p - 1)*m;
	if (sum <= 0) {
		if (tmp >= a[p - 1]) return true;
		else return false;
	}
	else {
		if (tmp < a[p - 1]) return false;
		int ii = k - 1;
		while (sum > 0) {
			if (ii == p - 2) return false;
			sum -= (tmp - a[ii]);
			ii--;
		}
		return true;
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false);
	while (cin >> n >> m >> v >> p) {
		for (int i = 0; i < n; ++i) cin >> a[i];
		sort(a, a + n, cmp);
		int ll = p-1, rr = n - 1;
		while (ll <= rr) {
			int mid = (ll + rr) / 2;
			//cout << ll << "," << rr << "," << mid << endl;
			if (isValid(mid)) {
				ll = mid + 1;
			}
			else {
				rr = mid - 1;
			}
		}
		cout << ll << endl;
	}
	return 0;
}

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

#define int ll 
typedef long long        ll;
 
#define fastio        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
 
const int N = 2e5+7; 

void solve() {
	for (int i = 1; i <= 5; i++) {
		int x; cin >> x;
		if (x == 0) {
			cout << i << endl;
			return;
		}
	}
}

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

    return 0;
}

Measured memory_bytes: 3584