akhauriyash/Code-Regression huggingface dataset:
/* ex 7_3
   アカウント名 */

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


int main(void){
    int i, j, k, row, column;
    char tmp;
    char **ptr;
    scanf("%d %d\n", &row, &column);
    int row_flag[row], column_flag[column];
    ptr = (char**)calloc(row, sizeof(char*));
    if(ptr == NULL){
        fprintf(stderr, "calloc error.\n");
        exit(1);
    }
    for(i = 0; i < row; i++){
        ptr[i] = (char*)calloc(column, sizeof(char));
        if(ptr[i] == NULL){
            fprintf(stderr, "calloc error.\n");
            exit(1);
        }
    }
    for(i = 0; i < row; i++){
        row_flag[i] = 0;
    }
    for(i = 0; i < column; i++){
        column_flag[i] = 0;
    }
    for(i = 0; i < row; i++){
        for(j = 0; j < column; j++){
            scanf(" %c", &ptr[i][j]);
            if(ptr[i][j] == '#'){
                row_flag[i] = 1;
                column_flag[j] = 1;
            }
        }
    }

    for(i = 0; i < row; i++){
        k = 0;
        for(j = 0; j < column; j++){
            if(row_flag[i] == 1 && column_flag[j] == 1){
                printf("%c", ptr[i][j]);
                k = 1;
            }
        }
        if(k == 1){
            printf("\n");
        }
    }

    for(i = 0; i < row; i++){
        free(ptr[i]);
    }
    free(ptr);

    return 0;
}

Measured memory_bytes: 1628
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final Random rng = new Random();
	static final int P = BigInteger.probablePrime(30, rng).intValue();
	
	void solve() throws IOException {
//		System.err.println(P);
		int n = nextInt();
		int k = nextInt();
		int[] a = new int[n];
		
		int[] ways = new int[k + 1];
		ways[0] = 1;
		
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			a[i] = Math.min(a[i], k);
			
			
			for (int j = k; j >= a[i]; j--) {
				ways[j] += ways[j - a[i]];
				if (ways[j] >= P) {
					ways[j] -= P;
				}
			}
		}
		
		int ret = 0;
		
		outer: for (int i = 0; i < n; i++) {
			int[] waysWO = ways.clone();
			for (int j = a[i]; j <= k; j++) {
				waysWO[j] -= waysWO[j - a[i]];
				if (waysWO[j] < 0) {
					waysWO[j] += P;
				}
			}
			
			for (int j = k - a[i]; j < k; j++) {
				if (waysWO[j] > 0) {
					continue outer;
				}
			}
			
			ret++;
			
		}
		
		out.println(ret);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 59220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ( )
{
	int n;
	scanf ( "%d", &n );
	vector<ll> a ( n );
	for ( int i = 0, x; i < n; ++i ) {
		scanf ( "%d", &x ); a[i] = x;
		if(i) a[i] += a[i-1];
	}

	ll ans = LLONG_MAX;
	for ( int asdf = 2; asdf--; ) {
		for ( auto& x : a ) x = -x;

		ll cur = 0, newCur = 0, cost = 0;
		for ( int i = 0; i < n; ++i ) {
			a[i] += cur;
			if ( (i&1) && a[i] >= 0 ) newCur = cur - a[i] - 1;
			if ( !(i&1) && a[i] <= 0 ) newCur = cur - a[i] + 1;
			a[i] -= cur;
			cost += abs ( cur - newCur );
			cur = newCur;
		}

		ans = min ( ans, cost );
	}

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


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

n = int(input())
alist = list(map(int, input().split()))

flag_d = 0 # 'DENIED'
flag_a = 0 # 'APPROVED'
for a in alist:
    if a % 2 == 0:
        if a % 3 == 0 or a %5 == 0:
            flag_a += 1
        else:
            flag_d += 1

if flag_d >= 1:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3060
#include <iostream>
#define ll long long
using namespace std;
ll dp[401][401]={},ar[401]={},n;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>ar[i];ar[i]+=ar[i-1];
	}
	for (int i=0;i<401;i++)
	{
		for (int j=0;j<401;j++)
		{
			dp[i][j]=10000000000000000;
			if (i==j) {dp[i][i]=0;}
		}
	}
	for (int i=2;i<=n;i++)
	{
		for (int j=1;j<=n-i+1;j++)
		{
			for (int k=j;k<j+i-1;k++)
			{
				dp[j][j+i-1] = min(dp[j][j+i-1],dp[j][k]+dp[k+1][j+i-1]);
			}
			dp[j][j+i-1]+=ar[j+i-1]-ar[j-1];
		}
	}
	cout<<dp[1][n]<<"\n";
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

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

using namespace std;
typedef long long ll;

int main(){
  int N; cin >> N;
  vector<long long> a(N);
  rep(i,N) cin >> a[i];

  //累積和と連想配列
  vector<long long> s(N+1, 0);
  map<long long, long long> nums;
  rep(i,N) s[i+1] = s[i] + a[i];
  rep(i,N+1) nums[s[i]]++;

  //集計処理
  long long res = 0;
  for(auto it: nums){
    long long num = it.second;
    res += num*(num-1)/2; //numC_2
  }
  cout << res << endl;


}


Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

string s, t;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> s >> t;
  ll ans=1e9;
  rep(i, 0, s.size()-t.size()){
  	ll cnt=0;
  	rep(j, 0, t.size()-1){
  		if(s[j+i]!=t[j]) cnt++;
  	}
  	ans=min(ans, cnt);
  }
  cout << ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    long long c = 1;
    multiset<long long> s;
    s.insert(a[n - 1]);
    for(int i = n - 2; i >= 0; --i){
        auto now = s.upper_bound(a[i]);
        if(now == s.end()){
            c++;
            s.insert(a[i]);
        }
        else{

            s.erase(now);
            s.insert(a[i]);
        }
    }
    cout << c;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int n,r,x,m=0x3f3f3f3f;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++,r+=(m>x),m=min(m,x))cin>>x;
    cout<<r;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a != c) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	float lo, hi, a;
	
	scanf("%f",&a);
	lo = hi = a;
	
	while(scanf("%f",&a)!=EOF)
	{
		if(a>hi)
			hi = a;
		else if(a<lo)
			lo = a;
			
	}
	
	printf("%.1f",hi-lo);

	return 0;
}

Measured memory_bytes: 0
def resolve():
    MOD = 998244353
    N, K = map(int, input().split())
    S = [tuple(map(int, input().split())) for _ in range(K)]
    L = [0] * K
    R = [0] * K
    L, R = zip(*S)
    # 今回は最小回数ではなくNマスにたどり着くすべての回数
    # なので、区間の和を累積和で求める

    dp = [0] * (N + 1)
    dp[1] = 1

    dp_acum = [0] * (N + 1)
    dp_acum[1] = 1

    for i in range(2, N + 1):
        for j in range(K):
            li = i - R[j]
            ri = i - L[j]
            if ri < 0:
                continue
            li = max(li, 1)
            dp[i] += dp_acum[ri] - dp_acum[li - 1]
            dp[i] %= MOD

        dp_acum[i] = dp_acum[i - 1] + dp[i]
        dp_acum[i] %= MOD

    print(dp[N])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 24616
import java.util.*;
import java.awt.Point;

 
class Main{
   public static void main(String a[]) throws java.io.IOException{
       Scanner scan =new Scanner (System.in);
       Point p= new Point();
       
      // while(scan.hasNext()){
 
           int H =scan.nextInt();
           int W =scan.nextInt();
           int N =scan.nextInt();
           int  [][] map = new int [H][W];
           
           for(int i=0;i<H;i++){
               String  tmp =scan.next();
               for(int j=0;j<W;j++){
                   map[i][j] = tmp.charAt(j);
                   
                   if(tmp.charAt(j)=='S'){    
                       p.x=j;
                       p.y=i;  
                   }
                   
               }
           }
           int ans=0;
       for(int i=1;i<=N;i++){
    	   Queue<Point> fifo = new LinkedList<Point>();
    	   fifo.add(p);
    	   int [][] dis =new int[H][W];
    	   for(int j=0;j<H;j++)
    		   for(int k=0;k<W;k++)
    			   dis[j][k] =10000000;
    	   dis[p.y][p.x]=0;
          while(fifo.peek()!=null){ 
           p = fifo.poll();
           int x=p.x;
           int y=p.y;
          if(map[y][x]==Integer.toString(i).charAt(0))break;
           int[] dx ={0,1,0,-1};
           int[] dy ={1,0,-1,0};
          for(int j=0;j<4;j++){
              int nx =x+dx[j];
              int ny =y+dy[j];
              if(0<=nx&&nx<W&&0<=ny&&ny<H&&map[ny][nx]!='X'&&dis[ny][nx]==10000000){
                  Point np =new Point();
                  np.x=nx;
                  np.y=ny;
                  fifo.add(np);
                  dis[ny][nx]=dis[y][x]+1;
                  
              }
          }
          }
          ans+=dis[p.y][p.x];
       }
       System.out.println(ans);
       
   
   
}
}
       

Measured memory_bytes: 26000
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var a = [];
  for(var i = 0; i < n; i++){
    a.push([next(),i]);
  }
  a.sort((a,b)=>b[0]-a[0]);
  var dp = xArray(0,n+1);
  for(var i = 0; i < n; i++){
    dp[i+1] = dp[i] + (n-i-a[i][1]-1) * a[i][0];
    for(var j = i; j; j--){
      dp[j] += (a[i][1]-(i-j)) * a[i][0];
      var t = dp[j-1] + (n-j-a[i][1]) * a[i][0];
      if(dp[j] < t)dp[j] = t;
    }
    dp[0] += (a[i][1]-i) * a[i][0];
  }
  return Math.max(...dp);
}

Measured memory_bytes: 33588
class dice init =
  let rot_n (x1,x2,x3,x4,x5,x6) = (x2,x6,x3,x4,x1,x5) and
      rot_e (x1,x2,x3,x4,x5,x6) = (x4,x2,x1,x6,x5,x3) in
  let rot_s l = rot_n l |> rot_n |> rot_n and
      rot_w l = rot_e l |> rot_e |> rot_e in
  let all_init =
    let rec rotate d list = function
        0 -> list
      | i -> rotate (rot_e d) (d::list) (i-1) in
    let rotate2 n l = rotate n l 4 in
    rotate2 init []
    |> rotate2 (rot_e init |> rot_s)
    |> rotate2 (rot_w init |> rot_s)
    |> rotate2 (rot_n init)
    |> rotate2 (rot_s init)
    |> rotate2 (rot_n init |> rot_n) in
object (self: 'self)
  val mutable faces:int*int*int*int*int*int = init
  val all:'a list = all_init

  method get_face = faces
  method equals (other:'self) = self#contains other#get_face
  method contains fc =
    let rec find l = match l with
        [] -> false
      | h::tl -> if h = fc then true else find tl
    in find all
end;;

let split_int s = Str.split (Str.regexp_string " ") s |> List.map int_of_string;;
let _ =
  let f n = (n 0,n 1,n 2,n 3,n 4,n 5) and
      nth s = split_int s |> List.nth and
      num = read_int() in
  let rec loop l = function
    | 0 -> l
    | i -> loop ((new dice (read_line () |> nth |> f))::l) (i-1)
  in
  let dice_l = loop [] num in
  let rec loop l = match l with
      [] -> print_endline "Yes"
    | h::tl ->
       if (let rec loop2 l2 = match l2 with
               [] -> true
             | h2::tl2 -> if h2#equals(h) then false else loop2 tl2
           in loop2 tl) then
         loop tl
       else print_endline "No"
  in loop dice_l;;

Measured memory_bytes: 2772
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K, karicount, count = 0;
  
  cin >> N >> K;
  
  vector<int> d(K);
  
  vector<int> NIN(N, 0);
  
  for(int i = 0; i < K; i++){
    cin >> d[i];
    for(int j = 0; j < d[i]; j++){
      cin >> karicount;
      NIN[karicount-1] = 1;
    }
  }
  
  for(int i = 0; i < N; i++){
    if(NIN[i] == 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

int main(void){
	int a, b, ans;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if (op == '+'){
		ans = a + b;
	}else if (op == '-'){
		ans = a - b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
  
  long long int N;
  
  cin >> N;
  
   vector<long long> a(N);
  
  for(long long int i=0;i<N;i++){
    cin >> a[i];
  }
  
  multiset<long long> mlt;
  
  for(long long int i=0;i<N;i++){
    
    long long int j = a[i];
    
   auto k = mlt.lower_bound(j);
    
    if(k != mlt.begin()){ 
      k--;
      mlt.erase(k);
    }
    
    mlt.insert(j);
   
  }
  
  cout << mlt.size() << endl;
  
  return 0;
  
}


Measured memory_bytes: 5760
import math
import numpy as np
a, b, h, m = map(int, input().split())
long_speed = 6*m
short_speed = 30*h + m/2
theta = abs(long_speed - short_speed)
if theta > 180:
    theta = 360 - theta
c = a*a + b*b - 2*a*b*math.cos(math.radians(theta))
c = np.sqrt(c)
print(c)

Measured memory_bytes: 27204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.Locale;

/**
 *
 * @author takumi.oodaira
 */
final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        Calendar calendar = Calendar.getInstance();
        while (true) {
            String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            String[] inputs = input.split(" ");
            if (inputs[0].equals("0")) {
                break;
            }
            calendar.set(2004, Integer.parseInt(inputs[0]) - 1, Integer.parseInt(inputs[1]));
            final String week = calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.ENGLISH);
            System.out.println(week);
        }
    }
}

Measured memory_bytes: 11000
import sys

def process(data):
	count1 = 0
	count2 = 0

	N = int(data[0][0])
	K = int(data[0][1])
	A = list(map(int, data[1]))

	for i in range(len(A)-1):
		for j in range(i+1, len(A)):
			if A[i] > A[j]:
				count1 += 1
	A.reverse()
	
	for i in range(len(A)-1):
		for j in range(i+1, len(A)):
			if A[i] > A[j]:
				count2 += 1	

	count1 = count1 * K*(K+1)/2
	count2 = count2 * (K-1)*K/2

	count = count1 + count2

	count = count % (10**9+7)
	return count



def main():
	d = []
	for i in range(2):
		data = raw_input()
		data = data.split(" ")
		d.append(data)
	print(process(d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 2820
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える

h,w = map(int,input().split())
s = ["."*(w+2)]
for i in range(h):
    s.append("."+str(input())+".")
s.append("."*(w+2))

ans = [[0 for i in range(w)] for i in range(h)]
# print(s)
for i in range(h):
    for j in range(w):
        if s[i+1][j+1]=="#":
            ans[i][j] = "#"
        else:
            count = 0
            for dx in range(-1,2):
                for dy in range(-1,2):
                    # print(i+dx+1,j+dy+1)
                    if dx==0 and dy==0:
                        pass
                    else:
                        if s[i+dx+1][j+dy+1] == "#":
                            count += 1
            ans[i][j] = str(count)
for i in range(h):
    print("".join(ans[i]))


Measured memory_bytes: 14296
#include <iostream>

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

    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                std::cout << "No" << std::endl;
                return 0;
            }
        } else {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    char z;
    cin>>z;
    if(z-'A'>=0 && z-'A'<=25)
    {
        cout<<"A";
    }
    else
    cout<<'a';

} 
    
 


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
signed main() {
	ll n, x;
	cin >> n >> x;
	ll cnt = 1;
	for (int i = 1; i <= x; i++)cnt *= 2;
	cout << ((n - x) * 100 + x * 1900)*cnt << endl;
	getchar(); getchar(); return 0;
}

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

using namespace std;

int main(){
    int a,b,c;
    scanf("%d%d",&a,&b);
    
    if(a>b) swap(a,b);
    while(b%a){
        c=a;
        a=b%a;
        b=c;
    }

    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    int ma=a[0]+a[1];
    for(int i=2;i<N;i++)
    {
        int t=a[i-2]+a[i-1]+a[i];
        if(t>ma)ma=t;
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl


signed main(void){
    int N;
    int a[14514],b[14514];
    int c[14514];
    PP D[14514];
    int E[14514];
    vector<int> G[14514];
    REP(i,14514){
        D[i].first=-INF;
        D[i].second=i;
    }
    cin >> N;
    
    REP(i,N){
        D[i].first=0;
    }
    REP(i,N-1){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        D[a[i]].first++;
        D[b[i]].first++;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    REP(i,N){
        cin >> c[i];
    }
    sort(c,c+N,greater<>());
    sort(D,D+N,greater<>());
    
    int S=D[0].second;
    vector<int> V;
    V.push_back(S);
    int now=0;
    E[S]=c[0];
    bool al[14514]={};
    
    while(!V.empty()){
        int v=V.size();
        int T=V[v-1];
        //cout << T << endl;
        V.pop_back();
        al[T]=1;
        E[T]=c[now];
        now++;
        REP(i,G[T].size()){
            if(al[G[T][i]]==0){
                V.push_back(G[T][i]);
            }
        }
        
    }
    
    
    
    /*
    REP(i,N){
        E[D[i].second]=c[i];
    }*/
    int Ans=0;
    REP(i,N-1){
        Ans+=min(E[a[i]],E[b[i]]);
    }
    cout << Ans << endl;
    REP(i,N){
        cout << E[i] << " ";
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>

using namespace std;

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

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

vector<ll> sz(51);
vector<ll> cnt_p(51);
ll solve(int n, ll x) {
    if (x <= 0) return 0;
    if (sz[n] - 1 <= x) return cnt_p[n];

    if (x <= sz[n] / 2) return solve(n - 1, x - 1);
    return cnt_p[n - 1] + 1 + solve(n - 1, x - sz[n - 1] - 2);
}

int main() {
    int n;
    ll x;
    cin >> n >> x;
    sz[0] = 1;
    repr(i, 1, n + 1) sz[i] = sz[i - 1] * 2 + 3;
    cnt_p[0] = 1;
    repr(i, 1, n + 1) cnt_p[i] = cnt_p[i - 1] * 2 + 1;
    
    cout << solve(n, x) << endl;
}

Measured memory_bytes: 256
gets;puts$<.map.with_index{|e,i|e.split.map(&:to_i)+[i]}.group_by{|e|e[0]}.flat_map{|_,e|e.sort.map.with_index{|f,i|['%06d%06d'%[f[0],i+1],f[2]]}}.sort_by{|e|e[1]}.map &:first

Measured memory_bytes: 44512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int main(){
    int h,n;scanf("%d %d",&h,&n);
    int a[n];for(int i=0;i<n;i++)scanf("%d",&a[i]);

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

    printf("%s\n",sum>=h?"Yes":"No");
}

Measured memory_bytes: 512
N=list(str(input()))
ans=0
if len(N)==1:
  print("0")
  exit()
for i in range(len(N)-1):
  if N[i]=="0" and N[i+1]=="0":
    N[i+1]="1"
    ans+=1
  elif N[i]=="1" and N[i+1]=="1":
    ans+=1
    N[i+1]="0"
print(ans)
  

Measured memory_bytes: 9668
import Control.Monad
import Data.List

type Bar = (Int, Int, Int)

barH (h, _, _) = h

getBar :: IO Bar
getBar = do
  [h, p, q] <- liftM (map ((\x -> x - 1) . read) . words) getLine
  return $ (h, p, q)

main :: IO ()
main = loop
    where loop = do
          [n, m, a] <- liftM (map read . words) getLine
          if n == 0 then return ()
            else do
              bars <- liftM (sortBy $ \x y -> barH x `compare` barH y) $ replicateM m getBar
              let nrs = solve bars [1..n]
              print $ nrs !! (a-1)
              loop

solve [] nrs = nrs
solve ((h, p, q):bars) nrs = solve bars (swp p q nrs)

swp i j xs = map (\n -> if n == i then xs !! j else if n == j then xs !! i else xs !! n) [ 0..(length xs)-1 ]

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

int main() {
  long int N,D,cou=0;
  cin>>N>>D;
  D*=D;
  long int x,y;
  for(long int i=0;i<N;i++){
    cin>>x>>y;
    if(x*x+y*y<=D)cou++;
  }
  cout<<cou<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair

const ll MaxN=100001;
ll N,M,S,T;
vector<P> d[MaxN];
ll ds[MaxN];
ll dpS[MaxN], dpT[MaxN];

vec Use[MaxN];

int main(){
    cin>>N>>M>>S>>T;
    S--; T--;
    rep(i,M){
        ll u,v,x; cin>>u>>v>>x;
        u--; v--;
        d[u].pb(mp(x,v));
        d[v].pb(mp(x,u));
    }

    P_queue Q;
    Q.push(mp(0,S));
    rep(i,MaxN) if(i!=S) ds[i]=INF;
    while(!Q.empty()){
        ll x=Q.top().first, y=Q.top().second;
        Q.pop();
        rep(i,d[y].size()){
            ll X=d[y].at(i).first, Y=d[y].at(i).second;
            if(ds[Y]>x+X){
                ds[Y]=x+X;
                Q.push(mp(x+X,Y));
            }
        }
    }

    ll DIST=ds[T];

    vector<P> hiku;
    rep(i,N) {
        rep(j,d[i].size()){
            ll a=d[i].at(j).first, b=d[i].at(j).second;
            ll PU=0;
            if(ds[b]==ds[i]+a) PU=1;;
            if(ds[i]==ds[b]+a) PU=-1;
            if(ds[b]==ds[i]+a && ds[b]*2>DIST && ds[i]*2<DIST) PU=2;
            if(ds[i]==ds[b]+a && ds[b]*2<DIST && ds[i]*2>DIST) PU=-2;
            Use[i].pb(PU);
            if(PU==2) hiku.pb(mp(i,b));
        }
        if(ds[i]*2==DIST) hiku.pb(mp(i,i));
    }// 1のときはS→Tのときに使える辺、-1のときはT→S

    vector<P> K;
    rep(i,N) if(ds[i]<ds[T] || i==T) K.pb(mp(ds[i],i));
    sort(K.begin(),K.end());

    ll n=K.size();
    dpS[S]=1;
    dpT[T]=1;

    rep(j,n){
        ll i=K.at(j).second;
        dpS[i]=dpS[i]%mod;
        rep(k,Use[i].size()) if(Use[i].at(k)>0) dpS[d[i].at(k).second]+=dpS[i];
    }

    rep(j,n){
        ll i=K.at(n-1-j).second;
        dpT[i]=dpT[i]%mod;
        rep(k,Use[i].size()) if(Use[i].at(k)<0) dpT[d[i].at(k).second]+=dpT[i];
    }

    ll ans=(dpS[T]*dpT[S])%mod;

    ll HIKU=0;
    rep(i,hiku.size()) {
        ll AA=(dpS[hiku.at(i).first]*dpT[hiku.at(i).second])%mod;
        HIKU=(HIKU+AA*AA)%mod;
    }
    ans=(ans+mod-HIKU)%mod;
    cout<<ans<<endl;




}


Measured memory_bytes: 26608
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int n, Mi, Ma;
	std::cin >> n;
	long long S = 0;
	std::vector<int> a(n);
	for (int i = 0; i < n;++i) {
		std::cin >> a[i];
		Mi = *std::min_element(a.begin(), a.end());
		Ma = *std::max_element(a.begin(), a.end());
		S += a[i];
	}
	std::cout << Mi << ' ' << Ma << ' ' << S << std::endl;
	return 0;
}


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

int main(void){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> dp(10, vector<int>(10, 10001));
    int c;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c;
            dp[i][j] = c;
        }
    }
    for (int i = 0; i < 10; i++) {
        dp[i][i] = 0;
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    int sum = 0, A;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            if (A == -1) continue;
            sum += dp[A][1];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3604
# require 'pry'
N = gets.to_i
crr = []
srr = []
frr = []
(N-1).times do
  s, t, u = gets.split.map(&:to_i)
  crr << s
  srr << t
  frr << u
end
# p crr, srr, frr
if N > 1
  ans = [crr[-1] + srr[-1]]
  # binding.pry
  (N-3).downto(0) do |i|
    nex = srr[i]
    i.upto(N-3) do |j|
      csrr = crr[j] + nex
      if csrr >= srr[j+1]
        # nex = (csrr / frr[j+1]) * frr[j+1] + csrr % frr[j+1]
        nex = csrr + ((frr[j+1] - (csrr % frr[j+1])) % frr[j+1])
      else
        nex = srr[j+1]
      end
    end
    ans.unshift(nex + crr[-1])
  end
  ans.each do |an|
    puts an
  end
end
puts 0

Measured memory_bytes: 3836
using System;

namespace ABC102B
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] strA = Console.ReadLine().Split(' ');
            long[] A = new long[strA.Length];
            for(int i=0;i<N;i++)
            {
                A[i] = long.Parse(strA[i]);
            }
            Array.Sort(A);
            long ans = A[N - 1] - A[0];
            Console.WriteLine(ans);
        }
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

vector<vector<int32>> adj;
vector<int32> cnt;

vector<int32> ans;

void dfs(int32 v, int32 c = 0){
    c += cnt[v];
    ans[v] = c;
    for(int32 u : adj[v]){
        if(ans[u] != -1)continue;
        dfs(u, c);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,q;
    cin >> n >> q;
    adj.resize(n);
    REP(i,n-1){
        int32 a,b;
        cin >> a >> b;
        a--;b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    cnt.resize(n,0);
    REP(i,q){
        int32 p,x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    ans.resize(n,-1);
    dfs(0);
    REP(i,n){
        if(i != 0)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 22784
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N,L,size;
vector<ll> segtree;

void update(ll i, ll x){
    i += size - 1;
    segtree[i] = x;
    while(i > 0){
        i = (i - 1) / 2;
        segtree[i] = min(segtree[i*2+1],segtree[i*2+2]);
    }
}

ll query(ll a, ll b, ll i, ll l, ll r){
    if(a<=l && r<=b) return segtree[i];
    if(b<=l || r<=a) return INF;
    ll vl = query(a,b,i*2+1,l,(l+r)/2);
    ll vr = query(a,b,i*2+2,(l+r)/2,r);
    return min(vl,vr);
}


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> L;
    size = 1;
    while(size < N) size *= 2;
    segtree.assign(size*2 - 1,INF);
    REP(i,N){
        ll t;
        cin >> t;
        update(i,t);
    }
    REP(i,N-L+1){
        cout << query(i,i+L,0,0,size);
        cout << (i==N-L ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 19212
#include <bits/stdc++.h>
#define ll long long
#define lb long double
#define f(i,a,b) for(ll i = a;i <= b;i ++)
#define fi(i,a,b) for(ll i = a;i >= b;i --)
using namespace std;
ll n,dem;
int main()
{
    cin >> n;
    f(i,1,n)
    {
        f(j,1,n)
        {
            f(k,1,n)
            {
                ll a1 = __gcd(i,j),a2 = __gcd(j,k);
                dem += __gcd(a1,a2);
            }
        }
    }
    cout << dem;
    return 0;
}


Measured memory_bytes: 3636
<?php
 fscanf(STDIN, "%d", $N);
$a = 0;

for($i = 1; $i <= $N; $i++){
  if(strlen($i)%2 !== 1){
  $a =$a + 0;
  }else{
     $a =$a + 1;
  }
}
echo $a;
?>

Measured memory_bytes: 3576
# -*- coding: utf-8 -*-
s = raw_input()
start = 0
end = 0
for i,stri in enumerate(s):
    if stri == "A":
        start = i
        break
for i,stri in enumerate(s[::-1]):
    if stri == "Z":
        end = i
        break

print (len(s)-end)-start


Measured memory_bytes: 3304
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int a[20],b[20],c[20];
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> c[i];
    }
    int sum=0;
    int back=-1;
    for (int i = 0; i < n; i++) {
        sum+=b[a[i]-1];
        if(back==a[i]-1){
            sum+=c[back-1];
        }
        back=a[i];
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d,e,f,g,h,n,m,t;
int main()
{
    string s1,s2;
    cin>>s1;
    cin>>s2;
    a=s1.size();
    b=s2.size();
    s1="@"+s1;
    s2="@"+s2;
    int dp[a+1][b+1];
    for(int i=0;i<=a;i++)dp[i][0]=0;
    for(int i=0;i<=b;i++)dp[0][i]=0;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            if(s1[i]==s2[j])dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    if(dp[a][b]==0){
        cout<<""<<endl;
        return 0;
    }
    string ans="";
    while(a&&b){
        if(s1[a]==s2[b]){ans.push_back(s1[a]);a--;b--;continue;}
        if(dp[a][b]==dp[a-1][b]){a--;continue;}
        b--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35456
# -*- coding: utf-8 -*-


def main():

    input_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = int(input())

    # 出力
    print(input_list[k -1])


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;

using namespace std;
signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,d,ans=0;
    cin>>n>>d;
    vector<vector<int> > x(n,vector<int>(d));

    rep(i,n) rep(j,d){
        cin>>x[i][j];
    }

    rep(i,n){
        for(int j=i+1; j<n; j++){
            int norm=0;
            for(int k=0; k<d; k++){
                int diff = abs(x[i][k] - x[j][k]);
                norm += diff * diff;
            }
            bool flag=false;
            for(int k=0; k<=norm; k++){
                if(k * k == norm){
                    flag = true;
                }
            }
            if(flag) ans++;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int dat[800010];
int u;
void seginit(int n){
  int y=1;
  for(int i=0;;i++){
    
    if(y>=n){
      u=y;
      break;
    }
    y*=2;
  }
  fill(dat,dat+2*u,-1000000000);
}
void add(int n,int x){
  int i=n+u-1;
  dat[i]=x;
  while(i>0){
    i=(i-1)/2;
    dat[i]=max(dat[2*i+1],dat[i*2+2]);
  }
}
int que(int a,int b,int k,int l,int r){
  if(a>=r||b<=l)return -1000000000;
  if(a<=l&&b>=r)return dat[k];
  int m1=que(a,b,2*k+1,l,(l+r)/2);
  int m2=que(a,b,2*k+2,(l+r)/2,r);
  return max(m1,m2);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    string s[n];
    rep(i,0,n)cin>>s[i];
    int cnh[n],cnw[n];
    int tot=0;
    int y=0;
    rep(i,0,n){
        cnh[i]=0;
        rep(j,0,n){
            if(s[i][j]=='#')cnh[i]++;
        }
        tot+=cnh[i];
        cnw[i]=0;
        rep(j,0,n){
            if(s[j][i]=='#')cnw[i]++;
        }
        tot+=cnw[i];
        if(cnw[i]==n)y++;
    }
    if(tot==0){
        cout<<-1<<endl;
        return 0;
    }
    int ans=100000000;
    rep(i,0,n){
        if(cnh[i]==n){
            ans=min(ans,n-y);
        }
        else{
            int sum=n-cnh[i];
            if(cnw[i]==0)sum++;
            sum+=n-y;
            //cout<<sum<<" ";
            ans=min(ans,sum);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
arr=input().split()
x=input()
for i in x:
    if i=='W':
        arr=[arr[k-1] for k in [3,2,6,1,5,4]]
    if i=='E':
        arr=[arr[k-1] for k in [4,2,1,6,5,3]]
    if i=='N':
        arr=[arr[k-1] for k in [2,6,3,4,1,5]]
    if i=='S':
        arr=[arr[k-1] for k in [5,1,3,4,6,2]]
print(arr[0])



Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    string s, s1;
    while(cin>>s>>s1){
        ll ans=0;
        int n=s.size(), m=s1.size();
        bool l=(m==n+1);
        for(int i=0; i<n; ++i){
        	if(s[i]!=s1[i]){
        		l=0;
        		break;
        	}
        }
        if(l){
        	cout<<"Yes"<<endl;
        }
        else{
        	cout<<"No"<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 3636
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int n,k,a[200010];
int main(){
	std::cin>>n>>k;
	rep(i,n)std::cin>>a[i];
	int min=0,max=1000000000;
	while(min+1<max){
		int mid=(min+max)/2;
		lint cnt=0;
		rep(i,n){
			cnt+=(a[i]+mid-1)/mid-1;
		}
		if(cnt>k)min=mid;
		else max=mid;
	}
	std::cout<<max<<std::endl;
	return 0;
}

Measured memory_bytes: 4392
#include <iostream>
#include <complex>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }
int main()
{
    queue<xy_t> vertice;
    xy_t first, second;
    double x, y;
    cin>>x;

    while (cin >> x >> y)
    {
        vertice.push(xy_t(x, y));
    }
    xy_t origin = vertice.front();
    vertice.pop();
    double area = 0.0;
    while (vertice.size() != 1)
    {
        first = vertice.front()-origin;
        vertice.pop();
        second = vertice.front()-origin;
        area += cross_product(first, second);
    }
    cout.setf(ios::fixed,ios::floatfield);
    cout.precision(1);
    cout << 0.5 * abs(area) << endl;
}


Measured memory_bytes: 3268
(defun solve (xs &optional (cnt 0))
  (cond
    ((= cnt 3) t)
    ((null xs) nil)
    ((= (first (first xs)) (rest (first xs))) (solve (rest xs) (1+ cnt)))
    (t (solve (rest xs) 0))))


(defun main ()
  (let* ((n (read))
         (xs (loop repeat n collect (cons (read) (read)))))
    (princ (if (solve xs)
               "Yes"
               "No"))
    (fresh-line)))

#-swank (main)


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    Vl A(N + 2);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    ll sum = 0;
    for (int i = 0; i <= N; i++) {
        sum += abs(A[i] - A[i + 1]);
    }

    for (int i = 1; i <= N; i++) {
        ll ans = sum;
        ans -= abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]);
        ans += abs(A[i - 1] - A[i + 1]);
        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 2048
-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE ScopedTypeVariables #-}
-- {-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE ViewPatterns #-}
-- {-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
-- import qualified Data.Vector.Algorithms.Merge as VAM
-- import qualified Data.Heap as HP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

--------------------------------------------------------------------------
solve x i
    | i > 10^5 = 0
    | range = 1 
    | otherwise = solve x (i+1)
    where
        range = (100*i) <= x && x <= (105*i)

main = do
    x <- int
    print $ solve x 0
--------------------------------------------------------------------------

-- Input Util
int :: IO Int
int = readLn 

double :: IO Double
double = readLn 

str :: IO String
str = getLine

strBC :: IO BC.ByteString
strBC = BC.getLine

sLineToIntL :: IO [Int]
sLineToIntL = getLine >>= return . map read . words

sLineToDoubleL :: IO [Double]
sLineToDoubleL = getLine >>= return . map read . words

sLineToIntV :: Int -> IO (VU.Vector Int)
sLineToIntV n = BC.getLine >>= return . VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace)

sLineToDoubleV :: Int -> IO (VU.Vector Double)
sLineToDoubleV n = BC.getLine >>= return . VU.fromList . map (read . BC.unpack) . BC.words

mLinesToIntL :: Int -> IO [Int]
mLinesToIntL n = replicateM n readLn

mLinesToDoubleL :: Int -> IO [Double]
mLinesToDoubleL n = replicateM n readLn

mLinesToIntV :: Int -> IO (VU.Vector Int)
mLinesToIntV n = VU.replicateM n readLn

mLinesToDoubleV :: Int -> IO (VU.Vector Double)
mLinesToDoubleV n = VU.replicateM n (BC.getLine >>= return . read . BC.unpack)

mLinesToTupleL :: Int -> IO [(Int, Int)]
mLinesToTupleL n = replicateM n (getLine >>= return . (\[a,b] -> (a,b)) . map read . words)

mLinesToTupleV :: Int -> IO (VU.Vector (Int, Int))
mLinesToTupleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, _) = BC.readInt $ BC.dropWhile isSpace bs'
    return (a,b)
    
mLinesToTripleV :: Int -> IO (VU.Vector (Int, Int, Int))
mLinesToTripleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, bs'') = BC.readInt $ BC.dropWhile isSpace bs'
        Just (c, _) = BC.readInt $ BC.dropWhile isSpace bs''
    return (a,b,c)

-- others
strToChr :: String -> Char
strToChr [x] = x

chrToStr :: Char -> String
chrToStr x = [x]

m1 :: Int -> Int
m1 x = subtract 1 x

toDouble :: Int -> Double
toDouble x = fromIntegral x

toInt :: Double -> Int
toInt x = floor x

Measured memory_bytes: 508
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    S=readline().strip()
    li=[0]*2019
    n=int(S[-1])%2019
    m=1
    for i in range(len(S)):
        if i==0:
            pass
        else:
            m*=10
            m%=2019
            l=int(S[len(S)-i-1])
            n+=m*l
            n%=2019
        li[n]+=1

    res=li[0]
    for i in range(2019):
        res+=li[i]*(li[i]-1)//2
    print(res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 9384