akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

int main() {

    int N;
    std::cin >> N;

    std::vector<int> array;
    std::vector<int> result;

    for( int i = 0; i < N; ++i ) {
        int tmp;
        std::cin >> tmp;
        array.push_back(tmp);
    }

    bool fail = false;
    for( int i = N; i > 0; --i ) {
        bool found = false;
        for( int j = i - 1; j >=0; --j ) {
            if( array[j] == j + 1 ) {
                result.insert(result.begin(), array[j]);
                array.erase(array.begin() + j);
                found = true;
                break;
            }
        }
        if( found == false ) {
            fail = true;
            break;
        }
    }

    if( fail ) {
        std::cout << -1 << std::endl;
    }
    else {
        for( int i = 0; i < N; ++i ) {
            std::cout << result[i] << std::endl;
        }
    }

    return 0;

}

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

int N, d;

int main() {
  set<int> ds;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> d;
    ds.insert(d);
  }

  cout << ds.size() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=5e5+10;
const int INF=1e9;
char str[maxn];
int dp[maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n;
	n=read();
	scanf("%s",str+1);
	int flag=-1;
	for(i=3;i<=n;i++) {
		dp[i]=dp[i-1];
		if(str[i]=='1' && str[i-1]=='0' && str[i-2]=='1'){
			flag=i;
			for(j=i-2;str[j]=='1' && j>=1;j--)
				dp[i]=max(dp[i],dp[j-1]+i-j-1);
		}
		if(str[i]=='0')flag=-1;
		if(str[i]=='1' && flag!=-1)
			dp[i]=max(dp[i],dp[flag-3]+i-flag+1);
	}
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	string s;
	cin>>s;
	lli sum=0;
	for(auto ch : s)
	{
		sum+=ch-'0';
	}
//	cout<<sum<<endl;
	if(sum%9)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}


Measured memory_bytes: 3728
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
N = len(s)
se = set(s)
ans = INF
for x in se:  # xとの距離を調べる
	tmp = 0
	ans = min(ans, max([len(l) for l in s.split(x)]))

print(ans)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007LL;

class ModCombination
{
public:
    ModCombination(const int n, const ll mod = MOD) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)  // mod should be prime
    {
        for (ll i = 2; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % mod;
            inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod;
            inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod;
        }
    }
    ll factorial(const int n) const { return fact[n]; }
    ll inverseFactorial(const int n) const { return inv_fact[n]; }

private:
    vector<ll> fact;
    vector<ll> inv;
    vector<ll> inv_fact;
};

int main()
{
    int N;
    ll X, Y;
    cin >> N >> X >> Y;
    vector<vector<ll>> weight(N);
    for (int i = 0; i < N; i++) {
        int c;
        ll w;
        cin >> c >> w;
        weight[c - 1].push_back(w);
    }
    ll mini = 1LL << 60;
    int minind = -1;
    for (int i = 0; i < N; i++) {
        if (weight[i].empty()) { continue; }
        sort(weight[i].begin(), weight[i].end());
        if (mini > weight[i].front()) {
            mini = weight[i].front();
            minind = i;
        }
    }
    ll mini2 = 1LL << 60;
    for (int i = 0; i < N; i++) {
        if (weight[i].empty()) { continue; }
        if (minind == i) { continue; }
        mini2 = min(mini2, weight[i].front());
    }
    int sum = 0;
    vector<int> len(N, 0);
    vector<bool> mix(N, false);
    mix[minind] = true;
    for (int i = 0; i < N; i++) {
        if (weight[i].empty()) { continue; }
        sort(weight[i].begin(), weight[i].end());
        const ll inf = weight[i].front();
        len[i] = max(1, (int)(upper_bound(weight[i].begin(), weight[i].end(), X - inf) - weight[i].begin()));
        const int tmp = (i == minind) ? upper_bound(weight[i].begin(), weight[i].end(), Y - mini2) - weight[i].begin()
                                      : upper_bound(weight[i].begin(), weight[i].end(), Y - mini) - weight[i].begin();
        len[i] = max(len[i], tmp);
        if (tmp > 0) { mix[i] = true; }
        if (mix[i]) { sum += len[i]; }
    }
    ModCombination mod(N);
    ll ans = mod.factorial(sum);
    for (int i = 0; i < N; i++) {
        if (mix[i]) { (ans *= mod.inverseFactorial(len[i])) %= MOD; }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14976
h, w = gets.split.map(&:to_i)
ss = h.times.map { gets.chomp }

ans = Array.new(h) { Array.new(w, 0) }

h.times do |i|
  w.times do |j|
    c = ss[i][j]

    if c == "#"
      ans[i][j] = c
      next
    end

    count = 0
    l = j - 1 < 0 ? j : j - 1
    r = j + 1 > w ? j : j + 1

    if i - 1 >= 0
      count += ss[i - 1][l..r].count("#")
    end

    count += ss[i][l..r].count("#")

    if i + 1 <= h - 1
      count += ss[i + 1][l..r].count("#")
    end

    ans[i][j] = count
  end
end

ans.each { |a| puts a.join }


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


void fun(vector<int> h,int N){
	int cost;
	vector<int> memo(N);
	
	memo[1]=abs(h[0]-h[1]);
	for(int i=2;i<N;i++){
		memo[i]=min(memo[i-1]+abs(h[i]-h[i-1]),memo[i-2]+abs(h[i]-h[i-2]));
		
	}
	cout<<memo[N-1]<<endl;
	
	
}
int main(){
	cin>>N;
	vector<int> h(N);
	
	for(int i=0;i<N;i++){
		cin>>h[i];
	}
	fun(h,N);
	return 0;
	
}


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

int main(){
  int K;
  int N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  //cout << A.at(0) << endl;
  
  
  vector<int> B(N);
  B.at(0) = K - A.at(N-1) + A.at(0);
  for(int i=1; i<N; i++){
    B.at(i) = A.at(i) - A.at(i-1);
  }
  
  sort(B.begin(), B.end());
  
  cout << K - B.at(N-1) << endl;
  
  

}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int a;
	int b;
	int c;
	int d;

	scanf("%d %d %d %d",&a,&b,&c,&d);

	/*printf("%d %d %d %d",a,b,c,d)*/

	if (abs(a-c)<=d){
		printf("Yes\n");
	}else if(abs(a-b)<=d && abs(b-c)<=d){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(){
  char input[7];
  int num[100];
  int i = 0;

  while(scanf("%s", input) != EOF){
    if(input[0] == '+') num[i-2] = num[i-2] + num[i-1];
    else if(input[0] == '-') num[i-2] = num[i-2] - num[i-1];
    else if(input[0] == '*') num[i-2] = num[i-2] * num[i-1];
   
    else {
      num[i] = atoi(input);
      i += 2;
    }
    i--;
  }
  
  printf("%d\n", num[0]);
 
  return 0;
}

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

int R;

int main() {
	cin >> R;

	if (R < 1200) {
		cout << "ABC";
	}
	else if (R < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
	int t=1;
	//cin>>t;
	while(t--){
		int a,b,c;
		cin>>a>>b>>c;
		int curr=c;
		for(int i=0;i<10;i++){
			cout<<(a*curr)-b<<endl;
			curr=(a*curr)-b;
		}

	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
 
using namespace std;

int N;
bool check(vector<int> &A) {
	rep(i, N - 1) {
		if (A[i] > A[i + 1]) return false;
	}
	return true;
}

signed main() {
	cin >> N;

	vector<int> A(N);
	rep(i, N) cin >> A[i];

	int maxV = *max_element(all(A));
	int minV = *min_element(all(A));

	vector<pair<int, int>> ret;
	if (abs(maxV) >= abs(minV)) {
		int maxArg = -1;
		rep(i, N) if (A[i] == maxV) maxArg = i;
		while (A[0] < maxV) {
			A[0] += maxV;
			ret.push_back(make_pair(1, maxArg + 1));
		}
		REP(i, 1, N - 1) {
			while (A[i] < A[i - 1]) {
				A[i] += A[i - 1];
				ret.push_back(make_pair(i + 1, i));
			}
		}
	} else {
		int minArg = -1;
		for (int i = N - 1; i >= 0; i--) if (A[i] == minV) minArg = i;
		while (A[N - 1] > minV) {
			A[N - 1] += minV;
			ret.push_back(make_pair(N, minArg + 1));
		}
		for (int i = N - 2; i >= 0; i--) {
			while (A[i] > A[i + 1]) {
				A[i] += A[i + 1];
				ret.push_back(make_pair(i + 1, i + 2));
			}
		}
	}

	cout << ret.size() << endl;
	rep(i, ret.size()) {
		cout << ret[i].second << " " << ret[i].first << endl;
	}

	rep(i, N) cerr << A[i] << " ";
	cerr << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline


def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))

  non_loop_time = 0
  loop_time = 0
  time = [0]*(N+1)
  stack = [1]
  visited = set()
  visited.add(1)
  t = 0
  root = [1]

  while len(stack):

    t += 1
    now = stack[-1]
    time[now] = t
    next_ = A[now-1]

    if next_ not in visited:
      root.append(next_)
      visited.add(next_)
      stack.append(next_)
    else:
      non_loop_time = time[next_] - 1
      loop_time = time[now] - time[next_] + 1
      break

  if K <= non_loop_time:
    print(root[K])
  else:
    K -= non_loop_time
    K %= loop_time
    print(root[non_loop_time+K])


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 146996
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 300005;
int cntX[N], cntY[N];
pr target[N];
int h,w;
int n;
int solve(int xMax, int yMax){
	set<int> x;
	set<int> y;
	for(int i=1;i<=h;++i) if (cntX[i] == xMax) x.insert(i);
	for(int i=1;i<=w;++i) if (cntY[i] == yMax) y.insert(i);
	// for(auto v : y) cout << v << ' '; cout << '\n';
	long long cnt = 0;
	for(int i=1;i<=n;++i){
		if (x.find(target[i].first) != x.end() && y.find(target[i].second) != y.end()){
			cnt++;
		}
	}
	return (cnt == 1LL * x.size() * y.size());
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> h >> w >> n;
	up(i,1,n){
		cin >> target[i].first >> target[i].second;
		cntX[target[i].first]++;
		cntY[target[i].second]++;
	}
	int xMax = 0, yMax = 0;
	up(i,1,h) if (cntX[i] > xMax) xMax = cntX[i];
	up(i,1,w) if (cntY[i] > yMax) yMax = cntY[i];
	// cout << xMax << ' ' << yMax << '\n';
	cout << xMax +  yMax - solve(xMax, yMax)<< '\n';
}

Measured memory_bytes: 36424
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long A = sc.nextInt();
		long B = sc.nextInt();
		long result = 0;
		long x=gcd(A,B);
		result=A*B/x;

		out.println(result);

		out.flush();
	}


	public static long gcd(long a, long b) {
		if(b==0) {
			return a;
		}
		else {
			return gcd(b,a%b);
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}



Measured memory_bytes: 21332
#include <stdio.h>
#include <string.h>
int main(void)
{
    char str[1024];
    char word_T[1024];
    char word_H[1024];
    int n, score_T = 0, score_H = 0;
    
    fgets(str, sizeof(str), stdin);
    sscanf(str,"%d", &n);
    for(int i = 0; i < n; i++)
    {
        fgets(str, sizeof(str), stdin);
        sscanf(str, "%s %s", word_T, word_H);
        if (strcmp(word_T, word_H) > 0)
        {
            score_T += 3;
        }
        else if(strcmp(word_T, word_H) < 0)
        {
            score_H += 3;
        }
        else
        {
            score_T++;
            score_H++;
        }
    }
    printf("%d %d\n", score_T, score_H);
}



Measured memory_bytes: 2036
def isprime(x):
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return x!=1


dic={}
n=int(input())
t=int(n**0.5)+1
for i in range(2,t):
    cnt=0
    while n%i==0:
        cnt+=1
        n//=i
    dic[i]=cnt
if n!=1:
    dic[n]=1
ans=0
for i in dic:
    x=dic[i]
    r=(-1+(1+8*x)**0.5)//2
    ans+=r
print(int(ans))




Measured memory_bytes: 169936
#include<iostream>
using namespace std;
int main(){
   int N,T; cin>>N>>T;
   int tmp=1001,ans;
   for(int i=0;i<N;i++){
      int c,t;
      cin>>c>>t;
      if(t>T)continue;
      if(c<tmp){
         tmp=c;
         ans=tmp;
      }
   }
   if(tmp==1001)cout<<"TLE"<<endl;
   else cout<<ans<<endl;
   return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  int answer;
  
  if(L >= 0){
    answer = (2*L+N)*(N-1)/2;
  }
  else if(L < 0 && L+N-1 >= 0){
    answer = (2*L+N-1)*N/2;
  }
  else{
    answer = (2*L+N-2)*(N-1)/2;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(max(a-2*b, 0));
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

namespace VC20190528 {
  class Problem1 {
    static void Main(string[] args) {
      int n = Input.num;
      int[][] section = new int[n][];
      for (int i = 0; i < n; i++) {
        section[i] = Input.nums;
      }
      int sum = 0;
      for (int i = 0; i < n; i++) {
        sum += section[i][1] - section[i][0] + 1;
      }
      System.Console.WriteLine(sum);
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	bool C=0,F=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(C && s[i]=='F')F=1;
		if(s[i]=='C')C=1;
	}
	if(C&&F)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::f64::consts::PI;
#[fastout]
fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }
    let rad = PI * 2.0 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0);
    let ans = (a * a + b * b - 2.0 * a * b * rad.cos()).sqrt();
    println!("{}", ans);
}


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

int main(){
  int n,m;
  string s;
  set<string> id;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    id.insert(s);
  }

  cin >> m;
  bool open = false;
  for(int i=0;i<m;i++){
    cin >> s;
    if(id.find(s) == id.end()){
      cout << "Unknown " << s << endl;
    }else{
      if(open)cout << "Closed by " << s << endl;
      else cout << "Opened by " << s << endl;
      open = !open;
    }
  }
}
  

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int p,q,r;
	cin >> p >> q >> r;

	int min = p+q;
	chmin(min, q+r);
	chmin(min, r+p);

	cout << min << endl;


  return 0;
}


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

int main(){
  int n;
  cin>> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>> a.at(i);
  
  auto ca=a;
  sort(ca.begin(),ca.end());
  int first=ca.at(n-1),second=ca.at(n-2);
  for (int i=0; i<n; i++){
    if (a.at(i)==first) cout<< second <<endl;
    else cout<< first <<endl;
  }
}

Measured memory_bytes: 3200
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int d,t,s;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
cin>>d>>t>>s;
cout << ((s*t >= d) ? "Yes":"No");

 return 0;
}


Measured memory_bytes: 3648
x = int(input())
n = 10**5

def blp(dp,num):
    l = 0
    r = len(dp)-1
    while l <= r:
        mid = (l+r)//2
        if num == dp[mid]:return mid
        elif num >= dp[mid]:l = mid+1
        else:r = mid-1
    return 0

def bln(dp,num):
    l = 0
    r = len(dp)-1
    while l>=r:
        mid = (l+r)//2
        if num == dp[mid]:return mid
        elif num >= dp[mid]:r = mid+1
        else:l = mid-1
    return 0
            
ap = [i**5 for i in range(n)]
an = [-(i**5) for i in range(n)]

for b in range(-n,n):
    num = x + b**5
    a = max(blp(ap,num),bln(an,num))
    if a:print(a,b) ; break

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;


void ABC126A()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	S[K - 1] = S[K - 1] == 'A' ? 'a' : S[K - 1] == 'B' ? 'b' : 'c';
	cout << S << endl;
}

int main()
{
	ABC126A();
	return 0;
}


Measured memory_bytes: 256
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

s = str(input())

if is_kaibun(s):
    if is_kaibun(s[0:int((len(s)-1)/2)]):
        if is_kaibun(s[int((len(s)+3)/2):len(s)-1]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

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

ll mod = 1e18;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<vector<ll>> nxt(70, vector<ll>(N, 0));
    map<int, int> mp;
    for (int i = 0; i < N*2; i++) {
        int t = A[i%N];
        if (mp.find(t) == mp.end()) {
            mp[t] = i;
        }else{
            if (mp[t] < N) {
                nxt[0][mp[t]] = i - mp[t] + 1;
                mp[t] = i;
            }
        }
    }
    for (int i = 1; i < 70; i++) {
        for (int j = 0; j < N; j++) {
            nxt[i][j] = (nxt[i-1][j]+nxt[i-1][(j+nxt[i-1][j])%N])%mod;
        }
    }
    /*
    for (int i = 1; i < 5; i++) {
        for (int j = 0; j < N; j++) {
            cout << nxt[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    ll now = 0;
    while (now < N*K) {
        ll p = now%N;
        if (now+nxt[0][p] >= N*K-1) break;
        ll cnt = 0;
        while (now+nxt[cnt+1][p] <= N*K) cnt++;
        now += nxt[cnt][p];
    }
    vector<bool> exist(200001, false);
    vector<int> raw;
    for (ll i = now; i < N*K; i++) {
        if (exist[A[i%N]]) {
            while (exist[A[i%N]]) {
                int s = raw.size();
                exist[raw[s-1]] = false;
                raw.resize(s-1);
            }
        }else {
            raw.push_back(A[i%N]);
            exist[A[i%N]] = true;
        }
    }
    for (int i = 0; i < (int)raw.size(); i++) {
        if (i == 0) printf("%d", raw[i]);
        else printf(" %d", raw[i]);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 122980
a=input()
b=a.split(" ")
N=int(b[0])
M=int(b[1])
in2=[]
out2=[]
for i in range(M):
    c=input()
    d=c.split(" ")
    in1=int(d[0])
    out=int(d[1])
    if in1==1:
        in2.append(str(out))
    elif out==N:
        out2.append(str(in1))
        
in2_set=set(in2)
out2_set=set(out2)
matched_list=list(in2_set & out2_set)
#print(matched_list)
if len(matched_list)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  int lx,ly;

  cin >> x1 >> y1 >> x2 >> y2;
  lx = x2-x1;
  ly = y2-y1;

  x3 = x2 - ly;
  y3 = y2 + lx;

  x4 = x3 - lx;
  y4 = y3 - ly;

  cout << x3 << " " << y3 << " " << " " << x4 << " " << y4;

  return 0;
}


Measured memory_bytes: 256
A=[]
p=[]
a=i=0
for c in input():
 if"\\"==c:A+=[i]
 elif"/"==c and A:
  j=A.pop()
  t=i-j
  a+=t
  while p and p[-1][0]>j:t+=p[-1][1];p.pop()
  p+=[(j,t)]
 i+=1
print(a)
if p:print(len(p),*list(zip(*p))[1])
else:print(0)


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

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    sort(ALL(p));
    int ans = x;
    rep(i,x+1){
        if(!binary_search(ALL(p), x-i)){
            ans = x-i;
            break;
        }
        if(!binary_search(ALL(p), x+i)){
            ans = x+i;
            break;
        }
    }

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int A,B;
	char buf[2];

	scanf("%d %s %d",&A,buf,&B);

	if(buf[0] == '+'){

		printf("%d\n",A+B);

	}else{

		printf("%d\n",A-B);
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;

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

  ll N, K, S;
  cin >> N >> K >> S;

  for(int i = 0 ; i < K ; i++) {
    cout << S << ' ';
  }
  for(int i = 0 ; i < N - K ; i++) {
    if(S == 1e9) {
      cout << S - 1 << ' ';
    }
    else {
      cout << S + 1 << ' ';
    }
  }


} 


Measured memory_bytes: 1280
#include<stdio.h>

int i,j,a,b,c,ans=0;

int main(){
    while(scanf("%d %d",&a,&b)!=EOF){
        c=a+b;
        while(c!=0)c=c/10,ans++;
        printf("%d\n",ans);ans=0;
    }
    
    return 0;
}


Measured memory_bytes: 1980
//☠️_Do_not_copy_from_me_☠️//
#include <bits/stdc++.h>
#define ll/*////////*/long long
#define gcd()/*////////*/___gcd()
#define pi/*////////*/3.1415926536
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//------Enter your code here.------
	int n,a,ans=0;cin>>n;for(int i=1;i<=n;i++){cin>>a;if(i%2 and a%2){ans++;}}cout<<ans<<"\n";	
}

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

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

ll lcm(ll a, ll b){
    ll ret = (a * b)/gcd(a,b);
    return ret;
}

int main(){
    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    double mx = 0;
    ll sugar = 0, water = 100 * A;
    for(ll c = 0; c < F+1; c += C){
        for(ll d = 0; d < F+1 - c; d += D){
            ll s = c + d;
            for(ll a = 0; a < F+1; a += A * 100){
                for(ll b = 0; b < F+1 - a; b += B * 100){
                    ll w = a + b;
                    if(s + w > F) continue;
                    if(s > E * (ll)(w/100)) continue;
                    if(s + w == 0) continue;
                    double node = (double)(s) / (double)(w + s);
                    if(node > mx){
                        mx = node;
                        sugar = s;
                        water = w;
                    }
                }
            }
        }
    }
    cout << water + sugar << " " << sugar << endl;

    return 0;
}

Measured memory_bytes: 384
// AOJ 1093: KND Runs for Sweets
// 2017.11.16 bal4u@uu

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

#define KAI  35
#define GSS  1.681
#define GSB  2.681

int x[101], y[101], v[101]; int n;
int max;

double fx(double a, double b)
{
	int i;
	double d, max;
	
	max = 0;
	for (i = 0; i < n; i++) {
		d = hypot(a-x[i], b-y[i]) / v[i];
		if (d > max) max = d;
	}
	return max;
}

double srchy(double x)
{
	int i;
	double l, r, a, b;

	l = 0, r = max;
	i = KAI; while (i--) {
		a = (GSS*l + r) / GSB;
		b = (l + GSS*r) / GSB;
		if (fx(x, a) < fx(x, b) ) r = b;
		else                      l = a;
	}
	return fx(x, (l+r)/2);
}

double srch3()
{
	int i;
	double l, r, a, b;
	
	l = 0, r = max;
	i = KAI; while (i--) {
		a = (GSS*l + r) / GSB;
		b = (l + GSS*r) / GSB;
		if (srchy(a) < srchy(b)) r = b;
		else                     l = a;
	}
	return srchy((l+r) / 2) ;
}

int main()
{
	int i;

	while (scanf("%d", &n) && n > 0) {
		max = 0;
		for (i = 0; i < n; i++)	{
			scanf("%d%d%d", x+i, y+i, v+i);
			if (x[i] > max) max = x[i];
			if (y[i] > max) max = y[i];
		}
		printf("%.8f\n", srch3());
	}
	return 0;
}

Measured memory_bytes: 1840
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll N,X,T,c;
    cin>>N>>X>>T;
    if(X>N){
        if(X%N==0){
            c=(X/N)*T;
            cout<<c<<endl;
        }
        else{
            c=T;
            cout<<c<<endl;
        }
    }
    else{
        if(N%X==0){
            c=(N/X)*T;
            cout<<c<<endl;
        }
        else{
            c=((N/X)+1)*T;
            cout<<c<<endl;
        }
    }
}

Measured memory_bytes: 3632
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;

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

    int s, w;
    cin >> s >> w;
    if(s  > w)
        cout << "safe" << endl;
    else if(s  <= w)
        cout << "unsafe" << endl;

}

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

using namespace std;

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

#define PI 3.14159265358979323846264338327950L

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);

    printf("%20.20Lf\n", sqrtl(rsq));
}

Measured memory_bytes: 4068
#include <iostream>
#include <queue>


using namespace std;

const int N = 1000;

int main()
{
	queue<int> Q[N];
	int n, q;
	cin >> n >> q;
	
	while (q--)
	{
		int d, t;
		cin >> d >> t;
		if (d == 0)
		{
			int x;
			cin >> x;
			Q[t].push(x);
		}
		else if (d == 1)
		{
			if (!Q[t].empty())
				cout << Q[t].front() << endl;
		}
		else
		{
			if (!Q[t].empty())
				Q[t].pop();
		}
	}
}


Measured memory_bytes: 4328
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N; cin >> N; int a[7];
  rep(i, 8){
    a[i] = pow(2, i);
  }
  rep(i, 7){
    if(N>=a[i] && N<a[i+1]) cout << a[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  ll b[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }

  ll ans=0;
  for(int i=n-1;i>=0;i--){
    ans+=(b[i]-(a[i]+ans)%b[i])%b[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		List<Integer> list = new ArrayList<>();
		for (int k = 3 ; k < 55555 ; k++) {
			boolean a = true;
			for (int i = 2; i < k && i < Math.floor(Math.sqrt(55555)) ; i++) {
				if (k % i == 0) {
					a = false;
					break;
				}
			}
			if (a && k % 5 == 1) {
				list.add(k);
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n ; i++) {
			if (i != n-1) {
				sb.append(list.get(i)).append(" ");
			} else {
				sb.append(list.get(i));
			}
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)


struct block{
  ll w,s,v,ws;
};

bool o(block b1,block b2){
  return b1.ws==b2.ws?b1.s<b2.s:b1.ws<b2.ws;
}

block b[1010];
ll n,w,s,v,t=0,dp[1010][30010]={};

int main(){
  cin>>n;
  fr(i,n){cin>>w>>s>>v;b[i]=(block){w,s,v,w+s};}
  sort(b,b+n,o);
  Fr(i,n){
    fr(W,30010){
      dp[i][W]=max(dp[i][W],dp[i-1][W]);
      if(W>=b[i-1].w){
        if(W>=b[i-1].ws) dp[i][W]=max(dp[i][W],dp[i-1][b[i-1].s]+b[i-1].v);
        else dp[i][W]=max(dp[i][W],dp[i-1][W-b[i-1].w]+b[i-1].v);
      }
    }
  }
  //fr(i,5) cout<<dp[1][i]<<" ";
  fr(i,300010) t=max(t,dp[n][i]);
  //fr(i,100) cout<<vm(1,i)<<endl;
  cout<<t<<endl;
}

Measured memory_bytes: 235520
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;


int main(void){
	int a[3];
	rep(i,3) cin >> a[i];
	sort(a,a+3);
	
	if((a[0]%2 == a[1]%2) && (a[1]%2 == a[2]%2)){
		cout << (a[2]-a[0])/2+(a[2]-a[1])/2 << endl;
	}
	else{
		if(a[0]%2 == a[1]%2){
			a[0]++;
			a[1]++;
		}
		else if(a[0]%2 == a[2]%2){
			a[2]++;
			a[0]++;
		}
		else{
			a[1]++;
			a[2]++;
		}
		sort(a,a+3);
		cout << (a[2]-a[0])/2+(a[2]-a[1])/2+1 << endl;
	}
	return 0;

}


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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

void solve(){
    int n,q;
    cin >> n;
    vector<llint>S(n);
    for(int i=0;i<n;i++)cin >> S[i];
    cin >> q;
    vector<llint>T(q);
    for(int i=0;i<q;i++)cin >> T[i];
    int ans=0;
    for(int i=0;i<q;i++){
        int l=0,r=n;
        while(l+1<r){
            int m=(l+r)/2;
            if(S[m]<=T[i])l=m;
            else r=m;
        }
        if(S[l]!=T[i])continue;
        ans++;
    }
    cout << ans << endl;


}

int main(){
    solve();
    return 0;
}






Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  ll arr[4];
  arr[0]=a*c;
  arr[1]=a*d;
  arr[2]=b*c;
  arr[3]=b*d;
  ll max=arr[0];
  for(ll i=1; i<4; i++){
    if(max<arr[i])
      max=arr[i];}
  cout<<max;
  
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

nA, sA, i = [N, N], [0],  N - 1
for a in range(1, A[0] * 2):
    di = 0
    while i - di >= 0 and A[i - di] == a:
        di += 1
    nA.append(nA[-1] - di)
    i -= di
for a in A:
    sA.append(sA[-1] + a)

L, R, ans = 0, A[0] * 2 + 1, 0
while R - L > 1:
    mid = L + (R - L) // 2
    mA = [nA[max(mid - A[i], 0)] for i in range(N)]
    sM = sum(mA)
    if M <= sM:
        L = mid
        ans = sum([A[i] * mA[i] + sA[mA[i]]
                   for i in range(N)]) - mid * (sM - M)
    else:
        R = mid

print(ans)


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

int main(){
  int n;
  int ans = 0;
  map<int,int> mp;
  cin >> n;

  int a;
  for(int i = 0;i < n;i++){
    cin >> a;
    if(mp[a] == 0){
      ans++;
      mp[a] = 1;
    }else{
      ans--;
      mp[a] = 0;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector < ll >
#define vvll vector < vll >
#define vld vector < ld >
#define pll pair < ll,ll > 
#define ppll pair < ll, pll>
#define pld pair < ld,ld > 
#define vpll vector < pll >
#define vpld vector < pld >
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
vll emptyVector;
const ll MAX = 2e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll binaryExpo(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 0)
		return binaryExpo((x*x), n/2);
	return (x*binaryExpo((x*x), n/2));
}
const double pi = 3.141592653589793238462643383279502884197169399375105;
/*-------------------------------------------		CODE STARTS FROM HERE		------------------------------------------*/



void solve(void)
{
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double an = 30*h - 60*m;
	an = (ld)(h + (ld)m / 60)*30 - (ld)m*6;
	an = (ld)an/57.2957795131;

	// cout << "an = " << an << endl;
	// cout << "cos(" << an << ") = " << cos(an) << endl;

	double c = a*a + b*b;
	// cout << "c = " << c << endl;

	c -= 2*a*b*cos(an);

	// cout << c << endl;

	cout << setprecision(15) << sqrt(c) << endl;


}


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

	// int t;
	// cin >> t;
	// while(t--)
	{
		solve();
	}
	




	return 0;
}

Measured memory_bytes: 4144
// AOJ 2745: Curry Making
// 2017.10.9 bal4u@uu

#include <stdio.h>

int main()
{
	int r0, w0, c, r, i;

    while (scanf("%d%d%d%d", &r0, &w0, &c, &r) && r0 > 0) {
        for (i = 0; r0+r*i < c*w0; i++);
		printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  int n,a[100050];
  int dist[100010];
  ll sum=0;

  a[0]=0;
  cin>>n;
  reps(i,n+1)cin>>a[i];
  a[n+1]=0;


  rep(i,n){
    dist[i]=abs(a[i]-a[i+2]);
    //cout<<dist[i]<<endl;
  }


  rep(i,n+1){
    sum+=abs(a[i]-a[i+1]);
  }

  reps(i,n+1){
    cout<<sum+dist[i-1]-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])<<endl;
  }
  return 0;
}


Measured memory_bytes: 4380
H, W = map(int, input().split())
s = []
n = []
for i in range(H):
    s.append(input())
    n.append([])
    for j in range(W):
        if s[i][j] == ".":
            n[i].append(0)
        else:
            n[i].append(-1)

for i in range(H):
    for j in range(W):
        if n[i][j] == -1:
            for k in range(-1, 2, 1):
                for l in range(-1, 2, 1):
                    if 0 <= i + k and i + k < H and 0 <= j + l and j + l < W:
                        if n[i + k][j + l] != -1:
                                n[i + k][j + l] += 1
for i in range(H):
    ans = ""
    for j in range(W):
        if n[i][j] == -1:
            ans += "#"
        else:
            ans += str(n[i][j])
    print(ans)


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

int n, m;
int p[100010];
int prt[100010];
int rnk[100010];
int ans;

int fnd(int p){
	if(prt[p] == p ) return p;
	return prt[p] = fnd(prt[p]);
}

void unite(int p, int q){
	p = fnd(p);
	q = fnd(q);
	if(p == q) return;
	if(rnk[p] < rnk[q]) prt[p] = q;
	else{
		prt[q] = p;
		if(rnk[p] == rnk[q]) ++rnk[p];
	}
}

bool same(int p, int q){
	return fnd(p) == fnd(q);
}

int main(){
	cin >> n >> m;
	for(int i=0; i<n; ++i) cin >> p[i];
	for(int i=0; i<n; ++i){
		prt[i] = i;
		rnk[i] = 0;
	}
	for(int i=0; i<m; ++i){
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}
	for(int i=0; i<n; ++i)
		if(same(p[i], i+1))
			++ans;
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>  // ver1.9.6
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;



struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



signed main() {
  cout << fixed << setprecision(8);
  int n,m;
  cin >> n >> m;
  Vi a(n);
  rep(i,0,n){
    cin >> a[i];
    a[i]--;
  }
  
  UnionFind tree(n);
  
  int qw,er;
  rep(i,0,m){
    cin >> qw >> er;
    qw--,er--;
    tree.unite(qw,er);
  }
  
  int ans =0;
  rep(i,0,n){
    if(tree.same(i,a[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
vl adj[N];
ll indeg[N],lev[N],ans=0;
void topo(ll n){
    queue<ll> q;
    f(i,1,n+1) if(indeg[i]==0) q.push(i);
    while(!q.empty()){
        ll f = q.front();
        q.pop();
        for(auto u:adj[f]){
            if(indeg[u]){
                indeg[u]--;
                lev[u] = max(lev[u], 1 + lev[f]);
                if(!indeg[u]) q.push(u);
            }
        }
    }
}

void solve(){
    ll n,m;
    cin>>n>>m;
    f(i,0,m){
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        indeg[y]++;
    }
    topo(n);
    f(i,1,n+1){
        ans = max(ans, lev[i]);
    }
    cout<<ans;

}
signed main() {
    teevra_gati
   
    solve();

    return 0;
}

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

int main(){
  int n[20001][2]={0},a,k,c,h;
  k=0;
  c=0;
  for(int i=1;i<20001;i++){
    h=i;
    while(h%2==0){
      k++;
      h/=2;
    }
    h=i;
    while(h%5==0){
      c++;
      h/=5;
    }
    n[i][0]=k;
    n[i][1]=c;
  }
  while(1){
    cin>>a;
    if(a==0)break;
    else {
      if(n[a][1]>=n[a][0])cout<<n[a][0]<<endl;
      if(n[a][1]<n[a][0])cout<<n[a][1]<<endl;
    }
  }
  return 0;
}

	 

Measured memory_bytes: 3132