akhauriyash/Code-Regression huggingface dataset:
<?php
 
$first = explode(" ", trim(fgets(STDIN)));
 
$n = $first[0];
$m = $first[1];

$task = [];
for ($i = 0; $i < $n; $i++) {
    $tmp = explode(" ", trim(fgets(STDIN)));
    $task[$tmp[0]][] = $tmp[1];
}

$total_reward = 0;
$pq = new SplPriorityQueue();

for($i = 1; $i <= $m; $i++) {
    if(array_key_exists($i, $task)) {
        foreach($task[$i] as $value) {
            $pq->insert($value, $value);
        }
    }
    
    if($pq->valid()) {
        $total_reward += $pq->extract();
    }
}
 
echo $total_reward;

Measured memory_bytes: 59896
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

int main( void ) {
  int N, ans = 0;
  cin >> N;
  vector<int> d(N);

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

  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(i<j){
      	ans += d.at(i)*d.at(j);
      }
    }
  }

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


Measured memory_bytes: 256
// AOJ 2619: Thread Tree
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int ko, nxt, end; char s[52]; } T;
T node[1002];

void dopr(int k, int level)
{
	int w = level; while (w--) putchar('.');
	puts(node[k].s);
	if (node[k].ko >= 0) dopr(node[k].ko, level+1);
	if (node[k].nxt >= 0) dopr(node[k].nxt, level);
}

int main()
{
	int n, i, k;
	T *p, *q;

	scanf("%d", &n);

	p = node + 1;
	p->ko = p->nxt = p->end = -1;
	scanf("%d%s", &k, p->s);

	for (i = 2; i <= n; i++) {
		q = node + i;
		scanf("%d%s", &k, q->s);
		p = node + k;
		q->ko = q->nxt = q->end = -1;

		if (p->ko < 0) p->ko = p->end = i;
		else {
			node[p->end].nxt = i;
			p->end = i;
		}
	}
	dopr(1, 0);
	return 0;
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        string s; cin>>s;
        if(s[5]=='1' or s[6]>='5'){
                cout<<"TBD"<<endl;
        }
        else{
                cout<<"Heisei"<<endl;
        }
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 4e5 + 5;
const int inf = 1e16 + 2;


/*
 */
void solve(int Case) {
    int n , k ;
    cin >> n >> k;
    int a[n];
    for(int i = 0 ; i < n ; i ++) cin >> a[i];
    for(int i = k ; i < n ; i ++) {
        if(a[i] > a[i - k]) cout << "Yes" << '\n';
        else  cout << "No" << '\n';
    }
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}
 



Measured memory_bytes: 5200
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');

const k = parseInt(inputs[0], 10);
const ab = inputs[1].split(' ').map(v => parseInt(v, 10));

if (k === 1) {
  console.log('OK');
  return;
}

if (k === ab[0]) {
  console.log('OK');
  return;
}

let c = Math.floor(ab[0] / k);
if (c === 0) {
  c = 1
}

for (;;) {
  if (c * k < ab[0]) {
    ++c;

    continue;
  }

  if (c * k > ab[1]) {
    break;
  }

  if (c * k % k === 0) {
    console.log('OK');
    return;
  }

  ++c;

  if (c * k > ab[1]) {
    break;
  }
}

console.log('NG');

Measured memory_bytes: 29628
#include <bits/stdc++.h>
#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--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int H[N];

    REP(i, N){
        cin >> H[i];
    }

    int res = 0, ans = 0;
    REP(i, N-1){
        if(H[i] >= H[i+1]){
            res++;
        }
        else{
            ans = max(ans, res);
            res = 0;
        }
    }
    ans = max(ans, res);
    cout << ans << endl;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    int i,x,n,ans=0,dist=999,j=0;
    cin>>x>>n;
    if(n==0){
        cout<<x;
        return 0;
    }
    vector<int> p(n);
    for(i=0;i<n;i++) cin>>p[i];
    sort(p.begin(),p.end());
    for(i=1;i<x;i++){
        if(i!=p[j]){
            ans=i;
        }else{
            j++;
        }
    }
    for(i=x;i<x+(x-ans);i++){
        if(i!=p[j]){
            ans=i;
            break;
        }else{
            j++;
        }
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
int a[101][101],b[101];
int main(){
	int m,n,sum;
	scanf("%d%d",&m,&n);
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<m;i++){
		sum=0;
		for(int j=0;j<n;j++){
			sum+=b[j]*a[i][j];
			//printf("%d\n",sum);
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <cmath>

typedef long long ll;
using namespace std;
const int mod=1000000007;
int main (){
    ll n;
    cin >> n;
    ll ans=1;
    for (int i = 0; i < n; i++){
        ans*=(i+1);
        ans%=mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int D, G;
	cin >> D >> G;

	vector<int> p(D), c(D);
	for (int i = 0; i < D; i++) {
		cin >> p.at(i) >> c.at(i);
	}

	int ans = INT_MAX;
	for (int bit = 0; bit < (1 << D); bit++) {
		int sum = 0;
		int cnt = 0;
		vector<int> v;

		for (int i = 0; i < D; i++) {
			if (bit & (1 << i)) {
				sum += 100 * (i + 1) * p.at(i) + c.at(i);
				cnt += p.at(i);
			}
			else {
				v.push_back(i);
			}
		}

		if (sum < G) {
			for (int i = v.size() - 1; i >= 0; i--) {
				for (int j = 0; j < p.at(v.at(i)); j++) {
					sum += 100 * (v.at(i) + 1);
					cnt++;
					if (sum >= G) break;
				}
				if (sum >= G) break;
			}
		}

		ans = min(ans, cnt);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3572
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      cnt+=1
  else:
    cnt+=1
print('APPROVED' if cnt==N else 'DENIED')

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int list[1001][4],ans[301],n,k,i,j,a,b,c,x;
	while(1){
		scanf("%d%d%d",&a,&b,&c);
		if(a==0 && b==0 && c==0)break;
		scanf("%d",&n);
		for(i=0;i<a+b+c;i++)ans[i]=2;
		for(i=0;i<n;i++){
			for(j=0;j<4;j++)scanf("%d",&list[i][j]);
		}
		for(i=0;i<n;i++){
			if(list[i][3]==1){
				ans[list[i][0]-1]=1;
				ans[list[i][1]-1]=1;
				ans[list[i][2]-1]=1;
			}
		}
		x=0;
		for(i=0;i<n;i++){
			if(list[i][3]==0){
				for(j=0;j<a+b+c;j++){
					if(ans[list[i][0]-1]==1 && ans[list[i][1]-1]==1)ans[list[i][2]-1]=0;
					if(ans[list[i][0]-1]==1 && ans[list[i][2]-1]==1)ans[list[i][1]-1]=0;
					if(ans[list[i][1]-1]==1 && ans[list[i][2]-1]==1)ans[list[i][0]-1]=0;
				}
			}
		}
		for(i=0;i<a+b+c;i++)printf("%d\n",ans[i]);
	}
	return 0;
}


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

using namespace std;

int main(){
  long long int N;
  vector<long long int> a;
  long long int b;
  long int sum = 0;

  cin >> N;
  for(long long int i = 0; i < N; i++){
    cin >> b;
    a.push_back(b);
    sum += b;
  }

  int trial = sum / (N*(N+1)/2);
  if (sum % (N*(N+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }

  for(long long int i = 0; i < N; i++){
    if((a[i] + trial - a[(i+1)%N]) % N != 0 || a[i] + trial - a[(i+1)%N] < 0){
        cout << "NO" << endl;
        return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
int n, a[123456], ans = 1, p = 1; bool b[123456], flag=0;
vector<pair<int,int>>v;
signed main() {
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i]; b[i] = 1;
		v.push_back(make_pair(a[i], i));
		if(a[i] > 0) flag = 1;
	}
	if(!flag) {cout << "0\n"; return 0;}
	sort(v.begin(), v.end());
	for(int i = 0; i < n; i++){
		if(i && v[i].first != v[i-1].first)	ans = max(ans, p);
		b[v[i].second] = 0;
		if(b[v[i].second-1] && b[v[i].second+1]) p++;
		else if(!b[v[i].second-1] && !b[v[i].second+1]) p--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5480
/*
 © 2020-08-22 12:40:23 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n; cin >> n;
  lli last = 0;
  lli res = 0;
  fore(i, 0, n){
    lli x; cin >> x;
    if(x < last){
      res += last - x;
    }else last = x;
  }
  cout << res << ENDL;
  return 0;
}


Measured memory_bytes: 3656
A, B, H, M = gets.split.map(&:to_i)

ar = 360 * Rational(H, 12) + 30 * Rational(M, 60)
br = 360 * Rational(M, 60)

r = (ar - br).abs
t = [r, 360 - r].min

c = A ** 2 + B ** 2 - 2 * A * B * Math.cos(t * Math::PI / 180.0)
puts Math.sqrt(c)


Measured memory_bytes: 14664
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let A: Vec<Vec<i64>> = {
        let mut A = vec![];
        for _ in 0..H {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            A.push(
                line.split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect(),
            );
        }
        A
    };
    let B: Vec<Vec<i64>> = {
        let mut B = vec![];
        for _ in 0..H {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            B.push(
                line.split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect(),
            );
        }
        B
    };

    let S = 80 * 160;
    let mut dp = vec![vec![vec![false; S + 1]; W + 1]; H + 1];
    dp[0][1][0] = true;
    for i in 0..H {
        for j in 0..W {
            let d = (A[i][j] - B[i][j]).abs() as usize;
            for k in 0..(S + 1) {
                dp[i + 1][j + 1][k] = (k + d <= S && (dp[i][j + 1][k + d] || dp[i + 1][j][k + d]))
                    || (k >= d && (dp[i][j + 1][k - d] || dp[i + 1][j][k - d]))
                    || (d >= k && (dp[i][j + 1][d - k] || dp[i + 1][j][d - k]));
            }
        }
    }
    let ans = (0..(S + 1)).find(|&k| dp[H][W][k]).unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 98684
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	
      	int n = sc.nextInt();
      	String s = sc.next();
      	String ref = "ABC";
      	int sum = 0;
      
      	for (int i = 0; i + 2 < n; i++){
        	if (ref.equals(s.substring(i, i+3)))
            	sum++;
        }
      	
      	System.out.println(sum);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	cin >> S;
	int N = S.length();
	string Sr;
	for(int i = 0; i < N; i++) {
		if(i < N-1 && S[i] == 'B' && S[i+1] == 'C') {
			Sr += 'X';
			i++;
			continue;
		}
		Sr += S[i];
	}
	N = Sr.length();
	// AX -> XA
	cat ans = 0, cnt = 0;
	for(int i = N-1; i >= 0; i--) {
		if(Sr[i] == 'A') ans += cnt;
		else if(Sr[i] == 'X') cnt++;
		else cnt = 0;
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 916
from collections import defaultdict
def Sieve_of_Eratosthenes(maxA):
    lst = [-1]*(maxA+1)
    lst[0] = 0
    lst[1] = 1
    for i in range(2, maxA+1):
        if lst[i] == -1:
            for g in range(i, maxA+1, i):
                if lst[g] == -1:
                    lst[g] = i
    return lst

def factorization(n):  # 「n = 1」はダメ！！！
    d = defaultdict(int)
    now = n
    while True:
        if now == lst[now]:
            if now != 1:
                d[now] += 1
            break
        r = lst[now]
        while now % r == 0:
            now //= r
            d[r] += 1
    ans = 1
    for i, m in d.items():
        ans *= (m+1)
    return ans

n = int(input())

ans = 0
lst = Sieve_of_Eratosthenes(n+1)
for c in range(1, n):
    ans += factorization(n-c)

print(ans)

Measured memory_bytes: 76848
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   int S,W;
   cin >> S >> W;
   if(S<=W){
   cout << "unsafe" << endl;
   }else{
   cout << "safe" << endl;
   }
  
}

Measured memory_bytes: 3636
using System;

class Atcoder84
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if (a <= b)
            Console.WriteLine(a);
        else
            Console.WriteLine(a - 1);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int o,p,q,r,x,y,n,i,top,f[200005],zhan[200005],sum,l,mid,max1,flag;
double ans;
struct nyh{
	int x,y;
}s[200005];
bool cmp(nyh u,nyh v){
	return u.x<v.x;
}
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	o=read();p=read();q=read();r=read();
   	if(o>q){
   		swap(o,q);
   		swap(p,r);
   	}
   	if(p>r){
		flag=1;
		p=r*2-p;
	}
	n=read();
	for(i=1;i<=n;i++){
		x=read();y=read();
		if(flag==1)
			y=r*2-y;
		if(o<=x&&x<=q&&p<=y&&y<=r){
			top++;
			s[top].x=x;
			s[top].y=y;
		}
	}
	sort(s+1,s+top+1,cmp);
	ans=100.0*((q-o)+(r-p));
	flag=min(q-o+1,r-p+1);	
	for(i=1;i<=top;i++){
		max1=0;
		l=1;r=sum;mid=(l+r>>1);max1=0;
		while(l<=r){
			if(s[i].y>zhan[mid]){
				max1=max(max1,mid);
				l=mid+1;
			}
			else
				r=mid-1;
			mid=(l+r>>1);
		}
		f[i]=max1+1;
		if(max1==sum){
			sum++;
			zhan[sum]=s[i].y;
		}
		else if(zhan[f[i]]>s[i].y)
			zhan[f[i]]=s[i].y;
	}
	if(sum==flag)
		ans+=pi*5.0;
	ans-=(20.0-pi*5.0)*sum;
	printf("%.12lf\n",ans);		
    return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int A1 = NextInt();
        int A2 = NextInt();
        int A3 = NextInt();
        Console.WriteLine(A1+A2+A3 > 21? "bust":"win");
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 11220
W, H, N = map(int,input().split())
x = []
y = []
a = []
x1 = 0
x2 = W
y1 = 0
y2 = H
for i in range(N):
    temp = list(map(int,input().split()))
    x.append(temp[0])
    y.append(temp[1])
    a.append(temp[2])

for i in range(N):
    if a[i] == 1:
        x1 = max(x1,x[i])
    if a[i] == 2:
        x2 = min(x2,x[i])
    if a[i] == 3:
        y1 = max(y1,y[i])
    if a[i] == 4:
        y2 = min(y2,y[i])
if (x2-x1)<0 or (y2-y1)<0:
    print(0)
else:
    print((x2-x1)*(y2-y1))

Measured memory_bytes: 3064
use proconio::{input, fastout};
use std::cmp::Reverse;
use std::collections::BinaryHeap;

#[derive(Clone, Copy, Debug, Default)]
struct Adjacent {
    to: usize,
    fare: u64,
    time: u64,
}

#[derive(Clone, Debug, Default)]
struct Graph {
    n: usize,
    links: Vec<Vec<Adjacent>>,
}

impl Graph {
    fn new(n: usize) -> Graph {
        Graph {
            n,
            links: vec![vec![]; n],
        }
    }

    fn add_edge(&mut self, from: usize, to: usize, fare: u64, time: u64) {
        self.links[from].push(Adjacent { to, fare, time });
        self.links[to].push(Adjacent { to: from, fare, time });
    }
}


fn dijkstra(g: Graph, src: usize, initial_silver: u64, max_silver: u64, exchanges: Vec<(u64, u64)>) -> Vec<u64> {
    const INF: u64 = 1u64 << 60;
    let mut result = vec![0u64; g.n];

    let mut q = BinaryHeap::<Reverse<(u64, usize, u64)>>::new();
    let mut fix_count = 0;
    let mut visitable = vec![INF; g.n];
    q.push(Reverse((0, src, initial_silver)));

    while q.len() > 0 {
        let (cost, v, silver) = q.pop().unwrap().0;
        if visitable[v] == INF {
            result[v] = cost;
            fix_count += 1;
            if fix_count == g.n { break; }
        } else if visitable[v] >= silver { continue; }
        visitable[v] = silver;
        for adj in &g.links[v] {
            if silver < adj.fare { continue; }
            let new_silver = silver - adj.fare;
            if visitable[adj.to] != INF && visitable[adj.to] >= new_silver { continue; }
            q.push(Reverse((cost + adj.time, adj.to, new_silver)));
        }
        if silver < max_silver {
            let (c, d) = &exchanges[v];
            q.push(Reverse((cost + *d, v, silver + *c)));
        }
    }

    return result;
}

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        s: u64,
        links: [(usize, usize, u64, u64); m],
        exchanges: [(u64, u64); n],
    }

    let mut g = Graph::new(n);
    for &(u, v, a, b) in &links {
        g.add_edge(u - 1, v - 1, a, b);
    }
    let mut link_costs = links.iter().map(|&l| l.2).collect::<BinaryHeap<u64>>();
    let max_silver: u64 = (0..n - 1).map(|_| link_costs.pop().unwrap()).sum();

    let result = dijkstra(g, 0, s, max_silver, exchanges);

    for k in 1..result.len() {
        println!("{}", result[k]);
    }
}


Measured memory_bytes: 2252
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
signed main()
{
	fast_io
	int n, w;
	cin >> n >> w;
	vector < int > wt(n), val(n);
	int dp[n + 1][w + 1] = {0};

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

	for(int i = 0; i <= w; i++) // base case
	{
		if(i >= wt[0])
			dp[1][i] = val[0];
		else
			dp[1][i] = 0;
	}
	for(int i = 2; i <= n; i++) // tabulation
	{
		for(int j = 0; j <= w; j++)
		{
			dp[i][j] = 0;
			if(j - wt[i - 1] >= 0)
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wt[i - 1]]  + val[i - 1]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 78592
S = input ()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)


Measured memory_bytes: 9016
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

void update(ll BIT[], ll n, ll x, ll i)
{
    for(; i <= n; i += (i) & (-i)) BIT[i] += x;
}

ll query(ll BIT[], ll l)
{
    ll sum1 = 0;
    for(; l; l = l & (l - 1)) sum1 += BIT[l];
    return sum1;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, x, y;
        cin >> n;
        pair<long double, pair<int,int> > a[2 * n];
        long double ans = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x >> y;
            a[i].ff = atan2(y, x);
            a[i].ss.ff = x;
            a[i].ss.ss = y;
        }
        sort(a, a + n);
        for(int i = n; i < 2 * n; i++) a[i] = a[i - n], a[i].ff += 2 * PI;
        for(int i = 0; i < 2 * n; i++)
        {
            x = 0, y = 0;
            for(int j = i; j < 2 * n; j++)
            {
                x += a[j].ss.ff;
                y += a[j].ss.ss;
                if(a[j].ff - a[i].ff < PI)
                {
                    ans = max((ll)ans, x * x + y * y);
                }
                else break;
            }
        }
        ans = sqrt(ans);
        cout << fixed << setprecision(11) << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <functional>
 
using namespace std;
long long binomial(long long N, long long K) {
  if(K < 0 || N < K) return 0;
  long long ret = 1;
  for(long long i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
int main() {
    long long n,m;
    cin>>n>>m;
    long long ans = binomial(n,2)+binomial(m,2);
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	const int maxn = 1e5 + 5;
	long long N, h, n;
	long long w1, w2;
	bool ans = false;
	scanf("%lld",&N);
	for(h = 1; h <=3500; h++) {
		for(n = 1; n <= maxn ; n++) {
			w1 = N*h*n;
			w2 = 4*h*n-N*h-N*n;
		if(w1>0&&w2>0&&w1%w2==0)  {
	    	printf("%lld %lld %lld",h, n, w1/w2);
	    	ans = true;
	        break;	
	    }
	}
        if(ans) break;
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

int A[100001];
signed main() {
	int n;
	scanf("%d", &n);
	REP(i, n + 1) {
		scanf("%d", &A[i]);
	}
	i64 s = 0;
	REP(i, n) {
		int b;
		scanf("%d", &b);
		int m = A[i] < b ? A[i] : b;
		s += m;
		b -= m;
		m = A[i + 1] < b ? A[i + 1] : b;
		s += m;
		A[i + 1] -= m;
	}
	printf("%lld", s);
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  double s = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    s += 1.0 / (double)a;
  }
  cout << 1/s << endl;

  return 0;
}



Measured memory_bytes: 256
import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ld A, B;
    ll ans;
    cin >> A >> B;
    ans = A * B;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        int num = int.Parse(a.ToString() + b.ToString());

        bool ok = false;
        for (int i = 1; i * i <= num; i++)
        {
            if (i * i == num)
            {
                ok = true;
                break;
            }
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,ll>pa;

const int N=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

ll a[N];
ll n,k;
bool check(int x)
{
     ll sum=0;
    for(int i=1;i<=n;i++){
        sum+=a[i]/x;
        if(a[i]%x==0) sum--;
    }
    if(sum<=k) return true;
    else return false;
}
int main()
{
    ll ans=1e9;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll l=1,r=1e9;
    while(r>=l){
        ll mid=l+r>>1;
        if(check(mid)) ans=min(ans,mid),r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4968
b,a,d,c = map(int, input().split())

t = 0

while 1:
	if t == 0:
		d -= a
		t=1
		if d<=0:
			print("Yes")
			exit(0)
	else:
		b-= c
		t=0
		if b<=0:
			print("No")
			exit(0)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> A (3,vector<int>(3));
  
  for(int i=0;i<3;i++){
  for(int j=0;j<3;j++) {
    cin>>A.at(i).at(j);
    }
  }
  int N; cin>>N;
  vector <int> b(N);
  for(int i=0;i<N;i++){
   cin>>b.at(i);
  }
  vector <vector<bool>> ok (3,vector<bool>(3,false));
  
  for(int k=0;k<N;k++){
    for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    if(b.at(k)==A.at(i).at(j))
      ok.at(i).at(j)=true;
    }
    
    }
 }
  
  
  string ans="No";
  
  for(int i=0;i<3;i++){
  if(ok.at(i).at(0) && ok.at(i).at(1) && ok.at(i).at(2)){
       ans="Yes"; break;
  }
  
  }
  if(ans!="Yes"){
  for(int i=0;i<3;i++){
  if(ok.at(0).at(i) && ok.at(1).at(i) && ok.at(2).at(i)){
       ans="Yes"; break;}
  }
  
  }
    if(ans!="Yes"){
    if(ok.at(0).at(0) && ok.at(1).at(1) && ok.at(2).at(2))
       ans="Yes"; 
      if(ok.at(0).at(2) && ok.at(1).at(1) && ok.at(2).at(0))
       ans="Yes"; 
  
    
    
    
    }  cout<<ans<<endl;
  
  return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int t, d, l;
  while (cin >> t >> d >> l, t) {
    vector<int> imos(t + d);
    for (int i = 0; i < t; ++i) {
      int x;
      cin >> x;
      if (x >= l) {
        imos[i] += 1;
        imos[i + d] -= 1;
      }
    }
    for (int i = 0; i + 1 < t + d; ++i) {
      imos[i + 1] += imos[i];
    }
    int res = 0;
    for (int i = 0; i < t - 1; ++i) {
      res += !!imos[i];
    }
    cout << res << '\n';
  }
}



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

int main() {
    string S,T,U;
    cin >> S >> T >> U;
    char s = S.at(0)-32;
    char t = T.at(0)-32;
    char u = U.at(0)-32;
    cout << s << t << u << endl;
}

Measured memory_bytes: 3636
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
dp = [[0, 0, 0] for _ in range(n)]
dp[0] = arr[0]
# print (arr)
# print (dp)
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0]
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + arr[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2]
print (max(dp[-1]))

Measured memory_bytes: 47384
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[100315],b[100315];
int used[100315];
vector<pint> v;
int main()
{
	int n;
	cin>>n;
	lint sa=0,sb=0,sum=0;
	rep(i,n){
		cin>>a[i]>>b[i];sa+=a[i];sb+=b[i];
		v.pb(mp(a[i],i));v.pb(mp(b[i],i+n));
	}
	lint out=min(sa,sb);
	sort(All(v));
	memset(used,0,sizeof(used));
	rep(i,n){
		sum+=v[i].fi;
		used[v[i].se%n]++;
	}
	rep(i,n){
		if(used[i]!=1){
			cout<<min(sum,out)<<endl;return 0;
		}
	}
	rep(i,n){
		int mn=min(a[i],b[i]),mx=max(a[i],b[i]);
		if(mn==v[n-1].fi) out=min(out,sum-v[n-2].fi+mx);
		else out=min(out,sum-v[n-1].fi+mx);
	}
	cout<<out<<endl;
}


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

int main(){
  string s; cin >> s;
  set<int> Set;
  for(int i=0; i<s.size(); i++){
    Set.insert(s[i]);  
  }
  if(s.size()==Set.size()){
    cout<<"yes"<<endl;  
  } else {
    cout<<"no"<<endl;      
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    // Aller 1
    rep(i, sy, ty)
        cout << "U";
    rep(i, sx, tx)
        cout << "R";
    // Retour 1
    cout << "D";
    rep(i, sx+1, tx)
        cout << "L";
    rep(i, sy+1, ty)
        cout << "D";
    cout << "L";
    // Aller 2
    cout << "D";
    cout << "RR";
    rep(i, sy+1, ty)
        cout << "U";
    rep(i, sx+1, tx)
        cout << "R";
    cout << "UU";
    cout << "L";
    // Retour 2
    cout << "U";
    rep(i, sx-1, tx)
        cout << "L";
    rep(i, sy-1, ty)
        cout << "D";
    cout << "R";
    return 0;
}

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

#define MAX 50

int n, m;
char A[MAX][MAX], B[MAX][MAX];

int main() {
	cin >> n >> m;

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

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

	bool judge = false;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i + m - 1 >= n || j + m - 1 >= n)continue;

			bool match = true;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (A[i + k][j + l] != B[k][l]) {
						match = false;
					}
				}
			}
			if (match) {
				judge = true;
			}
		}
	}

	if (judge) cout << "Yes";
	else cout << "No";

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int n, tmp;
  std::cin >> n;

  for(int i = 1; i <= n; i++){
    tmp = i;
    if(tmp%3 == 0){
      std::cout << " " << i;
      continue;
    }
    while(tmp){
      if(tmp%10 == 3){
	std::cout << " " << i;
	break;
      }
      tmp /= 10;
    }
  }
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 3080
fun main(args : Array<String>) { 
  val (sx,sy,tx,ty) = readLine()!!.split(" ").map(String::toInt)
  println("U".repeat(ty - sy) + "R".repeat(tx - sx+1) + "D".repeat(ty - sy+1) + "L".repeat(tx - sx+1) + "U"+
         "R".repeat(tx-sx) + "U".repeat(ty - sy+1) + "L".repeat(tx - sx + 1)+ "D".repeat(ty - sy + 1)+ "R")
}


Measured memory_bytes: 37872
using System;

public class Test{
  public static void Main(){
    
    //文字列の読み込み
    string[] str1 = System.Console.ReadLine().Split(' ');
    string[] str2 = System.Console.ReadLine().Split(' ');
    long k = Convert.ToInt64(str1[0]);
    long n = Convert.ToInt64(str1[1]);
    long[] a = new long[n];

    //最大経路の探索
    long max = 0;
    a[0] = Convert.ToInt64(str2[0]);
    for(int i=1; i<n; ++i){
        a[i] = Convert.ToInt64(str2[i]);
        if(a[i]-a[i-1] > max){
            max = a[i]-a[i-1];
        }
    }
    if(a[0]+k-a[n-1] > max){
        max = a[0]+k-a[n-1];
    }
   	System.Console.WriteLine(k-max);
  }
}


Measured memory_bytes: 34652
#include <cstdio>
#include <algorithm>

using namespace std;

int main ()
{
  //  freopen ("file.in", "r", stdin);

    int n;
    scanf ("%d", &n);

    int lst = 0;
    long long p = 0LL;
    for (int i = 1; i <= n; ++i)
    {
        int x;
        scanf ("%d", &x);

        if (!x)
        {
            lst = 0;
            continue;
        }

        if (lst) p += 1LL, --x;

        p += 1LL * (x / 2);
        lst = (x % 2);
    }

    printf ("%lld\n", p);

    return 0;
}


Measured memory_bytes: 128
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

int main(){


	double a,b,c,d,e,f;

	while(true){

	cin >> a >> b >> c >> d >> e >> f;

	if(cin.fail()) break;

	double z=a*e-b*d;

	double x=(c*e-b*f)/z;
	double y=(-c*d+a*f)/z;


	if(x==-0.0000) x=0.0000;
	if(y==-0.0000) y=0.0000;



    printf("%.3lf %.3lf\n",x,y);

	}


	return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

int main(void)
{
	li a, b;
	cin >> a >> b;
	if (a < b)swap(a, b);
	li res = a;
	res += (a > b ? a - 1 : b);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { xs <- getInts
  ; putInts (sort xs)
}

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts =putStrLn . unwords . map show

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int[] root = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                if (s < t)
                {
                    while (root[s] != root[t])
                    {
                        sb.Append(root[s] + " ");
                        s = (s + 1) % 15;
                    }
                    sb.AppendLine(root[t].ToString());
                }
                else
                {
                    if (s <= 5)
                    {
                        while (root[s] != root[t])
                        {
                            sb.Append(root[s] + " ");
                            s--;
                        }
                        sb.AppendLine(root[t].ToString());
                    }
                    else
                    {
                        while (root[s] != root[t])
                        {
                            sb.Append(root[s] + " ");
                            s = (s + 1) % 15;
                        }
                        sb.AppendLine(root[t].ToString());
                    }
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long total = 0;
		int count = 0;
		if(h == 1) {
			System.out.println(1);
			return;
		}
		while(h > 0) {
			h /= 2;
			total += Math.pow(2,count);
			count++;
		}
		if(h % 2 == 1) {
			System.out.println(total + 2);
		}else {
			System.out.println(total);
		}

	}

}


Measured memory_bytes: 24916
A, B, C, D, E, F = map(int, input().split())
A, B = 100 * A, 100 * B
W = set()
S = set()

for i in range(F // A+1):
    for j in range(F // B+1):
        w = A * i + B * j
        if w <= F:
            W.add(w)

for i in range(F // C+1):
    for j in range(F // D+1):
        s = C * i + D * j
        if s <= F:
            S.add(s)

max_rat = -24
for w in W:
    for s in S:
        if w + s <= F and s <= w / 100 * E and s+w!=0:
            rat = s / (s + w)
            if rat > max_rat:
                x, y, max_rat = w, s, rat

print(x + y, y)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

const int INF=1e9+7;

void solve(){
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;++i) cin >> h[i];
	vi dp(n,INF);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] <<  nl;
}

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

	solve();
	
	return 0;
}


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

int comp(const int *a,const int *b){
	return *a - *b;
}

int main(int argc, char const *argv[]){
	int N,*A,ans = 0;
	scanf("%d",&N);
	A = (int *)malloc(sizeof(int) * N);


	for(int i = 0;i < N; ++i)  scanf("%d",&A[i]);
	qsort(A, N, sizeof(int), comp);

	for(int i = 0;i < N; ++i){
		if(A[i] == A[i + 1])  ++i;
		else  ++ans;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 892
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

def isOk(i):
    if i < P:
        return True

    b = A[i] + M
    if b < A[P - 1]:
        return False

    cnt = (P - 1) * M + (N - i) * M

    for a in A[P - 1: i]:
        cnt += max(0, b - a)
    return cnt >= M * V

ok = 0
ng = N
while ng - ok > 1:
    mid = (ng + ok) // 2

    if isOk(mid):
        ok = mid
    else:
        ng = mid
print(ng)



Measured memory_bytes: 14480
//一和倒数第二个 二和倒数第三个 
#include <bits/stdc++.h>
using namespace std;
int N;
int Bel[105],qwqq,Bel1[105];
bool pd[105][105];
bool Isin[105];
bool dfs(int las,int Now)
{
	if (Now==0)
	  return true;
	for (int i=las;i<=Now;i++)
	  if (Now-i>=0)
	  {
	  	Bel[++qwqq]=i;
	  	Isin[i]=true;
	    if (dfs(las+1,Now-i)) return true;
	    Isin[i]=false;
	    qwqq--;
	  }
}
int main()
{
	scanf("%d",&N);
	int cnt=0;
	for (int i=1;i<=N;i++)
	cnt+=i;
	if (cnt%2==0)
	{
		int R=cnt/2,qwq=0;
		for (int i=N;i>=1;i--)
		  if (R-i>=0)
  		{
		  R-=i;
		  Bel[++qwqq]=i;
		  Isin[i]=true;
	    }
		int qwqq1=0;
		for (int i=1;i<=N;i++)
		  if (!Isin[i])
		    Bel1[++qwqq1]=i;
		int ans=qwqq*qwqq1;
		printf("%d\n",ans);
		for (int i=1;i<=qwqq1;i++)
		  for (int j=1;j<=qwqq;j++)
		    printf("%d %d\n",Bel1[i],Bel[j]);
	}
	else
	if (N%2)
	{
		int ans=0;
		ans=N*(N-1)/2;
		for (int i=1;i<=N/2;i++)
		  	pd[i][N-i]=true,ans--;
		printf("%d\n",ans);
		for (int i=1;i<=N;i++)
		  for (int j=i+1;j<=N;j++)
		    if (!pd[i][j])
		      printf("%d %d\n",i,j);
	}
	else
	{
		int ans=0;
		ans=N*(N-1)/2;
		for (int i=1;i<=N/2;i++)
		  	pd[i][N-i+1]=true,ans--;
		printf("%d\n",ans);
		for (int i=1;i<=N;i++)
		  for (int j=i+1;j<=N;j++)
		    if (!pd[i][j])
		      printf("%d %d\n",i,j);
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for j in range(n):
    for i in range(n):
        f = True
        for k in range(n):
            if l[i][j] > l[i][k]+l[k][j]:
                print(-1)
                exit()
            if l[i][j] == l[i][k] + l[k][j] and i !=k and k != j:
                f = False
        if f:
            ans += l[i][j]
print(ans//2)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ll MOD(ll x, ll m) {
    ll r = x % m;
    if (r < 0) {
        r += m;
    }
    return r;
}

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    string s, t;
    cin >> s >> t;

    ll res = 0;
    REP(i, s.size()) {
        res += s[i] != t[i];
    }

    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 3784