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

const int maxn = 2e3 + 5;
LL a[maxn];
LL b[maxn][maxn];//b[i][k] : 当整个过程使用了【k】次魔法，获得【color i】时的最少花费的时间。(不包括【k * x】).

int main(){
    int n;
    LL x,sum = 1LL << 60LL;
    cin >> n >> x;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= n;i++){
        b[i][0] = a[i];
        for(int k = 1;k <= n - 1;k++){
            int pos = i - k;
            if(pos <= 0) pos = n - abs(pos);
            b[i][k] = min(b[i][k - 1],a[pos]);//【b[i][k]】的转移方程.
        }
    }
    for(int k = 0;k <= n - 1;k++){
        LL ans = 0;
        for(int i = 1;i <= n;i++){
            ans += b[i][k];
        }
        sum = min(sum,ans + x * k);//取最小值.
    }
    cout << sum << endl;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int main() {
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[2]-a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n").map(Number);
	input.shift();
	var sum = 0;
	for(var i=0;i<input.length;i++){
	    sum += input[i];
	}
	input.sort(function(a,b){return a-b});
	var flag = true;
	input.unshift(0)
 // console.log(input)
	for(i=0;i<input.length;i++){
      //console.log(sum-input[i])
	    if((sum-input[i])%10!=0){
	        console.log(sum-input[i]);
	        flag = false;
	        break;
	        }
	}
	if(flag) console.log(0)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7500
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
    int i = 1;
    int n;
    while (cin >> n) {
        if (n != 0) {
            cout << "Case " << i << ": " << n << endl;
            i++;
        } else {
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 200005

using namespace std;

int main()
{   __

    int h,n;
    ll sum = 0;

    cin >> n >> h;

    int a[n];

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

    sort(a,a+n);

    for(int i=0;i<(n-h);i++)
    {
        sum+=a[i];
    }

    cout << sum << '\n';


    return 0;
}




Measured memory_bytes: 1024
s=input()+"1"
a=0
b=[]
i=0
l=len(s)
e=0
while True:
    if s[i]==s[i+1]:
        a+=1
    else:
        b.append(a+1)
        a=0
    i+=1
    if i+1>=l:
        break
if s[-2]=='<':
    b.append(0)
if s[0]=='>':
    b.insert(0,0)
for i in range(len(b)//2):
    c,d=max(b[i*2],b[i*2+1]),min(b[i*2],b[i*2+1])
    e+=(c*(c+1)//2)+(d*(d-1)//2)
print(e)

Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<62;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

map<ll, ll> mm;

ll f(ll n, ll a, ll b, ll c, ll d) {
	if (n == 0) return 0;
	auto it = mm.find(n);
	if (it != mm.end()) return it->se;
	
	ll res = longINF;
	if ((long double)n * d < longINF) res = n * d;
	mm[n] = res;
	
	for (int i = 4; i >= -4; --i) {
		ll nex = n + i;
		if (nex < 0) break;
		ll cur = abs(i) * d;
		if (nex == 0) {
			chmin(res, cur);
			continue;
		}
		
		if (nex % 2 == 0) {
			ll nexv = f(nex / 2, a, b, c, d);
			if ((long double)nex / 2 * d + cur + nexv < longINF) chmin(res, nex / 2 * d + cur + nexv);
			if ((long double)a + cur + nexv < longINF) chmin(res, a + cur + nexv);
		}
		if (nex % 3 == 0) {
			ll nexv = f(nex / 3, a, b, c, d);
			if ((long double)nex / 3 * 2 * d + cur + nexv < longINF) chmin(res, nex / 3 * 2 * d + cur + nexv);
			if ((long double)b + cur + nexv < longINF) chmin(res, b + cur + nexv);
		}
		if (nex % 5 == 0) {
			ll nexv = f(nex / 5, a, b, c, d);
			if ((long double)nex / 5 * 4 * d + cur + nexv < longINF) chmin(res, nex / 5 * 4 * d + cur + nexv);
			if ((long double)c + cur + nexv < longINF) chmin(res, c + cur + nexv);
		}
	}
	return mm[n] = res;
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		mm.clear();
		ll N, A, B, C, D;
		cin >> N >> A >> B >> C >> D;
		cout << f(N, A, B, C, D) << endl;

	}
	return 0;
}


Measured memory_bytes: 6452
#include <iostream>

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

int main()
{
  int a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') {
    cout << a + b << endl;
  }else{
    cout << a + (b * -1) << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<vector>
#define N_MAX 100005
using namespace std;
struct Node{
    vector<int> vct;
    short type;
    char state;//0:undiscovered
};
vector<Node> nodes;
int n;
void bfs(){
    queue<int> Q;
    short type=1;
    for(int i=0;i<n;i++){
        if(nodes[i].state==0){
            Q.push(i);
            nodes[i].type = type;
            nodes[i].state = 1;
            while(!Q.empty()){
                int active = Q.front();
                int total = nodes[active].vct.size();
                for(int i=0;i<total;i++){
                    int newIndex=nodes[active].vct[i];
                    if(nodes[newIndex].state==0){
                        Q.push(newIndex);
                        //printf("== %d -> %d ==\n", active, newIndex);
                        nodes[newIndex].type = type;
                        nodes[newIndex].state = 1;
                    }
                }
                Q.pop();
            }
            type++;
        }
    }
}
int main(){
    int rel;
    scanf("%d%d", &n, &rel);
    for(int i=0;i<n;i++){//initial
        Node init;
        init.type=0;
        init.state=0;
        nodes.push_back(init);
        //printf("initial info: %d %d\n", init.type, init.state);
    }
    for(int i=0;i<rel;i++){
        int maj, sub;
        scanf("%d%d", &maj, &sub);
        nodes[maj].vct.push_back(sub);
        nodes[sub].vct.push_back(maj);//Undirected
    }
    bfs();
    short ques;
    scanf("%d", &ques);
    for(short i=0;i<ques;i++){
        int maj, sub;
        scanf("%d%d", &maj, &sub);
        if(nodes[maj].type==nodes[sub].type){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

    /*printf("\n============ now testing ================\n");
    for(int i=0;i<n;i++){
        printf("\t-- %d: type:%d state:%d --\n", i, nodes[i].type, nodes[i].state);
    }*/
    return 0;
}



Measured memory_bytes: 8568
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    H = [int(h) for h in input().split()]
    for i in reversed(range(N-1)):
        if H[i] > H[i + 1]: H[i] -= 1
        if H[i] > H[i + 1]: 
            print("No")
            break
    else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

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

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    a, b, x = read_h()
    ans = b // x - a // x + int(a % x == 0)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {

		sc = new Scanner(System.in);
		String order = sc.next();
		int price = 700;

		if ("o".equals(order.subSequence(0,1))) price += 100;
		if ("o".equals(order.subSequence(1,2))) price += 100;
		if ("o".equals(order.subSequence(2,3))) price += 100;

		System.out.println(price);
	}

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int si = -1, ei = 0;
  rep(i,s.length()){
    if(si == -1 && s[i] == 'A') si = i;
    if(si != -1 && s[i] == 'Z') ei = i;
  }
  cout << ei +1 - si << endl;
  return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,m;
	while(cin >> n >> m,n|m)
	{
		ll ret = 0;
		vector<pair<int,int> > pv;
		REP(i,n)
		{
			int a,b;
			cin>>a>>b;
			pair<int,int> tmp = MP(b,a);
			pv.PB(tmp);
			ret += a*b;
		}
		
		sort(ALL(pv),greater<pair<int,int> >());
		
		for(int i = 0;m > 0 && i < n;i++)
		{
			if(m >= pv[i].SE)
			{
				ret -=pv[i].FI*pv[i].SE;
				m -= pv[i].SE;
			}
			else
			{
				ret -=m*pv[i].FI;
				m = 0;
			}
		}
		
		cout <<ret << endl;
		
	}
		
	return 0;
}

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

int main(){
    int N;cin>>N;
    int count=1,res=0;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        if(a==count){
        count+=1;
        }
        else{
            res+=1;
        }
    }
    if(count==1)cout<<-1<<endl;
    else cout<<res<<endl;

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

ll n,m;
#define N 1005
vector<ll>v[N];
ll used[N];

vector<ll>row;
vector<ll>cyc;
bool dfs(ll k){
    if(cyc.size()!=0)return 0;
    for(auto x:v[k]){
        if(used[x]==1){
            if(cyc.size()!=0)return 0;
            bool fl=false;
            rep(i,0,row.size()-1){
                if(fl)cyc.pb(row[i]);
                else if(row[i]==x){
                    cyc.pb(row[i]);fl=true;
                }
            }
            return 0;
        }else if(used[x]==0){
            row.pb(x);
            used[x]=1;
            dfs(x);
            row.pop_back();
        }
    }
    return 0;
}

int main(){fastio
    cin>>n>>m;
    rep(i,1,m){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
    }
    rep(i,1,n){
        if(used[i]==0){
            row.pb(i);
            dfs(i);
            rep(j,1,n){
                if(used[j]==1)used[j]=2;
            }
        }
    }
    if(cyc.size()==0){
        cout<<-1;return 0;
    }
    
    rep(i,1,n)sort(v[i].begin(),v[i].end());
    bool ok[n+1];memset(ok,false,sizeof(ok));
    while(1){
        bool flag=true;
        vector<ll>newcyc;
        ll cs=cyc.size();
        rep(i,0,cs-1){
            if(!flag)break;
            ll top=cyc[i];
            if(ok[top])continue;
            for(ll qj=(i+cs-1);qj>=i+2;qj--){
                ll j=qj%cs;
                if(*lower_bound(v[top].begin(),v[top].end(),cyc[j])==cyc[j]){
                    
                    if(i<j){
                        rep(k,0,i)newcyc.pb(cyc[k]);
                        rep(k,j,cs-1)newcyc.pb(cyc[k]);
                    }else{
                        rep(k,j,i)newcyc.pb(cyc[k]);
                    }
                    ok[top]=true;
                    flag=false;
                    break;
                }
            }
        }
        if(flag){
            cout<<cyc.size()<<endl;
            for(auto x:cyc)cout<<x<<endl;
            return 0;
        }else{
            cyc.clear();
            for(auto x:newcyc)cyc.pb(x);
        }
    }
    return 0;
}


Measured memory_bytes: 384
N,M=map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
a=str(0)*N
A=[a[i] for i in range(len(a))]
x=0
#print(sc)
b=[]
c=[]
for i in range(M):
    if (sc[i][0] == 1) and (sc[i][1]==0) and (N!=1):
        x=-1
        break
    else:
        if (sc[i][0]) in b:#左から何桁目の情報が既にある場合、既に登録されているその桁の値と新たに登録しようとしてるその桁の値が異なるとき弾く
            if sc[i][1]!=int(c[b.index(sc[i][0])]):
                #print(c[b.index(sc[i][0])])
                x=-1
                break
        else:
            A[sc[i][0]-1]=str(sc[i][1])
            b.append(sc[i][0])
            c.append(sc[i][1])
if x==-1:
    print(-1)      
elif b==[] and (N!=1):
    if N==2:
        print(10)
    elif N==3:
        print(100)
elif (1 not in b) and(N!=1):
    A[0]=str(1)
    a="".join(A)
    print(a)
elif  (1 not in b) and (2 not in b) and (N==3):
    A[0]=str(1)
    A[1]=str(0)
    a="".join(A)
    print(a)

else:
    a="".join(A)
    print(a)


Measured memory_bytes: 3064
N, x = STDIN.gets.chomp.split(' ').map(&:to_i)
A = STDIN.gets.chomp.split(' ').map(&:to_i)

A.sort!

cnt = 0

while A.length > 0 do
  child = A.shift
  if x > child
    cnt += 1
    x -= child
  elsif x == child
    cnt += 1
    x -= child
    break
  else
    A.unshift(child)
    break
  end
end

case
when x == 0
  puts cnt
when x > 0
  if A.length > 0
    puts cnt
  else
    puts cnt - 1
  end
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
static const int NMAX=100;
int N,K;
int x[NMAX];
int main(){
    cin>>N>>K;

    for(int i=0;i<N;i++)
        cin>>x[i];
    int ans=0;    
    for(int i=0;i<N;i++)
        ans+=min(2*x[i],2*(K-x[i]));
        
    cout<<ans<<"\n";    
    return 0;
}

Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m;
		// n=s.length();
		ll a[n];
		rep(i,n)
		{
			cin>>a[i];
			c+=a[i];
		}
		k=0;
		if(c%(4*m)==0) k=1;
		c/=(4*m);
		rep(i,n)
		{
			if(a[i]>c) cs++;
			else if(k==1 && a[i]==c) cs++;
		}
		// debug3(c,cs,m);
		cout<<(cs>=m?"Yes":"No");

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
POWER = 4.step(68, 4).map{|i| 10 ** i}
NAME = ["Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"]

until (m, n  = gets.split.map(&:to_i)).all?(&:zero?)
  remain = m ** n
  (POWER.size - 1).downto(0) do |i|
    digit = remain / POWER[i]
    print digit, NAME[i] unless digit.zero?
    remain %= POWER[i]
  end
  print remain unless remain.zero?
  puts ""
end

Measured memory_bytes: 6152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int a, b;

int main(){
	cin >> a >> b;

	if (a>b){
		REP(i,a) cout << b;
		cout << endl;
	}
	else {
		REP(i,b) cout << a;
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a *= a;
		b *= b;
		c *= c;
		if(a + b == c || a + c == b || b + c == a)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

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

Measured memory_bytes: 1152
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
const int maxn = 1e5 + 7;
const LL INF = 1e18;

int head[maxn << 1];
struct Edge {
    int to,next;
    LL w;
}edge[maxn << 1];
int tot;

void init() {
    memset(head,-1,sizeof(head));
    tot = 0;
}

void addedge(int u,int v,LL w) {
    edge[tot].to = v;
    edge[tot].w = w;
    edge[tot].next = head[u];
    head[u] = tot++;
}

struct node {
    int v;
    LL w;
    node (int _v = 0 , LL _w = 0):v(_v),w(_w){}
    bool operator < (const node &r) const {
        return w > r.w;
    }
};

LL dist[maxn];
bool vis[maxn];
priority_queue<node>pq;

void Dijkstra(int n,int start) {
    memset(vis,false,sizeof(vis));
    for(int i = 1 ; i <= n ; i++) dist[i] = INF;
    dist[start] = 0;
    while(!pq.empty()) pq.pop();
    pq.push(node(start,0));
    while(!pq.empty()) {
        node k = pq.top();
        pq.pop();
        int u = k.v;
        if(vis[u]) continue;
        vis[u] = true;
        for(int i = head[u] ; i != -1 ; i = edge[i].next) {
            int v = edge[i].to;
            LL w = edge[i].w;
//            cout << u << "---------------->" << v << " " << w << endl;
            if(dist[v] > dist[u] + w) {
                dist[v] = dist[u] + w;
                pq.push(node(v,dist[v]));
            }
        }
    }
}

int main() {
    int n,m;
    while(~scanf("%d%d",&n,&m)) {
        init();
        for(int i = 1 ; i < n ; i++) {
            addedge(i+1 , i , 0);
        }
        for(int i = 1 ; i <= m ; i++) {
            int L,R;
            LL w;
            scanf("%d%d%lld",&L,&R,&w);
            addedge(L,R,w);
        }
//        for(int i = 1 ; i <= n ; i++) {
//            for(int j = head[i] ; j != -1 ; j = edge[j].next) {
//                cout <<"i = " << i << " j = " << edge[j].to << "->" << edge[j].w << endl;
//            }
//        }
        Dijkstra(n,1);
//        for(int i = 1 ; i <= n ; i++) {
//            cout << dist[n] << endl;
//        }
        if(dist[n] == INF) dist[n] = -1;
        printf("%lld\n",dist[n]);
    }
    return 0;
}


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

int64_t Q=998244353;


int main() {
  int N,K;
  cin>>N>>K;
  vector<pair<int,int>> p(K);
  for(int i=0;i<K;i++){
    int a,b;
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }
  sort(p.begin(),p.end());
  vector<int64_t> dp(N+1);
  vector<int64_t> rui(N+1);
  dp[1]=1;
  rui[1]=1;
  for(int i=2;i<=N;i++){
    int64_t A=0;
    for(int j=0;j<K;j++){
      int a,b;
      tie(a,b)=p[j];
      if(i<=a){
        break;
      }
      A+=rui[i-a]-rui[max(i-b-1,0)];
      A+=Q;
      A%=Q;
    }
    dp[i]=A;
    rui[i]=(dp[i]+rui[i-1])%Q;
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 6304
import bisect
import math

N,M=map(int,input().split())

divisors=[]
for i in range(1,math.floor(math.sqrt(M))+1):
    if M%i==0:
        divisors.append(i)
        divisors.append(M//i)
        
divisors.sort()
print(M//divisors[bisect.bisect_left(divisors,N)])

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  ll N, K;
  cin >> N >> K;
  ll res = 0;
  for (ll k = K; k <= N + 1; k++) {
    ll first = k * (k - 1) / 2;
    ll last  = k * (2 * N - k + 1) / 2;
    res = (res + last - first + 1) % MOD;
  }
  cout << res << endl;
  return 0;	
}

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

int main() {
    int n,m;cin>>n>>m;
    long long h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    long long ab[m][2];
    for(int i=0;i<m;i++){
        for(int j=0;j<2;j++){
            cin>>ab[i][j];
        }
    }
    int result[n];
    for(int i=0;i<n;i++){
        result[i]=1;
    }
    for(int i=0;i<m;i++){
        if(h[ab[i][0]-1]>h[ab[i][1]-1]){
            result[ab[i][1]-1]=0;
        }else if(h[ab[i][0]-1]<h[ab[i][1]-1]){
            result[ab[i][0]-1]=0;
        }
        else if(h[ab[i][0]-1]==h[ab[i][1]-1]){
            result[ab[i][0]-1]=0;
            result[ab[i][1]-1]=0;
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(result[i]==1){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 6360
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        Console.WriteLine(int.Parse(Console.ReadLine()) ^ 1);
    }
}


Measured memory_bytes: 27380
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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; }



int main(){
    int N,A;
    cin>>N>>A;
    out((N+A-1)/A);
    
    
}

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

int main()
{
ll n , k ;
cin >> n >> k ;
set<ll> s;
rep(i,k){
  ll d ;
  cin >> d ;
  rep(j,d){
    ll e ;
    cin >> e ;
    s.insert(e);
  }
}
cout << n-s.size() << endl;
return 0;
}

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

int main() {

  int N;
  cin >> N ;
  
  int A[N];
  long ans[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans[i]=0;
  }
  
  unordered_map<int, long> boals;
  for (int i = 0; i < N; i++) {
    boals[A[i]]++;
  }

  long tmpAns=0;
  for ( auto boal : boals){
    tmpAns+=((boal.second*(boal.second-1))/2);
  }

  for (int i = 0; i < N; i++) {
    long count = boals[A[i]];
    long tmpMinus = (count*(count-1))/2;
    long tmpPlus = ((count-1)*(count-2))/2;
    
    ans[i] = tmpAns-tmpMinus+tmpPlus;
  }
  
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 9928
#include<stdio.h>

int whriswrng(int *p,int m){
  int a=p[0]+p[1];
  int b=p[1]+p[2];
  int c=p[2]+p[3];

  if(p[0]!=p[1]){
    if(a!=p[2]){
      if(b!=p[0]){
	return 0;
      }
      else{
	if(b!=c){
	  return 2;
	}
	else{
	  return 0;
	}
      }
    }
    else{
      return 1;
    }
  }
  else{
    if(a==p[2]){
      if(c!=p[0]){
	return 1;
      }
      else{
	return 3;
      }
    }
    else{
      int i=2;
      while(i!=m){
	if(p[i]!=p[0]){
	  return i+1;
	}
	i++;
      }
    }
  }

  return m;
}

int judge(int *p,int n){
  int m=n-1;
  int d[m];
  int i;

  for(i=0;i<m;i++){
    d[i]=p[i+1]-p[i];
  }

  return whriswrng(d,m);
}

void doit(int n){
  int a[n];
  int i;

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

  printf("%d\n",a[judge(a,n)]);
}

int main(){
  int n;
  scanf("%d",&n);
  if(n!=0){
    doit(n+1);
    return main();
  }
  else{
    return 0;
  }
}

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

int main(){
	int N;
  cin>>N;
  vector<int> vec(2);
  int sum=0;
  for(int i=0;i<N;i++){
  	cin>>vec.at(0)>>vec.at(1);
    sum+=vec.at(1)-vec.at(0)+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

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

	int a, b, c, k; cin >> a >> b >> c >> k;

	// c > b > a
	int cnt = 0;
	while (a >= b) {
		b <<= 1;
		++cnt;
	}
	while (b >= c) {
		c <<= 1;
		++cnt;
	}
	if (cnt <= k) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void)
{
	int s1;
	int s2;
	int s3;
	int nyu;
	int bee;
	bee = 0;
	
	scanf("%d",&nyu);
	
	s1 = nyu % 10;
	s2 = (nyu % 100 - s1) / 10;
	s3 = (nyu - s1 - (s2 * 10)) / 100;
	
	if((s1 == 1 || s1 == 0) && (s2 == 1 || s2 == 0) && (s1 == 1 || s1 == 0)){
		if(s1 == 1){
			bee++;
		}
		if(s2 == 1){
			bee++;
		}
		if(s3 == 1){
			bee++;
		}
		printf("%d",bee);
	}
	return(0);
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#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,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 998244353;

struct Combinations {
    int max, mod;
    VLL fac, finv, inv;

    Combinations(int _max, int _mod) : fac(_max), finv(_max), inv(_max) {
        max = _max;
        mod = _mod;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        REP2(i, 2, max) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod; 
        }
    }

    LL calc(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

void solve(long long N, long long M, long long K){
    Combinations comb(N, MOD);
    LL color = M;
    LL ans = 0;
    REP(i, N - K - 1) {
        color *= (M-1);
        color %= MOD;
    }

    RREP(i, K) {
        ans += color * comb.calc(N-1, i);
        ans %= MOD;
        color *= (M-1);
        color %= MOD;
        //cout << ans << " " << color << endl;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 8012
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	N = int(input())
	cnt = [0] * 4
	for _ in range(N):
		s = input()
		if s == 'AC':
			cnt[0] += 1
		elif s == 'WA':
			cnt[1] += 1
		elif s == 'TLE':
			cnt[2] += 1
		else:
			cnt[3] += 1
	print('AC x',cnt[0])
	print('WA x',cnt[1])
	print('TLE x',cnt[2])
	print('RE x',cnt[3])
if __name__ == '__main__':
	main()

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#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()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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
}
 
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;
}
 
using namespace std;

#define int64_t ll
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solve(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i+=2){
    auto x=divisor(i+1);
    if(x.size()==8)++ans;
  }
  cout<<ans<<"\n";
}

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

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

#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define P1(XX) cout<<"db1: "<<XX<<endl
#define P2(XX,YY) cout<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cout<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


using namespace std;
#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;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007LL
#define MX 200005


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll m, n;
ll a[MX];
queue<ll>s1,s2;
int main()
{
    int test, tc=0, i, j;
    ll b,k,ans;
    //scanf("%d", &test);
    test=1;
    while(test--)
    {
       ans=0;
        cin>>n>>k;
       for(i=0;i<n;i++)
       {
           scanf("%lld",&a[i]);


       }
       sort(a,a+n);
       for(i=0;i<k;i++)
       {
           ans+=a[i];
       }
       cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	vector<vector<int>>v(26);
	for(int i=0;i<s.size();++i)v.at(s.at(i)-'a').emplace_back(i);
	for(int i=0;i<s.size();++i)v.at(s.at(i)-'a').emplace_back(i+s.size());
	int64_t ans=0; int cur=0;
	for(int i=0;i<t.size();++i){
		int c=t.at(i)-'a';
		if(v.at(c).size()==0){
			cout<<"-1\n"s;
			return 0;
		}
		cur=*lower_bound(v.at(c).begin(),v.at(c).end(),cur)+1;
		if(cur<s.size())continue;
		cur-=s.size();
		ans+=s.size();
	}
	cout<<ans+cur<<"\n"s;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N,M; cin >> N >> M;
    vector<string> A(N), B(M);
    REP(i,N) cin >> A[i];
    REP(i,M) cin >> B[i];
    REP(i,N-M+1){
        REP(j,N-M+1){
            bool ok = true;
            REP(k,M){
                REP(l,M){
                    if(B[k][l] != A[k+i][l+j]) ok = false;
                }
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

int main(){
    db n;
    cin >> n;
    ll m = n;
    if(m % 2 == 0) cout << 0.5 << endl;
    else cout  << 0.5 + 1 / (2 * n) << endl;
}

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

int main(){
  int a;
 int c,b;
  cin>>a>>b>>c;
    if(b>=c){
cout<<"delicious"<<endl;
  }
    else if(b+a>=c){
   cout<<"safe"<<endl;
    }
  else{
    cout<<"dangerous"<<endl;
  }
}



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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define mp make_pair
#ifndef MY
    #define endl '\n'
#endif
//#define int long long
#define sz(x) (int)x.size()

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair < int, int > pii;

ostream & operator << (ostream & out, vector < int > & lst) {
    for (auto a : lst)
        out << a << ' ';
    out << endl;
    return out;
}

signed main() {
#ifdef MY
    freopen("f.in", "r", stdin);
    //freopen("f.out", "w", stdout);
#endif // MY
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s;
    int n;
    cin >> n >> s;
    if (sz(s) <= n) {
        cout << s;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    cout << "...";
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x=0; string s, t;
    cin>>s>>t;
    for(int i=0; s[i]!='\0'; i++)
    {
        if(s[i]!=t[i]) x++;
    }
    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
#include<complex>
#define eps 1e-9
using namespace std;
typedef complex<double> point;
typedef pair<point, point> line;
//b??????a??????????????????
double dis(point a, point b){
  return abs(a - b);
}

//??????
double dot(point a, point b){
  return a.real()*b.real() + a.imag()*b.imag();
}

//??????
double cross(point a, point b){
  return imag(conj(a) * b);
}

//counter clock wise
int ccw(point a, point b, point c){
  if(cross(b - a, c - a) >  eps)return  1;//??????ab????????´
  if(cross(b - a, c - a) < -eps)return -1;//??????ab????????´
  if(dot(b - a, c - a) < -eps)return 2;//??´???ab??????a???????????????
  if(abs(b - a) + eps < abs(c - a))return -2;//??´???ab??????b???????????????
  return 0;//??´???ab???
}

double line_to_point_dis(line l, point p){
  return abs(cross(p - l.first, l.second - l.first))/
    abs(l.second - l.first);
}

double seg_to_point_dis(line l, point p){
  point a = l.first, b = l.second, c = p;
  if(dot(b - a, c - a) < eps)return abs(c - a);
  if(dot(a - b, c - b) < eps)return abs(c - b);
  return line_to_point_dis(l, p);
}

double seg_to_seg_dis(line a, line b){
  double res = seg_to_point_dis(a, b.first);
  res = min(res, seg_to_point_dis(a, b.second));
  res = min(res, seg_to_point_dis(b, a.first));
  res = min(res, seg_to_point_dis(b, a.second));
  return res;
}

bool is_cross(line a, line b){
  if(ccw(a.first, a.second, b.first) *
     ccw(a.first, a.second, b.second) <= 0 &&
     ccw(b.first, b.second, a.first) *
     ccw(b.first, b.second, a.second) <= 0){
    return true;
  }
  return false;
}

point cross_point(line a, line b){
  double d1 = cross(b.second - b.first,
                    b.first - a.first);
  double d2 = cross(b.second - b.first,
                    a.second - a.first);
  return a.first + (a.second - a.first) * d1/d2;
}

pair<point, point> norm(point p){
  return pair<point, point>(p*point(0, 1),
                            p*point(0, -1));
}

int main(int argc, char *argv[]){
  point x[3], p;
  double real[3], imag[3], r, i;
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n", &real[0], &imag[0],
              &real[1], &imag[1], &real[2], &imag[2], &r, &i) != EOF){
    for (int i = 0; i < 3; i++) {
      x[i] = complex<double>(real[i], imag[i]);
    }
    p = complex<double>(r, i);
    line l[3];
    for (int i = 0; i < 3; i++) {
      l[i].first = x[i];
      l[i].second = x[(i + 1)%3];
    }
    int a[3];
    for (int i = 0; i < 3; i++) {
      a[i] = ccw(x[i], x[(i + 1)%3], p);
    }
    if(a[0] == a[1] && a[1] == a[2] && a[0] == a[2])std::cout << "YES" << std::endl;
    else std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

#include <cstdio>
#include <cstring>
#include <cmath>

#define taskname "a"

using namespace std;

string s;
long long a[200005], num = 0;

int main() {
//  freopen(taskname".in", "r", stdin);
//  freopen(taskname".out", "w", stdout);

  cin >> s;
  long long n = (long long)s.size();

  for (char c = 'a'; c <= 'z'; c++) {
    for (int i = 0; i < n; i++) {
      if (s[i] == c) {
        a[c - 'a']++;
      }
    }
  }

  for (int i = 0; i < 26; i++) {
    num += a[i] * (a[i] - 1) / 2;
  }
  cout << n * (n - 1) / 2 - num + 1;

  return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int x, y; cin >> x >> y;
    string res = "No";
    // if(x == 2 || y == 2)
    int N[12]; rep(i, 12) N[i] = 0;
    N[3] = N[5] = N[8] = N[10] = 1;
    N[1] = 2;
    --x; --y;
    if(N[x] == N[y]) res = "Yes";
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n, m, a, b, k=0;
    cin >> n >> m;
    long long A[n], K[m+1], M[m+1];
    long long S=0, Mi=0, R=2000000000000;
    for (int i = 0; i <= m; i++)
    {
        K[i] = 0;
        M[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        if (i != 0)
        {
            a = A[i]+1;
            if (a > m)
            {
                a -= m;
            }
            K[a]--;
            b = A[i];
            if (A[i] < A[i-1])
            {
                b += m;
            }
            M[a] += b-A[i-1]-1;
            a = A[i-1] + 2;
            if (a > m)
            {
                a -= m;
            }
            K[a]++;
            if (A[i] < A[i-1])
            {
                Mi += m - A[i-1];
                S += m - A[i-1] + A[i];
                if (A[i-1] != m)
                {
                    k++;
                }
            }
            else
            {
                S += A[i] - A[i-1];
            }
        }
    }
    R = S-Mi;
    for (int i = 2; i <= m; i++)
    {
        Mi -= M[i];
        k += K[i];
        Mi += k;
        if (S-Mi < R)
        {
            R = S-Mi;
        }
    }
    cout << R;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int r;
    cin>>r;
    cout<<r*r<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr LL kInf = 1e18;

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

LL dist(LL x, LL a, LL b) {
  LL y = min(a, b);
  LL z = max(a, b);
  if (x <= y) return z - x;
  else if (y < x && x <= z) return (z - y) + min(z - x, x - y);
  else        return x - y;
}

int main() {
  int A, B, Q; cin >> A >> B >> Q;
  vector<LL> s(A), t(B), x(Q); cin >> s >> t >> x;
  s.push_back(-kInf); s.push_back(kInf);
  t.push_back(-kInf); t.push_back(kInf);
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for (LL v : x) {
    auto it1 = lower_bound(s.begin(), s.end(), v);
    auto it2 = it1 - 1;
    auto it3 = lower_bound(t.begin(), t.end(), v);
    auto it4 = it3 - 1;

    LL vmin = kInf;
    for (LL a : {*it2, *it1}) {
      for (LL b : {*it4, *it3}) {
//        cout << dist(v, a, b) << "(" << a << "," << b << ") ";
        vmin = min(vmin, dist(v, a, b));
      }
    }
    cout << vmin << endl;
  }
}


Measured memory_bytes: 6404
n = int(input())
lst = [0]
a = [int(i) for i in input().split()]
lst  += a + [0]

dist = []
for i in range(n+1):
    dist.append(abs(lst[i+1] - lst[i]))

s = sum(dist)
for i in range(1,n+1):
    ans = s + abs(lst[i-1] - lst[i+1]) - (abs(lst[i-1] - lst[i]) + abs(lst[i] - lst[i+1]))
    print(ans)

Measured memory_bytes: 14048
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans;
    rep(i, 0, N) {
        if (i==0.5*N-1) {
            if (a[i+1]- a[i] ==0) {
                ans=0;
            } else {
               ans = a[i+1]-a[i];
               }
        }
    }
            
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1), sl = s.length;
  var x = xArray(0,sl+1);
  for(var i = 1; i < sl+1; i++){
    if(s[i-1] === "<")x[i] = x[i-1]+1;
  }
  var ans = x[sl];
  for(var i = sl; i > 0; i--){
    if(s[i-1] === ">" && x[i]+1 > x[i-1])x[i-1] = x[i]+1;
    ans += x[i-1];
  }
  return ans;
}

Measured memory_bytes: 21192