akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
	#include <algorithm>
	#include <iostream>
	#include <iterator>
	#include <numeric>
	#include <sstream>
	#include <fstream>
	#include <cassert>
	#include <climits>
	#include <cstdlib>
	#include <cstring>
	#include <string>
	#include <cstdio>
	#include <vector>
	#include <math.h>
	#include <queue>
	#include<memory>
	#include <deque>
	#include <stack>
	#include <list>
	#include <map>
	#include <set>
	#include <cmath>
	#include <bitset>
	#include<list>
	#include <iomanip>
	using namespace std;
	typedef long long ll;
	int m[200005];
	void go()
	{
		m[0] = 1;
		m[1] = 1;
		for (int i = 2; i < 40000; i++)
		{
			for (int j = i * i; j < 10000; j += i)
			{
				m[j] = 1;
			}
		}
	}
	ll dp[(ll)1e5+110];
	ll n;
	ll q[1000005];
	ll k;
	ll solve(ll index) {
		if (index + 1  == n)return 0;
		if (index > n)return 1e8;
		ll &re = dp[index];
		if (re != -1)return re;
		ll d =(ll) 1e9;
		for (int i = 1; i <= k; i++)
		{
			re = min(abs(q[index] - q[index + i]) + solve(index + i), re == -1 ? (int)1e9 : re);
		}
		return re;
	}


	int main()
	{
		cerr << "FUCK YOU" << endl;

		ios::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		memset(dp, -1, sizeof dp);
		memset(q, 0, sizeof q);
		int x;
		cin >> n;
		cin >> k;
		for (int i = 0; i < n; i++)
		{
			cin >> q[i];
		}
		cout << solve(0) << endl;;
		return 0;
	}

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

int main(){
  int n;
  long long X=0,x=0,ans=1000000000000000000LL;
  cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    X+=a[i];
    }
    for(int i=0;i<n;i++){
      x+=a[i];
      if(i+1<n)ans=min(ans,abs(X-2*x));
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp[5],tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
set<pair<ll,pair<ll,ll>>> st;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        rep(j,3)cin>>tmp[j];
        sort(tmp,tmp+3);
        st.insert({tmp[0],{tmp[1],tmp[2]}});
    }
    Cout(n-Size(st));
    return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> ii;

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

char arr[200][200];
bool used[200][200];

vector<vector<int>> dir{{1,0},{0,1},{-1,0},{0,-1}};

int N, M,maxi = 0;

int solve(int i, int j, int targetI, int targetJ){
    queue<tuple<int,int,int>> Q;
    Q.push(tuple<int,int,int>(i,j,0));
    used[i][j] = true;
    while(!Q.empty()){
        i = get<0>(Q.front());
        j = get<1>(Q.front());
        int de = get<2>(Q.front());
        Q.pop();
        if(arr[i][j] == '#')continue;
        if(i==targetI && j==targetJ)return de;
        for(int d = 0; d < 4; d++){
            if(i+dir[d][0] < 0 || j+dir[d][1] < 0 || i+dir[d][0] >= N || j+dir[d][1] >= M) continue;
            if(used[i+dir[d][0]][j+dir[d][1]])continue;
            used[i+dir[d][0]][j+dir[d][1]] = 1;
            if(arr[i+dir[d][0]][j+dir[d][1]] == '#')continue;
            Q.push(tuple<int,int,int>(i+dir[d][0],j+dir[d][1],de+1));
        }
    }
    return 100000000;
}

int main(){
    ios_base::sync_with_stdio(false);

    cin >> N >> M;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> arr[i][j];
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            for(int ti = 0; ti < N; ti++){
                for(int tj = 0; tj < M; tj++){
                    if(arr[i][j] == '.' && arr[ti][tj] == '.'){
                        memset(used,false,sizeof used);
                        int ans = solve(i,j, ti,tj);
                        if(ans < 1000000)
                            maxi = max(maxi, ans);
                    }
                }
            }
        }
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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



    const long long INF = 1LL << 60;
    long long dp[100010][3];
    REP(i,100010)REP(j,3) dp[i][j] = -INF;
    REP(j,3) dp[0][j] = 0;

    int N;
    cin >> N;
    int a[N][3];
    REP(i,N)REP(j,3) cin >> a[i][j];

    REP(i,N)REP(j,3)REP(k,3){
        if (j==k) continue;
        chmax(dp[i+1][k],dp[i][j]+a[i][k]);
    }

    int ans = 0;
    REP(i,3) ans = max(ans,(int)dp[N][i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<char,int> mp;
int main(){
int n,k;
cin>>n>>k;
vector<ll> v(n+1,0);
for(int i=0;i<n;i++)cin>>v[i];
int m=n+1;
int ma=min(k,n);//取れる区間の最大値
ll ans=0;
for(int i=ma;i>=1;i--){//iは区間
for(int j=m-i-1;j<m;j++){
    ll res=0;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    int l=0;
while(l!=i+1){res+=v[(l+j)%m];pq.push(v[(l+j)%m]);l++;}
    int times=k-i;
   while(times--){
       if(pq.empty())break;
        ll tmp=pq.top();
        pq.pop();
        if(tmp>=0)break;
        res-=tmp;
    }
ans=max(ans,res);
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
import operator
from itertools import product

A, B, C, D = list(map(int, list(input())))
map_operator = {0: operator.sub, 1: operator.add}
map_string = {0: '-', 1: '+'}

for i, j, k in product((0, 1), repeat=3):
    sum = map_operator[k](map_operator[j](map_operator[i](A, B), C), D)
    if sum == 7:
        break

print(str(A) + map_string[i] + str(B) + map_string[j] \
    + str(C) + map_string[k] + str(D) + "=7")


Measured memory_bytes: 3064
a = [int(input())]

while True:
    if a[-1] % 2 == 0:
        a_next = int(a[-1] / 2)
    else:
        a_next = 3 * a[-1] + 1
    
    if a_next in a:
        print(len(a) + 1)
        break
    else:
        a.append(a_next)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
int a[MAXN];

int main() { 

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

  long long l = 2, r = 2;
  for (int i = n - 1; i >= 0; i--) {
    long long mn = 1ll * a[i] * ((l + a[i] - 1) / a[i]);
    long long mx = 1ll * a[i] * (r / a[i]);
    if (mn > r) {
      puts("-1");
      return 0;
    }
    l = mn; r = mx + a[i] - 1;
  }

  cout << l << " " << r << endl;

  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 1e5 + 5;

int a[N];
int main(){
    int n;
    scanf("%d", &n);
    multiset<int> st;
    for(int i = 0 ; i < n ; ++i){
        scanf("%d", a + i);
        st.insert(a[i]);
    }
    for(int i = 0 ; i < n ; ++i){
        st.erase(st.find(a[i]));
        printf("%d\n", *st.rbegin());
        st.insert(a[i]);
    }
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll n;
vector<pi> ar;

ll dp[19][2][1<<19];

ll func(ll idx,int s,ll mask)
{
    if(mask==(1<<n)-1){return 0;}

    if(dp[idx][s][mask]==-1){
    ll ans=INT_MAX;
    ll count=0;
    int ch[n]={0};
    for(ll i=0;i<n;++i){
        if((mask&(1<<i))!=0){++count;ch[i]=1;}
    }
    for(ll i=n-2;i>=0;--i){ch[i]+=ch[i+1];}
    for(ll i=0;i<n;++i)
    {
        if((mask&(1<<i))==0)
        {
            ll cost=0;
            if(i<n-1){cost=ch[i];}
            ll val=INT_MIN;
            if(count>0)
            {val=ar[idx].first;
            if(s){val=ar[idx].second;}
            }
            ll myval=ar[i].first;
            int ss=abs(i-count);
            if(ss%2==1){myval=ar[i].second;}
            if(val<=myval)
            {
                ans=min(ans,cost+func(i,ss%2,mask|(1<<i)));
            }
        }
    }
    dp[idx][s][mask]=ans;
    }
    return dp[idx][s][mask];
}

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

    cin>>n;
    ar.resize(n);
    for(ll i=0;i<n;++i){
        cin>>ar[i].first;
    }
    for(ll i=0;i<n;++i){
        cin>>ar[i].second;
    }

    memset(dp,-1,sizeof(dp));
    ll ans=func(n,0,0);
    if(ans==INT_MAX){ans=-1;}
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 155904
def abc174_c():
    k = int(input())
    ans = -1
    if k % 2 == 0 or k % 5 == 0:
        return ans
    f = 0
    for i in range(k+1):
        f = (f * 10 + 7) % k
        if f == 0:
            ans = i + 1
            break
    return ans

if __name__ == '__main__':
    print(abc174_c())

Measured memory_bytes: 9156
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
print(max(a) - min(a))

Measured memory_bytes: 72392
// Problem_E.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
const int MAX_K = 17;	// 2^17 = 131072

int N, L, Q;
vi X;
vector<vi> r;

int main(void) {
	cin >> N;
	X.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> X[i];
	cin >> L >> Q;

	vi v;
	v.resize(N);
	r.resize(MAX_K + 1, v);
	for (int i = 0; i < N; ++i)
		r[0][i] = upper_bound(X.begin(), X.end(), X[i] + L) - X.begin() - 1;
	for (int i = 1; i <= MAX_K; ++i) {
		for (int j = 0; j < N; ++j)
			r[i][j] = r[i - 1][r[i - 1][j]];
	}

	int a, b, k, ans;
	for (int i = 0; i < Q; ++i) {
		cin >> a >> b;
		if (a > b)
			swap(a, b);
		--a; --b;
		ans = 0;
		k = a;
		for (int i = MAX_K; i >= 0; --i) {
			if (r[i][k] < b) {
				k = r[i][k];
				ans += (1 << i);
			}
		}
		if (k < b) {
			k = r[0][k];
			++ans;
		}
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
const int MAX_N=300005;
int n;
int pre[MAX_N*3];
int rev[MAX_N*3];
int a[MAX_N*3];
signed main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	cin>>n;
	For(i,1,3*n)cin>>a[i];
	priority_queue <GREATER(int)> q1;
	For(i,1,3*n)
	{
		pre[i]=pre[i-1]+a[i];
		q1.push(a[i]);
		if(q1.size()>n)
		{
			pre[i]-=q1.top();
			q1.pop();
		}
	}
	priority_queue <int> q2;
	per(i,3*n,1)
	{
		rev[i]=rev[i+1]+a[i];
		q2.push(a[i]);
		if(q2.size()>n)
		{
			rev[i]-=q2.top();
			q2.pop();
		}
	}
	int ans=-LONG_LONG_MAX;
	For(i,n,2*n)
	{
		ans=max(ans,pre[i]-rev[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 16244
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
    int n, t[100001], x[100001], y[100001];
    int i, dt, dist;
    scanf("%d", &n);
    t[0] = x[0] = y[0] = 0;
    for (i=1; i<n+1; i++)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
 
    for (i=1; i<n+1; i++)
    {
        dt =  t[i] - t[i-1];
        dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if (dt < dist) {
            printf("No");
            return 0;
        }
        if (dt%2 != dist%2) {
            printf("No");
            return 0;
        }
    }
 
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1280
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	set := make(map[string]int)
	for i := 0; i < N; i++ {
		s := sc.nextStr()
		f := s[0]
		if f == 'M' || f == 'A' || f == 'R' || f == 'C' || f == 'H' {
			set[string(f)]++
		}
	}
	if len(set) < 3 {
		fmt.Fprintln(wtr, 0)
		wtr.Flush()
		return
	}
	strs := []string{}
	for key, _ := range set {
		strs = append(strs, key)
	}
	ans := 0
	for i := 0; i < len(strs); i++ {
		for j := i + 1; j < len(strs); j++ {
			for k := j + 1; k < len(strs); k++ {
				ans += set[strs[i]] * set[strs[j]] * set[strs[k]]
			}
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <climits>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

int main()
{
	int n = in();
	vector<int> W(n), S;
	vector<bool> V(n);
	unordered_map<int, int> M;
	for (int &w: W)
		w = in();
	S = W;
	sort(S.begin(), S.end());
	for (int i = 0; i < n; i++)
		M[S[i]] = i;
	int r = 0, s = S[0];
	for (int i = 0; i < n; i++) {
		if (V[i])
			continue;
		int S = 0, l = 0, m = INT_MAX;
		for (int c = i, v; !V[c]; c = M[v]) {
			V[c] = true;
			v = W[c];
			S += v;
			l++;
			m = min(m, v);
		}
		r += min(S + (l - 2) * m, m + S + (l + 1) * s);
	}
	out(r, '\n');
}


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

int a,b,c,x,ans;

int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a&&500*i<=x;i++)
    {
        for(int j=0;j<=b&&100*j+500*i<=x;j++)
        {
            for(int k=0;k<=c&&50*k+100*j+500*i<=x;k++)
            {
                if(500*i+100*j+50*k==x)
                {
                    ans++;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
/*
    BHAGWAN TUSSI GREAT HO! TOOFA KUBUL KARO XD
Hi! Stalker
█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█ 
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX_LIMIT 100000
using namespace std;
int main(){
    ll a,b;
    cin>>a>>b;
    if(a>=13){
        cout<<b<<endl;
    }
    else if(a>=6 && a<=12){
        cout<<b/2<<endl;
    }
    else if(a<6){
        cout<<"0"<<endl;
    }
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    string s;
    cin>>s;
    int n=-1;
    bool m=true; //maeが月になるか
    bool u=true; //usiroが月になるか
    if(s[0]>='1'&&s[1]>='3') m=false;
    if(s[0]>='2') m=false;
    if(s[0]=='0'&&s[1]=='0') m=false;
    if(s[2]>='1'&&s[3]>='3') u=false;
    if(s[2]>='2') u=false;
    if(s[2]=='0'&&s[3]=='0') u=false;

    if(m&&u) cout<<"AMBIGUOUS"<<endl;
    else if(m) cout<<"MMYY"<<endl;
    else if(u) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 2019;

int main()
{
    ciosup;
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll x0 = 0;
    int eo = 1;
    REP(i, n)
    {
        x0 += eo * a[i];
        eo *= -1;
    }
    x0 /= 2;
    ll xi=x0;
    REP(i,n-1){
        cout << 2*xi << " ";
        xi = a[i] - xi;
    }
    cout << 2*xi << endl;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int A = sc.nextInt(),
			    B = sc.nextInt(),
			    C = sc.nextInt();
			System.out.println(A+B+C-Math.max(A,Math.max(B,C)));
		}
	}
}



Measured memory_bytes: 22100
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int[] t = IntStream.range(0, scanner.nextInt()).map(i -> scanner.nextInt() * 2).toArray(), s = IntStream.concat(IntStream.of(0), IntStream.concat(Arrays.stream(t).flatMap(i -> Collections.nCopies(i, scanner.nextInt() * 2).stream().mapToInt(Integer::intValue)), IntStream.of(0))).toArray();
        IntStream.rangeClosed(0, s.length - 2).peek(i -> s[i + 1] = Math.min(s[i + 1], s[i] + 1)).map(i -> s.length - 2 - i).forEach(i -> s[i] = Math.min(s[i], s[i + 1] + 1));
        System.out.println(IntStream.rangeClosed(0, s.length - 2).mapToDouble(i -> Math.min(s[i], s[i + 1]) + Integer.compare(s[i + 1], s[i]) / 2d).sum() / 4);
    }
}

Measured memory_bytes: 29268
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, l = li()

apples = [l+i for i in range(n)]
minabs = float("inf")

for ai in apples:
    if abs(ai) < abs(minabs):
        minabs = ai

print(sum(apples) - minabs)

Measured memory_bytes: 3064
#include<iostream> 
#include<vector> 
#include<iomanip>
using namespace std; 
#define lld long long int
#define X 1000000007
#define fast();  ios_base::sync_with_stdio(false); cin.tie(0);
# define rec(i,n) for(int i=0;i<n;i++) 
#define w(t) int t; cin>>t; while(t--)
int main()
{
    fast(); 
     double  r; 
     cin>>r; 
     r=2*r; 
     r=r*(3.1415926); 
     cout<<fixed<<setprecision(5)<<r<<endl; 
	return 0;
}

Measured memory_bytes: 3752
A = int(input())
B = int(input())
C = int(input())
X = int(input())//50

ans = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 10*a + 2*b + c == X:
        ans += 1
print(ans)

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

using namespace std;

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

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

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

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

  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }

  long long sum = 0;
  for (int i=0; i<N-1; i++){
    if (abs(vec.at(i)-vec.at(i+1)) <= T){
      sum += abs(vec.at(i)-vec.at(i+1));
    }
    else {
      sum += T;
    }
  }
  sum += T;
  cout << sum << endl;
}


Measured memory_bytes: 1024
// D - Median of Medians

// 長さNの数列aのすべての部分列に対して, 中央値を求める
// それらすべての中央値を集めた数列に対する中央値を出力する

// 1 <= N <= 1e5
// 1 <= ai <= 1e9

// 解説: 二分探索・累積和・転倒数
//   [l,r]の中央値がX以上である ⇔ [l,r]はX以上の値が過半数を占める
//   X以上の要素を+1, X未満の要素を-1に置き換えて, 累積和Sを求めると,
//   区間和が正の数になるような[l,r]を数え上げる問題に言い換えられる
//   さらに, S[0,l] <= S[0,r]であるような[l,r]を数え上げる問題に言い換えられる

// 解法: O(N^2)
//   lを全探索
//   rを増やしながら, (abs(al未満の個数 - al超の個数) <= alと等しい個数)であるような[l,r]をカウント
//   これにより, 各aiが中央値になる回数が分かる

#include<vector>
#include<unordered_map>
#include<algorithm>
template<typename T> class Compression {
 public:
  Compression(const std::vector<T>& list) : value_(list) {
    std::sort(begin(value_), end(value_));
    value_.erase(std::unique(begin(value_), end(value_)), end(value_));
    for(int i = 0; i < value_.size(); ++i) index_[value_[i]] = i;
  }
  int size() const {return value_.size();}
  int index(const T& v) const {return index_.at(v);}
  int operator[](const int i) const {return value_.at(i);}
 private:
  std::unordered_map<T, int> index_;
  std::vector<T> value_;
};

#include<vector>
using Size = int;
template<typename T> class SegmentTree {
 public:
  SegmentTree(Size N) : N(size(N)), node_(2 * size(N) - 1) {}
  void update(Size i, T v) {
    i += N - 1;
    node_[i] = v;
    while(i != parent(i)) {
      i = parent(i);
      node_[i] = node_[lchild(i)] + node_[rchild(i)];
    }
  }
  T find(Size a, Size b) const {return find(a, b, 0, 0, N);}
 private:
  constexpr Size pop_lsb(Size N) const {return N & (N - 1);}
  constexpr Size msb(Size N) const {while(pop_lsb(N)) N = pop_lsb(N); return N;}
  constexpr Size size(Size N) const {return pop_lsb(N) ? msb(N) << 1 : N;}
  inline Size parent(Size n) const {return (n - 1) / 2;}
  inline Size lchild(Size n) const {return 2 * n + 1;}
  inline Size rchild(Size n) const {return 2 * n + 2;}
  T find(Size a, Size b, Size k, Size l, Size r) const {
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b) return node_[k];
    auto m = (l + r) / 2;
    return find(a, b, lchild(k), l, m) + find(a, b, rchild(k), m, r);
  }
  const Size N;
  std::vector<T> node_;
};

#include<bits/stdc++.h>
using namespace std;

int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for(auto& i: A) cin >> i;

  auto M = N + (N * (N-1) / 2);

  auto ok = [&](auto X) {
    vector<long long> S = {0};
    for(auto i: A) S.emplace_back(S.back() + (i<X ? -1 : 1));
    Compression<long long> C(S);
    SegmentTree<long long> T(C.size() + 1);
    long long cnt = 0;
    for(auto i=0; i<S.size(); ++i) {
      cnt += T.find(0, C.index(S[i]) + 1);
      auto x = T.find(C.index(S[i]), C.index(S[i]) + 1);
      T.update(C.index(S[i]), x + 1);
    }
    return (M+1)/2 <= cnt;
  };

  long long l = 1, h = 1e9+1;
  while(1 < h-l) {
    auto m = (l + h) / 2;
    if(ok(m)) l = m;
    else      h = m;
  }
  cout << l << endl;
}


Measured memory_bytes: 9048
/**
 *  author: mahfuzz
 *  created: 22.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    double l; cin >> l;
    
    double a = l / 3.;
    
    cout << fixed << setprecision(12) << a * a * a << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;


int main(){
	ll h, w; cin >> h >> w;
	vvl a(h, vl(w, 0)), b(h, vl(w, 0));
	rep(i, h) rep(j, w) cin >> a[i][j];
	rep(i, h) rep(j, w) cin >> b[i][j];
	vvvb pat(h, vvb(w, vb(2 * 80*80 + 1, false)));
	pat[0][0][80*80 + a[0][0] - b[0][0]] = true;
	pat[0][0][80*80 - a[0][0] + b[0][0]] = true;
	rep(i, h) rep(j, w){
		if (i){
			rep(k, pat[i - 1][j].size()){
				if (pat[i - 1][j][k]){
					ll sa = abs(a[i][j] - b[i][j]);
					if (k + sa <= 2*80*80)pat[i][j][k + sa] = true;
					if (k - sa >= 0)pat[i][j][k - sa] = true;
				}
			}
		}
		if (j){
			rep(k, pat[i][j - 1].size()){
				if (pat[i][j - 1][k]){
					ll sa = abs(a[i][j] - b[i][j]);
					if (k + sa <= 2*80*80)pat[i][j][k + sa] = true;
					if (k - sa >= 0)pat[i][j][k - sa] = true;
				}
			}
		}
	}
	ll ans = inf;
	rep(i, pat[h - 1][w - 1].size()){
		if (pat[h - 1][w - 1][i]) ans = min(ans, abs(80*80 - i));
	}cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10880
import java.io.*;

public class Main {
    public static void main(String[] args){
        try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = r.readLine().split(" ");
            int a = Integer.parseInt(input[0]);
            int b = Integer.parseInt(input[1]);
            System.out.println(String.format("%d %d", a * b, 2 * (a + b)));
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24576
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        
        int count = 0;
        while (a >= b) {
            b *= 2;
            count++;
        }
        while (b >= c) {
            c *= 2;
            count++;
        }
        
        if (count <= k) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int X, A, B;

int main(void){
    
    scanf("%d %d %d", &X, &A, &B);
    
    printf("%d\n", (X - A) % B);
    
    return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    if(a<=8&&b<=8){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
    
    
    
    
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

map<ll, ll> mp;
void prime_factorization(ll x){
    bool flag = true;
    while(flag){
        ll sqx = sqrt(x)+1;
        for(ll j=2;j<sqx+1;j++){
            if(x%j==0){
                mp[j]++;
                x/=j;
                break;
            }
            if(j==sqx) flag = false;
        }
    }
    if(x!=1){
        mp[x]++;
    }
}

int main(){
	ll N;
	cin >> N;
	REP(i, N){
		prime_factorization(i+1);
	}
	ll res = 0;
	ll i2 = 0;
	ll i4 = 0;
	ll i14 = 0;
	ll i24 = 0;
	ll i74 = 0;
	for(map<ll, ll>::iterator itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second>=2) i2++;
        if(itr->second>=14) i14++;
        if(itr->second>=24) i24++;
        if(itr->second>=74) i74++;
        if(itr->second>=4) i4++;
    }
    res += (i4*(i4-1))/2 * (i2-2);
    res += i14 * (i4-1);
    res += i24 * (i2-1);
    res += i74;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
    int x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3092
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn dfs(
    cur_step: usize,
    cur_pos: usize,
    edges: &Vec<Vec<usize>>,
    checked: &mut Vec<HashSet<usize>>,
    dest: &mut Vec<usize>,
) {
    checked[cur_step].insert(cur_pos);
    if cur_step == 2 {
        for &to in edges[cur_pos].iter() {
            // checked[2].insert(to);
            dest.push(to);
        }
        return;
    }
    for &to in edges[cur_pos].iter() {
        if checked[cur_step + 1].contains(&to) {
            continue;
        }
        // checked[cur_step + 1].insert(to);
        dfs(cur_step + 1, to, edges, checked, dest);
    }
}
fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut rev_edges = vec![vec![]; n];

    for _ in 0..m {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        rev_edges[b].push(a); // enable b from a
    }

    let v = read_vec::<usize>();
    let (s, t) = (v[0] - 1, v[1] - 1);

    let mut checked = vec![HashSet::new(); 3];
    let mut que = VecDeque::new();
    que.push_back((t, 0));

    while let Some((cur_pos, cycle)) = que.pop_front() {
        // debug!(checked);
        if cur_pos == s {
            println!("{}", cycle);
            return;
        }
        let mut dest = vec![];
        if checked[0].contains(&cur_pos) {
            continue;
        }
        dfs(0, cur_pos, &rev_edges, &mut checked, &mut dest);
        for d in dest {
            que.push_back((d, cycle + 1));
        }
    }
    println!("-1");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 20344
#include <stdio.h>
#include <stdlib.h>

int char_to_int(char c){
	return (int)c - (int)'A';
}

char int_to_char(int x){
	return (char)(x + (int)'A');
}

int main(){
	int N, Q, i, j, k, f;
	scanf("%d%d", &N, &Q);
	char *s = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s", s);
	char *t = (char *)malloc(sizeof(char) * Q);
	char *d = (char *)malloc(sizeof(char) * Q);
	char sub[2];
	for(i = 0; i < Q; i++){
		scanf("%s", sub);
		t[i] = sub[0];
		scanf("%s", sub);
		d[i] = sub[0];
	}
	int **next = (int **)malloc(sizeof(int *) * (Q + 1));
	for(i = 0; i <= Q; i++){
		next[i] = (int *)malloc(sizeof(int) * 26);
	}
	for(j = 0; j < 26; j++){
		next[Q][j] = Q;
	}
	for(i = Q - 1; i >= 0; i--){
		for(j = 0; j < 26; j++){
			if(t[i] == int_to_char(j)){
				next[i][j] = i;
			}
			else{
				next[i][j] = next[i + 1][j];
			}
		}
	}
	int ans = 0;
	int l = -1, h, r = N;
	while(r - l > 1){
		h = (l + r) / 2;
//		printf("h = %d\n", h);
		f = 1;
		for(j = h, k = next[0][char_to_int(s[j])]; k < Q; k = next[k + 1][char_to_int(s[j])]){
			if(d[k] == 'L'){
				j--;
			}
			else{
				j++;
			}
			if(j < 0){
				f = 0;
				break;
			}
			if(j < 0 || N <= j){
				break;
			}
		}
//		printf("f = %d\n", f);
		if(f == 1){
			r = h;
		}
		else{
			l = h;
		}
	}
//	printf("(l, r) = (%d, %d)\n", l, r);
	ans += l + 1;

	l = -1;
	r = N;
	while(r - l > 1){
		h = (l + r) / 2;
//		printf("h = %d\n", h);
		f = 1;
		for(j = h, k = next[0][char_to_int(s[j])]; k < Q; k = next[k + 1][char_to_int(s[j])]){
			if(d[k] == 'L'){
				j--;
			}
			else{
				j++;
			}
			if(N <= j){
				f = 0;
				break;
			}
			if(j < 0 || N <= j){
				break;
			}
		}
		if(f == 1){
			l = h;
		}
		else{
			r = h;
		}
	}
//	printf("(l, r) = (%d, %d)\n", l, r);
	ans += N - r;
	printf("%d\n", N - ans);
	return 0;


	for(i = 0; i < N; i++){
//		printf("i = %d\n", i);
		f = 1;
		for(j = i, k = next[0][char_to_int(s[j])]; k < Q; k = next[k + 1][char_to_int(s[j])]){
			if(d[k] == 'L'){
				j--;
			}
			else{
				j++;
			}
			if(j < 0 || N <= j){
				f = 0;
				break;
			}
		}
		ans += f;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main()
{
  int n, l; 
  cin >> n >> l;
  
  vector<string > a(n);
  for(auto &it: a)
    cin >> it;
  
  sort(a.begin(), a.end());
  string res = "";
  for(auto it: a)
    res += it;
  
  cout << res;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>


using namespace std;

int main(){
  size_t n{};
  cin >> n;
  vector<int> v(n);
  for(auto& it: v) cin >> it;

  map<size_t ,size_t> m[2];
  for(size_t i = 0; i < n ; ++i) ++m[i%2][v[i]];

  vector<pair<size_t,size_t>> pairs[2];
  for(size_t i = 0; i<2; ++i){
    m[i][0] = 0;
    for(auto&& p : m[i]) pairs[i].emplace_back(p.second,p.first);
    sort(pairs[i].rbegin(),pairs[i].rend());
  }

  size_t ans{};
  if(pairs[0][0].second != pairs[1][0].second){
    ans = n - pairs[0][0].first - pairs[1][0].first;
  }else{
    ans = n - max(
      pairs[0][1].first + pairs[1][0].first,
      pairs[0][0].first + pairs[1][1].first);
  }

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


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int n;
  while (cin >> n, n){
    int a[n], cnt = 0;
    REP(i, n) cin >> a[i];
    for (int i = n; i > 0; i--){
      for (int j = 0; j < i - 1; j++){
        if (a[j] > a[j + 1]){
          swap(a[j], a[j + 1]);
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}

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

int main (){
	int n;
	cin >> n;
	vector<int> b(n-1);
    vector<int> a(n);

    for(int i=0;i<n-1;i++){
        cin>>b.at(i);
    }
    a[0]=b[0];
    for(int i=1;i<=n-2;i++){
        a.at(i)=min(b.at(i),b.at(i-1));
    }
    a[n-1]=b[n-2];
    int ans=0;
    for(int i=0; i<n; i++){
        ans+=a.at(i);
    }
    cout<<ans<<endl;
}


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

namespace AtCoderBeginnerContest149
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split(' ').ToList().Select(x => long.Parse(x)).ToList();
			var a = inputs[0];
			var b = inputs[1];
			var k = inputs[2];

			if (a >= k)
			{
				a -= k;
				Console.WriteLine(a + " " + b);
				return;
			}
			else
			{
				k -= a;
				if (b >= k)
				{
					b -= k;
					Console.WriteLine("0 " + b);
					return;
				}
				else
				{
					Console.WriteLine("0 0");
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>

int gcd(int a, int b, int c){
    int tmp, f;
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
    f = a % b;
    while(f != 0){
        a = b;
        b = f;
        f = a % b;
    }

    if (b < c)
    {
        tmp = b;
        b = c;
        c = tmp;
    }
    f = b % c;
    while (f != 0)
    {
        b = c;
        c = f;
        f = b % c;
    }
    return c;
}

int main(){
    int K,a,b,c;
    unsigned long N;

    scanf("%d", &K);

    N = 0;
    for (a = 1; a <= K; a++){
        for (b = 1; b <= K; b++){
            for (c = 1; c <= K;c++){
                N += gcd(a, b, c);
            }
        }
    }

    printf("%ld", N);

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int a[n+1]={0};
    for (int i=0;i<q;i++)
    {
        int ele;
        scanf("%d",&ele);
        a[ele]++;
    }
    for (int i=1;i<=n;i++)
    {
        if ((k-(q-a[i]))<=0)
        printf("No\n");
        else
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 4148
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;
    vector<ll> L(N);
    REP(i, N)
    cin >> L[i];

    ll count = 0;
    REP(i, N)
    FOR(j, i, N - 1)
    FOR(k, j, N - 1)
    {
        if (i == j || j == k || k == i)
            continue;

        if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i])
            continue;

        if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j])
            count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long  ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

//�ő����
int ans;


signed main(){

    string s;
    cin>>s;
    int f=1;
    rep(i,s.size()){
        if(i%2){
            if(s[i]!='L' && s[i]!='U' && s[i]!='D')f=0;
        }
        else{
            if(s[i]!='R' && s[i]!='U' && s[i]!='D')f=0;
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10**9 + 7
s = [0 for i in range(k+1)]
ret = 0

for i in range(k, 0, -1):
    p = int(k/i)
    c = pow(p, n, mod)
    for j in range(2, k+1):
        if i*j <= k:
            c -= s[i*j]
        else:
            break
    
    s[i] = c%mod

    ret = (ret + (c%mod)*i)%mod

print(ret)

Measured memory_bytes: 79276
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

x, y = map(int, input().split())

# 同じ数字の場合
if x == y:
    print(-1)
else:
    g = gcd(x, y)
    if (x * g) % y != 0:
        print(x * g)
    else:
        if x * (g + 1) % y != 0:
            print(x * (g + 1))
        else:
            print(-1)



Measured memory_bytes: 2940
#include<iostream>
#include<cstdlib>

using namespace std;

struct Node {
	int key;
	Node *parent;
	Node *left;
	Node *right;
};
Node* NIL;
Node* root = NIL;

void insert(Node* rot, int key)
{
	Node* z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->parent = NIL;
	z->left = NIL;
	z->right = NIL;

	Node* y = NIL;
	Node* x = rot;
	while (x != NIL)
	{
		y = x;
		if (key > x->key)
			x = x->right;
		else
			x = x->left;
	}

	z->parent = y;

	if (y == NIL)
		root = z;
	else if (key < y->key)
		y->left = z;
	else
		y->right = z;
}
void inOrder(Node* x)
{
	if (x->left != NIL)
		inOrder(x->left);

	cout << ' ' << x->key;

    if(x->right != NIL)
		inOrder(x->right);
}
void preOrder(Node* x)
{
	cout << ' ' << x->key;

	if (x->left != NIL)
		preOrder(x->left);

	if (x->right != NIL)
		preOrder(x->right);
}
int main()
{
	int n,key;
	char C[10];

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> C;
		if (C[0] == 'i')
		{
			cin >> key;
			insert(root, key);
		}
		else
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 26560
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,aa[110000],cnt=1,ma=0;
string s;
signed main()
{
	cin>>a;
	cout<<a*a;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

vector<pair<ll,ll>> f(ll n){
    vector<pair<ll,ll>> p;
    for(ll i = 2;i * i<=n;++i){
        if(n%i == 0){
            ll tmp = 0;
            while(n%i == 0){
                n/=i;
                tmp++;
            }
            p.push_back(make_pair(i,tmp));
        }
    }
    if(n != 1) p.push_back(make_pair(n,1));
    return p;
}



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

    int n;
    string s,t;
    cin >> n >> s >>t;
    int same = 0;

    rep(i,n){
        rep(j,n){
            if(s[i] == t[same]){
                same++;
                break;
            }
            else same = 0;
        }
    }
    cout << 2*n-same << endl;

    return 0;
}


Measured memory_bytes: 256