akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int DPx[17000][8005], DPy[17000][8005];

int main() {
  string S;
  cin>>S;
  int x, y;
  cin>>x>>y;
  DPx[8500][0] = 1;
  DPy[8500][0] = 1;
  vector<int> xarr, yarr;
  bool nowx = true;
  int tmp = 0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='F') {
      tmp++;
    }
    else {
      if(nowx) {
        nowx = false;
        xarr.push_back(tmp);
        tmp = 0;
      }
      else {
        nowx = true;
        yarr.push_back(tmp);
        tmp = 0;
      }
    }
  }
  if(nowx) xarr.push_back(tmp);
  else yarr.push_back(tmp);
  if(xarr.size()==0) xarr.push_back(0);
  if(yarr.size()==0) yarr.push_back(0);
  for(int i=0;i<xarr.size();++i) {
    for(int j=0;j<17000;++j) {
      if(DPx[j][i]==1) {
        if(i==0 && S[0]=='F') DPx[j+xarr[i]][i+1] = 1;
        else {
          DPx[j+xarr[i]][i+1] = 1;
          DPx[j-xarr[i]][i+1] = 1;
        }
      }
    }
  }
  for(int i=0;i<yarr.size();++i) {
    for(int j=0;j<17000;++j) {
      if(DPy[j][i]==1) {
        DPy[j+yarr[i]][i+1] = 1;
        DPy[j-yarr[i]][i+1] = 1;
      }
    }
  }
  if(DPx[x+8500][xarr.size()]==1 && DPy[y+8500][yarr.size()]==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 73288
#include <iostream>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>

#define int64 long long int

using namespace std;

int main()
{
	int n;
	stack<int> st;

	while(cin >> n){
		if(n==0){
			cout << st.top() << '\n';
			st.pop();
		} else {
			st.push(n);
		}
	}	
	
	return 0;
}

Measured memory_bytes: 1200
main(f){
  float w;
  char*p[]={"light fly","fly","bantam","feather","light","light welter",
	    "welter","light middle","middle","light heavy","heavy"};
  //  while(scanf("%f",&w)!=-1)
  for(;~scanf("%f",&w);){
    f=w>48?w>51?w>54?w>57?w>60?w>64?w>69?w>75?w>81?w>91?10:9:8:7:6:5:4:3:2:1:0;
    puts(p[f]);
  }
  return 0;
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(100000)
n = int(input())
x = []
y = []
for i in range(n):
    s = list(map(int, input().split()))
    x.append([s[0], i])
    y.append([s[1], i])

x.sort()
y.sort()

xdiff = []
ydiff = []
for i in range(1, n):
    xdiff.append([x[i][0] - x[i - 1][0], x[i - 1][1], x[i][1]])
    ydiff.append([y[i][0] - y[i - 1][0], y[i - 1][1], y[i][1]])

xdiff.sort()
ydiff.sort()

parent = [-1] * n

def getParent(index):
    if parent[index] == -1:
        return index
    else:
        parent[index] = getParent(parent[index])
        return parent[index]

count = 0
ans = 0
xIndex = 0
yIndex = 0
while count != n - 1:
    if xIndex != n - 1:
        xTemp = xdiff[xIndex]
    if yIndex != n - 1:
        yTemp = ydiff[yIndex]

    if yIndex == n - 1 or (xIndex != n - 1 and xTemp[0] < yTemp[0]):
        xIndex += 1
        temp = xTemp
    else:
        yIndex += 1
        temp = yTemp

    parent1 = getParent(temp[1])
    parent2 = getParent(temp[2])
    if parent1 == parent2:
        continue
    else:
        count += 1
        ans += temp[0]
        parent[parent1] = parent2

print(ans)

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

int main(){
  string s;
  cin >> s;
  
  int a, z;
  bool A = false;
  for(int i = 0; i < s.size() ; i++){
    if(s[i] == 'A' && A == false){
      a = i;
      A = true;
    }
    if(s[i] == 'Z'){
      z = i;
    }
  }
  cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
using System;

namespace AtCoder
{
	public class ProblemA
	{
		public static void Main(string[] args)
		{
			string[] line = Console.ReadLine().Split(' ');
			int h = int.Parse(line[0]);
			int w = int.Parse(line[1]);

			char[,] tiles = new char[h, w];

			int sharp = 0;

			for (int i = 0; i < h; i++)
			{
				string s = Console.ReadLine();
				bool isTop = i == 0;
				for (int j = 0; j < w; j++)
				{
					bool isLeft = j == 0;

					char c = s[j];
					tiles[i, j] = c;
					if (c == '.')
						continue;

					sharp++;

					// 左と上だけを見る
					bool canPaint = false;
					if (!isTop && tiles[i - 1, j] != '.')
					{
						canPaint = true;
						if (tiles[i - 1, j] == '#')
						{
							sharp--;
							tiles[i - 1, j] = 'B';
						}
					}
					if (!isLeft && tiles[i, j - 1] != '.')
					{
						canPaint = true;
						if (tiles[i, j - 1] == '#')
						{
							sharp--;
							tiles[i, j - 1] = 'B';
						}
					}

					if (canPaint)
					{
						sharp--;
						tiles[i, j] = 'B';
					}
				}
			}

			Console.WriteLine(sharp == 0 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 27516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

ll w[101],v[101],memo[102][100005];
int n;

ll f(int i,int remw){
    if(i==n || remw==0) return memo[i][remw] = 0;
    if(w[i]>remw) return memo[i][remw] = f(i+1,remw);
    if(memo[i][remw]!= -1) return memo[i][remw];
    return memo[i][remw] = max(f(i+1,remw),v[i]+f(i+1,remw-w[i]));
}

main(){
    int W;cin>>n>>W;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    ll ans = f(0,W);
    cout<<ans;
}

Measured memory_bytes: 83224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c=0,N;cin>>N;vector<int>s(N),p(N),q(N);
  for(int i=0;i<N;i++)s.at(i)=i+1;
  for(int i=0;i<N;i++)cin>>p.at(i);
  for(int i=0;i<N;i++)cin>>q.at(i);
  do{
    c++;
    if(p==s)a=c;
    if(q==s)b=c;
  }while(next_permutation(s.begin(),s.end()));
  cout<<max(a-b,b-a)<<endl;
}

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

void fin(){
  cout<<"Impossible"<<endl;
  exit(0);
}

signed main(){
  int n;cin>>n;
  map<int,int> m;
  while(n--){
    int a;cin>>a;m[a]++;
  }
  int M=m.rbegin()->first;
  if(M==1){
    if(m[1]==2)cout<<"Possible"<<endl;
    else fin();
    return 0;
  }
  for(int i=M;i>M/2;i--)if(m[i]<2)fin();
  if(!(M&1)){if(m[M/2]!=1)fin();}
  else if(m[(M+1)/2]>2)fin();
  for(int i=(M-1)/2;i>0;i--)if(m[i])fin();
  cout<<"Possible"<<endl;
}


Measured memory_bytes: 256
"use strict"
const Main = (input) =>{
  	let xs = input.trim().split("\n");
    let xs1 = xs[0].split(" ").map(Number);
    let H = xs1[0];
    let W = xs1[1];
    console.log(Array(W+3).join("#"));
    for(let i = 1; i<=H; i++){
    console.log("#%s#",xs[i]);//("#"+xs[i]+"#");
    }
    console.log(Array(W+3).join("#"));
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	string s, t;
	cin >> s >> t;
	int ans = INT_MAX;
	for (int i = 0; i + t.size() - 1 <= s.size() - 1; i++) {
		int cnt = 0;
		for (int j = 0; j < t.size(); j++) {
			if (t[j] != s[i + j])cnt++;
		}
		ans = min(cnt, ans);
	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define phi 3.1415926535
 
using namespace std;
 
ll tc, cnt = 0, number, many, total = 0;
int rmove[4] = {0, 0, -1, 1};
int cmove[4] = {1, -1, 0, 0};



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // g++ -std=c++11 Default.cpp  -o test

    cin >> many;

    int arr[many];
    map <int, int> mapping;
    for(int i = 0; i < many; i++)
    {
        cin >> arr[i];
        mapping[arr[i]]++;
    }

    int answer = 0;
    for(int i = 0; i < many; i++)
    {
        int temp = arr[i];
        bool condition = false;

        mapping[temp]--;
        for(int j = 1; j <= sqrt(temp) && !condition; j++)
        {
            if(temp % j == 0)
            {
                if(mapping[j] > 0 || mapping[temp / j] > 0)
                    condition = true;
            }
        }

        mapping[temp]++;
        if(!condition)
        {
            answer++;
            // cout << arr[i] << " ";
        }
    }
    // cout << endl;

    cout << answer << endl;
    
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 33196
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] t = new int[N];
		for (int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
		}

		long count = IntStream.of(t).filter(i -> i < A || B <= i).count();

		System.out.println(count);
	}
}

Measured memory_bytes: 15820
import java.util.Arrays;

//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//毎回余りを求めることでオーバーフローしなくなる
//nextLineよりnextだ
//charは''で囲うんだぞ
//読み込みは先に全部やっておけ
//for文を回す回数に気をつけろ
	//for文は10^3の三重はTLE,10^5の二重はTLE,10^9のforはTLE
//貪欲は使えるか？？試した？？

import java.util.Scanner;

public class Main {

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

		    int n = sc.nextInt();
		    int[] ar = new int[n];
		    for(int i = 0; i < n; i++) {
		    	ar[i] = sc.nextInt();
		    }
		    Arrays.sort(ar);
		    int count = 0;
		    int ans = 0;
		    for(int i = 0; i < n; i ++) {
		    	if(i >= 1) {
		    		if(ar[i] == ar[i-1]) {
		    			if(count % 2 == 0) {
		    				ans--;
		    				count++;
		    			}else {
		    				ans++;
		    				count++;
		    			}
		    		}else {
		    			count = 0;
		    			ans++;
		    		}
		    	}else {
		    		ans++;
		    		count = 0;
		    	}
		    }
		    
		    System.out.println(ans);
		    
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
}


Measured memory_bytes: 49668
from collections import defaultdict
n, a = map(int, input().split())
x = list(map(int, input().split()))

dp = [defaultdict(int) for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    for j in reversed(range(n)):
        for s in dp[j]:
            dp[j+1][s+x[i]] += dp[j][s]

# for dp_i  in dp:
#     print(dp_i)

ans = 0
for i in range(1, len(dp)):
    ans += dp[i][a*i]
print(ans)


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N - 2; ++i) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import std;

alias P = Tuple!(double, "x", double, "y");

double radians(double deg) {
    return PI * deg / 180.0;
}

P rotate(P p, double degree) {
    auto rad = radians(degree);
    auto x = p.x * cos(rad) - p.y * sin(rad);
    auto y = p.x * sin(rad) + p.y * cos(rad);
    return P(x, y);
}

double calc(double a, double b, double h, double m) {
    // 短針:
    //     1 周するのに 12 * 60 分
    //     現在の角度 = (60 * h + m) / (12 * 60) * 360
    // 長針:
    //     1 周するのに 60 分
    //     現在の角度 = m / 60 * 360

    auto s = rotate(P(0, a), (60 * h + m) / (12 * 60) * 360);
    auto t = rotate(P(0, b), m / 60 * 360);
    return hypot(s.x - t.x, s.y - t.y);
}

// 複素数を用いた解法
double calc2(double a, double b, double h, double m) {
    auto s = fromPolar(a, (60 * h + m) / (12 * 60) * 2 * PI);
    auto t = fromPolar(b, m / 60 * 2 * PI);
    return abs(s - t);
}

// Vec2 を用いた解法
double calc3(double a, double b, double h, double m) {
    auto s = Vec2(0, a).rotate((60 * h + m) / (12 * 60) * 2 * PI);
    auto t = Vec2(0, b).rotate(m / 60 * 2 * PI);
    return Vec2.distance(s, t);
}

void main() {
    int a, b, h, m; scan(a, b, h, m);
    writefln("%.20f", calc3(a, b, h, m));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

struct Vec2 {
    immutable double x;
    immutable double y;

    this(double x, double y) {
        this.x = x;
        this.y = y;
    }

    double dot(Vec2 other) { return this.x * other.x + this.y * other.y; }
    double cross(Vec2 other) { return this.x * other.y - other.x * this.y; }
    double mag() { return sqrt(magSq()); }
    double magSq() { return this.x * this.x + this.y * this.y; }

    Vec2 normalized() {
        auto m = mag();
        if (m != 0 && m != 1)
            return Vec2(this.x / m, this.y / m);
        return this;
    }

    Vec2 rotate(double rad) const {
        auto x2 = this.x * cos(rad) - this.y * sin(rad);
        auto y2 = this.x * sin(rad) + this.y * cos(rad);
        return Vec2(x2, y2);
    }

    static double distance(Vec2 a, Vec2 b) {
        return (a - b).mag();
    }

    // a の b への射影を求める
    static Vec2 project(Vec2 a, Vec2 b) {
        auto e = b.normalized();
        return a.dot(e) * e;
    }

    Vec2 opUnary(string op)() if (op == "-") { return Vec2(-this.x, -this.y); }
    Vec2 opBinary(string op)(Vec2 o) if (op == "+") { return Vec2(this.x + o.x, this.y + o.y); }
    Vec2 opBinary(string op)(Vec2 o) if (op == "-") { return Vec2(this.x - o.x, this.y - o.y); }
    Vec2 opBinary(string op)(double d) if (op == "*") { return Vec2(this.x * d, this.y * d); }
    Vec2 opBinaryRight(string op)(double d) if (op == "*") { return Vec2(this.x * d, this.y * d); }
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string s; cin >> s;
  string p(s);
  reverse(p.begin(), p.end());
  if (s == p) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 256
S=input()

S = S.replace("dream","w")
S = S.replace("erase","x")
S = S.replace("wer","y")
S = S.replace("xr","z")

if len(S) == S.count("w")+S.count("x")+S.count("y")+S.count("z"):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 62632
S = input()
Q = int(input())
query = [0]*Q

for i in range(Q):
    inp = input()
    if inp == "1":
        query[i] = "1"
    else:
        query[i] = list(inp.split())

left_head_if_even = 0
right = ""
left = ""

for i in range(Q):
    if query[i] == "1":
        left_head_if_even += 1
    else:
        if query[i][1] == "1":
            if left_head_if_even%2 == 0:
                left = query[i][2] + left
            else:
                right = right + query[i][2]

        else:
            if left_head_if_even%2 == 1:
                left = query[i][2] + left
            else:
                right = right + query[i][2]

if left_head_if_even%2==0:
    S = left + S + right
else:
    S = left + S + right
    S = S[::-1]

print(S)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
    double r;
    cin>>r;
    double ans=2.0;
    ans*=r;
    ans*=3.1415926535;
    cout<<fixed<<setprecision(10)<<ans;
}

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

int main () {
    string s; cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    if (a+b+c+d == 7) printf("%d+%d+%d+%d=7", a, b, c, d);
    else if (a+b+c-d == 7) printf("%d+%d+%d-%d=7", a, b, c, d);
    else if (a+b-c+d == 7) printf("%d+%d-%d+%d=7", a, b, c, d);
    else if (a-b+c+d == 7) printf("%d-%d+%d+%d=7", a, b, c, d);
    else if (a+b-c-d == 7) printf("%d+%d-%d-%d=7", a, b, c, d);
    else if (a-b-c+d == 7) printf("%d-%d-%d+%d=7", a, b, c, d);
    else if (a-b-c-d == 7) printf("%d-%d-%d-%d=7", a, b, c, d);
    else if (a-b+c-d == 7) printf("%d-%d+%d-%d=7", a, b, c, d);
    else ;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(void)
{
    ll x, y;
    cin >> x >> y;
    ll ans = mod;
    if(y>=x)
        ans = min(ans, y - x);
        if(y>=-x)
            ans = min(ans, y + x + 1);
            if(-y>=x)
                ans = min(ans, -y - x + 1);
                if(-y>=-x)
                    ans = min(ans, -y + x + 2);
                cout << ans << endl;
                return 0;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 2e5 + 10;
int cnt[N];
vector<int> a[N];

void DFS(int u, int parent) {
  for (auto& v : a[u]) {
    if (v == parent) continue;
    DFS(v, u);
    cnt[u]++;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int p;
    scanf("%d", &p);
    --p;
    a[p].push_back(i);
  }
  DFS(0, -1);
  for (int i = 0; i < n; ++i) {
    printf("%d\n", cnt[i]);
  }
  return 0;
}


Measured memory_bytes: 27944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

const ll INF=1e18;
void chmin(ll &a,ll b){
    if(a>b) a=b;
}

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

  vector<ll> dp(N+1,INF);
  reverse(S.begin(),S.end());
  dp[0]=0;
  ll mi=0;
  for(int i=0;i<N;i++){
      int now=S[i]-'0';
      chmin(dp[i+1],dp[i]+now);
      chmin(dp[i+1],mi+now+1+1);
      if(i==N-1) chmin(dp[i+1],mi+10-now+1);
      mi+=9-now;
      chmin(mi,dp[i+1]);
  }
  cout<<dp[N]<<endl;


  return 0;
}


Measured memory_bytes: 9220
#include <iostream>
#include <queue>
#include <string>

int main()
{
    std::queue<std::string> process;
    std::queue<int> left_time;
    
    int number_process, max_time;
    std::cin >> number_process >> max_time;//?????????????????°??¨??????????????????????????????????????????
    
    for(int i = 0; i < number_process; i++) {//???????????????????????????????????±???????????????
        std::string process_name;
        int process_time;
        
        std::cin >> process_name >> process_time;
        
        process.push(process_name);
        left_time.push(process_time);
    }
    
    int left_process = number_process;
    
    while(left_process != 0) {//????????????????????????????????§??°?????????
        static int now_time = 0;
        std::string now_process;
        int now_process_time;
        
        now_process = process.front();
        process.pop();
        
        now_process_time = left_time.front();
        left_time.pop();
        
        if(now_process_time > max_time) {//?????§????????????????????????????????£???????????£????????????????????????
            now_process_time -= max_time;//?????????????????????
            process.push(now_process);//?????\?????????????????\?????????
            left_time.push(now_process_time);
            
            now_time +=max_time;//max_time????????????????????????
        } else {
            now_time += now_process_time;//??????????????????????????????????????????
            
            std::cout << now_process << " " << now_time << std::endl;//????????£????????§??????
            
            left_process--;//?????£???????????????????????°?????????????????????
        }
    }
    
    return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){

  int k;
  cin >> k;
  int res;
  vector<int> v = {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} ;
  
  res = v[k-1];

  cout << res << endl;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if (V <= W) {
        cout << "NO" << endl;
        return 0;
    }
    ll D = abs(B - A);
    if (T * (V - W) >= D)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3652
N = int(input())
i = 0
S = 'a'
if N == 0:
    S += '0'
while N != 0:
    if i % 2 == 0:
        if N % 2**(i+1) == 0:
            S += '0'
        else:
            N -= 2**i
            S += '1'
    else:
        if N % 2**(i+1) == 0:
            S += '0'
        else:
            N += 2**i
            S += '1'
    i += 1
print(S[:0:-1])

Measured memory_bytes: 3060
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0360?year=2017

#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;

    bool double_booked = false;
    for (int i = 0; i < n; ++i) {
        int s, f;
        cin >> s >> f;
        if (max(a, s) < min(b, f)) double_booked = true;
    }

    cout << (double_booked ? 1 : 0) << endl;
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(i,a,b) for(int i=a;i<b;i++)
#define incl(i,a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define PII pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

int mygcd(int a,int b)
{
    if(b==0)
        return a;
    return mygcd(b,a%b);
}

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

int temp,temp1,temp2;

signed main()
{
    fatafat;
    string s;
    cin>>s;
    int cnt1=0,cnt2=0;
    for(unsigned int i=0;i<s.size();i++)
    {
        if((s[i]-'0')!=i%2)
            cnt1++;
        else
            cnt2++;
    }
    //cout<<cnt1<<" "<<cnt2;
    cout<<min(cnt1,cnt2);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
    FIO
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++){cin>>v[i];}
    int cnt=0;
    for(int i=0;i<v.size();i++){
        if(v[i]>=k){
            cnt++;
        }
    }
    cout<<cnt;
    
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<long double> res;
    long double ans = 0;
    long double cnt = 0;

    rep(i, n) {
        cin >> x[i];
        cin >> y[i];
    }
    vector<ll> ptn(n);
    rep(i, n) ptn.at(i) = i;

    do {
        // rep(i, ptn.size()) cout << ptn.at(i) << ' ';
        // cout << endl;
        for(size_t i = 0; i < n - 1; i++) {
            res.push_back((long double)sqrt(
                pow(x.at(ptn.at(i)) - x.at(ptn.at(i + 1)), 2) +
                pow(y.at(ptn.at(i)) - y.at(ptn.at(i + 1)), 2)));
        }
        cnt++;

    } while(next_permutation(all(ptn)));

    rep(i, res.size()) {
        ans += res.at(i);
        // cout << res.at(i) << endl;
    }
    // cout << ans / cnt << endl;ac
    ans /= cnt;
    // printf("%f16", (double)ans);
    cout << fixed << setprecision(10) << ans;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  vi32 a(n); cin >> a;
  vi32 sul(n + 1), sur(n + 1);
  rep(i, n) sul[i + 1] = max(sul[i], a[i]);
  rrep(i, n) sur[i] = max(sur[i + 1], a[i]);
  rep(i, n) {
    cout << max(sul[i], sur[i + 1]) << '\n';
  }
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <stdlib.h>
 
static int stack[100];
static int top = 0;
 
int isEmpty(void) {
  if (top == 0) {
    return -1;
  }
  return 0;
}
 
int isFull(void) {
  if (top == 100) {
    return -1;
  }
  return 0;
}
 
void push(int v) {
  if (isFull() < 0) {
    puts("push ERROR: stack full");
    exit(EXIT_FAILURE);
  }
  stack[++top] = v;
}
 
int pop(void) {
  if (isEmpty() < 0) {
    puts("pop ERROR: stack empty");
    exit(EXIT_FAILURE);
  }
  return stack[top--];
}
 
int main(void) {
  int a, b;
  char input[100];
   
  while ( scanf("%s", input) != EOF ) {
    switch (input[0]) {
    case '+':
      b = pop();
      a = pop();
      push(a+b);
      break;
    case '-':
      b = pop();
      a = pop();
      push(a-b);
      break;
    case '*':
      b = pop();
      a = pop();
      push(a*b);
      break;
    default:
      push(atoi(input));
    }
  }
  printf("%d\n", pop());
 
  exit(EXIT_SUCCESS);
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define COUNTER int i= 0,j = 0,k = 0,l = 0;

using namespace std;

int main (void){
    
    COUNTER
    double eyseight[43][2];
    int answer[43][2] = {0};
    
    while(cin >> eyseight[i][0] >> eyseight[i][1])
    {
        int j = 0;
        while(j != 2)
        {
            if(eyseight[i][j] >= 1.1)
                answer[0][j]++;
            else if(eyseight[i][j] < 1.1 && eyseight[i][j] >= 0.6)
                answer[1][j]++;
            else if (eyseight[i][j] < 0.6 && eyseight[i][j] >=0.2)
                answer[2][j]++;
            else
                answer[3][j]++;
            j++;
        }
        i++;
    }
    REP(j,4)
    {
        cout << answer[j][0] <<" " << answer[j][1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
int main(){
	int n,k,sum=0,max=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&k);
		if(k>max)max=k;
		sum+=k;
	}
	sum-=max/2;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N;
int main(){
	cin>>N;
	vector<ll> A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(),A.end());
	ll x=A[N-1];
	ll ma=0;
	ll ans;
	for(int i=0;i<N-1;i++){
		ll mi=min(A[i],x-A[i]);
		if(ma<=mi)ans=A[i],ma=mi;
	}
	cout<<x<<" "<<ans<<endl;
}

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

int main(void)
{
	int r,c,d;
	int ct[101];

	cin >> r >> c;
	rep(i, c+1) ct[i] = 0;
	rep(i,r)
	{
		int rt = 0;
		rep(j, c) {
			cin >> d;
			rt += d;

			cout << d << " ";
			ct[j] += d;
		}
		cout << rt << endl;
		ct[c] += rt;
	}
	rep(i, c)
		cout << ct[i] << " ";
	cout << ct[c] << endl;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

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


    cout<<max(b+c-a,0);
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main() {
    int q, x;
    char com[20];
    // 標準ライブラリよりlistを使用
    list<int> v;
    scanf("%d", &q);
    for (int i = 0; i < q; i++){
        scanf("%s", com);
        if (com[0] == 'i'){
            // insert
            scanf("%d", &x);
            v.push_front(x);
        }
        else if (com[6] == 'L'){
            // deleteLast
            v.pop_back();
        }
        else if (com[6] == 'F'){
            // deleteFirst
            v.pop_front();
        }
        else if (com[0] == 'd'){
            // delete
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++){
                if (*it == x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++){
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 33984
import java.util.*;
import java.io.*;
public class Main{
  public static void main(String[] args) throws IOException{
    StringBuilder sb = new StringBuilder();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n =Integer.parseInt(br.readLine());
    boolean[] arr = new boolean[n+1];
    String s = br.readLine();
    String[] str = s.trim().split("\\s+");
    TreeMap<Integer, Integer> map = new TreeMap<Integer,Integer>();
    for(int i=0;i<n-1;i++){
      //int a = sc.nextInt();
      int a = Integer.parseInt(str[i]);
      arr[a]=true;
      if(map.get(a)!=null){
        map.put(a, map.get(a)+1);
      }
      else{
        map.put(a,1);
        //arr.remove((Integer)a);
      }
    }
    for(int i=1;i<arr.length;i++){
      if(arr[i]==false){
        map.put(i,0);
      }
    }
    map.forEach((k, v) -> sb.append(v+"\n")); 
    System.out.print(sb);
  }
}

Measured memory_bytes: 79120
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=0,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> A >> B >> C;
  Out(min(B,C));
  if(B+C-A<0)Out(0);
  else Out(B+C-A);
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi a(n); rep(i, n) std::cin >> a[i];
  sort(a.rbegin(), a.rend());
  double mid = a[0] / 2.0, dist = inf;
  int candidate = inf;
  rrep(i, n-1) {
    double tmp = abs(mid - a[i]);
    if (dist > tmp) dist = tmp, candidate = a[i];
  }
  std::cout << a[0] << ' ' << candidate << "\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define*********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void) {
	ll N; cin >> N;
	ll ans = 0;
	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (ll n = 1; n <= sqrt(N); n++) {
		if (N %n == 0) {
			if (n != 1) {
				if (N / (n - 1) == N % (n - 1)) ans += n - 1;
			}
			if (N*n / (N - n) == N % (N / n - 1)) ans += N / n - 1;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

vector<ll> V;

void prime(ll N){

bool C = 1;

    for(ll i = 2; i <= sqrt(N); i++){

    if(N%i == 0){C = 0;break;}
   
    }

if(C)V.push_back(N);

}

int main(){
ll Q;cin >> Q;
vector<ll> A;

rep(i, 2, 100000)prime(i);

//for(auto v : V )cout << v << endl;

rep(i, 0, V.size()){

    bool C = binary_search(ALL(V), (V[i] + 1)/2);

    if(C)A.push_back(V[i]);

}

rep(i, 1, Q + 1){

    ll l, r;cin >> l >> r;

    ll p = A.end() - lower_bound(ALL(A), l), q = A.end() - upper_bound(ALL(A), r);

    cout << p - q << endl;

}
}

Measured memory_bytes: 3816
#include<iostream>
using namespace std; 
 
int main(void){
  int n,m,a,b;
  cin >> n >> m >> a >> b;
  int x[n+1];
  int y[m+1];
  for(int i=0; i<n; i++) cin >> x[i];
  for(int i=0; i<m; i++) cin >> y[i];
  x[n] = a;
  y[m] = b;
  int x_max = -100;
  int y_min = 100;
  for(int i=0; i<n+1; i++){
    if(x_max<=x[i])x_max=x[i];
  }
  for(int i=0; i<m+1; i++){
    if(y_min>=y[i])y_min=y[i];
  }
  int z = x_max+1;
  if(z <= y_min){
    if(a<b){
      cout<<"No War"<<endl;
    }
  } else{
    cout<<"War"<<endl;
  }
}

Measured memory_bytes: 256
x = [0 for i in range(26)]
while True:
    try:
        s  = input().lower()
    except:
        break
    for i in range(len(s)):
        t = ord(s[i])-ord("a")
        if (t>=0 and t<26) :
            x[t] += 1

for i in range(26):
    print(f"{chr(97+i)} : {x[i]}")
        


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

int main(){
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    
    double x=(30*H-5.5*M)*M_PI/180;

    
   
    double c = cos(x);



    printf("%.21f\n",sqrt(A*A+B*B-2*A*B*c));
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ll X, K;
    cin >> X >> K;
    vector<ll> R(K+2, 0);
    for (int i = 1; i <= K; i++) scanf("%lld", &R[i]);
    R[K+1] = 1e18;
    int Q;
    cin >> Q;
    vector<ll> T(Q), A(Q);
    for (int i = 0; i < Q; i++) scanf("%lld %lld", &T[i], &A[i]);
    int pos = 0;
    bool increase = true;
    ll l = 0, r = X, smin = 0;
    vector<ll> ans(Q, 0);
    for (int i = 0; i <= K; i++) {
        increase = !increase;
        //cout << l << " " << r << " " << smin << endl;
        while (pos < Q && T[pos] < R[i+1]) {
            if (increase) ans[pos] = clamp(clamp(A[pos], l, r)-l+smin+T[pos]-R[i], 0LL, X);
            else ans[pos] = clamp(clamp(A[pos], l, r)-l+smin-(T[pos]-R[i]), 0LL, X);
            pos++;
        }
        if (increase) {
            if (r-l+smin+(R[i+1]-R[i]) >= X) {
                r = max(l, X-(R[i+1]-R[i])+l-smin);
            }
            smin = min(X, smin+R[i+1]-R[i]);
        }
        else {
            if (R[i+1]-R[i] >= smin) {
                l = min(r, l-smin+(R[i+1]-R[i]));
            }
            smin = max(0LL, smin-(R[i+1]-R[i]));
        }
    }
    
    for (int i = 0; i < Q; i++) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 6468
import java.util.*;

public class Main {
    public static void main(String[] args) {
        aldl_1_2_b();
    }

    static void aldl_1_2_b() {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            data.add(sc.nextInt());
        }
        sc.close();
        int count = 0;

        for (int i = 0; i < data.size() - 1; i++) {
            int minIndex = -1;
            int min = data.get(i);
            for (int j = i+1; j < data.size(); j++) {
                if (data.get(j) < min) {
                    min = data.get(j);
                    minIndex = j;
                }
            }
            if (minIndex > 0) {
                data.set(minIndex, data.get(i));
                data.set(i, min);
                count++;
            }
        }
        for (int i = 0; i < data.size(); i++) {
            if (i > 0)
                System.out.print(" ");
            System.out.print(data.get(i));
        }
        System.out.println();
        System.out.println(count);
    }
}


Measured memory_bytes: 26380