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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int h, w = 0;
 	cin >> h >> w;
	vector<string> str(h + 2);
	str[0] = string(w + 2, '#');
	REP(i, h)
	{
		string buf = "";
		cin >> buf;

		str[i + 1] = "#" + buf + "#";
	}
	str[str.size() - 1] = string(w + 2, '#');

	REP(i, str.size())
	{
		COUT(str[i]);
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[200010];
int list[200010];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		list[ a[i] ]++;
	}
	int sum=0;
	for(int i=1;i<=n;i++)
		if(list[i]>=0)
			sum++;
	if(sum<=k)
	{
		cout<<"0"<<endl;
		return 0;
	}
	sort(list+1,list+1+200000);
	int ans=0;
	for(int i=200000-k;i>0;i--)
		ans+=list[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let cols = lines[0].split(/\s/).map((v) => v - 0);
    let A = cols[0], B = cols[1];
    const odd = (v) => v % 2 != 0;
    let ans = false;
    for (let c = 1; c <= 3 && !ans; c++) {
        ans = odd(A * B * c);
    }
    console.log(ans ? "Yes" : "No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		String str = "";
	
		while(sc.hasNextLine()){
			str = sc.nextLine();
			String[] numStrs = str.split(" ");
			int a = Integer.parseInt(numStrs[0]);
			int b = Integer.parseInt(numStrs[1]);
			if(b>a){
				int w = a;
				a = b;
				b = w;
			}
			solve(a, b);
		}
	}

	public void solve(int a, int b) {
		int gcdRes = gcd(a, b);
		int lcmRes = lcm(a, b, gcdRes);
		
		System.out.println(gcdRes + " " + lcmRes);
	}
	
	private int gcd(int a, int b){
		if(a%b == 0)
			return b;
		
		return gcd(b, a%b);
	}
	
	private int lcm(int a, int b, int gcdNum){
		return (int)(((long)a*b) / gcdNum);
	}
	
	/** バグがある? **/
	private int lcm(int a, int b){
		if(a<=3){
			if(a==b)
				return a;
			else
				return a*b;
		}else if(a%b==0){
			return a;
		}

		int r = b;
		for(int i=2;i*i<=a;i++){
			int aFact = 1;
			while(a%i==0){
				a = a/i;
				aFact*=i;
			}
			
			int bFact = 1;
			while(b%i==0){
				b = b/i;
				bFact*=i;
			}
			
			if(aFact>bFact)
				r *= (aFact/bFact);
		}
		return r*a;
		
	}
	

}

Measured memory_bytes: 17200
####C-bamboo
N,A,B,C = map(int,input().split())
l =[]
for _ in range(N):
    l.append(int(input()))
INF = 10**9

def dfs(cur,a,b,c):
    if cur == N:
        if min(a,b,c) > 0:
            ans = abs(a-A) + abs(b-B) + abs(c-C) -30 
            #接合は各一回ずつ余分
        else:
            ans = INF
        return ans
    ret0 = dfs(cur+1,a+l[cur],b,       c)        + 10
    ret1 = dfs(cur+1,a,       b+l[cur],c)        + 10
    ret2 = dfs(cur+1,a,       b,       c+l[cur]) + 10
    ret3 = dfs(cur+1,a,       b,       c)
    #a,b,c,どこにも入れないの4通り
    #分けて接合 -> 10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))


Measured memory_bytes: 3188
program main
  implicit none
  integer i,N,al,av
  integer,allocatable :: d(:)
  read(*, *) N
  allocate(d(N))
  read(*, *) (d(i), i = 1,N)

  call qsort(d)

  write(*, *) abs(d(N/2)-d(N/2+1))

  contains

  recursive subroutine qsort(a)
  implicit none
  integer,intent(inout) :: a(:)
  integer::i,j,toobig,toosmall,pv,n
  n = size(a)
  i = 1
  j = n
  pv = a((i+j)/2)
  do
     do
       if (a(i) < pv) then
         i = i+1
       else
         exit
       end if
     end do
     do
       if(a(j) > pv) then
         j = j-1
       else
         exit
       end if
     end do
     if (i>=j) then
       exit
     else
       toobig = a(j)
       toosmall = a(i)
       a(i) = toobig
       a(j) = toosmall
       i = i+1
       j = j-1
     end if
   end do
   if (i > 2) then
     call qsort(a(1:i-1))
   end if
   if (j < n-1) then
     call qsort(a(j+1:n))
   end if
  end subroutine qsort
end program main


Measured memory_bytes: 1152
def sqrt(n, s, e):
	if s >= e:
		return s
	temp = ((s+e)//2)**2
	if temp == n: return (s+e)//2
	elif temp < n: return sqrt(n, (s+e+1)//2, e)
	else: return sqrt(n, s, (s+e-1)//2)

def main(n):
	temp = n
	sqrtn= int(sqrt(n, 1, n))
	blst = [True]*(2+sqrtn)
	ans = [str(n)+":"]
	for i in range(2, sqrtn+1):
		if blst[i]:
			for j in range(1, i//(sqrtn)):
				blst[i*j] = False
			while temp % i == 0:
				ans += [str(i)]
				temp = temp // i
			if temp == 1:
				break
	if temp != 1:
		ans +=[str(temp)]
	print(" ".join(ans))
	return 

main(int(input()))




Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

double calc(int l, double a, double b) {
  return a * b * (l - a - b);
}

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

  int l;
  cin >> l;

  double p = 10000 / l;
  // cerr << p << endl;

  double ans = 0.0;

  for (int i = 1; i < l * p; i++) {
    for (int j = 1; j < l * p; j++) {
      chmax(ans, calc(l, i / p, j / p));
    }
  }

  printf("%.7f\n", ans);

  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 55;
int h, w;
char a[N][N];
vector<ii> dxy = {{1,0},{-1,0},{0,1},{0,-1}};
bool check(int x, int y) {
    for (auto &[dx, dy] : dxy) {
        int nx = x + dx;
        int ny = y + dy;
        if (nx < 0 || ny < 0 || nx == h || ny == w) continue;
        if (a[nx][ny] == '#') return false;
    }
    return true;
}
int main() {
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == '#' && check(i, j)) {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int n;
	cin>>n;cout<<n*n<<endl;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
D = ((1,0),(0,1))

H,W  = LI()
dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
mp = [sys.stdin.readline().rstrip() for _ in range(H)]

dp[0][1] = 1
for i in range(1,H+1):
    for j in range(1,W+1):
        if mp[i-1][j-1] == '#': continue
        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD

print(dp[-1][-1])

Measured memory_bytes: 53720
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static long lcm(long a, long b){
		return a / gcd(a, b) * b;
	}
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		long answer = 0;
		
		long fst = 1, snd = 1;
		for(int i = 0; i < N; i++){
			final int T = sc.nextInt();
			final int A = sc.nextInt();
			
			final long fst_over = (fst + T - 1) / T;
			final long snd_over = (snd + A - 1) / A;
			
			fst = T * Math.max(fst_over, snd_over);
			snd = A * Math.max(fst_over, snd_over);
			//System.out.println(fst + ", " + snd);
		}
		
		System.out.println((fst + snd));
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8916
line = input().split()

n = int(line[0])
k = int(line[1])

sum_p = 0
for i in range(n):
    score = i + 1
    p = 1 / n
    count = 0
    while score <= k - 1:
        score *= 2
        p /= 2
        count += 1
    sum_p += p
    
print('{:.12f}'.format(sum_p))

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n;cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  rep(i,n)cin>>a[i]>>b[i];
  vector<int> ok(100003,0);
  rep(i,n)
  {
    ok[a[i]]++;
    ok[b[i]+1]--;
  }
  ok[1]++;
  ok[100002]--;
  rep(i,100001)ok[i+1]+=ok[i];
  int ans=0;
  for(i=n+1;i>=1;i--)
  {
    if(ok[i]<i)continue;
    int kans=min(ok[i],i);
    ans=max(ans,kans);
  }
  cout<<ans-1<<endl;
}



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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}

signed main() {
	int n,x,ans=0,now=0;
	cin>>n>>x;
	rep(i,n){
		int a;
		cin>>a;
		now+=a;
		if(now<=x){
			ans++;
		}
		else{
			break;
		}
	}
	cout<<ans+1<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 1; i <= n; i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		for (int i = n-1; i > 0; i--) {
			System.out.print(list.get(i) + " ");
		}
		System.out.println(list.get(0));
	}
}



Measured memory_bytes: 26480
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    long T=gl();
	    long[] t=new long[n];

	    long ans=0;
	    long start=0;
	    long end=0;
	    for (int i=0; i<n;i++) {
	    	t[i]=gl();
	    	if(end<t[i]) {
	    		ans+=end-start;
	    		start=t[i];
	    	}
	    	end=t[i]+T;
	    }
	    
	    ans+=end-start;
	    System.out.println(ans);
//	    if(n>=Math.floorDiv(m, 2)) {
//	        System.out.println(Math.floorDiv(m, 2));
//	    } else {
//	    	long c=n;
//	    	m-=2*n;
//	    	c+=Math.floorDiv(m, 4);
//	    	System.out.println(c);
//	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 61140
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007LL;
LL a[50];
int main() {
	LL K;
	cin >> K;
	LL q = K / 50, r = K % 50;
	for (int i = 0; i < 50; i++) {
		a[i] = i + q;
		if (i < r) a[i] += 50 - (r - 1);
		else a[i] -= r;
	}
	cout << 50 << endl;
	cout << a[0];
	for (int i = 1; i < 50; i++) {
		cout << " " << a[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;


string S;
size_t len;
vector<string> strs;


vector<string> split_naive(const string& s, char delim) {
	vector<string> elems;
	string item;
	for (char ch : s) {
		if (ch == delim) {
			if (!item.empty())
				elems.push_back(item);
			item.clear();
		}
		else {
			item += ch;
		}
	}
	if (!item.empty())
		elems.push_back(item);
	return elems;
}


string func(ll i, string s0) {
	if (i == len) return s0;

	auto s1 = s0 + S[i];
	s1 = func(i + 1, s1);
	if (s1 != "") strs.emplace_back(s1);

	auto s2 = s0 + "+" + S[i];
	s2 = func(i + 1, s2);
	if (s2 != "") strs.emplace_back(s2);

	return "";
}


int main() {
	cin >> S;
	len = S.size();

	if (len == 1) {
		cout << S << endl;
		return 0;
	}

	ll sum = 0;

	func(1, S.substr(0, 1));

	for (auto&& s : strs) {
		auto s_split = split_naive(s, '+');

		for (auto&& ss : s_split) {
			sum += stoll(ss);
		}

	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
using namespace std;
#define Pair pair<int,int>
#define Point pair<int, Pair>
#define S_P pair<ll,Point>

#define ll long long

ll X, Y, Z, K;
vector<ll> A,B,C;




int solve(){
	sort(A.begin(), A.end(), std::greater<ll>());
	sort(B.begin(), B.end(), std::greater<ll>());
	sort(C.begin(), C.end(), std::greater<ll>());

	
	ll sum; S_P cur;
	int x,y,z,count=0;

	set<Point> visit;

	priority_queue<S_P> q;
	sum = A[0]+B[0]+C[0];

	q.push({sum,{0,{0,0}}});
	visit.insert({0,{0,0}});
	while(true){
		cur = q.top(); q.pop();
		cout << cur.first << endl;
		count++;
		if(count==K) return 0;
		
		x = cur.second.first;
		y = cur.second.second.first;
		z = cur.second.second.second;

		if(!visit.count({x+1,{y,z}}) && x+1<X){
			visit.insert({x+1,{y,z}});
			sum = A[x+1]+B[y]+C[z];
			q.push({sum,{x+1,{y,z}}});
			//cout << x+1 << y << z << endl;
		}
		if(!visit.count({x,{y+1,z}}) && y+1<Y){
			visit.insert({x,{y+1,z}});
			sum = A[x]+B[y+1]+C[z];
			q.push({sum,{x,{y+1,z}}});
			//cout << x << y+1 << z << endl;
		}
		if(!visit.count({x,{y,z+1}})&& z+1<Z){
			visit.insert({x,{y,z+1}});
			sum = A[x]+B[y]+C[z+1];
			q.push({sum,{x,{y,z+1}}});
			//cout << x << y << z+1 << endl;
		}

		

	}

}



int main(){
	cin >> X >> Y >> Z >> K;
	A.resize(X); B.resize(Y);C.resize(Z);
	for(int i=0;i<X;i++){
		cin >> A[i];
	}

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

	for(int i=0;i<Z;i++){
		cin >> C[i];
	}


	solve();
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    int x, l;
    REP(i, n) {
        cin >> x >> l;
        v[i] = make_pair(x + l, x - l);
    }
    SORT(v);
    int p = -INF * 2;
    int ans = 0;
    for (auto r : v) {
        if (r.second >= p) {
            ans++;
            p = r.first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }

        // 何度でも同じ魔法が使えるので, 基本同じ魔法しか使わない(はず)
        // 魔法の種類がN(<=10^3).
        // 普通に全ての魔法について, その魔法が最も効率の高い魔法であるという前提の元,
        // 攻撃を行う。すると, 最後の一撃に関してだけは, それよりも効率のいい一撃が存在する
        // 可能性があることに気がつく。
        // そのような魔法は, 残りの体力以上の攻撃力を持つ最も魔力の小さな攻撃である
        // (その中には当該魔法も含む)
        // 攻撃力の降順に魔法をソートしておくと,
        // dp[i] := iまでの魔法の中で最も魔力の小さなもの
        // を計算しておくことでこれを高速に導出できる.

//        int[] idx = IntStream.range(0, N)
//                .boxed().sorted(Comparator.comparing(i -> A[i]))
//                .mapToInt(i -> i).toArray();
//        int[] dp = new int[N+1];
//        dp[N] = Integer.MAX_VALUE;
//        for (int i = N - 1; i >= 0; i--) {
//            dp[i] = Math.min(B[idx[i]], dp[i+1]);
//        }
//
//        int min = Integer.MAX_VALUE;
//        for (int i = 0; i < N; i++) {
//            int count = (H / A[i]);
//            int residue = (H % A[i]);
//            if (residue > 0) {
//                int j = binarySearch(idx, A, residue, -1, N - 1);
//                min = Math.min(min, dp[j] + count * B[i]);
//            } else {
//                min = Math.min(min, count * B[i]);
//            }
//        }
//
//        System.out.println(min);

        // 実際のところ, 最後の一手を最初に与えるべきっぽい気がした.
        // 回答ではdpを使っているが,使わなくてもいけそうなきがする.
        // その場合, ある効率の良いと考えられる魔法について,
        // 最初の一手を全ての魔法の中から選ぶ必要があり,
        // O(N^2) で今回 N(<=10^3) なので,間に合うか微妙?
//        int min = Integer.MAX_VALUE;
//        for (int last = 0; last < N; last++) {
//            for (int best = 0; best < N; best++) {
//                min =
//                    Math.min(min, B[last] +
//                        (int)Math.ceil((H - A[last]) / (double)A[best]) * B[best]);
//            }
//        }
//
//        System.out.println(min);

        // どうやら, 二種類でいける訳ではないので結局dpが必要
        // dp[i] := iダメージを与えるのに必要な最小の魔力
        int[] dp = new int[H+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int h = 0; h <= H; h++) {
            if (dp[h] == Integer.MAX_VALUE) continue;
            for (int i = 0; i < N; i++) {
                if (h+A[i] >= H) {
                    dp[H] = Math.min(dp[H], dp[h] + B[i]);
                } else {
                    dp[h+A[i]] = Math.min(dp[h+A[i]], dp[h] + B[i]);
                }
            }
        }

        System.out.println(dp[H]);
    }

//    private static int binarySearch(int[] idx, int[] A, int N, int left, int right) {
//        if (right - left > 1) {
//            int mid = left + (right - left) / 2;
//            if (A[idx[mid]] >= N) return binarySearch(idx, A, N, left, mid);
//            else return binarySearch(idx, A, N, mid, right);
//        } else {
//            return right;
//        }
//    }
}


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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A(MAXN, 0), C;
vector<vector<ll>> G;

void dfs(ll now, ll pre) {
    for(int i=0;i<G[now].size();i++) {
        if(G[now][i]==pre) continue;
        dfs(G[now][i], now);
    }
    A[now] = C.back();
    if(now!=0) ans += C.back();
    C.pop_back();
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=0;i<N;i++) {
        ll cn;
        cin >> cn;
        C.push_back(cn);
    }
    sort(C.begin(), C.end(), greater<ll>());
    dfs(0,-1);
    cout << ans << endl;
    for(int i=0;i<N;i++) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<int>> matrix;
const int64_t m = 1e18;
void solve()
{

    ll n;
    cin >> n;
    int64_t a[n];
    bool zero = 0;
    fr(i, n)
    {
        cin >> a[i];
        if (a[i] == 0)
            zero = 1;
    }
    int64_t ans = 1;
    if (zero == 1)
    {
        cout << 0 << "\n";
        return;
    }
    fr(i, n)
    {
        if (a[i] > m / ans)
        {
            cout << -1 << "\n";
            return;
        }
        ans *= a[i];
    }
    cout << ans;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 4444
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int main()
{
	int q;scanf("%d",&q);
	while (q--)
	{
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		if (a>=b)
		{
			int l=(a-1)/(b+1)+1;
			int h=1,t=min(b,a/l+2);
				while (h<=t)
				{
					int mid=(h+t)>>1;
					if ((a-ll(mid)*l+1)*l<b-mid+1) t=mid-1; else h=mid+1;
				}
				int h0=0,t0=l;
				while (h0<=t0)
				{
					int mid=(h0+t0)>>1;
					if ((a-ll(t)*l-mid+1)*l>=b-t+(mid==0)) h0=mid+1; else t0=mid-1;
				}
				int x=t*(l+1)+t0-(t0==0);
				for (int i=c;i<=d;i++)
					if (i<=x)
					{
						if (i%(l+1)) putchar('A'); else putchar('B');
					}
					else
					{
						if ((i-x)%(l+1)==(a+b+1-x)%(l+1)) putchar('A'); else putchar('B');
					}
				puts("");
		}
		else
		{
			int l=(b-1)/(a+1)+1;
			int x=b-a*l;
			if (x>0)
			{
				for (int i=c;i<=d;i++)
					if (i<=x) putchar('B');
					else
					{
						if ((i-x)%(l+1)==1) putchar('A'); else putchar('B');
					}
				puts("");
			}
			else
			{
				int h=1,t=min(b,a/l+2);
				while (h<=t)
				{
					int mid=(h+t)>>1;
					if ((a-ll(mid)*l+1)*l<b-mid+1) t=mid-1; else h=mid+1;
				}
				int h0=0,t0=l;
				while (h0<=t0)
				{
					int mid=(h0+t0)>>1;
					if ((a-ll(t)*l-mid+1)*l>=b-t+(mid==0)) h0=mid+1; else t0=mid-1;
				}
				int x=t*(l+1)+t0-(t0==0);
				for (int i=c;i<=d;i++)
					if (i<=x)
					{
						if (i%(l+1)) putchar('A'); else putchar('B');
					}
					else
					{
						if ((i-x)%(l+1)==(a+b+1-x)%(l+1)) putchar('A'); else putchar('B');
					}
				puts("");
			}
		}					
	}
	return 0;
}



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

using namespace std;

#define int long long

signed main(){

	int N;
	int con[2] = {};
	vector<int> A;
	
	cin>>N;
	
	A.assign(N,0);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		con[A[i]%2]++;
	}
	
	if(!con[0] || !con[1]) cout<<0<<endl;
	else {
		int x = 0;
		
		if(con[1]%2){
			x = con[1]/2;
			
			cout<<con[0]+x*2<<endl;
		} else {
			x = (con[1]-1)/2;
			
			cout<<con[0]+x*2<<endl;
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 4332
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <utility>
#include <queue>
#define ull unsigned long long
#define ll long long
#define mod 998244353
using namespace std;

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

    int br = 0;
    for (int i=1;i<=n;i++){
        int d = i;
        int b = 0;
        while ( d ) d/=10, b++;
        if ( b & 1 ) br++;
    }

    cout<<br<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _ % MOD
#define __ %= MOD

#define each(it, s) for (auto it = s.begin(); it != s.end(); ++it)
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.begin(), v.end(), greater<auto>())
#define fill(a) memset(a, 0, sizeof(a))

#define swap(a, b) \
	{              \
		a = a + b; \
		b = a - b; \
		a = a - b; \
	}
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repA(i, a, n) for (ll i = a; i <= (n); ++i)
#define repD(i, a, n) for (ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) << endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)                                 \
	{                                         \
		rep(i, a.size()) cout << a[i] << " "; \
		cout << endl;                         \
	}
#define mark(v) cout << "Here--" << v << endl;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1)
			res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
} // modular exponent

int main()
{
	ios_base::sync_with_stdio(false); // don't use printf and scanf
	cin.tie(NULL);					  // cout<<fixed<<setprecision
	float a, b;
	cin >> a >> b;
	double ans = a * (b * 100) / 100;
	cout << floor(ans) << endl;
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int v, e, m;
vector<int> g[100010];
int h[100010], ans[100010];
int main(){
  	cin >> v >> m;
  	e = v + m - 1;
  	for(int i=0;i<e;i++){
    	int s, t;
    	cin >> s >> t;
    	g[s].push_back(t);
    	h[t]++;
  	}
	stack<int> st;
	for(int i=1;i<=v;i++){
		if(h[i] == 0) st.push(i);
	}
  	while(st.size()) {
    	int i = st.top(); st.pop();
	    for(auto& j: g[i]) {
	    	h[j]--;
    		ans[j] = i;
    		if(h[j] == 0) st.push(j);
   		}
   	}
   	for(int i=1;i<=v;i++){
   		cout << ans[i] << endl;
   	}
	return 0;
}

Measured memory_bytes: 7040
import math


a, b, h, m = list(map(int, input().split(' ')))

theta = abs((30 * h - 6 * m) + 0.5 * m)
if theta >= 180:
    theta = 360 - theta

print(math.sqrt((float(a) ** 2 + float(b) ** 2) -
                (2 * float(a) * float(b) * math.cos(math.radians(float(theta))))))


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

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

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

    int ans = 0;
    for (int A = 1; A <= N; ++A) {
        for (int B = 1; A*B < N; ++B) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
  string a,b,c;cin >> a >> b >> c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	vector<int>pl;
	vector<int>mi;
	rep(i, 0, N)cin >> A[i];
	
	sort(all(A));
	rep(i, 0, N) {
		if (i == 0)mi.pb(A[i]);
		else if (i == N - 1)pl.pb(A[i]);
		else {
			if (A[i] >= 0)pl.pb(A[i]);
			else mi.pb(A[i]);
		}
	}

	vector<pair<int, int>>p;
	int now = mi[mi.size()-1];
	rep(i, 0, pl.size() - 1) {
		p.pb({ now,pl[i] });
		now -= pl[i];
	}
	int now2 = pl[pl.size() - 1];
	rep(i, 0, mi.size() - 1) {
		p.pb({now2,mi[i]});
		now2 -= mi[i];
	}
	p.pb({ now2,now });
	cout << now2 - now << endl;
	rep(i, 0, N - 1) {
		cout << p[i].first << " " << p[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int t,n,s,f;
    while (cin>>t) {
        if (t==0) {
            break;
        } else {
            int sum=0;
            cin>>n;
            for (int i=0;i<n;i++) {
                cin>>s>>f;
                sum+=(f-s);
            }
            if (sum>=t) {
                cout<<"OK"<<endl;
            } else {
                cout<<t-sum<<endl;
            }
        }
    }
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

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

	String N = in.next();

	if(N.indexOf("9") == -1){
		System.out.println("No");
	}
	else{
		System.out.println("Yes");
	}
}
}

Measured memory_bytes: 23892
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1234567891234567891;
int main() {
	int N;
	cin >> N;
	vector<long long> A(N), S(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		S[i + 1] = S[i] + A[i];
	}
	vector<long long> pl(N + 1, -inf), pr(N + 1, inf); // ---> A[i]
	vector<long long> ql(N + 1, -inf), qr(N + 1, inf); // A[i] <---
	set<long long> s;
	for (int i = 2; i <= N; ++i) {
		s.insert(S[i - 1]);
		set<long long>::iterator it = s.lower_bound((S[i] + 1) / 2);
		long long mindiff = inf;
		if (it != s.end()) {
			mindiff = 2 * (*it) - S[i];
		}
		if (it != s.begin()) {
			--it;
			mindiff = min(mindiff, S[i] - 2 * (*it));
		}
		pl[i] = (S[i] - mindiff) / 2;
		pr[i] = (S[i] + mindiff) / 2;
	}
	s.clear();
	for (int i = N - 2; i >= 0; --i) {
		s.insert(S[N] - S[i + 1]);
		set<long long>::iterator it = s.lower_bound((S[N] - S[i] + 1) / 2);
		long long mindiff = inf;
		if (it != s.end()) {
			mindiff = 2 * (*it) - (S[N] - S[i]);
		}
		if (it != s.begin()) {
			--it;
			mindiff = min(mindiff, (S[N] - S[i]) - 2 * (*it));
		}
		ql[i] = (S[N] - S[i] - mindiff) / 2;
		qr[i] = (S[N] - S[i] + mindiff) / 2;
	}
	long long ans = inf;
	for (int i = 2; i <= N - 2; ++i) {
		ans = min(ans, max(pr[i], qr[i]) - min(pl[i], ql[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19072
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    vector<int> dp1(N+1),dp2(N+1);
    dp2[0] = -1e9;
    rep(i,N) {
        int k = S[i] - '0';
        dp1[i+1] = dp1[i] + k;
        dp2[i+1] = max(dp1[i]+max(0,k-1),dp2[i]+9);
    }

    cout << max(dp1[N],dp2[N]) << ln;
}

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


int main(){
  int X; cin>>X;
  if(X==1){
    cout <<1 << endl;
    return 0;
  }
  
  int ans=0;
  for(int i=2; i*i<=X; i++){
    int j=i;
    while(j*i<=X){
      j *=i;
      ans = max(j,ans);
    }
  }
  cout << ans << endl;
}


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

int main()
{
   int i = 1;
   int x;

   while( true ) 
   {
      cin >> x;
      if ( x ) {
         cout << "Case " << i << ": " << x << '\n';
         i++;
      }else
      {
         break;
      }
   } 
  return 0;
}

Measured memory_bytes: 1156
function main()
	nt = parse.(split(readline()))
	min = 1001
	for i in 1:nt[1]
		ct = parse.(split(readline()))
		if ct[2] <= nt[2] && ct[1] < min
			min = ct[1]
		end
	end
	if min >= 1001
		print("TLE")
	else
		print(min)
	end
end


main()

Measured memory_bytes: 144944
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    long long ans;
    scanf("%d%d",&n,&k);
    ans=k;
    for(int i=2;i<=n;i++)
        ans*=(k-1);
    printf("%lld",ans);
    return 0;
}



Measured memory_bytes: 128
#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];
DP[10][10][10][10][51];
CalcO(o,x,y){
	c[x][y]>0?o+=c[x][y],o>m?o=m:0:0;
	return o;
}
CalcF(f,x,y){//càÌvZ
	c[x][y]<0?f+=c[x][y]:0;
	return f;
}
Walk(x,y,l,r,o,f){
	int*p=&DP[y][x][l][r][o];
	f>*p?*p=f:0;
}
Dig(x,y,l,r,o,f){
	Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));
}
main(){
	int x,y,g,d,v,f,o,l,r,f0;
	for(;scanf("%d%d",&W,&H)*W;){
		scanf("%d%d%d",&f0,&m,&o);
		rep(y,H)rep(x,W)
			scanf("%d",&c[x][y]);
		f0++;
		if(o>1)
			rep(x,W)
				DP[0][x][x][x][CalcO(o-1,x,0)]=CalcF(f0,x,0);
		rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)
		{
			r=l+g;
			if(f=DP[y][x=d?l+v:r-v][l][r][o]){
				Dig(x,y+1,x,x,o,f);
				x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;
				x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;
			}
		}
		f=0;
		rep(x,W)rep(o,m)
			v=DP[H-1][x][x][x][o+1],v>f?f=v:0;
		printf(f?"%d\n":"NA\n",f0-f);
		memset(DP,0,sizeof(DP));
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

#define dTolerance 1.0e-10

struct POINT {
    int x;
    int y;
    int Norm;
};

bool operator<(const POINT& a, const POINT & b) {
    if (a.x * b.y - a.y * b.x != 0) {
        return a.x * b.y - a.y * b.x > 0;    //偏角の大小で順序を定める
    }
    else {
        return a.Norm < b.Norm;    //偏角が等しい場合基準点との距離で見る
    }
};

int main() {
    int n;
    scanf("%d", &n);
    int iStart = 0;    //探索を始める点  y座標最小となる点(x[iStart],y[iStart])をとる
    int x[n], y[n];

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &x[i], &y[i]);
        if (y[i] < y[iStart]) {
            iStart = i;
        }
        if (y[i] == y[iStart] && x[i] < x[iStart]) {
            iStart = i;
        }

    }


    vector<POINT> vzPoint;
    for (int i = 0; i < n; i++) {
        POINT zPoint;
        zPoint.x = x[i] - x[iStart];
        zPoint.y = y[i] - y[iStart];
        zPoint.Norm = (x[i] - x[iStart]) * (x[i] - x[iStart]) + (y[i] - y[iStart]) * (y[i] - y[iStart]);
        vzPoint.push_back(zPoint);
    }
    sort(vzPoint.begin(), vzPoint.end());

    vector<int> viPoint;
    viPoint.push_back(0);
    viPoint.push_back(1);
    for (int i = 2; i < n; i++) {
        while (viPoint.size() >= 2) {
            int j1 = viPoint.back();
            viPoint.pop_back();
            int j0 = viPoint.back();
            int x1, x2, y1, y2;
            x1 = vzPoint[j1].x - vzPoint[j0].x;
            y1 = vzPoint[j1].y - vzPoint[j0].y;
            x2 = vzPoint[i].x - vzPoint[j1].x;
            y2 = vzPoint[i].y - vzPoint[j1].y;
            if (x1 * y2 - x2 * y1 >= 0) {
                viPoint.push_back(j1);
                break;
            }
        }
        viPoint.push_back(i);
    }
    
    while (viPoint.size() >= 2) {     //ここ実はいらない  ∵最後に加えた点は偏角最大なので
        int j1 = viPoint.back();
        viPoint.pop_back();
        int j0 = viPoint.back();
        int x1, x2, y1, y2;
        x1 = vzPoint[j1].x - vzPoint[j0].x;
        y1 = vzPoint[j1].y - vzPoint[j0].y;
        x2 = vzPoint[0].x - vzPoint[j1].x;
        y2 = vzPoint[0].y - vzPoint[j1].y;
        if (x1 * y2 - x2 * y1 >= 0) {
            viPoint.push_back(j1);
            break;
        }
    }
    
    //最後に得られた辺上の点が除かれてしまっているので遠くから順に与える
    int iEnd = viPoint.back();
    for(int i = vzPoint.size() - 1; i > 0; i--){    //vzPointは偏角が同じものはノルムが小さい順にソートされているので逆順にみる
        if(i == iEnd){    //最後に加えた頂点は無視
            continue;
        }
        int x1,x2,y1,y2;
        x1 = vzPoint[i].x - vzPoint[0].x;
        y1 = vzPoint[i].y - vzPoint[0].y;
        x2 = vzPoint[iEnd].x - vzPoint[0].x;
        y2 = vzPoint[iEnd].y - vzPoint[0].y;
        if(x1 * y2 - x2 * y1 != 0){    //偏角が異なる点が出てきたら終わる
            break;
        }
        viPoint.push_back(i);
    }


    printf("%d\n", viPoint.size());
    for (int i = 0; i < viPoint.size(); i++) {
        printf("%d %d\n", vzPoint[viPoint[i]].x + x[iStart], vzPoint[viPoint[i]].y + y[iStart]);
    }
    return 0;
}



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

int main() {
	string S;
	cin >> S;
	vector<long long> L, R;
	L.resize(S.size() + 1), R.resize(S.size() + 1);
	L[0] = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '<') L[i + 1] = L[i] + 1;
		else L[i + 1] = 0;
	}
	R[S.size()] = 0;
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == '>') R[i] = R[i + 1] + 1;
	}
	long long ANS = 0;
	for (int i = 0; i <= S.size(); i++) ANS += max(L[i], R[i]);
	cout << ANS << endl;
}

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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 10;
vector<ll> a, sub, r, c;
vector<vector<ll>> G(maxn, vector<ll>(maxn, 0));
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    a.resize(n);
    for(auto &i:a)cin >> i;
    sort(all(a),greater<ll>());
    int fir = (n+1)/2;
    ll res = 0;

    res = accumulate(a.begin(), a.begin() + fir-1, 0LL);
    res = accumulate(a.begin() + 1, a.begin() + fir, res);
    if(n%2==0){
        res += a[n/2-1];
    }

    cout << res << endl;


}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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 pair<int, int> pair;
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする
 
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//dpTable
int dp[100050];

int main(){
    string S;
    cin >> S;
    if (S.at(0) == 'R') {
        if (S.at(1) == 'R') {
            if (S.at(2) == 'R') {
                cout << 3 << endl;
            }
            else cout << 2 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
    else {
        if (S.at(1) == 'R') {
            if (S.at(2) == 'R') cout << 2 << endl;
            else cout << 1 << endl;
        }
        else {
            if (S.at(2) == 'R') cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
int n, q;
int tmp;
int s[50000], t[10000];
int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for(int i = 0; i < q; i++) scanf("%d", &t[i]);
  
  int ans=0;
  for(int i = 0; i < q; i++){
    for(int j = 0; j < n; j++){
      if(t[i] == s[j]) {
        ans++;
        break;
      }
    }
  }
  printf("%d\n", ans);
}


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

int main() {
  int K;
  cin >> K;
  vector<int> A = {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 };
  for(int i = 0; i < 32; i++) {
    cin >> A.at(i);
  }
  cout << A.at(K-1) << endl;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define MAXN 1005
ll sx,sy,dx,dy,N,M;
ll vis[MAXN][MAXN];
ll ddx[] = {1,-1,0,0};
ll ddy[] = {0,0,1,-1};
map<pair<ll,ll>,ll> mp;

bool inBounds(ll x,ll y)
{
    return(x >= 0 && x < N && y >= 0 && y < M);
}

void DFS(ll x,ll y,string s[],ll c)
{
    vis[x][y] = c;
    for(ll i=0;i<4;++i)
    {
        ll nx = x + ddx[i];
        ll ny = y + ddy[i];
        if(inBounds(nx,ny) && !vis[nx][ny] && (s[nx][ny]  == '.'))
            DFS(nx,ny,s,c);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>N>>M;
    cin>>sx>>sy>>dx>>dy;
    string s[N];
    
    for(ll i=0;i<N;++i)
        cin>>s[i];
    
    /*for(ll i=0;i<N;++i)
        cout<<s[i]<<endl;*/
    
    ll c = 1;
    for(ll i=0;i<N;++i)
    {
        for(ll j=0;j<M;++j)
        {
            if(!vis[i][j] && (s[i][j] == '.'))
                DFS(i,j,s,c++);
        }
        
    }
    
    vector<ll> adj[c];
    ll vis2[c] = {0};
    ll dis[c] = {0};
    
    for(ll i=0;i<N;++i)
    {
        for(ll j=0;j<M;++j)
        {
            if(s[i][j] == '#')
                continue;
            
            for(ll a = (-2);a<=2;++a)
            {
                for(ll b = (-2);b<=2;++b)
                {
                    if(inBounds(i + a,j + b) && (s[i + a][j + b] == '.') && (vis[i][j] != vis[i + a][j + b]) && (mp[{vis[i][j],vis[i + a][j + b]}] == 0))
                        adj[vis[i][j]].push_back(vis[i + a][j + b]);
                }
            }
        }
    }
    
    ll src = vis[sx - 1][sy - 1];
    ll des = vis[dx - 1][dy - 1];
    
    //cout<<src<<" "<<des<<endl;
    if(src == 0 || des == 0)
    {
        cout<<-1<<endl;
        return(0);
    }
    
    queue<ll> q;
    q.push(src);
    vis2[src] = 1;
    
    while(!q.empty())
    {
        ll val = q.front();
        q.pop();
        
        for(auto it: adj[val])
        {
            if(!vis2[it])
            {
                dis[it] = dis[val] + 1;
                q.push(it);
                vis2[it] = 1;
            }
        }
    }
    
    if(!vis2[des])
        cout<<-1<<endl;
    else
        cout<<dis[des]<<endl;
}

Measured memory_bytes: 45472