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

#ifdef LOCAL_PC
	#define debug(args...) cout.flush(); fflush(stdout); fprintf(stderr, args)
#else
	#define debug(args...) ; /*  */
#endif
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class num> inline void rd(num &x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
	x = (x << 3) + (x << 1) + c - '0';
	if (neg) x = -x;
}
template <class T, class... Args> inline void rd(T& x, Args&... args) { rd(x); rd(args...); }


const int MAXN = 1e5 + 5, INF = 0x3f3f3f3f;

inline bool check(ll n, ll k, ll m) {
	ll x = k * (n - 1);
	ll l = m - x;
	return l > 0 && l%k == 0;
}

int main() {
	ll n, m; rd(n, m);

	ll ans = 1;
	for (ll i = 1; i*i <= m; i++) {
		if (m%i) continue;
		if (check(n, i, m)) ans = max(ans, i);
		if (check(n, m/i, m)) ans = max(ans, m/i);
	}

	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 305
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int d[maxn];
bool check()
{
    for(int i=1;i<=n;i++)
      if(d[i]!=2) return false;
    return true;
}
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int fac[maxn],inv[maxn];
void pre_work()
{
    fac[0]=1;
    for(int i=1;i<=n;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    inv[n]=quick_pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int ans;
int f[maxn][maxn][2];
void add(int &x,int y)
{
    x=(x+y>=mod)?x+y-mod:x+y;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  d[i]=read();
    pre_work();
    if(check())
    {
        ans=1ll*fac[n-1]*inv[2]%mod;
        cout<<ans<<endl;
        return 0;
    }
    f[0][0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i-1;j++)
        {
            for(int k=0;k<2;k++)
            {
                if(!f[i-1][j][k])  continue;
                add(f[i][j][k],1ll*f[i-1][j][k]*inv[d[i]-1]%mod);
                if(d[i]>=2)  add(f[i][j+1][k],1ll*f[i-1][j][k]*inv[d[i]-2]%mod);
                if(d[i]>=3&&!k)  add(f[i][j+1][1],1ll*f[i-1][j][k]*inv[d[i]-3]%mod);
            }
        }
    }
    for(int i=3;i<n;i++)  ans=(ans+1ll*f[n][i][1]*fac[n-i-1]%mod*fac[i-1]%mod*inv[2]%mod)%mod;
    cout<<ans<<endl;
    return 0;
}

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

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		string str = cin.next();
		int num = 0;
		int max = 0;
		for (int i = 0; i < str.Length; i++)
		{
			if(str[i] == 'T')
			{
				num++;
			}
			else
			{
				num--;
			}
			max = Math.Max(max, num);
		}
		Console.WriteLine(max * 2);
	}

}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 4312
n = int(input())
a_s = list(map(int, input().split()))
sum_a_s = sum(a_s)

tmp_sum = 0
for i in range(n - 1):
	tmp_sum += a_s[i]
	if tmp_sum > sum_a_s - tmp_sum:
		break

tmp_res1 = abs(sum(a_s[:i]) * 2 - sum_a_s)
tmp_res2 = abs(sum(a_s[:i + 1]) * 2 - sum_a_s)
res = min(tmp_res1, tmp_res2)

print(res)


Measured memory_bytes: 26024
# encoding: utf-8
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

route = [[] for i in range(N)]

for ai, bi in ab:
    route[ai - 1].append(bi - 1)
    route[bi - 1].append(ai - 1)

def walk(pos, pos_prev, footprint):
    # print("#", pos, footprint)
    footprint = (2 ** pos) | footprint
    ret = footprint
    for pos_next in route[pos]:
        # print("##", pos_next, (2 ** pos_next) & footprint)
        if (2 ** pos_next) & footprint > 0: continue
        ret = ret | walk(pos_next, pos, footprint)
    return ret

ans = 0
for ai, bi in ab:
    # temporary remove
    route[ai - 1].remove(bi - 1)
    route[bi - 1].remove(ai - 1)
    # connection check
    if walk(0, -1, 0) < (2 ** N - 1): ans += 1
    # recovery
    route[ai - 1].append(bi - 1)
    route[bi - 1].append(ai - 1)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string n;
  cin >> n;
  int k = n.length();
  int win=0;
  for(int i=0; i<k; i++){
    if(n[i]=='o'){
      win+=1;
    }
  }
  if((15-k+win)>=8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define ll long long

using namespace std;

int main() {
	
	int a,b,c;
	cin >> a >> b >> c;
    int k;
    cin >> k;
    int count = 0;
    while(a >= b)
    {
        b = b*2;
        count+=1;
        if(count >= k)
        {
            
            break;
        }
    }
    if(count < k)
    while(b >= c)
    {
        c = c*2;
        count+= 1;
        if(count >= k)
        {
            break;
        }
    }
    if((a < b) && (b < c) && (count <= k))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  ll ans = 0;
  rep(i, sz(s)) ans += (s[i] - '0');
  if (ans % 9 == 0)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3708
inputs = []
while input = $stdin.gets do
  inputs << input.chomp.split(" ")
end

n = inputs.shift
citys = []

inputs.each.with_index(1) do |city, i|
  city << i
  citys << city
end

citys_name_sort = citys.sort

super_citys = []
names = []

citys_name_sort.each do |name|
  names << name[0]
end

names.uniq.each do |name|
  check_names = []
  citys_name_sort.each do |city_n|
    if name == city_n[0]
      check_names << city_n
    end
  end
  super_citys << check_names.sort{ |a, b| b[1].to_i <=> a[1].to_i }
end

super_citys.each do |a0|
  a0.each do |a1|
    p a1[2]
  end
end

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    ll h, sum = 0;
    int n;
    cin >> h >> n;

    REP(i, n) {
        int tmp; cin >> tmp;
        sum += tmp;
    }
    if (sum < h) cout << "No" << endl;
    else cout << "Yes" << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq; 
 
class Program
{
    static void Main(string [] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        var result = (l.Where(x => x == 5).Count() == 2) && (l.Where(x => x == 7).Count() == 1);
        Console.WriteLine(result ? "YES" : "NO");
    }
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

ll dp[105][int(1e5) + 10], w[105], v[105];

int main() {
	faster;

	ll n, W;
	cin >> n >> W;

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

	for(int i= 1; i <= n; i++){
		for(int j = 1; j <= W; j++){
			if(w[i-1] <= j){
				dp[i][j] = max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
			}else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	cout << dp[n][W] << endl;

	return 0;
}

Measured memory_bytes: 81596
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    string res;
    for(int64_t i=0; i<107; i++){
        c -= b;
        if(c<=0){
            res = "Yes";
            break;
        }
        a -= d;
        if(a<=0){
            res = "No";
            break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3640
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)998244353;
//}}}

int digitSum(ll n){
  int res = 0;
  while(n){
    res += n % 10;
    n /= 10;
  }
  return res;
}
int digit(ll n){
  int res = 0;
  do{
    res++;
    n /= 10;
  }while(n);
  return res;
}

int f(ll n){
  int res = 0;
  while(n){
    res = n % 10;
    n /= 10;
  }
  return res;
}

int main(){
  ll N;
  cin >> N;
  ll ans;
  if(digitSum(N) == 1){
    if(N == 1){
      ans = 1;
    }else{
      ans = (digit(N) - 1) * 9;
    }
  }else{
    ans = max(digitSum(N), f(N) - 1 + (digit(N) - 1) * 9);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
$drops = [
  [[0, 0], [-1, 1], [0, 1], [1, 1], [0, 2]],
  [[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], ],
  [[0, 0], [-1, 1], [0, 1], [1, 1], [-2, 2], [-1, 2], [0, 2], [1, 2], [2, 2],
   [-1, 3], [0, 3], [1, 3], [0, 4]]
]

$areas = [5, 9, 13]

$cnts = [[0, 1], [1, 1], [0, 2]]

### subroutines

def dropped?(x, y, d, pl)
  $drops[d].each do |v|
    x0 = x + v[0]
    y0 = y + v[1]
    if x0 >= 0 && x0 <= 9 && y0 >= 0 && y0 <= 9 && pl[y0][x0] == 0
      return false
    end
  end

  return true
end

def paint(x, y, d, c, pl)
  $drops[d].each do |v|
    x0 = x + v[0]
    y0 = y + v[1]
    if x0 >= 0 && x0 <= 9 && y0 >= 0 && y0 <= 9
      pl[y0][x0] += c
    end
  end
end

def check_pl(x, y, n, cs, pl, pts = [])
  if n == 0
    if cs == 0
      pts.each{|p| puts p.join(" ")}
      return true
    end
    return false
  end

  while pl[y][x] == 0
    x += 1
    if x > 9
      x = 0
      y += 1
    end
  end

  for d in (0...$drops.length)
    if dropped?(x, y, d, pl)
      xc = x + $cnts[d][0]
      yc = y + $cnts[d][1]
      pts.push [xc, yc, d + 1]
      paint(x, y, d, -1, pl)

      if check_pl(x, y, n - 1, cs - $areas[d], pl, pts)
        return true
      end

      paint(x, y, d, 1, pl)
      pts.pop
    end
  end

  return false
end

### main

while (line = gets)
  n = line.chomp.to_i

  pl = []
  cs = 0

  10.times.each do
    hl = gets.chomp.split(" ").map{|s| s.to_i}
    pl.push hl
    hl.each {|c| cs += c}
  end

  check_pl(0, 0, n, cs, pl)
end

Measured memory_bytes: 6104
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int a, b;
    scan(a, b);
    writeln((a + b + 1) / 2);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
  	"math"
)

func Degree2Radian(deg float64) float64 {
	return deg * math.Pi / 180.0
}

func Radian2Degree(rad float64) float64 {
	return rad * 180.0 / math.Pi
}

// 時・分を受け取り時針の角度[degree]を返す
func HourHandAngle(h, m int) float64 {
	return 30.0*float64(h) + float64(m)/2.0
}

// 分を受け取り分針の角度[degree]を返す
func MinuteHandAngle(m int) float64 {
	return 6.0 * float64(m)
}

// 時針と分針がなす小さい方の角[degree]を返す
func AcuteAngle(h, m int) float64 {
	diff := HourHandAngle(h, m) - MinuteHandAngle(m)
	if diff < 0 {
		diff *= -1
	}
	if diff > 180.0 {
		diff = 360.0 - diff
	}
	return diff
}

func main() {
	var a, b, h, m int
	fmt.Scan(&a, &b, &h, &m)

	rad := Degree2Radian(AcuteAngle(h, m))

	ans := math.Sqrt(float64(a*a) + float64(b*b) - 2.0*float64(a)*float64(b)*math.Cos(rad))
	fmt.Println(ans)
}

Measured memory_bytes: 1820
#include <stdio.h>

int main(void){
	int n, m, p, x, sum;
	int t[100] = {0};

	scanf("%d", &n);
	for(int i=0; i < n; i++) {
		scanf("%d", &t[i]);
	}
	scanf("%d", &m);

	for(int i=0; i < m; i++) {
		sum = 0;
		scanf("%d%d", &p, &x);
		for(int j=0; j < n; j++) {
			if(j != p - 1)
				sum += t[j];
			else
				sum += x;
		}
		printf("%d\n", sum);
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
typedef long long ll;
std::vector<int> adj[200005];
ll arr[200005];
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main(int argc, char const *argv[])
{
	   FAST();
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
 char a;
  int b;
  ll sum=0;
 while(cin>>a){
   b=int(a);
   b=b-48;
   //cerr<<b<<" ";
   sum=sum+b;
 }
 //cout<<sum<<endl;
 if(sum%9==0)
 	cout<<"Yes";
   else
   	 cout<<"No";

	return 0;
}

Measured memory_bytes: 8232
import java.util.Scanner;

public class Main {

	static int n;
	static int[] x, y;
	
	static double calcMinkowskiDist(int p) {
		double d = 0.0;
		for (int i = 0; i < n; i++) {
			d += Math.pow(Math.abs(x[i] - y[i]), p);
		}
		d = Math.pow(d, 1.0 / p);
		
		return d;
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		n = scan.nextInt();
		x = new int[n];
		y = new int[n];
		
		for (int i = 0; i < n; i++) {
			x[i] = scan.nextInt();
		}

		for (int i = 0; i < n; i++) {
			y[i] = scan.nextInt();
		}
		
		for (int p = 1; p <= 3; p++) {
			System.out.println(calcMinkowskiDist(p));
		}

		double d = 0.0;
		
		for (int i = 0; i < n; i++) {
			d = Math.max(d, Math.abs(x[i] - y[i]));
		}
		
		System.out.println(d);
		scan.close();
	}

}

Measured memory_bytes: 20476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(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 ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
 
 
int main() {
    IN(string, a);
    deque<char> s;
    REP(i, a.length()) s.push_back(a[i]);
    int now = 0;
    IN(int, q);
    REP(i, q){
        IN(int, t);
        if (t==1) {
            now++;
            now %= 2;
        }else{
            IN(int, f);
            IN(char, c);
            if ((f+now)%2 == 1) {
                s.push_front(c);
            }else{
                s.push_back(c);
            }
        }
    }
    if (now == 0) {
        while (!s.empty()) {
            char ch =  s.front();
            s.pop_front();
            cout << ch;
        }
    }else{
        while (!s.empty()) {
            char ch =  s.back();
            s.pop_back();
            cout << ch;
        }
    }
    cout << endl;
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    p[n - 1] /= 2;

    cout << accumulate(p.begin(), p.end(), 0) << endl;

    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int score = 0;
  int a[n];
  int b[n];
  int c[n];
  for(int i=0;i<n;i++){cin>>a[i];}
  for(int i=0;i<n;i++){cin>>b[i];}
  for(int i=0;i<(n-1);i++){cin>>c[i];}
  
  for(int i=0;i<n;i++){
    score = score + b[a[i]-1];
    if(i!=(n-1)){
      if(a[i]==(a[i+1]-1)){
      score = score + c[a[i]-1];
      }
    }
  }
  cout<<score<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> d(m);
    vector<int> ind(n, -1);
    for (int i = 0; i < m; ++i) {
        cin >> d[i];
        --d[i];
        ind[d[i]] = i;
    }
    vector<vector<int>> edge(m, vector<int>(k, -1));
    for (int i = 0; i < n; ++i) {
        if (ind[i] == -1) {
            for (int j = 0; j < k; ++j)
                scanf("%*d");

            continue;
        }
        for (int j = 0; j < k; ++j) {
            int a;
            cin >> a;
            --a;
            edge[ind[i]][j] = ind[a];
        }
    }
    vector<int> c(1 << m, M);
    queue<int> q;
    q.push((1 << m) - 1);
    c[(1 << m) - 1] = 0;
    while (!q.empty()) {
        int p = q.front();
        q.pop();
        for (int i = 0; i < k; ++i) {
            int nex = 0;
            for (int j = 0; j < m; ++j)
                if (((p >> j) & 1) && edge[j][i] != -1)
                    nex |= 1 << edge[j][i];

            if (c[nex] > c[p] + 1) {
                c[nex] = c[p] + 1;
                q.push(nex);
            }
        }
    }
    cout << c[0] << "\n";
    return 0;
}

Measured memory_bytes: 3476
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

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

#define INF 10101010

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

int n,ma,mb;
struct Medicine
{
  int a,b,c,val;
  Medicine(int a,int b,int c) : a(a),b(b),c(c) {
    val = ma*b-mb*a;
  }
};

int main() {
  std::cin >> n >> ma >> mb;
  std::vector<Medicine> meds;
  meds.reserve(n);
  rep(i,n) {
    int a,b,c;
    std::cin >> a >> b >> c;
    meds.emplace_back(a,b,c);
  }
  std::unordered_map<int,int> map;
  std::unordered_map<int,int> tmap;
  // map.reserve(101010);
  map[0] = 0;
  int mincost = INF;
  for(auto m:meds) {
    tmap = map;
    for(auto i:tmap) {
      int next = i.first + m.val;
      if(next == 0) mincost = std::min(mincost,i.second+m.c);
      else {
        if(map.count(next)==0) map[next] = i.second+m.c;
        else map[next] = std::min(map[next],i.second+m.c);
      }
    }
  }
  if(mincost==INF) mincost = -1;
  std::cout << mincost << ENDL;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

// 単調非減少 always a[i] <= a[i + 1]
int main(void)
{
    int N;
    cin >> N;

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

    for (int i = 0; i < N - 1; i++)
    {
        if (H[i] < H[i + 1])
        {
            H[i + 1]--;
        }
    }

    bool isFine = true;
    for (int i = 0; i < N - 1; i++)
    {
        if (H[i] > H[i + 1])
        {
            isFine = false;
            break;
        }
    }

    if (isFine == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int ans = 0;
    for(int i=1; i<=N; i++){
        int num = i;
        int tmp = 0;
        while(num != 0){
            tmp += num%10;
            num /= 10;
        }
        //cout << tmp << endl;
        if(A <= tmp && tmp <= B) ans += i;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
h, w, n, *a = map(int, open(0).read().split())

c = [[0]*w for i in range(h)]
i = j = 0
tor = True
for k in range(n):
        for x in range(a[k]):
                c[i][j] = k+1

                if tor:
                        j += 1
                        if j>=w:
                                i += 1
                                j = w-1
                                tor = False
                else:
                        j -= 1
                        if j<0:
                                i += 1
                                j = 0
                                tor = True
for i in c: print(*i)

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

int main() {
    //
    long long num;
    cin >> num;

    for (long long i = -200; i <= 200; i++) {
        for (long long j = -200; j <= 200; j++) {
            if (i * i * i * i * i - j * j * j * j * j == num) {
                cout << i << " " <<j;
                return 0;
            }
        }
    }

    cout << "No";
    //
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	memo = make(map[int]int)
	fmt.Println(rec(N))
}

var memo map[int]int

func rec(n int) int {
	if _, e := memo[n]; e {
		return memo[n]
	}
	if n == 0 {
		return 0
	}
	if n == 1 {
		return 1
	}
	n6 := power(6, count6(n))
	n9 := power(9, count9(n))
	count := min(
		1+rec(n-n6),
		1+rec(n-n9),
	)
	memo[n] = count
	return count
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}
func count6(n int) int {
	ret := 1
	for power(6, ret) <= n {
		ret++
	}
	return ret - 1
}

func count9(n int) int {
	ret := 1
	for power(9, ret) <= n {
		ret++
	}
	return ret - 1
}

func power(a, pow int) int {
	if pow == 0 {
		return 1
	} else if pow == 1 {
		return a
	} else if pow%2 == 0 {
		rt := power(a, pow/2)
		return rt * rt //% MOD
	} else {
		return a * power(a, pow-1) //% MOD
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long inv(long long now) {
	long long tmp = 1;
	long long nowe = MAX_MOD - 2;
	while (nowe != 0) {
		if (nowe % 2 == 1) tmp *= now;
		tmp %= MAX_MOD;
		now *= now;
		now %= MAX_MOD;
		nowe /= 2;
	}
	return tmp;
}
long long going[200000] = {};
int main() {
#define int long long
	long long h, w, a, b;
	cin >> h >> w >> a >> b;
	long long tmp = 1;
	for (int i = 0;i < b-1;++i) {
		tmp *= (long long)(h - a - 1 + b - 1 - i);
		tmp %= MAX_MOD;
		tmp *= inv(i + 1);
		tmp %= MAX_MOD;
	}
	for (int i = b;i < w;++i) {
		tmp *= inv(i);
		tmp %= MAX_MOD;
		tmp *= (long long)(i + (h - a - 1));
		tmp %= MAX_MOD;
		going[i] = tmp;
	}
	long long ans = 0;
	long long mewmew = 1;
	for (int i = w - 1;i >= b;--i) {
		ans += mewmew * going[i];
		ans %= MAX_MOD;
		mewmew *= (long long)(a - 1 + w - i);
		mewmew %= MAX_MOD;
		mewmew *= inv(w - i);
		mewmew %= MAX_MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let mut a = get!([usize]).into_iter().collect::<BinaryHeap<_>>();

    let mut num = m;
    while let Some(next) = a.pop() {
        a.push(next/2);
        num -= 1;
        if num == 0 {
            break;
        }
    }
    println!("{}", a.into_iter().sum::<usize>());
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
char a[110],b[110];
int main()
{
	scanf("%s%s",a,b);
	int lena=strlen(a),lenb=strlen(b);
	int x=min(lena,lenb),y=max(lena,lenb);
    for(int i=0;i<=x-1;i++)
        cout<<a[i]<<b[i];
    if(lena>lenb)
    for(int i=x;i<=y-1;i++)
        cout<<a[i];
    else 
	for(int i=x;i<=y-1;i++)
        cout<<b[i];
	return 0;
}	


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define PI 3.14159265358979
#define MOD 1000000007

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100000];
	int i, j, k;
	bool flag = true;
	cin >> n >> m;
	l = 0;
	a = 0;
	b = 0;
	for (j = 0; j < m; j++) {
		a += j;
		b += n - j;
	}
	for (i = m; i <= n + 1; i++) {
		l += b - a + 1;
		l %= MOD;
		
		b += n - j;
		a += j;
		j++;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
    
	int64_t W, H;
	cin >> W >> H;
	vector<int64_t> P(W + H);
	for (int64_t i = 0, x; i < W + H; i++)
		cin >> x, P[i] = ((x << 1) | (i < W));
	sort(P.begin(), P.end());
	int64_t r = 0;
	int64_t wh[2] = {W + 1, H + 1};
	for (auto p : P) {
		int64_t t = p & 1;
		r += (p >> 1) * wh[t];
		wh[!t]--;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1792
fn main() {
    const W: usize = 1000;
    const H: usize = 1000;
    let mut a: [[i32; H + 1]; W + 1] = [[0; H + 1]; W + 1];
    let N:u32 = read_num();
    for i in 0..N {
        let v: Vec<usize> = read_nums();
        let (x1, y1, x2, y2) = (v[0], v[1], v[2], v[3]);
        a[x1][y1] += 1;
        a[x1][y2] -= 1;
        a[x2][y1] -= 1;
        a[x2][y2] += 1;
    }
    for i in 0..H+1 {
        for j in 0..W {
            a[i][j + 1] += a[i][j];
        }
    }
    for j in 0..W+1 {
        for i in 0..H {
            a[i + 1][j] += a[i][j];
        }
    }
    let mut result = 0;
    for i in 0..H {
        for j in 0..W {
            result = std::cmp::max(result, a[i][j]);
        }
    }
    println!("{}", result);
}

fn read_str() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

fn read_num<T>() -> T where 
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {
    read_str().trim().parse().unwrap()
}

fn read_nums<T>() -> Vec<T> where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {
    let s = read_str();
    let a: Vec<&str> = s.split_whitespace().collect();
    let mut v: Vec<T> = Vec::new();
    for x in a {
        v.push(x.parse().unwrap());
    }
    v
}


Measured memory_bytes: 8964
#include<cstdio>
int count=0;
int T;
void dfs(long long n,char flag357)
{
	if(n<=T)
	{
		if(flag357==07)
		count++;
		dfs(n*10+3,flag357|01);
		dfs(n*10+5,flag357|02);
		dfs(n*10+7,flag357|04);
	}
}

int main()
{
	char flag357;
	scanf("%d",&T);
	dfs(0,0);
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
  ll a, b;
  cin >> a >> b;
  b++;
  ll res1=0;
  if(b%2){
    res1=b-1;
    b--;
  }
  if(b/2%2)
    res1^=1;
  ll res2=0;
  if(a%2){
    res2=a-1;
    a--;
  }
  if(a/2%2)
    res2^=1;
  ll ans=res1^res2;
  cout << ans << endl;
  return 0;
}

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

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    --u, --v;
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    auto bfs = [&](int s) -> vector<int> {
        vector<int> dist(N, -1);
        queue<int> que;
        dist[s] = 0;
        que.push(s);
        while(!que.empty()) {
            int cur = que.front();
            que.pop();
            for(auto &to : G[cur]) {
                if(dist[to] == -1) {
                    dist[to] = dist[cur] + 1;
                    que.push(to);
                }
            }
        }
        return dist;
    };
    auto A = bfs(u), B = bfs(v);
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        if(B[i] >= A[i]) ans = max(ans, B[i]);
    }
    cout << ans - 1 << '\n';
    return 0;
}


Measured memory_bytes: 6656
s = input()
q = int(input())

reverse = False
count = 0
mae = []
ushiro = []
for i in range(q):
    qu = input()
    if qu[0] == "1":
        count += 1
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        _, f, c = qu.split()
        if reverse:
            if f == "1":
                ushiro.append(c)
            else:
                mae.append(c)
        else:
            if f == "1":
                mae.append(c)
            else:
                ushiro.append(c)

s = "".join(mae[::-1]) + s + "".join(ushiro)

if count % 2:
    print(s[::-1])
else:
    print(s)


Measured memory_bytes: 6256
tyo = 0
hisi = 0
while True:
    try:
        a,b,c = map(int, input().split(","))
        if c**2 == a**2+b**2 : tyo += 1
        if a == b: hisi += 1
    except EOFError:
        break
print(tyo)
print(hisi)

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  vector<tuple<string, int, int>> vt;
  rep(i,N) {
    string S; int P;
    cin >> S >> P;    
    vt.push_back(make_tuple(S, -P, i+1));
  }
  
  sort(vt.begin(), vt.end());

  rep(i,N) {
    int idx;
    tie(ignore, ignore, idx) = vt[i];
    cout << idx << endl;
  }
}


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

using namespace std;

using ll = long long;

ll Solve() {
    constexpr ll MOD = 1e9 + 7;

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

    vector<int> idx(n);
    for (int i = 0; i < n; ++i) idx[i] = abs(i - (n - i - 1));

    sort(a.begin(), a.end());
    sort(idx.begin(), idx.end());
    for (int i = 0; i < n; ++i)
        if (a[i] != idx[i]) return 0;

    if (n % 2 == 1) --n;
    ll res = 1;
    for (int i = 0; i * 2 < n; ++i) res = (2 * res) % MOD;

    return res;
}

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

    cout << Solve() << endl;

    return 0;
}


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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  int sum = a+b+c;
  
  if(sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  
}


Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
l,r,d = gets.chomp.split.map(&:to_i)
ans = 0
l.upto(r) do |i|
  if i % d == 0
    ans += 1
  end
end

puts ans




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

void solv() {
    int n;
    scanf("%d", &n);
    printf("%d\n", (1 + n)*n / 2);
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000;
int dp[N], n;
char s[N + 1];
int calc(int i) {
	if (i == n)
		return 1;
	int &ret = dp[i];
	if (ret != -1)
		return ret;
	ret = false;
	
	if (i + 5 > n)
		return ret;
	char tmp[10] = { };
	for (int j = 0; j < 5; ++j)
		tmp[j] = s[i + j];
	if ((strcmp(tmp, "dream") == 0 || strcmp(tmp, "erase") == 0) && calc(i + 5))
		return ret = 1;
	
	tmp[5] = s[i + 5];
	if (i + 6 > n)
		return ret;
	if (strcmp(tmp, "eraser") == 0 && calc(i + 6))
		return ret = 1;
	
	tmp[6] = s[i + 6];
	if (i + 7 > n)
		return ret;
	if (strcmp(tmp, "dreamer") == 0 && calc(i + 7))
		return ret = 1;
	return ret;
}

int main(int argc, char **argv) {
	scanf("%s", s);
	n = strlen(s);
	memset(dp, -1, sizeof dp);
	puts(calc(0) ? "YES" : "NO");
	return 0;
}


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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            List<int> ls = new List<int>();
            int obj = 0;int ans = 0;
            for(int i = 1;i<=1000000;i++){
                if(i == 1){
                    obj = int.Parse(s);
                    ls.Add(int.Parse(s));
                }else{
                    obj = Func(obj);
                    if(ls.Contains(obj)){
                        ans = i;
                        break;
                    }
                    ls.Add(obj);
                }
            }
            Console.WriteLine(ans);
        }

        static public int Func(int n){
            if(n%2 == 0){
                return n/2;
            }else{
                return (3*n)+1;
            }
        }
    }
}


Measured memory_bytes: 13140
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
    }
    let mut edges = vec![];
    if n == 3 {
        edges.push((1, 3));
        edges.push((2, 3));
    } else {
        let mut clusters = vec![];
        if n % 2 == 0 {
            for i in 0..n / 2 {
                clusters.push(vec![1 + i, n - i]);
            }
        } else {
            clusters.push(vec![n]);
            for i in 0..n / 2 {
                clusters.push(vec![1 + i, n - 1 - i]);
            }
        }
        // eprintln!("cl = {:?}", clusters);
        let m = clusters.len();
        for i in 0..m {
            for j in i + 1..m {
                for &u in &clusters[i] {
                    for &v in &clusters[j] {
                        edges.push((u, v));
                    }
                }
            }
        }
    }
    puts!("{}\n", edges.len());
    for &(u, v) in &edges {
        puts!("{} {}\n", u, v);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}
func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	L := make([]int, M)
	R := make([]int, M)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	for i := 0; i < M; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), " ")
		L[i], _ = strconv.Atoi(s[0])
		R[i], _ = strconv.Atoi(s[1])

	}
	lmax, rmin := L[0], R[0]
	for i := 1; i < M; i++ {
		lmax = max(lmax, L[i])
		rmin = min(rmin, R[i])
	}
	if rmin >= lmax {
		fmt.Println(rmin-lmax+1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ng = 0, ok = INF<int>;
    while(ok-ng>1){
        int mid = (ok+ng)/2;
        ll k = mid*a+(mid/7)*b;
        (k >= c ? ok : ng) = mid;
    }
    cout << ok << "\n";
    return 0;
}



Measured memory_bytes: 3088
n=int(input())
a=list(map(int,input().split()))
b=[]

i=n-1
while i>=0:
    b.append(a[i])
    i-=2

i=n%2
while i<n:
    b.append(a[i])
    i+=2

bstr=" ".join(str(x) for x in b)
print(bstr)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#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 (ll i = m; i < n; i++)

vector<ll> dp[3];
string s;

ll eval(int i, int j) {
    if (dp[j][i] != -1) return dp[j][i];
    if (i >= s.size() && j == 3)
        dp[j][i] = 1;
    else if (i >= s.size() && j < 3)
        dp[j][i] = 0;
    else if (i < s.size() && j == 3)
        dp[j][i] = ((s[i] == '?') ? 3 : 1) * eval(i + 1, j);
    else
        dp[j][i] = ((s[i] == '?') ? 3 : 1) * eval(i + 1, j) +
                   ((s[i] == (char)('A' + j) || s[i] == '?') ? 1 : 0) * eval(i + 1, j + 1);
    dp[j][i] %= MOD;
    return dp[j][i] % MOD;
}

int main() {
    cin >> s;
    REP(i, 4) {
        vector<ll> hoge(s.size() + 1, -1);
        dp[i] = hoge;
    }
    cout << eval(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 12144
#include <iostream>

using namespace std;

int main()
{
    int r;
    int d;
    int x;
    cin>>r>>d >>x;
    int total=x;
    for(int i=1;i<=10;i++){
        total=r*total-d;
        cout<<total<<endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
#include<numeric>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int a, p;
	cin >> a >> p;
	cout << ((a * 3) + p) / 2 << endl;
}



Measured memory_bytes: 256