akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
  string s;
	cin>>s;
	int n=s.size();
	vector<ll>v(n+1);
	ll cur=0;
	rep(i,n){
		if(s[i]=='<')v[i+1]=max(v[i]+1,v[i+1]);
	}
	for(int i=n-1;i>=0;--i){
		if(s[i]=='>')v[i]=max(v[i],v[i+1]+1);
	}
	
	cout<<accumulate(all(v),0LL)<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 7624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
  
public class Main {
    private static final String CRLF = System.lineSeparator();
    public void exec() throws IOException {
    	SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int[] A = in.readIntArray(in.readInt());
        int swapcount = selectionSort(A);
        intArrayToString(A,sb);
        out.print(sb.toString());
        out.println(swapcount);
        out.flush();
    }
    
    private int selectionSort(int[] A){
    	int ret=0;
    	int minj,tmp;
    	for(int i=0; i<A.length; i++) {
    		minj = i;
    		for(int j=i; j<A.length; j++){
    			if(A[j] < A[minj])
    				minj=j;
    		}
			if(i!=minj){
				tmp = A[i];
				A[i] = A[minj];
				A[minj] = tmp;
				ret++;
			}
    	}
    	return ret;
    }
    
    private void intArrayToString(int[] a, StringBuilder sb) {
        for(int i=0; i<a.length; i++) {
            if (i>0)
                sb.append(" ");
            sb.append(a[i]);
        }
        sb.append(CRLF);
    }
     
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public int readInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }
    public int[] readIntArray(int len) throws NumberFormatException, IOException{
        int[] a = new int[len];
        int i=0;
        for(String s: br.readLine().split(" ")){
            a[i++] = Integer.parseInt(s);
        }
        return a;
    }
    
}

Measured memory_bytes: 24448
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int n,m;
ll ct =0;
vector<string> lines(1005);


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

    for(int i =0; i< n; ++i)
    {
        string s;
        cin >> lines[i];
    }

    vector<vector<ll> > dp (n, vector<ll> (m,0));
    dp[0][0] = 1;
    for(int i =0; i< n; ++i)
    {
        for(int j= 0; j< m; ++j)
        {
            if(lines[i][j+1] == '.')
                dp[i][j+1]= (dp[i][j+1] + (dp[i][j] % MOD)) % MOD;
            if(lines[i+1][j] == '.')
                dp[i+1][j] = (dp[i+1][j] + (dp[i][j] % MOD)) % MOD;
        }
    }
    cout << dp[n-1][m-1] % MOD;
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  string S;
  cin >> N >> S;
  vector<vector<long>> data(N, vector<long>(3));
  for(int i = N - 1; i >= 0; i--){
    if(S.at(i) == 'R')data.at(i).at(0)++;
    else if(S.at(i) == 'G')data.at(i).at(1)++;
    else data.at(i).at(2)++;
    if(i != 0){
      data.at(i - 1).at(0) = data.at(i).at(0);
      data.at(i - 1).at(1) = data.at(i).at(1);
      data.at(i - 1).at(2) = data.at(i).at(2);
    }
  }
  long ans = 0;
  for(int i = 0; i < N - 2; i++){
    for(int j = i + 1; j < N - 1; j++){
      if(S.at(i) != S.at(j)){
        if(S.at(i) == 'R' && S.at(j) == 'G'){
          ans += data.at(j + 1).at(2);
        } else if(S.at(i) == 'G' && S.at(j) == 'R'){
          ans += data.at(j + 1).at(2);
        } else if(S.at(i) == 'G' && S.at(j) == 'B'){
          ans += data.at(j + 1).at(0);
        } else if(S.at(i) == 'B' && S.at(j) == 'G'){
          ans += data.at(j + 1).at(0);
        } else if(S.at(i) == 'R' && S.at(j) == 'B'){
          ans += data.at(j + 1).at(1);
        } else if(S.at(i) == 'B' && S.at(j) == 'R'){
          ans += data.at(j + 1).at(1);
        }
        if(2 * j - i >= 0 && 2 * j - i <= N - 1){
          if(S.at(i) != S.at(j) && S.at(j) != S.at(2 * j - i) && S.at(i) != S.at(2 * j - i))ans--;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n,m,t[100],p,x,ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> t[i];
    ans+=t[i];
  }
  cin >> m;
  for(int i=0; i<m; i++) {
    cin >> p >> x;
    cout << ans-t[p-1]+x << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A[4],B[4],
		i,j,
		hit,blow;
	
	while( hit=0,blow=0,
		scanf("%d %d %d %d",&A[0],&A[1],&A[2],&A[3])!=EOF,
		scanf("%d %d %d %d",&B[0],&B[1],&B[2],&B[3])!=EOF)
	{
		
		for(i=0;i<4;i++){
			if(A[i]==B[i]) hit++;
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(j==i) j++;		/*ツ督ッツつカツ湘ェツ渉環づ按づァツスツキツッツプ*/
				
				if(B[j]==A[i]) blow++;
			}
		}
		printf("%d %d\n",hit,blow);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    vector<int> cnt(2);
    string s;
    cin >> s;
    for (char c : s) {
        cnt[c - '0']++;
    }
    cout << min(cnt[0], cnt[1]) * 2 << endl;
}

Measured memory_bytes: 512
def min_cut_num(n, L, size):
    cnt = 0
    for wood in L:
        cnt += ((wood + size - 1) // size) - 1
    return cnt
    

def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    # k 回以内のカットで作成できる最小の上限サイズを特定する
    left = 0
    right = 10 ** 9    # 必ず k 回以内
    while right - left > 1:
        mid = (left + right) // 2
        if min_cut_num(n, L, mid) <= k:
            right = mid
        else:
            left = mid
    print(right)




if __name__ == '__main__':
    main()

Measured memory_bytes: 30836
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine().Split();
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var U = Console.ReadLine();
        if (s[0] == U) a[0]--;
        else a[1]--;
        Console.WriteLine($"{a[0]} {a[1]}");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;

vector<int> G[MAX_N];
vector<pair<int, int> > bridge;
int ord[MAX_N];	//?¨??????????
int low[MAX_N]; //low[u]???u????????????1???????????????????????£?????????????????????????????????ord???????°????
bool visit[MAX_N]; //?¨?????????????????????????????????°

void dfs(int v,int p,int &k) //&??????????????¨??§k???????????§?????? p???v??????
{
	visit[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	for(int i=0;i<G[v].size();i++){
		if(!visit[G[v][i]]){
			dfs(G[v][i],v,k);
			low[v] = min(low[v],low[G[v][i]]);	//??????????????????low??¨????????????
			if(ord[v] < low[G[v][i]]){
				bridge.push_back(make_pair(min(v,G[v][i]), max(v,G[v][i])));
			}
		}else if(G[v][i] != p){
			low[v] = min(low[v],ord[G[v][i]]); //???????????§????????£??????????¨????????????¨????????????
		}
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int k = 0;
	fill(visit,visit+n,false);
	for(int i=0;i<n;i++){
		if(!visit[i]) dfs(i,-1,k);
	}
	sort(bridge.begin(), bridge.end());
	for(int i=0;i<bridge.size();i++){
		printf("%d %d\n",bridge[i].first,bridge[i].second);
	}
}

Measured memory_bytes: 7180
N = int (input())
K = int (input())
x = list(map(int, input().split()))
sum_min = 0

for p in x:
  a = 2*p
  b = 2*abs(K-p)
  if a >= b:
    sum_min += b
  elif a < b:
    sum_min += a

print(sum_min)

Measured memory_bytes: 9160
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "limits.h"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
using namespace std;

ll n, m, ans;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	cin >> n >> m;
	ans = 0;
	if (n * 2 >= m) {
		ans += m / 2;
	}
	else {
		ans += n;
		m -= n * 2;
		ans += m / 4;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long n,m,w[105],v[105];
long long f[105][100008];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (long i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for (long i=0;i<=n;i++)
    {
        f[i][0]=0;
        for (long j=1;j<=100005;j++)
        {
            f[i][j]=1e18;
        }
    }
    for (long i=1;i<=n;i++)
    {
        for (long j=1;j<=100005;j++)
        {
            f[i][j]=f[i-1][j];
            if (j >= v[i])
            {
                f[i][j]=min(f[i-1][j],f[i-1][j-v[i]]+w[i]);
            }
        }
    }
    for (long j=100005;j>=0;j--)
    {
        if (f[n][j]<= m)
        {
            cout<<j;
            return 0;
        }
    }
}


Measured memory_bytes: 80128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val k_x = sc.nextLine().split(" ").map { Integer.parseInt(it) }
    val max = 1000000
    val min = -1000000
    val a = mutableListOf<Int>()
    for (i in (k_x[1]-k_x[0] + 1) until (k_x[1]+k_x[0])) {
        if (i < min || i > max) continue
        a.add(i)
    }
    println(a.joinToString(" "))
}

Measured memory_bytes: 36088
#include<bits/stdc++.h>
using namespace std;
int main(){
  string text;
  cin >> text;
  for(int i=0;i<text.size();i++){
    if(i%2==0){
    if(text.at(i)=='L'){
    cout << "No" <<endl;
    return 0;}}
    if(i%2==1){
    if(text.at(i)=='R'){
    cout << "No" <<endl;
    return 0;}}
  }
cout << "Yes" <<endl;
}

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


void solve(long long A, long long B, long long C, long long X){
  long long count = 0;
  REP(i, A+1) {
    REP(j, B+1) {
      REP(k, C+1) {
        if((i * 500)+(j * 100)+(k * 50) == X) count++;
      }
    }
  }

  cout << count << endl;
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long X;
  scanf("%lld",&X);
    solve(A, B, C, X);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main 
{
	static class C implements Comparator<Entry>
	{

		@Override
		public int compare(Entry o1, Entry o2) 
		{
			long ev = o2.eval() - o1.eval();
			if(ev<0)return-1;
			if(ev>0)return 1;
			return 0;
		}
		
	}
	
	static class Entry
	{
		int x,y,z;
		
		public Entry(int x0, int y0, int z0)
		{
			x=x0;
			y=y0;
			z=z0;
			set.add(key(x,y,z));
		}
		
		long eval()
		{
			return a[x] + b[y] + c[z];
		}
	}
	
	static Long[] a;
	static Long[] b;
	static Long[] c;
	static HashSet<String> set = new HashSet<>();
	
	static String key(int x, int y, int z)
	{
		return x + " " + y + " " + z;
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int k = sc.nextInt();
		
		a = new Long[x];
		b = new Long[y];
		c = new Long[z];
		
		for(int i = 0; i < x; i++)
			a[i] = sc.nextLong();
		for(int i = 0; i < y; i++)
			b[i] = sc.nextLong();
		for(int i = 0; i < z; i++)
			c[i] = sc.nextLong();
		
		Arrays.sort(a, Collections.reverseOrder());
		Arrays.sort(b, Collections.reverseOrder());
		Arrays.sort(c, Collections.reverseOrder());
		
		C c = new C();
		PriorityQueue<Entry> q = new PriorityQueue<>(c);
		
		q.add(new Entry(0,0,0));
		
		
		StringBuilder sb = new StringBuilder();
		for(int d = 0; d < k; d++)
		{
			Entry pos = q.poll();
			
			sb.append(pos.eval() + "\n");
			
			if(pos.x<x-1 && !set.contains(key(pos.x+1,pos.y,pos.z)) )q.add(new Entry(pos.x+1, pos.y, pos.z));
			if(pos.y<x-1 && !set.contains(key(pos.x,pos.y+1,pos.z)))q.add(new Entry(pos.x, pos.y+1, pos.z));
			if(pos.z<x-1 && !set.contains(key(pos.x,pos.y,pos.z+1)))q.add(new Entry(pos.x, pos.y, pos.z+1));
		}
		System.out.print(sb);
	}

}


Measured memory_bytes: 30404
def resolve():
	from collections import deque
	K = int(input())
	q = deque(str(i) for i in range(1, 10))
	cnt = 9
	if K < 10:
		print(K); return
	while True:
		tmp = q.popleft()
		las = int(tmp[-1])
		for i in range(las-1, las+2):
			if 0<=i<=9:
				q.append(tmp + str(i))
				cnt += 1
				if cnt==K:
					print(q.pop()); return
resolve()

Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
signed main(){
vector<int> b={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin>>x>>y;
  if(b[x]==b[y])
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] D = W.split(" ");

		int N = Integer.parseInt(D[0]);
		int A = Integer.parseInt(D[1]);
		int B = Integer.parseInt(D[2]);

		if(N*A < B){
			System.out.println(N*A);
		}else{
			System.out.println(B);
	}


	}


}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

map<ll, int> fctm( ll x ){
	map<ll, int> fmp;
	for( ;x>=4 && x%2==0; x/=2)  fmp[2]++;
	for(ll d=3, q=x/d; q>=d ; q=x/d){if(x%d==0) fmp[d]++, x=q; else d +=2;}
	if(x!=1) fmp[x]++;
	return fmp;
}
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	map<ll,int> mp;
	
	rep2(i,2,n+1){
		auto wm = fctm(i);
		for(auto x: wm){
			mp[x.first] += x.second;
		}
	}
	//for(auto x :mp) printf("%lld:%d, ",x.first,x.second); puts("");
	int cn=sz(mp), zc=0;
	vector<ll> s1(cn), s2(cn);
	
	for(auto x :mp){ s1[zc]=x.first; s2[zc]=x.second; zc++;}
	//for(auto x :s2) printf("%lld, ",x); puts("");
	
	ll ans =0;
	rep(i, cn) rep2(j,i+1,cn) rep2(k,j+1,cn){
		if(s2[i] >=2 && s2[j]>=4 && s2[k]>=4) ans++;
	}
	rep(i, cn) rep2(j,i+1,cn) rep2(k,j+1,cn){
		if(s2[i] >=4 && s2[j]>=2 && s2[k]>=4) ans++;
	}
	rep(i, cn) rep2(j,i+1,cn) rep2(k,j+1,cn){
		if(s2[i] >=4 && s2[j]>=4 && s2[k]>=2) ans++;
	}
	rep(i, cn) rep2(j,i+1,cn) {
		if(s2[i] >=2 && s2[j]>=24 ) ans++;
	}
	rep(i, cn) rep2(j,i+1,cn) {
		if(s2[i] >=24 && s2[j]>=2 ) ans++;
	}
	rep(i, cn) rep2(j,i+1,cn) {
		if(s2[i] >=4 && s2[j]>=14 ) ans++;
	}
	rep(i, cn) rep2(j,i+1,cn) {
		if(s2[i] >=14 && s2[j]>=4 ) ans++;
	}
	rep(i,cn) if(s2[i]>=74) ans++;
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n k ->
    let l = Array.init n (fun _ -> Scanf.scanf " %d" (fun l -> l)) in
    Array.sort (fun a b -> compare b a) l;
    let rec loop i acc =
        if i = k then acc else loop (i + 1) (acc + l.(i))
    in
    Printf.printf "%d\n" @@ loop 0 0
)

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 6E2;
int n, m;
double f[N], g[N];
vector<int> e[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        e[s].push_back(t);
    }
    for (int i = n - 2; i >= 0; --i) {
        for (int v : e[i])
            f[i] += f[v] + 1;
        f[i] /= e[i].size();
    }
    double ans = f[0];
    for (int i = 0; i < n; ++i) {
        if (e[i].size() <= 1)
            continue;
        double mx = 0;
        for (int v : e[i])
            mx = max(mx, f[v] + 1);
        copy(f, f + n, g);
        g[i] = (g[i] * e[i].size() - mx) / (e[i].size() - 1);
        for (int j = i - 1; j >= 0; --j) {
            g[j] = 0;
            for (int v : e[j])
                g[j] += g[v] + 1;
            g[j] /= e[j].size();
        }
        ans = min(ans, g[0]);
    }
    cout << setprecision(10) << fixed << ans << endl;
    return 0;
}

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

int main() {
  
  int a, b, c;

  std::cin >> a >> b >> c;

  if( a > b ) {
    std::swap(a, b);
  }

  if( b > c ) {
    std::swap(b, c);
  }

  if( a > b ) {
    std::swap(a, b);
  }

  printf("%d %d %d\n", a, b, c);

  
  return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<tuple<int, int, int>> a(n);
	for(int i = 0; i < n - 1; i++){
		cin >> get<0>(a[i]) >> get<1>(a[i]) >> get<2>(a[i]);
	}
	for(int i = 0; i < n; i++){
		int t = 0;
		for(int j = i; j < n - 1; j++){
			int c, s, f;
			tie(c, s, f) = a[j];
			if(t <= s) t = s + c;
			else{
				t = f * (int)((t + f - 1) / f) + c;
 			}
		}
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    long I;
    foreach (i; 0 .. N)
        if (A[i] == 1)
        {
            I = i;
            break;
        }
    long a = ((N - 1) + (K - 2)) / (K - 1);

    writeln(a);
}


Measured memory_bytes: 4412
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy
# sys.setrecursionlimit(1000000)

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def next(su, ai, sign):
    assert sign in [-1, 1]
    if (su + ai) * sign > 0:
        return ai
    else:
        nextsu = sign
        nextai = nextsu - su
        return nextai

def main():
    n = int(input())
    an = list(map(int, input().split()))

    ress = HUGEL
    for beg in [-1, 1]:
        res = 0
        su = 0
        sign = beg
        for i in range(n):
            ai = next(su, an[i], sign)
            su = su + ai
            res += abs(ai - an[i])
            sign *= (-1)
        ress = min(ress, res)

    print(ress)

main()


Measured memory_bytes: 14888
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  REP(i,s.size()) s[i] = 'x';

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  int n; cin>>n;
  vector<int>L(n);
  rep(i,n) cin>>L[i];
  int ans = 0;
  rep(i,n){
    for (int j=i+1;j<n;j++){
      for (int k=j+1;k<n;k++){
        int mx = max(L[i], max(L[j],L[k]));
        int mini = min(L[i], min(L[j],L[k]));
        int mid = L[i] + L[j] + L[k] - (mx + mini);
        if (mx==mid||mini==mid) continue;
        if (mini + mid > mx) ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
    long long n, y;
    cin >> n >> y;
    int ans[3] = {-1, -1, -1};
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n; j++) {
            int k = n - i - j;
            if(k < 0) {
               break;
            }
            if(10000 * i + 5000 * j + 1000 * k == y) {
                ans[0] = i;
                ans[1] = j;
                ans[2] = k;   
            }
        }
    }
    if(ans[0] == -1) {
        cout << "-1 -1 -1" << endl;
    } else {
        cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    }
    return 0;
}

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

template <class T>
bool Reduce(T &a,T const &b) {
	return a>b?a=b,1:0;
}

const int XN=2e5+11;

int main() {
	//freopen("input","r",stdin);
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);std::cout.tie(0);
	int n;std::cin>>n;
	static std::pair<int,int> p[XN*2];
	for(int i=1;i<=n;++i) {
		int x,y;std::cin>>x>>y;
		p[i]=std::make_pair(x,i);
		p[i+n]=std::make_pair(y,i);
	}
	std::sort(p+1,p+1+2*n);
	std::set<std::pair<int,int>> S1,S2;
	static int pre[XN];
	long long Ans=3e18;
	for(int i=1;i<=2*n;++i) {
		if(pre[p[i].second]) {
			S1.erase({pre[p[i].second],p[i].second});
			S2.insert({pre[p[i].second],p[i].second});
			S1.insert(p[i]);
		} else {
			S1.insert({pre[p[i].second]=p[i].first,p[i].second});
		}
		if(S1.size()==n)
			Reduce(Ans,1LL*(S1.rbegin()->first-S1.begin()->first)
				*((i!=2*n?p[2*n].first:S2.rbegin()->first)-(S2.empty()?p[i+1].second:S2.begin()->first)));
	}

	std::cout<<Ans<<'\n';
	return 0;
}

Measured memory_bytes: 22912
package main

import (
	"fmt"
  	"sort"
)

func main() {

	DistinctOrNot()

}

//DistinctOrNot te
func DistinctOrNot(){

	var N int

	fmt.Scan(&N)

	A := make([]int,N)
	
	for i:=0;i<N;i++{

		fmt.Scan(&A[i])
	}

	sort.Sort(sort.IntSlice(A))

	Flg := false

	for i:=0;i<len(A)-1;i++{

		if A[i]==A[i+1] {

			Flg=true
		}
	}


	if Flg == true{

		fmt.Println("NO")

	}else{

		fmt.Println("YES")
	}

}

Measured memory_bytes: 5760
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)



int main() {
	int a, b, c,ans;
	cin >> a >> b >> c;
	if (a + b < c) {
		ans = a+b+ + 1 + b;
		cout << ans << endl;
		return 0;
	}
	if (a + b >= c) {
		ans = b + c;
		cout << ans << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

const int N = 2e5 + 5;

vector <int> g[N];

int addv[N];

void add(int u, int v) {
  g[u].push_back(v);
  g[v].push_back(u);
}

int ans[N];

void dfs(int u, int fa, int now) {
  ans[u] = now;
  for (auto v : g[u]) {
    if (v != fa) {
      dfs(v, u, now + addv[v]);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    add(u, v);
  }
  for (int i = 1; i <= q; ++i) {
    int x, v;
    cin >> x >> v;
    addv[x] += v;
  }
  dfs(1, 0, addv[1]);
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 24064
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

BC = [[] for i in range(M)]

for i in range(M):
    BC[i]=list(map(int,input().split()))

BC = sorted(BC, key=lambda x: x[1], reverse=True)
maxC = BC[0][1]

count = 0
result = 0
while count < N:
    if len(BC) >0:
        if A[0] < BC[0][1]:
            for i in range(BC[0][0]):
                if count < N:
                    result += BC[0][1]
                    count+=1
                else:
                    break
            else:
                BC.pop(0)
        else:
            result+=A.pop(0)
            count+=1
    else:
        result+=A.pop(0)
        count+=1

print(result)   




Measured memory_bytes: 33708
import sys
input=sys.stdin.readline

def make_divisors(n):
    lsls=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            lsls.append(i)
            if i!=n//i:
                lsls.append(n//i)
    lsls.sort()
    return lsls

N,K=map(int,input().split())
A=list(map(int,input().split()))

S=sum(A)
lst=make_divisors(S)

ans=1
B=[0]*N
for u in lst:
    for i in range(N):
        B[i]=A[i]%u
    B.sort()
    kkk=0
    s=0
    while kkk<N and s+B[kkk]<=K:
        s+=B[kkk]
        kkk+=1
    t=0
    for i in range(kkk,N):
        t+=u-B[i]
    if s>=t:
        ans=u

print(ans)

Measured memory_bytes: 41836
#include <iostream>
    using namespace std;
     
    int main() {
	int h,w;
	while(1){
		cin>> h >> w;
		if(h == 0 && w == 0){
			break;
		}
	for (int j=0; j<h ; j++){
		for (int i=0; i<w ; i++){
			cout<< "#";
		};
		cout << endl;
	};
	cout << endl;
	}
    return 0;
    }




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i)=0;i<(int)(n);i++)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef vector<int> Array;

int l[20][202020];
int r[20][202020];
int dp1[20][202020];
int dp2[20][202020];

int main() {
	int n, k;
	cin >> n >> k;
	Array x(n);
	REP(i, n)cin >> x[i];
	REP(i, n)dp1[0][i] = l[0][i] = lower_bound(all(x), x[i] + k) - x.begin();
	REP(i, n)dp2[0][i] = r[0][i] = upper_bound(all(x), x[i] - k) - x.begin() - 1;
	REP(i, 19)REP(j, n)l[i + 1][j] = l[i][min(n - 1, l[i][j])];
	REP(i, 19)REP(j, n)r[i + 1][j] = r[i][max(0, r[i][j])];
	REP(i, 19)REP(j, n)dp1[i + 1][j] = dp1[i][j] + dp1[i][l[i][j]];
	REP(i, 19)REP(j, n)dp2[i + 1][j] = dp2[i][j] + dp2[i][r[i][j]];
	int q;
	cin >> q;
	while (q--) {
		int L, R;
		cin >> L >> R;
		L--;
		int ans = R - L;
		int x = L, y = R - 1;
		for (int i = 19; i >= 0; i--) {
			if (l[i][x] < R)ans += (1 << i) - dp1[i][x], x = l[i][x];
			if (r[i][y] >= L)ans += dp2[i][y], y = r[i][y];
		}
		cout << ans << "\n";
	}
	return 0;
}


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    a--;b--;
    cout<<(a+b-1)/a<<endl;

    timer();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int arr[n];
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  int counter = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      counter += arr[i] * arr[j];
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
// but in the end its me & I

#include <bits/stdc++.h>
#include <vector>

#define s second
#define f first
#define pb push_back
//#define int ll

using namespace std;

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

const long long MAX=2e5,INF=1e9+1,mod=998244353;

int n,m,k,a[3][MAX];
string s;
vector <int> v;
bool mark[MAX];

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[0][i] >> a[1][i] >> a[2][i];
        if(i==0)continue;
        a[0][i]+=max(a[1][i-1],a[2][i-1]);
        a[1][i]+=max(a[0][i-1],a[2][i-1]);
        a[2][i]+=max(a[1][i-1],a[0][i-1]);
    }
    cout << max({a[0][n-1],a[1][n-1],a[2][n-1]});
    return -0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/

string s;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    rep(i,s.size()-1){
        if (s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            break;
        }else if (i < s.size() - 2 && s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            break;
        }
        if(i == s.size() -2){
            cout << -1 << " " << -1 << endl;
        }
    }

}

Measured memory_bytes: 512
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> vec(n);
  rep(i,n) {
    int a;
    cin >> a;
    rep(j, a) {
      int x,y;
      cin >> x >> y;
      vec[i].push_back(make_pair(x-1, y));
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<bool> r(n, false);
    for (int j = 0; j < n; j++) {
      if(i >> j & 1) {
        r[j] = true;
      }
    }
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if(i >> j & 1) {
        for (auto p : vec[j]) {
          if (r[p.first] != p.second) {
            ok = false;
          }
        }
      }
    }
    
    if (!ok) continue;
    int cnt = 0;
    rep(j, n) {
      if (r[j]) cnt++;
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  ll N, T; cin >> N >> T;
  vector<ll> v(N);
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }

  long ans = N * T;
  for(int i = 0; i < N-1; i++){
    ans -= max(v.at(i) + T - v.at(i+1) , 0ll);
    //cout << ans << " " ;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

ll a[101010], b[101010];

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N; cin>>N;
  vector<ll> V(N);
  rep(i,N) cin>>V[i];
  if(N==2){
    cout<<abs(V[0]-V[1])<<endl;
    return 0;
  }
  sort(V.begin(),V.end());
  int l,r,L,R;
  if(N%2==0){
    a[N/2]=V[0];
    a[N/2-1]=V[N-1];
    l=1,r=N-2;
    L=N/2-2,R=N/2+1;
    int cnt=0;
    while(L>=0||R<N){
      if(cnt%2==0){
        if(L>=0) a[L--]=V[l++];
        if(R<N) a[R++]=V[r--];
      }else{
        if(L>=0) a[L--]=V[r--];
        if(R<N) a[R++]=V[l++];
      }
      cnt++;
    }
  }else{
    a[N/2]=V[0];
    a[N/2-1]=V[N-1];
    a[N/2+1]=V[N-2];
    l=1,r=N-3;
    L=N/2-2, R=N/2+2;
    int cnt=0;
    while(L>=0||R<N){
      if(cnt%2){
        if(L>=0) a[L--]=V[r--];
        if(R<N) a[R++]=V[r--];
      }else{
        if(L>=0) a[L--]=V[l++];
        if(R<N) a[R++]=V[l++];
      }
      cnt++;
    }
    b[N/2]=V[N-1];
    b[N/2-1]=V[0];
    b[N/2+1]=V[1];
    l=2, r=N-2;
    L=N/2-2, R=N/2+2;
    cnt=0;
    while(L>=0||R<N){
      if(cnt%2==0){
        if(L>=0) b[L--]=V[r--];
        if(R<N) b[R++]=V[r--];
      }else{
        if(L>=0) b[L--]=V[l++];
        if(R<N) b[R++]=V[l++];
      }
      
      cnt++;
    }
  }
  ll ans=0, tmp=0;
  rep(i,N-1) ans+=abs(a[i]-a[i+1]);
  if(N%2) rep(i,N-1) tmp+=abs(b[i]-b[i+1]);
  ans=max(ans,tmp);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int a, b;
    cin >> a >> b;
    int ret, count;
    if(a<b) ret=a, count=b;
    else ret=b, count=a;

    rep(i, count) cout << ret;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e5 + 9;
const ll p = 31;
// const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9 +7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
std::vector<ll> adj[N];
ll dp[N][2];
void dfs(ll v, ll p){
     ll all_w = 1;
     ll su = 1;
     for(auto u:adj[v]){
          if(u!=p){
               dfs(u,v);
               su*=(dp[u][0]+dp[u][1]);
               all_w*=dp[u][0];
               su%=mod;all_w%=mod;
          }
     }
     ll ob =su-all_w;
     ob%=mod;
     dp[v][0]=su;dp[v][1]=all_w;

}

int main()
{   
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);                       
     ll T= 1;
     // cin>>T;

     while(T--){
          ll n;cin>>n;
          for(int i = 0;i<n-1;i++){
               ll u,v;cin>>u>>v;u--;v--;
               adj[u].pb(v);
               adj[v].pb(u);
          }
          dfs(0,0);
          cout<<(dp[0][0]+dp[0][1])%mod<<'\n';

     }
    return 0;
}

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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>0 ?(a):-(a))
#define llong long long

int main(){
	llong A,V; scanf("%lld %lld",&A,&V);
	llong B,W; scanf("%lld %lld",&B,&W);
	llong T; scanf("%lld",&T);
	if( abs(A-B) <= (V-W)*T ) printf("YES");
	else printf("NO");
	return 0;
}


Measured memory_bytes: 1692
/* ex6_2
  sachiyan */

#include <stdio.h>
#include <string.h>

int main(void){
    char word[101]; //入力文字を格納する配列、null文字分含む
    int count; //間に挟まる文字数
    scanf("%s", word); //入力文字の読み取り
    count = strlen(word) - 2; //文字列の長さから両端を抜く
    printf("%c%d%c\n", word[0], count, word[strlen(word)-1]); //最初の文字、間の文字数、最後の文字を出力
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 305;

int n, m, dp[N][N][N], mod = 1e9 + 7;
vector <pair <int, int> > v[N];

void add(int &x, int y){
    x += y;
    if(x >= mod) x -= mod;
}
bool invalid(int i, int j, int k){
    if(j < i) swap(i, j);
    if(k < i) swap(i, k);
    if(k < j) swap(j, k);
    for(auto &s : v[k]){
        int cnt = 1;
        cnt += s.first <= i;
        cnt += s.first <= j;
        if(cnt != s.second) return 1;
    }
    return 0;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
        int l, r, x;
        cin >> l >> r >> x;
        v[r].push_back(make_pair(l, x));
    }
    dp[0][0][0] = 1;
    for(int i = 0 ; i <= n ; i++){
        for(int j = 0 ; j <= n ; j++){
            for(int k = 0 ; k <= n ; k++){
                if(invalid(i, j, k)) dp[i][j][k] = 0;
                int f = max(i, max(j, k)) + 1;
                add(dp[f][j][k], dp[i][j][k]);
                add(dp[i][f][k], dp[i][j][k]);
                add(dp[i][j][f], dp[i][j][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0 ; i <= n ; i++){
        for(int j = 0 ; j <= n ; j++){
            for(int k = 0 ; k <= n ; k++){
                if(i == n || j == n || k == n){
                    add(ans, dp[i][j][k]);
                }
            }
        }
    }
    cout << ans << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll x;
  cin >> x;

  for (ll a = 0;; a++) {
    ll v = a * a * a * a * a - x;

    if (v >= 0) {
      for (ll b = 0; b * b * b * b * b <= v; b++) {
        if (b * b * b * b * b == v) {
          cout << a << ' ' << b << endl;
          return 0;
        }
      }
    } else {
      for (ll b = 0; b * b * b * b * b >= v; b--) {
        if (b * b * b * b * b == v) {
          cout << a << ' ' << b << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

using Edge = pair<long long, long long>;
using Graph = vector<vector<Edge> >;

vector<long long> ans;
long long N;
Graph G;

void dfs(long long v, long long p, long long c){
    ans[v] = c;//塗る

    for(auto nv : G[v]){
        if(nv.first == p) continue;

        if(nv.second % 2 != 0) dfs(nv.first, v, 1-c);//奇数なら違う色
        else dfs(nv.first, v, c);//偶数なら同じ色
    }
}

int main(){
    cin >> N;

    //assginでvectorを初期化 assgin(要素数, 値)
    // 初期化の際は値をもたずに型で指定できる vector<long long>()みたいに
    G.assign(N, vector<Edge>());

    for(long long i = 0; i < N-1; i++){
        long long u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    ans.assign(N, 0);

    dfs(0, -1, 0);

    for(auto v : ans){
        cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 13300
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,ans=0,x[1005]={},y[1005]={},z[1005]={},cnt,a[1005]={};
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  for(int i=0; i<(1<<3); i++) {
    a[1005]={};
    cnt=0;
    for(int j=0; j<n; j++) {
      a[j]=x[j]*(i&1?1:-1)+y[j]*(i&2?1:-1)+z[j]*(i&4?1:-1);
    }
    sort(a,a+n,greater<ll>());
    for(int j=0; j<m; j++) {
      cnt+=a[j];
    }
    ans=max(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int n, m;
    cin >> n >> m;

    vector<int> s(n);
    for(int i = 0; i < n; ++i){
        s.at(i) = 0;
    }

    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        ++s.at(a-1);
        ++s.at(b-1);
    }

    for(int i = 0; i < n; ++i){
        cout << s.at(i) << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;



int main(){
	double N;
	cin >> N;
	ll k=(N-1)/2+1;
	cout << fixed << setprecision(10);
	cout<<(double)(k/N)<<endl;

return 0;
}  



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n;
const int SIZE = 1e5+10;
ll a[SIZE],b[SIZE];
ll ans;

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

    ll sum_num = 0;
    for(int i = n-1; i >= 0; i--){
        a[i] += sum_num;
        if(a[i] % b[i] == 0)    continue;
        if(a[i] <= b[i]){
            ans += b[i]-a[i];
            sum_num += b[i]-a[i];
        }
        else{
            ll tmp = a[i]/b[i]+1;
            ans += tmp*b[i]-a[i];
            sum_num += tmp*b[i]-a[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792