akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


typedef long long ll;

using namespace std;


const ll mod=1000000000+7;

struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};


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

    dsu d(N);

    int a,b;

    for(int i=0;i<M;i++){
        cin>>a>>b;
         --a;--b;
        d.merge(a,b);
    }

    cout<<d.groups().size()-1<<endl;


}

Measured memory_bytes: 8940
n = gets.to_i
as = gets.split.map(&:to_i)

cs = as.each_with_object(Hash.new(0)) do |a, h|
  h[a] += 1
end

sum = cs.values.inject(0) do |r, v|
  r + v * (v - 1) / 2
end

as.each do |a|
  c = cs[a]
  orig = c * (c - 1) / 2
  extracted = (c - 1) * (c - 2) / 2

  puts sum - (orig - extracted)
end


Measured memory_bytes: 29700
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  int N, W;
  cin >> N >> W;
  
  ll w1 = 0;
  vector<vector<ll> > vec(4);
  for (int i = 0; i < N; i++) {
    ll w, v;
    cin >> w >> v;
    
    if (w1 == 0) {
      w1 = w;
    }
    vec[w - w1].push_back(v);
  }
  for (int i = 0; i < 4; i++) {
    sort(vec[i].begin(), vec[i].end());
    vec[i].push_back(0);
    reverse(vec[i].begin(), vec[i].end());
    for (int j = 1; j < vec[i].size(); j++) {
      vec[i][j] += vec[i][j - 1];
    }
  }
  
  ll maxv = 0;
  for (int i = 0; i < vec[0].size(); i++) {
    for (int j = 0; j < vec[1].size(); j++) {
      for (int k = 0; k < vec[2].size(); k++) {
        for (int l = 0; l < vec[3].size(); l++) {
          ll weight = i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3);
          if (weight <= W) {
            maxv = max(maxv, vec[0][i] + vec[1][j] + vec[2][k] + vec[3][l]);
          }
        }
      }
    }
  }
  cout << maxv << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename T>
string to_string(vector<T> v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool ok = false;
  while (true) {
    if (ok) break;
    long long sum = 0;
    for (int i = 0; i < (int) s.size(); i++) {
      sum += (s[i] - '0');
    }
    if (sum < 10) {
      ok = true;
      if (sum % 9 != 0) {
        cout << "No\n";
      } else {
        cout << "Yes\n";
      }
    }
    s = to_string(sum);
  }
  return 0;
}


Measured memory_bytes: 3792
import itertools

N = int(input())
Fs = [tuple(map(int, input().split())) for i in range(N)]
Ps = [tuple(map(int, input().split())) for i in range(N)]

ans = -float('inf')
for numOP in range(1, 11):
    for iOPs in itertools.combinations(range(10), numOP):

        profit = 0
        for F, P in zip(Fs, Ps):
            c = sum([F[i] for i in iOPs])
            profit += P[c]
        ans = max(ans, profit)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;

int main() {
	
	int a, b, k;
	cin >> a >> b;
	if ((a+b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()
f = True
for a in S[:A]:
    if not a.isdecimal():
        f = False
if S[A] != "-":
    f = False
for b in S[A+1:]:
    if not b.isdecimal():
        f = False
if f:
    print("Yes")
else:
    print("No")

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

vector<int>tree[100000];
int depth_u[100000],depth_v[100000];
bool visited_u[100000],visited_v[100000];

void dfs(int v,int p,int cost,bool f){
    if(f){//u
        visited_u[v]=true;
        depth_u[v]=cost;
    }
    else{//v
        visited_v[v]=true;
        depth_v[v]=cost;
    }
    for(auto x:tree[v])if(x!=p)dfs(x,v,cost+1,f);
    return;
}
int main(){
    int n,u,v,a,b,ans=0;
    cin>>n>>u>>v;
    
    for(int i=1;i<n;i++){
        cin>>a>>b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    dfs(u-1,-1,0,true);dfs(v-1,-1,0,false);
    for(int i=0;i<n;i++){
        if(depth_u[i]<depth_v[i])ans=max(ans,depth_v[i]-1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11776
import std.stdio, std.string, std.conv;
import std.algorithm;

void main() {
	auto input = getStdin!(string[]);
	string s = input[0] ~ input[0];
	string p = input[1];
	if (s.count(p) > 0) {
		"Yes".writeln;
	}
	else {
		"No".writeln;
	}
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2504
import math
import pprint
#N以下の0以外のK種類の数が含まれている数字列
N = int(input())
K = int(input())


N_d = int(math.log10(N))


def N_n(n):
    return int(N//(10**(n))%(10))

dp = [[[-1]*2 for i in range(K+2)] for i in range(int(math.log10(N))+2)]




def rec(i,j,t):
    if j < 0 :
        return 0

    if dp[i][j][t]!=-1:
        return dp[i][j][t]
    
    nnn = N_n(i)
    #print("start",i,j,t, nnn)
    if i == 0:
        if j == 0:
            dp[i][j][t] = 1
        elif j == 1:
            if t:
                dp[i][j][t] = nnn
            else:
                dp[i][j][t] = 9
        else:
            dp[i][j][t] = 0
    else:
        if t:
            if nnn==0:
                dp[i][j][t] = rec(i-1,j,True)
            else:
                dp[i][j][t] = rec(i-1,j,False) + (rec(i-1,j-1,False) * (nnn-1)) + (rec(i-1,j-1,True))
        else:
            dp[i][j][t] = rec(i-1,j,False) + (rec(i-1,j-1,False) * 9)
    return dp[i][j][t]

print(rec(N_d,K,True))
#pprint.pprint(dp)

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

int main()
{
    int a,b,x,y,r;
    cin >> a >> b >> x >> y >> r;
    
   if(x-r < 0 || x+r > a || y+r >b || y-r < 0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
import sys
import math

input = sys.stdin.readline
n = int(input())
int_list = [int(input()) for i in range(n)]

count = 0
for i in int_list:
    x = i ** 0.5
    min_int = math.ceil(x)
    check_list = []
    for j in range(2, min_int+1):
        if i % j == 0 and i >= j:
            check_list.append('C')
            break
        else:
            check_list.append('S')

    if 'C' not in check_list:
        count += 1
    if i == 2:
        count += 1

print(count)



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

int main() {
  
  int n, a;
  cin >> n;
  
  a = 1;
  

  
  for(int i = 0; i < n;  i++){
    if(a*2 <= n){
      a *= 2;
    }
    
    else{
      cout << a << endl;
      break;
    }
  }
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,i=1;
    cin >> n;
    while(pow(i,2) <= n)i++;
    cout << (int)pow(i-1,2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
 
int main() {
    int n;
    cin >> n;
    map<string, int> ma;
    vector<string> s(n);
    rep(i, n) {
        string S;
        cin >> S;
        s[i] = S;
    }
    sort(s.begin(), s.end());
    rep(i, n) if(!ma.count(s[i])) ma[s[i]]++;
    rep(i, n) if(s[i] == s[i + 1]) ma[s[i]]++;
    int Max = -1;
    rep(i, n) Max = max(Max, ma[s[i]]);
    // cout << Max << endl;
    rep(i, n) if(ma[s[i]] == Max) {
        cout << s[i] << endl;
        i += Max - 1;
    }
    // cout << ma.size() << endl;
}

Measured memory_bytes: 25108
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$W = $key->A[0];
$a = $key->A[1];
$b = $key->A[2];

if ($a < $b) {
  //箱の終了位置
  $l = $a + $W;
  printf("%d\n",max($b-$l,0));
}
else {
  $l = $b + $W;
  printf("%d\n",max($a-$l,0));
}


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

int main(){
    int p[5]={0},ja,jb,ans=0;
    cin >>p[1]>>p[2]>>p[3]>>ja>>jb;
    sort(p, p+4);
    ans+=p[1];
    if(ja>jb)ans+=jb;
    else ans+=ja;
    ans-=50;
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string A = S;
    int lenS = S.length();

    for(size_t c = A.find_first_of('x'); c != string::npos; c = c = A.find_first_of('x')){
        A.erase(c,1);
    }
    int lenA = A.length();
    rep(i, lenA/2) {
        if (A[i] != A[lenA - i - 1]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    if (lenA == 0) {
        cout << "0" << endl;
        return 0;
    }
    int flag = 0;
    rep(i, lenS/2) {
        if (S[i] != S[lenS - i - 1]) {
            flag = 1;
        }
    }
    if (flag == 0) {
        cout << "0" << endl;
        return 0;
    }
    int cnt = 0;
    int i = 0;
    char test = A[lenA/2];
    int T = 0;
    int k = 0;
    while(k != (lenA+1)/2){
        if (S[i] != 'x') k++;
        i++;
    }
    i--;
    //dump(i);
    int j = 1;
    int L = 0;
    int R = lenS - 1;
    while(L < R) {
        if (S[L] != S[R]) {
            cnt++;
            if (S[L] == 'x') L++;
            else R--;
        } else {
            L++;
            R--;
        }
        
    } 
    //dump(lenS);
    //dump(lenA);
    //dump(cnt);
    cout << cnt << endl;
    
    


    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int judge(int i,int j,int k,int x){
    if(500*i+100*j+50*k==x)return 1;
    return 0;
}

int main(){
    int a, b, c, x, count=0;
    cin >> a >> b >> c >> x;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            for(int k=0;k<c+1;k++){
                count+=judge(i,j,k,x);
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using dl = long double;
int main()
{

    string s;cin>>s;
    int n  = s.length();
    int c=0;

        for(int i=0;i<n/2;i++){
            if(s[i]!=s[n-i-1])c++;
        }

        cout<<c;



    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  
  vector<int> ai(N);
  for (int i = 0; i < N; i++) {
    cin >> ai.at(i);
  }

  for (int i = 0; i < N ; i = i+2) {
    if (ai.at(i) % 2 == 1) {
      ans ++;
    }
  }

  cout << ans << endl;
}

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

namespace _0254
{
    class Program
    {
        static void Main(string[] args)
        {

            //var exStdIn = new System.IO.StreamReader("stdin.txt");
            //Console.SetIn(exStdIn);

            while (true)
            {
                int[] nm = RArInt();
                if (nm.Sum() == 0) break;
                int m = nm[1];

                long[] cumSumMod = new long[nm[0] + 1];
                int[] ks = RArInt();
                cumSumMod[0] = 0;
                for (int i = 0; i < ks.Length; i++)
                {
                    cumSumMod[i + 1] = (cumSumMod[i] + ks[i]) % m;
                }

                long res = 0;
                SortedList<long, long> ss = new SortedList<long, long>();
                ss.Add(cumSumMod[0], 0);
                for (int i = 1; i < cumSumMod.Length; i++)
                {
                    long j = UpperBound(ss, cumSumMod[i]);
                    res = Math.Max(res, (cumSumMod[i] - j + m) % m);
                    if (res == m - 1) break;
                    if(!ss.ContainsKey(cumSumMod[i])) ss.Add(cumSumMod[i], cumSumMod[i]);
                }
                Console.WriteLine(res);
            }
        }

        public static long UpperBound(SortedList<long, long> arr, long value)
        {
            int low = 0;
            int high = arr.Count();
            int mid;
            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (arr.Keys[mid] <= value)
                    low = mid + 1;
                else
                    high = mid;
            }
            return low != arr.Count() ? arr.Keys[low] : 0;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 40788
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char c[] = sc.next().toCharArray();
		for (int i=0; i<c.length; i++) {
			c[i] = (char)((c[i]-'A'+N) % 26 + 'A');
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ld a,b,h,m;cin>>a>>b>>h>>m;
    ld pi = acos(-1);
    ld t1 = 360*(60*h+m)/(12*60) * (pi/180);
    ld t2 = 360 * (m/60) * (pi/180);

    ld csa = a*cos(t1);
    ld sia = a*sin(t1);

    ld csb = b*cos(t2);
    ld sib = b*sin(t2);
    cout<<sqrt((csa-csb)*(csa-csb) + (sia-sib)*(sia-sib))<<endl;
}

Measured memory_bytes: 4184
import itertools
n_people, n_food = map(int, input().split(" "))
d_list = []
A_list = []
for i in range(n_food):
    d = int(input())
    A = [int(_) for _ in input().split(" ")]
    d_list.append(d)
    A_list.append(A)
    
print(n_people - len(set(itertools.chain.from_iterable(A_list))))

Measured memory_bytes: 9188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        String s1 = s.next();
        if(Character.isUpperCase(s1.charAt(0)))
            System.out.println("A");
        else
            System.out.println("a");

    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 25324
def main():
    N, M = map(int, input().split(" "))
    X = sorted(map(int, input().split(" ")))
    if N >= M:
        print(0)
        return
    subX = sorted([X[i+1] - X[i] for i in range(M-1)])
    if N == 1:
        print(sum(subX))
        return
    print(sum(subX[:-(N-1)]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 13968
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n, k;
	cin >> n >> k;

	if(k == 1)
		cout << 0 << endl;
	else
		cout << n - k << endl;
	return 0;
}

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

using namespace std;
#define ll long long

const int maxn = 1e5 + 100;
const ll inf = 1e18;

ll x[maxn];
ll dp[maxn], seg[maxn * 4];


void add(int v, int l, int r, int i, ll val)
{
    if(r - l == 1)
    {
        seg[v] = val;
        return ;
    }
    int mid = (l + r) / 2;
    if(i < mid)
        add(v * 2, l, mid, i, val);
    else
        add(v * 2 + 1, mid, r, i, val);
    seg[v] = min(seg[v * 2], seg[v * 2 + 1]);
}

ll query(int v, int l, int r, int b, int e)
{
    if(e <= l || r <= b)
        return inf;
    if(b <= l && r <= e)
        return seg[v];
    int mid = (l + r) / 2;
    return min(query(v * 2, l, mid, b, e), query(v * 2 + 1, mid, r, b, e));
}

int main()
{
    ll n, E, T;
    cin >> n >> E >> T;



    for(int i = 1; i <= n; i++)
        cin >> x[i], x[i] *= 2;

    add(1,0,n+1,0,-x[1]*2);
    for(int i = 1; i <= n; i++)
    {
        int j = lower_bound(x + 1, x + n + 1, x[i] - T) - x;

        if(x[j]>x[i]-T and j)
            j--;

        dp[i] = min(query(1, 0, n + 1, 0, j) + x[i] * 2,dp[j] + T*2 );



        add(1, 0, n + 1, i, dp[i] - 2 * x[i+1]);
    }

    cout << (dp[n] + E * 2) / 2 << endl;

}

Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
avg = sum(a) / n
min_i = 0
min_v = abs(a[0]-avg)
for i in range(len(a)):
    if min_v > abs(a[i]-avg):
        min_v = abs(a[i] - avg)
        min_i = i
print(min_i)


Measured memory_bytes: 3060
#ALDS1_2-C Sort 1 - Shell Sort
def insertionSort(A,n,g):
    cnt=0
    i=g
    while(i<n):
        v=A[i]
        j=i-g
        while(j>=0 and A[j]>v):
            A[j+g]=A[j]
            j=j-g
            cnt+=1
        A[j+g]=v
        i+=1
    return cnt


def shellSort(A,n):
    cnt=0
    G=[]
    h=1
    m=0
    shells=""
    while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

    if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
    print(shells[1:])
    for i in range(m):
        cnt+=insertionSort(A,n,G[i])
    print(cnt)

n=int(input())
A=[]
for i in range(n):
    A.append(int(input()))
shellSort(A,n)
for i in range(n):
    print(A[i])

Measured memory_bytes: 47420
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
int N; cin >> N; 
  vector<int> d(N);
  for(int i = 0; i < N; i++){cin >> d[i];}
  sort(d.begin(), d.end());
  
  cout << d[N/2] - d[N/2 - 1] << endl;
  return 0;}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool ans = false;
    if(abs(b-a) <= d && abs(c-b) <= d)ans=true;
    if(abs(c-a) <= d)ans=true;
    YN(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }



int main() {
  li cnt=0;
  int n; cin >>n;
  rep(i,n){
    int a=i+1;
    cnt+=(n-1)/a;
  }
  print(cnt);
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> a(n);
    int32 mx = - INF, mn = INF;
    int32 mxi, mni;
    REP(i,n){
        cin >> a[i];
        if(a[i] > mx){
            mx = a[i];
            mxi = i;
        }
        if(a[i] < mn){
            mn = a[i];
            mni = i;
        }
    }
    if(mn >= 0){
        cout << n - 1 << endl;
        REP(i, n-1){
            cout << i+1 << " " << i+2 << endl;
        }
    }else if(mx <= 0){
        cout << n-1 << endl;
        FORR(i,n-1,1){
            cout << i+1 << " " << i << endl;
        }
    }else if(mx > -mn){
        cout << 2 * n - 1 << endl;
        REP(i,n){
            cout << mxi + 1 << " " << i+1 << endl;
        }
        REP(i, n-1){
            cout << i+1 << " " << i+2 << endl;
        }
    }else{
        cout << 2 * n - 1 << endl;
        REP(i,n){
            cout << mni+1 << " " << i+1 << endl;
        }
        FORR(i,n-1,1){
            cout << i+1 << " " << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int a,b;
  rep(i,s.size()){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      b=i;
      break;
    }
  }
  cout<<b-a+1<<endl;
}

Measured memory_bytes: 720
n=int(input())
h=list(map(int,input().split()))
a=[0]*n
ans=0
while True:
    flag=0
    for i in range(n):
        if h[i]>a[i]:
            a[i]+=1
            flag=1
        elif h[i]==a[i] and flag:
            break
    if flag:
        ans+=1
    else:
        break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
	long long n;
	cin >> n;
	string o = "";
	while (n > 0) {
		n--;
		o += 'a'+(n%26);
		n /= 26;
	}
	reverse(o.begin(), o.end());
	cout << o << endl;
}

Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("commandos.in","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int * LIS_Lengths(vector<int> a) { int* lis = new int[a.size()];int b[a.size()];int maxLength = 1, lowerBound;lis[0] = 1, b[0] = a[0];for (size_t i = 1; i < a.size(); i++) {lowerBound = lower_bound(b, b + maxLength, a[i]) - b;lis[i] = lowerBound + 1;if (lowerBound == maxLength)    b[maxLength++] = a[i];else    b[lowerBound] = a[i];}return lis;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>

/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    int n,m;
    cin >> n >> m;
    vector<vi>g(n + 1);
    loop(m)
    {
        int x,y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    loop(n)
    {
        cout<<g[i+1].size()<<endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> v(10, vector<int>(10));
  for (int i = 1; i <= n; i++) {
    int last = i % 10, first = i;
    while (first >= 10) first /= 10;
    v.at(first).at(last)++;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += v.at(i).at(j) * v.at(j).at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n, m;
long a[1005];
long sum[1005];//累積和
long psum[2000000];//部分和
long bitflag = 1;


int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%ld", &a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	long pcnt = 0;
	for(int i = 0; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			psum[pcnt] = sum[j] - sum[i];
			pcnt++;
		}
	}
	long upmost = 0;
	for(long bitflag = 1; bitflag < 35184372088832; (bitflag <<= 1)){
		int cnt = 0;
		for(int i = 0; i < pcnt; i++){
			if(bitflag & psum[i]){
				cnt++;
			}
		}
		if(cnt >= m){
			upmost = bitflag;
		}
	}
	if(upmost == 0){
		printf("0\n");
		return 0;
	}
	//printf("%ld\n", upmost);
	std::set<int> st;
	for(int i = 0; i < pcnt; i++){
		st.insert(i);
	}
	while(upmost > 0){
		int cnt = 0;
		/*
		for(auto i = st.begin(); i != st.end(); i++){
			printf("%3ld ", psum[*i]);
		}
		printf("\n");
		//*/
		for(auto i = st.begin(); i != st.end(); i++){
			if(psum[*i] & upmost){
				cnt++;
			}
		}
		/*
		for(auto i = st.begin(); i != st.end(); i++){
			printf("%3ld ", psum[*i] & upmost);
		}
		printf("\n");
		//*/
		std::set<int> st2;
		if(cnt >= m){
			for(auto i = st.begin(); i != st.end(); i++){
				if(psum[*i] & upmost){
					st2.insert(*i);
				}
			}
			st = st2;
			st2.clear();
		}
		upmost >>= 1;
	}
	long ans = psum[*st.begin()];
	for(auto i = st.begin(); i != st.end(); i++){
		ans = (ans & psum[*i]);
	}
	printf("%ld\n", ans);
}
	


Measured memory_bytes: 33152
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  string s;
  cin >> s;
  int sum = 0;
  for(int i = 0; i < sz(s); i++) {
    sum = (sum + s[i] - '0') % 9;
  }
  if(sum) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int func(int x){
  for(int i=2;i<x;i++){
    if(x%i==0){
    return 0;
    }
  }
  return 1;
}


int main(){
  
   int N;
  cin>>N;
  bool a=false;
  while(a==false){
    if(func(N)==0){
      N++;
    }
    else if(func(N)==1){
      a=true;
      cout<<N<<endl;
    }
  }
}

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




//—————————————UnionFind木   UF uf(n);——————————————————————

struct UF {
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UF(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void reset(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

//—————————————————————————————————————————————————



int main() {
  int n,k,l;
  cin >>n>>k>>l;
  
  UF road(n);
  UF rail(n);
  
  rep(i,k){
  ll x,y;
  cin>>x>>y;
  road.unite(x-1,y-1);
  }
  rep(i,l){
  ll x,y;
  cin>>x>>y;
  rail.unite(x-1,y-1);
  }

  map<pair<ll,ll>,ll> p;
  rep(i,n){
    auto x=mp(road.root(i),rail.root(i));
    if(p.count(x)) p.at(x)++;
    else p[x]=1;
  }

  rep(i,n){
    auto x=mp(road.root(i),rail.root(i));
    cout << p.at(x) << " ";
  }
  
  cout << endl;
}


Measured memory_bytes: 18048
#include <iostream>
#include <bits/stdc++.h>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;

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

    int k;
    cin >> k;
    ll x= lcm(360,k);
    ll d= x/k;
    cout<< d<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include <string.h>

#include <algorithm>
#include <cmath>
#include <cstdlib>  // abs() for integer
#include <iostream>

using namespace std;

int main() {
  int H, W, K;  //行, 列, 残る黒いマス
  cin >> H >> W >> K;
  int c[H][W];  //マスの情報, 0:白, 1:黒
  string S[H];  //入力データ

  int black = 0;  //黒いマスの数

  //入力
  for (int i = 0; i <= H - 1; i++) {
    cin >> S[i];
    for (int j = 0; j <= W - 1; j++) {
      if (S[i][j] == '.') {  //白
        c[i][j] = 0;
      } else {  //黒
        c[i][j] = 1;
        black++;
      }
    }
  }

  int ans = 0;
  int c_original[H][W];

  for (int i = 0; i <= H - 1; i++) {
    for (int j = 0; j <= W - 1; j++) {
      c_original[i][j] = c[i][j];
    }
  }

  for (int i = 0; i <= pow(2, H) - 1; i++) {    // 2のH乗通り
    for (int j = 0; j <= pow(2, W) - 1; j++) {  // 2のW乗通り

      /*行*/
      for (int t = 0; t <= H - 1; t++) {  //ずらすビット
        if (((i >> t) & 1) == 1) {  //二進数表示したときにbitが1なら塗りつぶす
          for (int k = 0; k <= W - 1; k++) {
            c[t][k] = 0;  // x行目の塗りつぶし
          }
        }
      }

      /*列*/
      for (int s = 0; s <= W - 1; s++) {
        if (((j >> s) & 1) == 1) {
          for (int k = 0; k <= H - 1; k++) {
            c[k][s] = 0;
          }
        }
      }

      //計測
      int black_cnt = 0;
      for (int l = 0; l <= H - 1; l++) {
        for (int ll = 0; ll <= W - 1; ll++) {
          if (c[l][ll] == 1) {
            black_cnt++;
          }
        }
      }
      if (black_cnt == K) {
        ans++;
      }

      //初期化
      for (int l = 0; l <= H - 1; l++) {
        for (int ll = 0; ll <= W - 1; ll++) {
          c[l][ll] = c_original[l][ll];
        }
      }
    }
  }

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


Measured memory_bytes: 4092
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

static const int N = 100;



int main(void) {
	int n, p[N + 1], m[N + 1][N + 1];

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &p[i - 1], &p[i]);
	}

	for (int i = 1; i <= n; i++)m[i][i] = 0;
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	printf("%d\n", m[1][n]);

	return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
const int N=((int)1e5)*3+2;

int main(){
  long long int n,m;
  cin>>n>>m;
  long long int ans=1;
  for(long long int i=1;i*i<=m;++i){
    if(m%i==0){
      if(m/i * n <= m)
        ans=max(ans,m/i);
      if(i*n <= m)
        ans=max(ans,i);
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int n, count = 0;

	while(scanf("%d", &n) + 1){
		count = 0;
		for (int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						if(n == i + j + k + l){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
}

Measured memory_bytes: 1020
#include <stdio.h>

int main(void)
{
    int a, b, c, num;
    scanf("%d %d %d", &a, &b, &c);

    if(a > b){
        num = a;
        a = b;
        b = num;
    }
    if(b > c){
        num = b;
        b = c;
        c = num;
    }
    if(a > b){
        num = a;
        a = b;
        b = num; 
    }
    printf("%d %d %d\n", a, b, c);

    return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = scanner.nextDouble();
        double S = r*r*Math.PI;
        double L = 2*r*Math.PI;
        System.out.printf("%f %f\n",S,L);
    }

}

Measured memory_bytes: 28032
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          998244353
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<class T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll sx = in(), sy = in(), tx = in(), ty = in();
    REP(i, tx - sx)cout << 'R';
    REP(i, ty - sy)cout << 'U';
    REP(i, tx - sx)cout << 'L';
    REP(i, ty - sy)cout << 'D';

    cout << 'D';
    REP(i, tx - sx + 1)cout << 'R';
    REP(i, ty - sy + 1)cout << 'U';
    cout << 'L';
    cout << 'U';
    REP(i, tx - sx + 1)cout << 'L';
    REP(i, ty - sy + 1)cout << 'D';
    cout << 'R' << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h = Hash.new(0)
gets.chomp.split(" ").each do |a|
  h[a.to_i] += 1
end

n_even = 0
n_odd = 0
h.each do |k, v|
  if v.even? then
    n_even += 1
  else
    n_odd += 1
  end
end
if n_even.even? then
  puts n_odd + n_even
else
  puts n_odd + n_even - 1
end

Measured memory_bytes: 14340
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define foe(i,a) for(__typeof(a.begin())i=a.begin();i!=a.end();++i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef double ld;
typedef long long L;
typedef vector<int> VI;
typedef pair<int,int> pa;
const int mo=998244353,N=2.5e6+11;
L fpow(L a,L b){
	L r=1;
	for(;b;b>>=1,a=a*a%mo)
		if(b&1)r=r*a%mo;
	return r;
}
L jc[N+2],jcv[N+2];
L C(int n,int m){
	//assert(n<=N);
	return n<m?0:1ll*jc[n]*jcv[m]%mo*jcv[n-m]%mo;
}
L F(int n,int m){
	--n;
	return C(n+m,n);
}
L H(int n,int m){
	if(m<0) return 0;
	return C(n+m,n);
}
int M;
L G(int n,int m){
	if(n==1) return m<=2*M;
	L ans=F(n,m)-n*H(n-1,m-2*M-1);
	ans=(ans%mo+mo)%mo;
	return ans;
}
L GG(int n,int m,int i){
	if(m&1) return 0;
	m/=2;
	if(n==1) return m<=M;
	L ans=F(n,m)-i*H(n-1,m-M)-(n-i)*H(n-1,m-M-1);
	ans=(ans%mo+mo)%mo;
	return ans;

}
int main(){
	jc[0]=1;
	rep(i,1,N)jc[i]=jc[i-1]*i%mo;
	jcv[N]=fpow(jc[N],mo-2);
	per(i,1,N)jcv[i-1]=jcv[i]*i%mo;
	//cerr<<N<<endl;
	int n,m;
	cin>>n>>m;
	M=m;
	L ans=0;
	rep(i,0,m)ans=(ans+C(n,i)*GG(n,3*m-i,i))%mo;
	ans=(ans%mo+mo)%mo;
	cout<<ans<<endl;
	//cerr<<ans/2<<endl;
}

Measured memory_bytes: 39296
N = int(input())
AB = []
for i in range(N):
  AB.append(list(map(int, input().split())))
AB = sorted(AB, key = lambda x: x[1])

time = 0
f = False

for i in range(N):
  time += AB[i][0]
  if time > AB[i][1]:
    f = True
    break
if f:
  print("No")
else:
  print("Yes")

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

using i64 = int64_t;

int main(){
    i64 n;
    cin >> n;
    i64 ans = 1;
    for(i64 i=1;i*i<=n;++i){
        ans = i*i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,k;
    int n;
    // 整数の入力
    scanf("%d %d %d", &a, &b, &k);

    if(a == b){
       printf("%d\n",a);
    }else{
      n = b - a;
      if(n <  k * 2){
        for(a; a <= b; a++){printf("%d\n",a);}
      }else{
        int z = a + k;
        int m = b - k +1;
        
        for(a; a < z; a++){printf("%d\n",a);}
        for(m; m <= b; m++){printf("%d\n",m);}
      }
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
int main() {
  int a,b,c,i,d,e;
  while(1){
    std::cin>>a>>b>>c;
    e=a+b+c;
    if(e==0)break;
    int p[e];
    for(i=0; i<e; i++) p[i]=2;
    std::cin>>d;
    int s[4][d];
    for(i=0;i<d;i++) std::cin>>s[0][i]>>s[1][i]>>s[2][i]>>s[3][i];
    for(i=0;i<d;i++)
      if(s[3][i] == 1) p[s[0][i]-1]=1,p[s[1][i]-1]=1,p[s[2][i]-1]=1;
    for(i=0;i<d;i++) {
      if(p[s[0][i]-1]==1) s[0][i]=0;
      if(p[s[1][i]-1]==1) s[1][i]=0;
      if(p[s[2][i]-1]==1) s[2][i]=0;
    }
    for(i=0; i<d; i++){
      if((s[0][i]==0)&&(s[1][i]==0)) p[s[2][i]-1]=0;
      if((s[0][i]==0)&&(s[2][i]==0)) p[s[1][i]-1]=0;
      if((s[2][i]==0)&&(s[1][i]==0)) p[s[0][i]-1]=0;
    }
    for(i=0;i<e;i++) std::cout<<p[i]<<"\n";
  }
}

Measured memory_bytes: 0
n, q = map(int, input().split())
s = input()
t = [None] * q
d = [None] * q
for i in range(q):
    t[i], d[i] = input().split()
l, r = 0, n + 1
while r - l > 1:
    m = (l + r) // 2
    c = m - 1
    for i in range(q):
        if c >= 0 and s[c] == t[i]:
            if d[i] == 'L':
                c -= 1
            else:
                c += 1
        if c < 0:
            l = m
            break
        if c >= n:
            r = m
            break
    else:
        r = m
a = l
l, r = 0, n + 1
while r - l > 1:
    m = (l + r) // 2
    c = m - 1
    for i in range(q):
        if c < n and s[c] == t[i]:
            if d[i] == 'L':
                c -= 1
            else:
                c += 1
        if c >= n:
            r = m
            break
        if c < 0:
            l = m
            break
    else:
        l = m
b = n - l
print(max(0, n - a - b))


Measured memory_bytes: 75852
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int n, s = 0, k = 0;
	int a[20];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		s += a[i];
	}
	for (int i = 0; i < n; i++) {
		k = max(k, a[i]);
	}
	if (2 * k - s < 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256