akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define MAX_N 16
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
    int N;
    cin>>N;
    ll A[16][16];
    ll dp[1<<16];
    ll grp[1<<16];
    rep(i,N){
        rep(j,N){
            cin>>A[i][j];
        }
    }
    for(int bit = 0;bit < (1<<N);bit++){
        grp[bit]=0;
        for(int i = 0;i < N;i++){
            for(int j = i+1;j < N;j++){
                if((bit&(1<<i))!=0&&(bit&(1<<j))!=0){
                    grp[bit]+=A[i][j];
                }
            }
        }
        dp[bit]=grp[bit];
        for(int sub = bit; sub > 0;sub=(sub-1)&bit){
            dp[bit]=max(dp[bit],dp[sub]+dp[bit&(~sub)]);
        }
    }
    cout<<dp[(1<<N)-1]<<endl;
}


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


#define pb push_back
typedef long long int ll;


using namespace std;


void solve()
{

    ll h,w,m;
    cin>>h>>w>>m;

    int row[h+1];
    int col[w+1];

    map <pair<int,int>, int> mm;

    memset(row,0,sizeof(row));
    memset(col,0,sizeof(col));

    while(m--){
        int t1,t2;
        cin>>t1>>t2;
        row[t1]++;
        col[t2]++;
        mm[{t1,t2}]++;
    }

    int mr = 0;
    int mc = 0;

    for(int i=1;i<=h;i++){
        if(row[i]>mr) mr = row[i];
    }
    for(int i=1;i<=w;i++){
        if(col[i]>mc) mc = col[i];
    } 

    vector <int> vr,vc;

    for(int i=1;i<=h;i++){
        if(row[i]==mr) vr.pb(i);
    }
    for(int i=1;i<=w;i++){
        if(col[i]==mc) vc.pb(i);
    } 

    if(vr.size()*vc.size()>m){
        cout<<mr+mc;
    }
    else{
        for(auto i:vr){
            for(auto j:vc){
                if (mm[{i,j}]==0){
                    cout<<mr+mc;
                    return;
                }
            }
        }

        cout<<mr+mc-1;

    }
    // sort(row+1,row+1+h, greater<ll>());
    // sort(col+1,col+1+w, greater<ll>());

    // int rm = row[1];
    // int cm = col[1];

    // int ctrr = 0;
    // int ctrc = 0;

    // for(int i=1;i<=h;i++){
    //     if(row[i]==rm) 
    //         ctrr++;
    // }
    // for(int i=1;i<=w;i++){
    //     if(col[i]==cm)
    //         ctrc++;
    // }

    // cout<<ctrr<<ctrc;

    // if(ctrr==cm and ctrc==rm){
    //     cout<<cm+rm-1;
    // }
    // else{
    //     cout<<cm+rm;
    // }


}
int main() {



    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();   
        cout<<endl; 
    } 
 
}

Measured memory_bytes: 28388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<pair<int, int>> AB(N);
    REP(i, N) {
        int A, B;
        cin >> A >> B;
        AB[i] = make_pair(A, B);
    }
    sort(ALL(AB), [](auto& l, auto& r){ return l.second < r.second; });
    int time = 0;
    for(auto& pair : AB) {
        time += pair.first;
        if (time > pair.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

float min(float a, float b){
    if (a<b){
        return a;
    }else{
        return b;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> t(N+3,0),v(N+2,0);
    for(int i=2; i<N+2; i++){
        int a;
        cin >> a;
        t[i]=t[i-1]+2*a;
    }
    t[N+2]=t[N+1];
    for(int i=1; i<N+1; i++){
        cin >> v[i];
    }
    v[0]=0;v[N+1]=0;
    vector<float> v_limit(t[N+2]+1,10000);
    v_limit[0]=0;
    v_limit[t[N+2]]=0;
    for(int i=0; i<N+2; i++){
        //cout << i << ' ' << t[i] << ' ' << t[i+1] << ' ' << v[i] << endl;
        for(int j=t[i]; j<=t[i+1]; j++){
            v_limit[j]=min(v_limit[j],v[i]);
        }
        for(int j=1; t[i]-j>=0; j++){
            v_limit[t[i]-j]=min(v_limit[t[i]-j],(float)v[i]+0.5*j);
        }
        for(int j=1; t[i+1]+j<=t[N+2];j++){
            v_limit[t[i+1]+j]=min(v_limit[t[i+1]+j], (float)v[i]+0.5*j);
        }
    }
    float ans=0;
    for(int i=0; i<t[N+2]; i++){
        ans+=(v_limit[i+1]+v_limit[i]);
        if(i%2==0){
            //cout << i/2 << ' ' << v_limit[i] << endl;
        }
    }
    cout << fixed << setprecision(4) << ans/4 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define fastio                          ios::sync_with_stdio(false);   cin.tie(0);   cout.tie(0);
#define input(arr, n)                   for(i=1; i<=n; i++) cin >> arr[i];
#define output(arr, n)                  for(i=1; i<=n; i++) {cout << arr[i] << " "; } cout << "\n";
#define print(cont)                     for(auto it : cont) {cout << it << " "; } cout << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int main(){


    fastio;
    string s;
    cin >> s;
    int w;
    cin >> w;

    for(int i=0; i<s.size(); i+=w){
        cout << s[i];
    }
}

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

int main() {
  ll n,x,mi=1e18;
  cin>>n;
  for (int i=0; i<5; i++) {
    cin>>x;
    mi=min(mi,x);
  }
  
  cout<<(n+mi-1)/mi+4<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)

using namespace std;
int main(){
    
    char N[15];cin >> N;
    int size = 0;
    for(int i = 0;i<15;i++){
        if(N[i]=='o')size++;
        else if(N[i]=='x')size++;
    }
    // cout << size;
    int win=0;
    for(int i = 0;i<size;i++){
        if(N[i]=='o') win++;
    }
    int remain = 0;
    remain = 15-size;
    int ans = 0;
    ans = win + remain;
    if(ans >=8){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    } else {
        cout << r + ( 100 * (10 - n)) << endl;
    }

    return 0;
}


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

int main(){
    long long int x, k, d;
    cin >> x >> k >> d;

    if(x >= 0){
        long long int a;
        a = min(x/d + 1, k);
        x = x - a * d;
        k = k - a;
    }
    else{
        long long int a;
        a = min((-1*x)/d + 1, k);
        x = x + a * d;
        k = k - a;
    }

    if(k%2 == 0){
        cout << abs(x) << endl;
    }
    else{
        if(x < 0){
            cout << abs(x + d) << endl;
        }
        else{
            cout << abs(x - d) << endl;
        }
    }
}


Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

     
def main():
    N = I()

    h = LI()
    cnt = 0

    def dec_h(l, r):
        nonlocal cnt
        nonlocal h
        if l > r:
            return
        min_h = min(h[l:r+1])
        # print('l: {}, r: {}, min_h: {}'.format(l, r, min_h))
        for j in range(l, r+1):
            h[j] -= min_h
        cnt += min_h
        st = l
        en = r
        # print('h: {}'.format(h))
        for i in range(l, r+1):
            if h[i] == 0:
                en = i-1
                dec_h(st, en)
                st = i+1
            if i == r and st < r+1:
                dec_h(st, r)
    dec_h(0, N-1)
    print(cnt)

main()



Measured memory_bytes: 6096
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long int 

void lucifer()
{
	ll n;
	cin>>n;
	cout<<2*(M_PI)*n;
	return;


}



signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    ll t = 1;
    cout << fixed << setprecision(14);
    while(t--){
        lucifer();
    }
 

}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  bool ok=false;
  for(int i=0;i<=x;i++){
    if(2*(x+i)==y)ok=true;
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
A = [1e9] * n
f = True
for _ in range(m):
    s, c = map(int, input().split())
    if A[s - 1] != 1e9:
        if A[s - 1] != c: 
            f = False
    if s - 1 == 0 and c == 0 and n != 1:
        f = False
    A[s - 1] = c

if f:
    ans = ""
    for i in range(len(A)):
        if i == 0 and A[i] == 1e9:
            if n == 1:
                ans += "0"
            else:
                ans += "1"
        else:
            if A[i] == 1e9:
                ans += "0"
            else:
                ans += str(A[i])
    print(int(ans))
else:
    print(-1)

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

int main(){
  char x;
  cin >> x;
  
  if(x=='A')
    cout << "T" << endl;
  else if(x=='T')
    cout << "A" << endl;
  else if(x=='C')
    cout << "G" << endl;
  else
    cout << "C" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
for i in range(len(s)):
    if (ord(s[i]) + n) > ord("Z"):
        print(chr(n + ord(s[i]) - ord("Z") + ord("A") - 1), end='')
    else:
        print(chr(ord(s[i]) + n), end='')

Measured memory_bytes: 44780
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    sort(a.begin(), a.end(), greater<int>());
    int sum = 0;
    rep(i, k){
        sum +=a[i];
    }
    cout << sum << endl;
}


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

int Digit_num(int n){//桁数を返す関数
    int digit = 0;

    while(n>0){
        digit++;
        n/=10;
    }

    return digit;
}

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

    int count = 0;

    for(int i=1;i<=n;i++){
        if(Digit_num(i)%2 == 1){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
// CountingCharacters.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <string>

int get_alphabet_num(char c) {
	int ret = -1;
	if (65 <= c && c <= 90)
	{
		ret = c - 65;
	}
	else if (97 <= c && c <= 122)
	{
		ret = c - 97;
	}
	return ret;
}

int main()
{
	std::vector<int> alphabet_num(26);
	std::string alphabet = "abcdefghijklmnopqrstuvwxyz";
	int tmp;
	char ch;
	while ((ch = getchar()) != EOF) {
		tmp = get_alphabet_num(ch);
		if (tmp >= 0)
		{
			++alphabet_num[tmp];
		}
	}
	for (int i = 0; i < 26; ++i) {
		std::cout << alphabet[i] << " : " << alphabet_num[i] << std::endl;
	}
}



Measured memory_bytes: 3156
def gcd(x,y):
	if x < y:
		x, y = y, x
	while(y):
		x, y = y, x%y
	return x

def gcds(t,X,V):
	if X[t] > V[t]:
		x, y = X[t], V[t]
	else:
		x, y = V[t], X[t]
	while(y>0):
		x, y = y, x%y
		V[t+1] = x

def gcde(t,X,V):
	if X[t] > V[t+1]:
		x, y = X[t], V[t+1]
	else:
		x, y = V[t+1], X[t]
	while(y>0):
		x, y = y, x%y
		V[t] = x

def main():
	N = int(input())
	A = list(map(int,input().split()))
	ans = 1
	S = [A[0]]*(N+1)
	E = [A[N-1]]*(N+1)
	for t in range(N):
		gcds(t, A, S)
		gcde(N-t-1, A, E)
	ans = max(ans, E[1])
	ans = max(ans, S[N-1])
	for t in range(1,N-1):
		ans = max(ans, gcd(S[t], E[t+1]))
	print(ans)

main()

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

int main()
{
	int N;
	int data[3][100005];
	int64_t dp[3][100005] = {};

	cin >> N;
	for ( int i = 0; i < 3; i++ ) {
		for ( int j = 0; j < N; j++ ) {
			cin >> data[i][j];
		}
		sort(data[i], data[i] + N);
	}
	dp[0][0] = 1;
	for ( int i = 0; i < 2; i++ ) {
		int64_t sum = 0;
		for ( int j = 0; j < N; j++ ) {
			sum += dp[i][j];
			int lower = lower_bound(data[i + 1], data[i + 1] + N, data[i][j] + 1) - data[i + 1];
			if ( lower < N ) {
				dp[i + 1][lower] += sum;
			}
		}
	}

	int64_t ss = 0, ans = 0;
	for ( int i = 0; i < N; i++ ) {
		ss += dp[2][i];
		ans += ss;
	}
	cout << ans << endl;

	return ( 0 );
}


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

using namespace std;

int main(){

	int N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	A--;B--;C--;D--;
	string cadena;
	cin>>cadena;

	
	int temp1 = B-1;
	int temp2 = D+1;

	if(A<B && C<D){
		for(int i=A; i< cadena.size(); i++){
			if(i == D){
				cout<<"Yes"<<endl;
				break;
			}
			if(cadena[i]=='#'){
				if(cadena[i+1] == '#'){
					cout<<"No"<<endl;
					break;
				}
			}
		}
	}
	
	else{
		int aux = 0;
		bool aux2 = false;
		for(int i = temp1; i <= temp2; i++ ){
			if(cadena[i]=='.') aux++;
			else{
				aux = 0;
			}
			if(aux == 3){
				aux2 = true;
				break;
			}

		}
		if(aux2){
			for(int i=A; i< cadena.size(); i++){
				if(i == C){
					cout<<"Yes"<<endl;
					break;
				}
				if(cadena[i]=='#'){
					if(cadena[i+1] == '#'){
						cout<<"No"<<endl;
						break;
					}
				}
			}		

		}
		else cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define INF 999999999

using namespace std;

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

int m, n;
char f[1050][1050];
char em[3][3];

char flag[4] = { 'J','O','I' };

bool emblem(int i,int j)
{
	if (f[i][j] == em[0][0]) {
		if (f[i][j + 1] == em[0][1]) {
			if (f[i + 1][j] == em[1][0]) {
				if (f[i + 1][j + 1] == em[1][1]) {
					return 1;
				}
			}
		}
	}
	return 0;
}



int fchange(char a,int i,int j)
{
	char b = f[i][j];
	f[i][j] = a;

	int res = 0;

	int plus = emblem(i - 1, j - 1) + emblem(i - 1, j) + emblem(i, j - 1) + emblem(i, j);
	f[i][j] = b;
	int minus = emblem(i - 1, j - 1) + emblem(i - 1, j) + emblem(i, j - 1) + emblem(i, j);

	//cout << "plus:" << plus << "minus" << minus << endl;
	return plus - minus;

}

int main()
{
	cin >> m >> n;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> f[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> em[i][j];
		}
	}

	int num = 0;
	vector<P> change;

	for (int i = 1; i <= m - 1; i++) {
		for (int j = 1; j <= n - 1; j++) {
			int lu = 0, ru = 0, ll = 0, rl = 0;
			if (f[i][j] == em[0][0])lu = 1;
			if (f[i][j + 1] == em[0][1])ru = 1;
			if (f[i + 1][j] == em[1][0])ll = 1;
			if (f[i + 1][j + 1] == em[1][1])rl = 1;

			if (lu + ru + ll + rl == 4) {
				num++;
			}
			else if (lu + ru + ll + rl == 3) {
				if (lu == 0)change.push_back(P(i, j));
				if (ru == 0)change.push_back(P(i, j + 1));
				if (ll == 0)change.push_back(P(i + 1, j));
				if (rl == 0)change.push_back(P(i + 1, j + 1));
			}

		}
	}
	//cout << "num:" << num << endl;

	int max = 0;
	for (int i = 0; i < change.size(); i++) {
		//cout << "change:"<<change[i].first << change[i].second << endl;
		int imax = 0;
		for(int j = 0; j < 3; j++) {
			int k = fchange(flag[j], change[i].first, change[i].second);
			if (k > imax)imax = k;
		}
		if (imax > max)max = imax;
	}

	cout << num + max << endl;


	return 0;
}

Measured memory_bytes: 5876
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
time = 0
odd_flag = false
while true
  a.map!{|num|
    if num % 2 != 0 then
      odd_flag = true;
    else
      num / 2
    end
  }
  if odd_flag == true then
    break
  else
    time +=1
  end
end
print "#{time}"

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int W = sc.nextInt();
        final int H = sc.nextInt();
        final int N = sc.nextInt();

        final int[][] area = new int[W][H];
        for (int i = 0; i < W; i++) {
            for (int j = 0; j < H; j++) {
                area[i][j] = 1;
            }
        }

        for (int i = 0; i < N; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();

            switch (a) {
                case 1:
                    paint(area, 0, 0, x, H);
                    break;
                case 2:
                    paint(area, x, 0, W, H);
                    break;
                case 3:
                    paint(area, 0, 0, W, y);
                    break;
                case 4:
                    paint(area, 0, y, W, H);
                    break;
            }
        }

        int ans = 0;
        for (int i = 0; i < W; i++) {
            for (int j = 0; j < H; j++) {
                ans += area[i][j];
            }
        }

        System.out.println(ans);
    }

    private static void paint(int[][] area, int px, int py, int qx, int qy) {
        for (int i = px; i < qx; i++) {
            for (int j = py; j < qy; j++) {
                area[i][j] = 0;
            }
        }
    }

}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll N,K;
bool is_appear[100010];

signed main() {
    cin>>N>>K;
    vector<PLL> v(N); // {おいしさ、ネタID}
    rep(i,0,N){
        cin>>v[i].second>>v[i].first;
    }
    sort(begin(v), end(v), greater<PLL>());

    multiset<PLL> removable, appendable;
    multiset<PLL> s;
    ll t = 0, d = 0;
    rep(i,0,K){
        s.insert(v[i]);
        d += v[i].first;
        if (is_appear[v[i].second]) {
            removable.insert(v[i]);
        } else {
            is_appear[v[i].second]=true;
            t++;
        }
    }
    ll ans = d + t*t;

    rep(i,K,N){
        if (! is_appear[v[i].second]) {
            appendable.insert(v[i]);
            is_appear[v[i].second]=true;
        }
    }

    // debug
    // cout<<"s: "<<endl;
    // for (auto e: s){
    //     cout<<"deli="<<e.first<<", kind="<<e.second<<endl;
    // }
    // cout<<"removable: "<<endl;
    // for (auto e: removable){
    //     cout<<"deli="<<e.first<<", kind="<<e.second<<endl;
    // }
    // cout<<"appendable: "<<endl;
    // for (auto a = appendable.rbegin(); a != appendable.rend(); a++) {
    //     cout<<"deli="<<a->first<<", kind="<<a->second<<endl;
    // }
    //
    for (auto a = appendable.rbegin(); a != appendable.rend(); a++) {
        if(removable.size() > 0){
            t++;
            d -= removable.begin()->first;
            d += a->first;
            ans = max(ans, d+t*t);
            
            // remove
            auto it = removable.begin();
            removable.erase(it);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace AtCoder.B
{ 
    public class Program
    {
        public static void Main(string[] args)
        {
            var a = cr();
            var n = a[0];
            var k = a[1];
            var datas = cr();
            datas = datas.OrderBy(x => x).ToArray();
            var sum = 0;
            for(var i = 0; i < k;i++)
			{
                sum += datas[i];
			}
            P(sum);
        }

        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Er()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine();
        }
        public static string r()
        {
            return Console.ReadLine();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }
    }
}


Measured memory_bytes: 28664
#include<bits/stdc++.h>
using namespace std;
int n;
long double v[55];
long double ans=0;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		cin>>v[i];
	sort(v+1,v+1+n);
	ans=v[1];
	for(int i=2;i<=n;i++)
		ans=(ans+v[i])/2;
	cout<<fixed<<setprecision(7)<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int A;
  int B;
  cin >> A >> B;
  if(A <= 5){
  	cout << "0" << endl;
  }
  else if(A <= 12){
  	cout << B / 2 << endl;
  }
  else{
  	cout << B << endl;
  }
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec  8 21:14:49 2018
//
package main

import (
	"fmt"
	"sort"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	sort.Ints(arr)
	diff := 1000000000
	for i := 0; i+K-1 < N; i++ {
		diff = min(diff, arr[i+K-1]-arr[i])
	}
	fmt.Println(diff)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる

ll from0(ll x){
  if(x%4==3) return 0;
  if(x%4==0) return x;
  if(x%4==1) return 1;
  if(x%4==2) return 1^x;
}


int main() {
  ll a,b;
  cin >> a >> b;
  
  if(a==0) cout << from0(b) << endl;
  else cout << (from0(a-1)^from0(b)) << endl;




}


Measured memory_bytes: 256
S=input()
N=len(S)
Sr=''.join([S[-i-1] for i in range(N)])
T=''.join([S[i] for i in range(0,(N-1)//2)])
Tr=''.join([T[-i-1] for i in range(0,(N-1)//2)])
U=''.join([S[i] for i in range((N+1)//2,N)])
Ur=''.join([U[-i-1] for i in range(0,(N-1)//2)])
if S==Sr and Tr==T and U==Ur:
    print('Yes')
else:
    print('No')


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

int main() {
  long A,B;cin>>A>>B;
  long C,D;cin>>C>>D;
  long ans=0;
  ans += B/C;
  ans += B/D;
  ans -= (A-1)/C;
  ans -= (A-1)/D;
  long S=gcd(C,D);
  ans -= ((B/C)*S)/D;
  ans += (((A-1)/C)*S)/D;
  cout<<B-A+1-ans<<endl;
}


Measured memory_bytes: 3536
import sys
from heapq import *
input = sys.stdin.readline

def main():
  n, m, s, t = map(int, input().split())
  
  inf = pow(10, 15)
  
  tree = [[] for _ in range(n)]
  for i in range(m):
    u, v, a, b = map(int, input().split())
    tree[u-1].append((v-1, a, b))
    tree[v-1].append((u-1, a, b))
  
  ans_yen = [0]*n
  ans_snuke = [0]*n
  
  for start, ans in zip([s-1, t-1], [ans_yen, ans_snuke]):
    already = [False]*n
    not_yet = [(0, start)]
    
    while len(not_yet) > 0:
      c, p = heappop(not_yet)
      if already[p]:
        continue
      ans[p] = c
      already[p] = True
      
      for (value, a, b) in tree[p]:
        if already[value]:
          continue
        if start == s-1:
          cost = a
        else:
          cost = b
        heappush(not_yet, (c+cost, value))
  
  ans = [0]*n
  sub = inf
  for i in range(n-1, -1, -1):
    sub = min(sub, ans_yen[i]+ans_snuke[i])
    ans[i] = sub
  
  sub = inf
  for a in ans:
    print(sub-a)
      
  
  
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 61688
H,W,M = map(int,input().split())

hh = [[0,_] for _ in range(H+1)]
ww = [[0,_] for _ in range(W+1)]

#hh = [0]*(H+1)
#ww = [0]*(W+1)
d = {}

for i in range(M):
    h,w = map(int,input().split())
    hh[h][0] += 1
    ww[w][0] += 1
    d[(h,w)] = True

bomb = []
for kh,kw in d.keys():
    bomb.append(hh[kh][0] + ww[kw][0] -1)
bombMax = max(bomb)

hh.sort(reverse=True)
ww.sort(reverse=True)
Mh = hh[0][0]
Mw = ww[0][0]
maxh = []
maxw = []
for i in range(H):
    if hh[i][0] == Mh:
        maxh.append(hh[i][1])
    else:
        break
for i in range(W):
    if ww[i][0] == Mw:
        maxw.append(ww[i][1])
    else:
        break

for h in maxh:
    for w in maxw:
        if (h,w) not in d:
            print(Mh+Mw)
            break
    else:
        continue
    break
else:
    print(Mh+Mw-1)
"""
print(maxh)
print(maxw)
print(d)
print(bomb)
"""

Measured memory_bytes: 247232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
mt19937 rnd(random_device{}());

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac; void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}

ll randInt(ll l,ll r){return uniform_int_distribution<ll>(l,r)(rnd);}
double randDouble(double l,double r){return uniform_real_distribution<double>(l,r)(rnd);}
void dout(double d){printf("%.12f\n",d);}

const double PI = acos(-1);
const double EPS = 1e-10;
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;

const int N = 1e5;
int n;
ll a[N], s, ans[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a[i];
    s += a[i];
    if(i&1) s -= a[i]*2;
  }
  ans[0] = s;
  FOR(i, 1, n) ans[i] = (a[i-1]-ans[i-1]/2)*2;
  FOR(i, 0, n) cout << ans[i] << ' '; cout << endl;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
vector<int> a,parent;
int findparent(int x)
{
    if(parent[x]!=x)
    {
	parent[x]=findparent(parent[x]);
    }
    return parent[x];
}
void unionset(int a,int b)
{
    if((a=findparent(a))==(b=findparent(b)))
    {
	return;
    }
    parent[a]=b;
}
int main()
{
    int n,m,u,v;
    int i,ans=0;
    scanf("%d %d",&n,&m);
    a.resize(n+1);
    parent.resize(n+1);
    for(i=1;i<=n;i++)
    {
	scanf("%d",&a[i]);
    	parent[i]=i;
    }
    for(i=0;i<m;i++)
    {
	scanf("%d %d",&u,&v);
        unionset(a[u],a[v]);
    }
    for(i=1;i<=n;i++)
    {
	if(findparent(i)==findparent(a[i]))
	{
	    ans++;
	}
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
  string hoge[] = {"* = ****","* =* ***","* =** **","* =*** *","* =**** ",
                   " *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** ",};
  int n;
  int f = 0;
  while(cin>>n) {
    if (f) cout << endl; else f++;
    vector<string> ans(5);
    REP(i,5) {
      ans[i] = hoge[n%10];
      n/=10;
    }
    reverse(ALL(ans));
    REP(y,8) {
      REP(x,5) {
        cout << ans[x][y];
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int x[MAX],y[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i];
    for(int i=0;i<n;i++)
        cin>>y[i];
    int mx=0;
    for(int i=0;i<n;i++){
        if(x[i]>y[i])
            mx+=x[i]-y[i];
    }
    cout<<mx<<endl;


    return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int a;
		int b;
		int c;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		sc.close();

		int ret = c - ( a - b );
		if(ret < 0) {
			ret = 0;
		}
		System.out.println(ret);

	}

}


Measured memory_bytes: 23124
input_data = gets.chomp.to_i
n = input_data

while n != 0 do 
    g = gets.chomp.split(" ")
    a = g.map{|v| v.to_i}
    
    array = []
    (0..(n-2)).each do |i|
        ((i+1)..(n-1)).each do |j|
            array.push((a[i] - a[j]).abs)
        end
    end
    
    p array.min
    input_data = gets.chomp.to_i
    n = input_data
end


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

int main(){
	int n, b, f, r, v;
	int count[4][3][10] = {0};
	int i, j, k;
	
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		count[b - 1][f -1][r - 1] += v;
	}
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				cout << " " << count[i][j][k];
			}
			cout << endl;
		}
		if(i < 3){
			cout << "####################" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
    int n,m,i,j,k,a,b,sum=0,x;
    cin>>n;
    int ara[n];
    for(i=0;i<n;i++) cin>>ara[i];
    for(i=0;i<n;i++){
        sum+=ara[i];
    }
    cin>>m;
    x=sum;
    for(i=0;i<m;i++){
        cin>>a>>b;
        sum=sum-ara[a-1]+b;
        cout<<sum<<endl;
        sum=x;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dp[41][410][410];
int main(){
	int n;
	cin>>n;
	cout<<n*800-n/15*200<<endl;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    ll a, b, n;
    cin >> a >> b >> n;

    cout << (a * min(b-1, n)) / b << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static long N, M, Q;
        static long[] a, b, c, d;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var K = Sarray()[0];


            var dp = new long[N, 10, 4, 2];
            var F = 0;
            var T = 1;
            var Ss = S[0] - '0';
            for (var l = 1; l < Ss; ++l)
                dp[0, l, 1, F] = 1;
            dp[0, Ss, 1, T] = 1;
            for (var i = 1; i < N; ++i)
            {
                var Sn = S[i] - '0';
                var Sp = S[i - 1] - '0';

                for (var k = 1; k <= 3; ++k)
                {
                    //0に推移する場合
                    for (var j = 0; j <= 9; ++j)
                        dp[i, 0, k, F] += dp[i - 1, j, k, F];
                    if (0 != Sn)
                        dp[i, 0, k, F] += dp[i - 1, Sp, k, T];

                    //0以外に遷移する場合
                    for (var l = 1; l <= 9; ++l)
                        for (var j = 0; j <= 9; ++j)
                            dp[i, l, k, F] += dp[i - 1, j, k - 1, F];
                    for (var l = 1; l < Sn; ++l)
                        dp[i, l, k, F] += dp[i - 1, Sp, k - 1, T];

                    //張り付き
                    if (0 == Sn)
                        dp[i, Sn, k, T] = dp[i - 1, Sp, k, T];
                    else
                        dp[i, Sn, k, T] = dp[i - 1, Sp, k - 1, T];
                }
                //前全部0から推移
                for (var l = 1; l <= 9; ++l)
                    ++dp[i, l, 1, F];
            }
            var ans = 0L;
            for (var l = 0; l <= 9; ++l)
                for (var t = 0; t <= 1; ++t)
                    ans += dp[N - 1, l, K, t];
            WriteLine(ans);
        }
 
    }
}

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

int main()
{
    int N;
    cin >> N;
    if (N / 10 == 9 || N - (N / 10) * 10 == 9)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=[int1(input()) for i in range(N)]
    used=[False]*N
    v=0
    c=0
    while True:
        used[v]=True
        c+=1
        v=a[v]
        if used[v]:
            print(-1)
            exit()
        if v==1:
            print(c)
            exit()

if __name__ == '__main__':
    main()


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

signed main() {
	vector<int> s(6);
	for (int i = 0; i < 6; ++i) {
		cin >> s[i];
	}

	string com;
	cin >> com;
	char tmp;

	for (int i = 0; i < com.size(); ++i) {
		if (com[i] == 'N') {
			tmp = s[5];
			s[5] = s[4];
			s[4] = s[0];
			s[0] = s[1];
			s[1] = tmp;
		}
		else if (com[i] == 'E') {
			tmp = s[5];
			s[5] = s[2];
			s[2] = s[0];
			s[0] = s[3];
			s[3] = tmp;
		}
		else if (com[i] == 'W') {
			tmp = s[5];
			s[5] = s[3];
			s[3] = s[0];
			s[0] = s[2];
			s[2] = tmp;
		}
		else if (com[i] == 'S') {
			tmp = s[5];
			s[5] = s[1];
			s[1] = s[0];
			s[0] = s[4];
			s[4] = tmp;
		}
	}
	cout << s[0] << endl;
}



Measured memory_bytes: 3196
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;
use std::mem::*;
use std::cell::*;

struct Input {
    stdin: io::Stdin,
    buf: VecDeque<String>
}

impl Input {
    fn new() -> Input {
        Input { 
            stdin: io::stdin(),
            buf: VecDeque::new()
        }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_3<T: FromStr, U: FromStr, V: FromStr>(&mut self) -> (T, U, V)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug,
          <V as FromStr>::Err: fmt::Debug {
        (self.read(), self.read(), self.read())
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = self.stdin.read_line(&mut s);
            self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));
        }
        self.buf.pop_front()
    }
}

fn dijkstra<U: AsRef<[(usize, i64)]>>(g: &[U], s: usize) -> Vec<i64> {
    let n = g.len();
    let mut d = vec![i64::max_value(); n];
    let mut q = BinaryHeap::<(i64, usize)>::new();
    q.push((0, s));
    d[s] = 0;
    while let Some((ic, u)) = q.pop() {
        let c = -ic;
        if c <= d[u] {
            for &(v, w) in g[u].as_ref() {
                if c + w < d[v] {
                    d[v] = c + w;
                    q.push((-d[v], v));
                }
            }
        }
    }
    d
}

fn run() {
    let mut ip = Input::new();
    let (n, m, r) = ip.read_3();
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let (u, v, w): (usize, usize, i64) = ip.read_3();
        g[u].push((v, w));
    }
    let d = dijkstra(&g, r);
    for x in d {
        if x < i64::max_value() { println!("{}", x); }
        else { println!("INF"); }
    }
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(50 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}


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

using namespace std;

#define int long long

const int   N   = 1e5 + 1;

vector<int> g[N];
int n, R, a[N];
int f[N], p[N];

void dfs(int u,int pu)  {
    for(int v : g[u])
        if(v != pu) {
            p[v] = u;
            dfs(v,u);
            f[u] -= f[v];
        }
    if(f[u] < 0)    {
        puts("NO");
        exit(0);
    }
}

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

    cin >> n;

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

    for(int i = 1 ; i <  n ; ++i)   {
        int x, y;   cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    for(int i = 1 ; i <= n ; ++i)
        f[i] = (2 - (g[i].size() < 2)) * a[i];

    dfs(1,0);

    if(f[1])    return 0 * puts("NO");

    for(int i = 1 ; i <= n ; ++i)   {
        if(g[i].size() < 2) continue;
        int sum = f[i];
        for(int v : g[i])
            if(v != p[i])
                sum += f[v];
        if(f[i] > sum / 2)  return 0 * puts("NO");
        for(int v : g[i])
            if(v != p[i] && f[v] > sum / 2)
                return 0 * puts("NO");
    }
    puts("YES");
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if (b - a == c - b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
count=0
while 'LL'in s:
    l=len(s)
    s=s.replace('LL','L')    
    count+=l-len(s)
while 'RR'in s:
    l=len(s)
    s=s.replace('RR','R')    
    count+=l-len(s)
print(count+min(2*k,len(s)-1))



Measured memory_bytes: 3316
#include <iostream>
#include <vector>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.search3", "r", stdin );
	int n;

	while (1){
		cin >> n;

		if (!n ){
			break;
		} // end if

		vector <int> a (n, 0 );
		for (int i = 0; i < n; ++i){
			cin >> a[i];
		} // end for

		int key;
		cin >> key;
		int first = 0, last = n - 1, mid;
		int res = 0;

		do{
			mid = (first + last)/2;		
			++res;
			if (a[mid] < key ){
				first = mid + 1;
			}else if (a[mid] > key ){
				last = mid - 1;
			}else{
				break;
			} // end if
		}while (first <= last ); // end while

		cout << res << endl;	
		
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            int numLine = Integer.parseInt(sc.next());
            Map<Integer, Integer> aMap = new HashMap<>();
            
            long ans = 0;
            for(int i = 0; i < numLine; i++){
                int a = Integer.parseInt(sc.next());
                ans += a;
                if(!aMap.containsKey(a)) aMap.put(a, 1);
                else aMap.replace(a, aMap.get(a) + 1);
            }

            int query = Integer.parseInt(sc.next());

            for(int i = 0; i < query; i++){
                int b = Integer.parseInt(sc.next());
                int c = Integer.parseInt(sc.next());

                if(!aMap.containsKey(b)){
                    System.out.println(ans);
                }else{
                    ans += aMap.get(b) * (c - b);
                    System.out.println(ans);

                    if(!aMap.containsKey(c)){
                        aMap.put(c, aMap.get(b));
                        aMap.remove(b);
                    }else{
                        aMap.replace(c, aMap.get(c) + aMap.get(b));
                        aMap.remove(b);
                    }
                }
            }

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 71888
# 200322 A

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    
    if N <= 1:
        Nc = 0
    else:
        Nc = cmb(N,2)
    
    if M < 2:
        Mc = 0
    else:
        Mc = cmb(M,2)
    print(Nc + Mc)



        
    


Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))

max_ = 0
cnt = 0
for i in range(n - 1, 0, -1):
    if h[i - 1] < h[i]:
        max_ = max(max_, cnt)
        cnt = 0
    else:
        cnt += 1
max_ = max(max_, cnt)        
print(max_)

Measured memory_bytes: 14224
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string str;
	cin >> str;
	for (int i = 0; i < str.length() - 1; i++)
	{
		if (str[i] == 'C')
		{
			for (int j = i; j < str.length(); j++)
			{
				if (str[j] == 'F') {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
}

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

int main() {
    ll N, M; cin >> N >> M;
    ll ans = ((N-M)*100 + M*1900) * pow(2, M);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3936
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> pt(n);
    rep(i, n) {
        cin >> pt[i].first >> pt[i].second;
    }
    ll result = -1;
    vector<ll> ss(n), ds(n);
    rep(i, n) {
        ss[i] = pt[i].first + pt[i].second;
        ds[i] = pt[i].first - pt[i].second;
    }
    sort(ss.begin(), ss.end());
    sort(ds.begin(), ds.end());
    cout << max(abs(*ss.begin() - *ss.rbegin()), abs(*ds.begin() - *ds.rbegin())) << endl;
    return 0;
}


Measured memory_bytes: 9216