akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		int H = io.nextInt();
		int W = io.nextInt();
		String[] pic = new String[H];
		
		for (int i = 0; i < H; i++) {
				pic[i] = io.next();
		}
		
		for (int i = 0; i < W+2; i++) {
			System.out.print("#");
		}
		System.out.println();
		for (int i = 0; i < H; i++) {
			System.out.println("#"+pic[i]+"#");
		}
		for (int i = 0; i < W+2; i++) {
			System.out.print("#");
		}
		System.out.println();
	}
		
}	

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

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int K;
    cin>>K;

    int m=7%K;

    int c=1;
    while(1){
        if(m==0) break;
        if(c!=1&&c>K+100){
            c=-1;
            break;
        }
        m*=10;
        m+=7;
        m%=K;
        c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.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 DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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 namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, Q; cin >> n >> Q;
    Q++;
    vi a(Q), b(Q); rep(i, Q - 1) cin >> a[i] >> b[i], a[i]--, b[i]--;
    a[Q - 1] = b[Q - 1] = 0;

    vi to(n); rep(i, n) to[i] = i;
    rrep(i, Q){
        swap(to[a[i]], to[b[i]]);
    }

    int pos = 0;
    set<int> s;
    rep(i, Q){

        // magic
        if(pos + 1 < n) s.insert(to[pos + 1]);
        if(pos - 1 >=0) s.insert(to[pos - 1]);

        // no magic
        if(pos == a[i]) pos = b[i];
        else if(pos == b[i]) pos = a[i];

        swap(to[a[i]], to[b[i]]);
    }
    s.insert(pos);

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int A(int a) {
	int res = 0;
	while (a > 0) {
		res += a % 10;
		a /= 10;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	if (N%A(N) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n,a,b;
cin>>n>>a>>b;
ll temp=n/(a+b);
ll temp1=n%(a+b);
if(temp1<=a)
cout<<temp*a+temp1;
else
cout<<temp*a+a;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans;
  
  if (a + b > c + d)
    ans = "Left";
  else if (a + b == c + d)
    ans = "Balanced";
  else
    ans = "Right";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc095/b.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N, X; 
    int m[1050];
    cin >> N >> X;
    ll c = INF;
    int ans = 0;
    rep(i, N){
        cin >> m[i];
        X -= m[i];
        ans++;
        if(c > m[i]) c = m[i];
    }
    ans += X/c;
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n;

int main(){
	while(cin>>n){
		int two=1;
		vi ans;
		for(int i=0;i<10;i++){
			two*=2;
			if(n%two){
				n-=two/2;
				ans.push_back(two/2);
			}
		}
		for(int i=0;i<ans.size()-1;i++) cout<<ans[i]<<' ';
		cout<<ans[ans.size()-1]<<endl;
	}
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n, d;
  cin >> n >> d;
  cout << (ll)ceil(n / (2.0*d+1)) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

class UnionFind:
    def __init__(self, node:int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        
    def find(self, x:int) -> int:
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x:int, y:int) -> bool:
        if self.isSame(x,y):
            #print("x and y has already united")
            return False
        
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = self.par[ry]
        else:
            self.par[ry] = self.par[rx]
            
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
                
        return True
                
    def isSame(self, x:int, y:int) -> bool:
        return self.find(x) == self.find(y)

n,m = li()
p = list(li_())
xy = []
for _ in range(m):
    xy.append(tuple(li_()))
    
uf = UnionFind(n)

for x,y in xy:
    uf.unite(x,y)
    
rtnode = {i:set() for i in range(n)}
number = {i:set() for i in range(n)}

for i in range(n):
    uf.find(i)
    rtnode[uf.par[i]].add(i)
    number[uf.par[i]].add(p[i])
    
ans = 0
for i in range(n):
    ans += len(rtnode[i] & number[i])
    
print(ans)

Measured memory_bytes: 106080
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

int n;

void dfs(ll cur_val, int use_bit, ll & counter) {

    if (cur_val > n) return;

    if (use_bit == 0b111) counter++;

    dfs(cur_val * 10 + 7, use_bit | 0b001, counter);
    dfs(cur_val * 10 + 5, use_bit | 0b010, counter);
    dfs(cur_val * 10 + 3, use_bit | 0b100, counter);
}

int main()
{
    scanf("%d", &n);
    assert(1 <= n && n < pow(10, 9));

    ll counter = 0;
    dfs(0, 0b0, counter);

    printf("%lld\n", counter);

    return 0;
}


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

typedef long long ll;
typedef long double ld;


using namespace std;

const int MX = 2e5 + 1000;
const int INF = 1e9;

char s[MX];
int dp[MX][2];

int main() {
	for (int i = 0; i < MX; i++)
		for (int j = 0; j < 2; j++)
			dp[i][j] = -INF;

	ignore = scanf("%s", s);
	size_t n = strlen(s);
	
	if (n == 1) {
		printf("1\n");
		return 0;
	}
	
	dp[0][0] = 1;
	dp[1][1] = 1;
	if (s[0] != s[1])
		dp[1][0] = 2;
	
	for (size_t i = 2; i < n; i++) {
		dp[i][0] = max(dp[i][0], dp[i-1][1] + 1); // LEN=1; PREV_LEN=2;
		if (s[i] != s[i-1])
			dp[i][0] = max(dp[i][0], dp[i-1][0] + 1); // LEN=1; PREV_LEN=1; CUR != PREV;
		
		dp[i][1] = max(dp[i][1], dp[i-2][0] + 1); // LEN=2; PREV_LEN=1;
		if (i >= 3) {
			if (s[i-3] != s[i-1] or s[i-2] != s[i])
				dp[i][1] = max(dp[i][1], dp[i-2][1] + 1); // LEN=2; PREV_LEN=2; CUR != PREV;
		}
	}
	
	printf("%d\n", max(dp[n-1][0], dp[n-1][1]));
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	long long sum=0;
	for(int i=1;i<=m;i++)
	{
		int a;
		cin>>a;
		sum+=a;
	}
	if(sum>n)
	cout<<-1;
	else
	if(sum==n)
	cout<<0;
	else
	cout<<n-sum;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  set<int> s;
  int free = 0;
  rep(i,n) {
    if (1<=a[i] &&  a[i]<=399) s.insert(0);
    else if (a[i]<=799) s.insert(1);
    else if (a[i]<=1199) s.insert(2);
    else if (a[i]<=1599) s.insert(3);
    else if (a[i]<=1999) s.insert(4);
    else if (a[i]<=2399) s.insert(5);
    else if (a[i]<=2799) s.insert(6);
    else if (a[i]<=3199) s.insert(7);
    else free++;
  }

  int v_min, v_max;
  v_min = ((int)s.size()==0 ? 1 : (int)s.size());
  v_max = (int)s.size()+free;

  cout << v_min << " " << v_max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e6+5;

int main() {
   int n, k;
   cin >> n >> k;
   vector <int> a(n);
   for(int i=0; i<n; i++) scanf("%d", &a[i]);
   for(int i=k; i<n; i++) {
      if(a[i] > a[i-k]) puts("Yes");
      else puts("No");
   }
}


Measured memory_bytes: 4028
n, l = map(int,input().split())

Sum = 0

for i in range(n):
    Sum += l + i

ans = 10**18

for i in range(n):
    s = l + i
    if ans > abs(-s):
        ans = min(ans, abs(Sum-Sum-s))
        t = s

if t < 0:
    print(Sum+ans)
else:
    print(Sum-ans)

Measured memory_bytes: 3060
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();    
    int k = sc.nextInt();    
    int r = sc.nextInt();    
    int s = sc.nextInt();    
    int p = sc.nextInt();    
    String t = sc.next();
    char rivalHands[] = new char[n];
    
    int result = 0;
    for (int i=0; i<n; i++) {
      rivalHands[i] = t.charAt(i);
      if (i<k) {
        result += addPoint(rivalHands[i], r, s, p);
      }
      else {
        if (rivalHands[i-k]==rivalHands[i]) {
          rivalHands[i] = 'n';
        }
        else {
          result += addPoint(rivalHands[i], r, s, p);
        }
      }
    }
    System.out.println(result);
  } 
  
  public static int addPoint(char hand, int r, int s, int p) {
    int point = 0;
    if (hand=='r') {
      point = p;
    }
    else if (hand=='s') {
      point = r;
    }
    else if (hand=='p') {
      point = s;
    }
    return point;
  }
}

Measured memory_bytes: 28052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  cout<<"ABC"<<n<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int min = 1, res = 0;

        for(int i = b-a-1; i>1; i-- ) {
            min += i;
        } 
        res = min - a;

        System.out.println(res);

        sc.close();
    }
}

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

int main() {
	ios::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int> H(n); for(int &i : H) cin >> i;
	sort(H.begin(), H.end(), greater<int>());

	long long ans = 0;
	for(int i = k; i < n; i++) ans += H[i];
	cout << ans << '\n';
	return 0;
}


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

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

  if (abs(a - c) <= d){
    cout << "Yes" << endl;
  }
  else if (abs(a - b) <= d && abs(b - c) <= d){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N =  1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(8);
  }
}IO;

int32_t main(){
 int h, n;
 cin >> h >> n;
 int a[n + 1];
 int sum = 0;
 for (int i = 0; i < n; i++){
  cin >> a[i];
  sum += a[i];
 }
 cout << (sum >= h ? "Yes" : "No") << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

vector<int> a = {1867,1911,1925,1988};
vector<char> c = {'M','T','S','H'};

int main(){
  int E,Y;
  cin >> E >> Y;
  if(E == 0){
    for(int i = 3;i >= 0;i--){
      if(Y > a[i]){
        cout << c[i] << Y - a[i] << endl;
        return 0;
      }
    }
  }
  else{
    cout << Y + a[E - 1] << endl;
  }

}



Measured memory_bytes: 3092
while true
  h,w = gets.split.map{|v|
    v.to_i
  }
  if h == 0 && w == 0
    break
  end
   
  for i in 1..h
    for j in 1..w
      if (i + j) % 2 == 0
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
  print "\n"
end


Measured memory_bytes: 8888
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String crlf = System.getProperty("line.separator");
       
    
        
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
           
            if(h==0 && w==0){
                break;
            }else{
               
                for(int i=0;i<w;i++){
                   System.out.print("#"); //底辺
               }
               
               System.out.println();
               
               for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");    
                    System.out.println();
               }
               
               for(int i=0;i<w;i++){
                   System.out.print("#"); //上辺
               }
               System.out.println();
            }
            System.out.println();
            
        }
        
        
        
        
    }
}

Measured memory_bytes: 25020
open System.IO
open System

let [| n; k; q; |] = stdin.ReadLine().Split() |> Array.map int
let a = [| for _ in 1..q -> stdin.ReadLine() |> int |]

//最初にk-q持ち点で、正解で一点、最後に0点以下は消える
let pointArray = [|0..n|] |> Array.map (fun _ -> k-q )
do a |> Array.countBy (fun x -> x ) |> Array.iter (fun (i, x) -> pointArray.[i] <- pointArray.[i] + x)

// 出力
let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false
Console.SetOut(sw)

pointArray.[1..n] 
|> Array.map (fun x ->
    match x > 0 with
    |true -> "Yes"
    |false -> "No")
|> Array.iter (stdout.WriteLine)

stdout.Flush()



Measured memory_bytes: 29912
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const double eps = 1e-10;
clock_t START, END;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
};
typedef Point Vector;
Vector operator - (const Point& A, const Point& B) { return Vector(A.x - B.x, A.y - B.y); }
int dcmp(double x) { if (fabs(x) < eps)return 0; else return x < 0 ? -1 : 1; }
double Cross(Vector A, Vector B) { return A.x * B.y - A.y * B.x; }
double Dot(const Vector& A, const Vector& B) { return A.x * B.x + A.y * B.y; }
double Distance(Point u, Point v) {
	return sqrt(fabs((u.x - v.x) * (u.x - v.x)) + fabs((u.y - v.y) * (u.y - v.y)));
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	};
	int n;
	double x, y, ans;
	vector<Point> p;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x, &y);
		p.push_back(Point(x, y));
	}
	p.push_back(p[0]);
	for (int u = 0, v = 1; u < n; u++) {
		bool rev = false;
		for (;;) {
			int diff = dcmp(Cross(p[u + 1] - p[u], p[v + 1] - p[v]));
			if (diff)
				rev = true;
			if (diff <= 0 && rev) {
				ans = max(ans, Distance(p[u], p[v]));
				if (diff == 0)
					ans = max(ans, Distance(p[u], p[v + 1]));
				break;
			}
			v = (v + 1) % n;
		}
	}
	printf("%.6lf\n", ans);
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 4972
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, K, L = list(map(int, sys.stdin.readline().split()))
P, Q = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(K)]))
R, S = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(L)]))


class UnionFind:
    def __init__(self, size=None, nodes=None):
        """
        size か nodes どっちか指定。
        nodes は set、size は list を使う。
        set の最悪計算量は O(N) なので size 指定のほうが若干速い
        :param int size:
        :param collections.Iterable nodes:
        """
        assert size is not None or nodes is not None
        if size is not None:
            self._parents = [i for i in range(size)]
            self._ranks = [0 for _ in range(size)]
            self._sizes = [1 for _ in range(size)]
        else:
            self._parents = {k: k for k in nodes}
            self._ranks = {k: 0 for k in nodes}
            self._sizes = {k: 1 for k in nodes}

    def unite(self, x, y):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :return:
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        # rank が小さい方が下
        if self._ranks[x] > self._ranks[y]:
            # x が root
            self._parents[y] = x
            self._sizes[x] += self._sizes[y]
        else:
            # y が root
            self._parents[x] = y
            self._sizes[y] += self._sizes[x]
            if self._ranks[x] == self._ranks[y]:
                self._ranks[y] += 1

    def find(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.find(x)]


uf1 = UnionFind(size=N + 1)
for p, q in zip(P, Q):
    uf1.unite(p, q)
uf2 = UnionFind(size=N + 1)
for r, s in zip(R, S):
    uf2.unite(r, s)

counts = defaultdict(int)
for i in range(1, N + 1):
    counts[(uf1.find(i), uf2.find(i))] += 1

ans = []
for i in range(1, N + 1):
    ans.append(counts[(uf1.find(i), uf2.find(i))])
print(' '.join(map(str, ans)))


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

int main() {
  string S;
  cin >> S;
  vector<int> cnt(26);
  string alp = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < S.size(); i++) {
    cnt.at(alp.find(S.at(i)))++;
  }
  bool flag = false;
  for (int i = 0; i < 26; i++) {
    if (cnt.at(i) == 0) {
      cout << alp.at(i) << endl; 
      flag = true;
      break;
    }
  }
  if (!flag) {
    cout << "None" << endl;
  }
}

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

string solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    ll AMAX = 1e6+1;
    vector<ll> primes(AMAX, -1);
    for ( ll i = 2; i < AMAX; i++ ) {
        if ( primes[i] > 0 ) continue;
        for ( ll k = i; k < AMAX; k+=i ) {
            primes[k] = i;
        }
    }
    vector<ll> cnt(AMAX);
    for ( int i = 0; i < N; i++ ) {
        ll a = A[i];
        map<ll,int> m;
        while ( a > 1 ) {
            m[primes[a]]++;
            a /= primes[a];
        }
        for ( auto p : m ) {
            cnt[p.first]++;
        }
    }
    bool pc = true, sc = true;
    for ( int i = 0; i < AMAX; i++ ) {
        if ( cnt[i] > 1 ) pc = false;
        if ( cnt[i] == N ) sc = false;
    }
    if ( pc ) return "pairwise coprime";
    else if ( sc ) return "setwise coprime";
    else return "not coprime";
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 26628
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		while(true){
		int n=sc.nextInt();//the number of nodes
		int q=sc.nextInt();//the number of operations
		if(n==0&&q==0)break;
		int[] d=new int[n];
		int[] marked=new int[n];
		marked[0]++;
		DJSet ds=new DJSet(n);
		for(int i=1;i<n;i++){
			int parent=sc.nextInt()-1;
			d[i]=parent;
		}
		int[] memo=new int[q];
		char[] j=new char[q];
		for(int i=0;i<q;i++){
			String str=sc.next();
			j[i]=str.charAt(0);
			int v=sc.nextInt()-1;
			memo[i]=v;
			if(str.equals("M"))marked[v]++;
		}
		for(int i=1;i<n;i++){
			if(marked[i]>0)continue;
			ds.setUnion(i, d[i]);
		}
		long ans=0;
		for(int i=q-1;i>=0;i--){
			if(j[i]=='Q'){
				ans+=find_ancestor(memo[i],d,marked)+1;
			}else if(j[i]=='M'){
				marked[memo[i]]--;
				if(marked[memo[i]]==0){
					ds.setUnion(memo[i],d[memo[i]]);
				}
			}
		}
		System.out.println(ans);
		}
	}
	int find_ancestor(int x,int[] d,int[] marked){
		while(marked[x]==0){
			x=d[x];
		}
		return x;
	}
	void tr(Object...o){System.out.println(Arrays.deepToString(o));}
	class DJSet{
		int n;//the number of vertices
		int[] d;
		DJSet(int n){
			this.n=n;
			d=new int[n];
			Arrays.fill(d, -1);
		}
		int root(int x){
			return d[x]<0?x:root(d[x]);
		}
		boolean setUnion(int x,int y){
			x=root(x);
			y=root(y);
			if(x!=y){
				if(x<y){
					int d=x;
					x=y;
					y=d;
				}
//				x>y
				d[y]+=d[x];
				d[x]=y;
			}
			return x!=y;
		}
		boolean same(int x,int y){
			return root(x)==root(y);
		}
		int size(int x){
			return d[root(x)]*(-1);
		}
	}
}

Measured memory_bytes: 294728
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion


// 060 B - Choose Integers
#define MAX 100000
int main(void) {
	ll a,b,c,i;

	scanf("%lld %lld %lld", &a,&b,&c);
	for ( i = 1; i < MAX; i++)
		if ((a * i - c) % b ==0)break;

	if (i == MAX) printf("NO\n");
	else          printf("YES\n");

	return 0;
}






Measured memory_bytes: 2092
#include <stdio.h>
 
int main() {
 
  long long i,j,k,n,m,l,a,b,c;
  long long A[101][101] = {0};
  long long B[101][101] = {0};
  long long C[101][101] = {0};
 
  scanf("%lld %lld %lld",&n,&m,&l);
 
  for(j=0; j<n; j++) {
    for(i=0; i<m; i++) {
 
      scanf("%lld", &a);
      A[j][i] = a;
     
    }
  }
 
  for(j=0; j<m; j++){
    for(i=0;i<l;i++){
      scanf("%lld",&b);
      B[j][i] = b;
    }
  }
 
    for(i=0 ;i<n; i++) {
      for(j=0; j<l; j++){
    C[i][j] = 0;
    for(k=0;k<m; k++) {
       C[i][j] += A[i][k]*B[k][j];  
       /*    printf("%d ",C[i][j]); */
    }
    /* printf("\n"); */
      }
    }
 
 
     for(i=0; i<n; i++) {
      for(j=0; j<l; j++) {
    printf("%lld",C[i][j]);
    if(j !=l-1) {
      printf(" ");
    }
      }
      printf("\n");
      } 
 
    return 0;
 
  }


Measured memory_bytes: 2140
#include<stdio.h>
int a[6000000];
int n;
int sum=0;
void hebing(int a[],int q,int p,int l,int d){
  int i,j,k,b[n];
  i=q;
  j=l;
  k=q;
  while(i<=p&&j<=d){
    if(a[i]<a[j]){b[k++]=a[i++];sum++;}
    else {b[k++]=a[j++];sum++;}
  }
  while (i<=p){b[k++]=a[i++];sum++;}
  while (j<=d){b[k++]=a[j++];sum++;}
  for(int i=q;i<=d;i++){
    a[i]=b[i];
  }
}
void paixu(int a[],int m,int n){
    if(n>m){
int x=(n+m)/2;
paixu(a,m,x);
paixu(a,x+1,n);
hebing(a,m,x,x+1,n);
}
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}
paixu(a,0,n-1);
printf("%d",a[0]);
for(int i=1;i<n;i++){
    printf(" %d",a[i]);
}
printf("\n%d\n",sum);
return 0;
}

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

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;



int32_t main()
{
            IOS;

            string s;
            cin>>s;

            if (s[0] == s[1] && s[1] == s[2] )
                  cout<<"No"<<endl;
            else 
                  cout<<"Yes"<<endl;
            
            



            



      


        
























            return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int kazu,i,j,smi;
		Scanner sca = new Scanner(System.in);
		kazu=sca.nextInt();
		String hai1[]=new String[kazu],hai2[]=new String[kazu],hz;
		int order1[]=new int[kazu], order2[]=new int[kazu],hzi;
		for(i=0;i<kazu;i++){
			hai2[i]=hai1[i]=sca.next();
			order2[i]=order1[i]=i;
		}
       for(i=0;i<kazu-1;i++){
    	   for(j=kazu-1;j>0;j--){
    		   if((int)(hai1[j].charAt(1))<(int)(hai1[j-1].charAt(1))){
    			   hz=hai1[j];
    			   hai1[j]=hai1[j-1];
    			   hai1[j-1]=hz;
    			   hzi=order1[j];
    			   order1[j]=order1[j-1];
    			   order1[j-1]=hzi;
    		   }
    	   }
	}
  for(i=0;i<kazu;i++){
    if(i!=kazu-1){	 
     System.out.print(hai1[i]+" ");
     }else{
    	 System.out.println(hai1[i]);
     }
     }
     System.out.println(hantei(order1,hai1));
 /*select sort*/ 
		for(i=0;i<kazu;i++){
			smi=i;
			for(j=i+1;j<kazu;j++){
				if((int)(hai2[smi].charAt(1))>(int)(hai2[j].charAt(1))){
					smi=j;
				}
				}
			if(smi!=i){
				hz=hai2[smi];
				hai2[smi]=hai2[i];
				hai2[i]=hz;
 			   hzi=order2[smi];
 			   order2[smi]=order2[i];
 			   order2[i]=hzi;				
			}
		}
	     for(i=0;i<kazu;i++){
	    	    if(i!=kazu-1){	 
	    	     System.out.print(hai2[i]+" ");
	    	     }else{
	    	    	 System.out.println(hai2[i]);
	    	     }
	    }
	    	     System.out.println(hantei(order2,hai2));
     
}
	static String hantei(int[] index,String[] data){
		int i;
		for(i=0;i<data.length-1;i++){
			if((data[i].charAt(1))==(data[i+1].charAt(1))){
				if(index[i]>index[i+1]){
					return "Not stable";
				}
				}
		}
		return "Stable";
		
	}
}


Measured memory_bytes: 26312
// TEMPLATE {{{
#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
#define OJ 1
#else
#define OJ 0
#endif
 
#define endl '\n'
#define TIMESTAMP merr << "Execution time: " << (double)clock()/CLOCKS_PER_SEC << " s.\n"
class C_ {}; template <typename T> C_& operator <<(C_& __m, const T& __s) { if (!OJ) cerr << "\E[91m" << __s << "\E[0m"; return __m; }
C_ merr;
 
struct __s { __s() { if (OJ) { ios_base::Init i; cin.sync_with_stdio(0); cin.tie(0); } } ~__s(){ TIMESTAMP; } } __S;
/// END OF TEMPLATE }}}

#define size_t unsigned long long

vector<size_t> G[111111];
bool u[111111];

void dfs(size_t v) {
    if (u[v]) return;
    u[v] = 1;
    for (auto vv : G[v]) {
        dfs(vv);
    }
}

int main(void) {
    size_t n, m;
    cin >> n >> m;
    for (size_t i = 0; i < m; i++) {
        size_t a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    size_t ans = 0;
    for (size_t i = 0; i < n; i++) {
        if (!u[i]) {
            ans++;
            dfs(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9216
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
  return (a<b)?a:b;
}
int max(int a,int b){
  return (a>b)?a:b;
}
int fp(int a,int b){
  if(b==0) return 1;
  int x=fp(a,b/2);
  x=(x*x)%mod;
  if(b&1) x=(x*a)%mod;
  return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 string s;
 cin>>s;
 if(s[0]=='7'||s[1]=='7'||s[2]=='7')
  cout<<"Yes";
 else 
  cout<<"No";

}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main()
{
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if(y >= 2019){
        if(m >= 5){
            cout << "TBD" << endl;
        }
        else cout << "Heisei" << endl;
    }
    else cout << "Heisei" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 1e18L+5
using namespace std;
int32_t main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll k=t.length();
        ll dp[n+1][k+1];
        string o="";
        ll ma=-1;
        for(int i=0;i<=n;i++){
            for(int j=0;j<=k;j++){
                if(i==0||j==0){
                    dp[i][j]=0;
                }else{
                    if(s[i-1]==t[j-1]){
                        dp[i][j]=1+dp[i-1][j-1];
                    }
                    else{
                        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                    }
                }
            }
        }
        ll count=0;
        ll i=n,j=k;
        while(i>0&&j>0){
               if(s[i-1]==t[j-1]){
                    o+=s[i-1];
                    i--;
                    j--;
                    //index--;
               }
                else if(dp[i-1][j]>dp[i][j-1]){
                    i--;
                }
                else{
                    j--;
                }
            
        }
    reverse(o.begin(),o.end());
      if(o.length()>=1)cout<<o;
      else cout<<" ";
}




Measured memory_bytes: 70656
M=4294967311

def pmod(v):
	return (v%M+M)%M

def mpow(x,N):
	res=1
	while (N>0):
		if(N%2):
			res=pmod(res*x)
		x=pmod(x*x)
		N/=2
	return res

def minv(a):
	return mpow(a,M-2)

N=input()
v=0
for i in range(N):
	c,y=map(int,raw_input().split())
	if (c==1):
		v=pmod(v+y)
	if (c==2):
		v=pmod(v-y)
	if (c==3):
		v=pmod(v*y)
	if (c==4):
		v=pmod(v*minv(y))

if (v<(1<<31)):
	v=v
else:
	v=v-M;

print "%d" % v

Measured memory_bytes: 7392
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n; cin >> n;
  while(n--) {
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double d = sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));

    int ans;
    if(d > ra+rb) ans = 0;
    else if(ra > d+rb) ans = 2;
    else if(rb > d+ra) ans = -2;
    else ans = 1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1240
N = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

dp = Array.new(N, 10**10)

dp[0] = 0
dp[1] = (h[1] - h[0]).abs

def min(a,b)
  a < b ? a : b
end

2.upto(N-1) do |i|
  a = (h[i] - h[i-2]).abs + dp[i-2]
  b = (h[i] - h[i-1]).abs + dp[i-1]
  dp[i] = min(a, b)
end

p dp.last


Measured memory_bytes: 9220
#include<cstdio>
int main(){
	char a[16];
	scanf("%s",&a);
	int ans=0;
	if(a[0]!='C')ans++;
	if(a[1]!='O')ans++;
	if(a[2]!='D')ans++;
	if(a[3]!='E')ans++;
	if(a[4]!='F')ans++;
	if(a[5]!='E')ans++;
	if(a[6]!='S')ans++;
	if(a[7]!='T')ans++;
	if(a[8]!='I')ans++;
	if(a[9]!='V')ans++;
	if(a[10]!='A')ans++;
	if(a[11]!='L')ans++;
	if(a[12]!='2')ans++;
	if(a[13]!='0')ans++;
	if(a[14]!='1')ans++;
	if(a[15]!='6')ans++;
	printf("%d\n",ans);
}

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

int main(){
	
	int i=0;
	int idx=0;
	char input[10], output[10];

	scanf("%s", input);
	
	for(; i < strlen(input); i++){
		if(input[i] == '1'){
			output[idx++] = '1';
		}else if(input[i] == '0'){
			output[idx++] = '0';
		}else if(input[i] == 'B'){
			if(idx > 0)
				idx--;
		}
	
	}

	output[idx] = '\0';
	printf("%s\n", output);
	return 0;
	
}


Measured memory_bytes: 128
N=int(input())
A=input()
def check_l(A):
    for i in range(1,len(A)+1):
        if not i==len(A):
            if A[-i]=="(":
                pass
            else:
                return i
                break
        elif i==len(A):
            if A[-i]=="(":
                return 0
            else:
                return i
                break
def check_t(A):
    for i in range(0,len(A)):
        if not i==len(A)-1:
            if A[i]==")":
                pass
            else:
                return i
                break
        elif i==len(A)-1:
            if A[i]==")":
                a=len(A)
                return a
            else:
                return i
def all(A,C):
    if check_l(A)==0:
        for i in range(len(A)):
            C=C+")"
        print(C)
        exit()
    elif not check_l(A)==0:
        for i in range(check_l(A)-1):
            A=A+")"
            C=C+")"

    if check_t==len(A):
        for i in range(len(A)):
            C="("+C
        print(C)
        exit()
    else:
        for i in range(check_t(A)):
            A="("+A
            C="("+C

    for i in range(10**9):
        if "()" in A:
            A=A.replace("()","")
        else:
            break
    return A,C

X=A

for i in range(N):
    if A=="":
        print(X)
        break
    else:
        A,X=all(A,X)


Measured memory_bytes: 3064
import numpy as np
import sys

n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.read().split(),dtype=np.int64)

a.sort()
neg=a[a<0]
zero=a[a==0]
pos=a[a>0]

def count(x):
    cnt=0
    if x>=0:
        cnt+=len(zero)*n
    cnt+=np.searchsorted(a,x//pos,side='right').sum()
    cnt+=(n-np.searchsorted(a,(-x-1)//(-neg),side='right')).sum()
    cnt-=np.count_nonzero(a*a<=x)
    return cnt//2


left=-10**18
right=10**18

while left+1<right:
    x=(left+right)//2
    out=count(x)
    if out>=k:
        right=x
    if out<k:
        left=x

print(right)


Measured memory_bytes: 34324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5e5+10;
char s[N];
int a[N],b[N];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int cnt=1;
    a[0]=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='<')
        {
            a[i]=a[i-1]+1;
        }
        else
        {
            a[i]=0;
        }
    }

    b[n]=0;
    for(int i=n;i>=1;i--)
    {
        if(s[i]=='>')
        {
            b[i-1]=b[i]+1;
        }
        else
        {
            b[i-1]=0;
        }
    }
   /* for(int i=0;i<=n;i++)
    {
        cout<<a[i]<<" "<<b[i]<<" "<<s[i]<<"\n";
    }*/
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        ans=ans+max(a[i],b[i]);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count=0;
  int Max=0;
  for(int i = 0; i < s.size(); i++){
    if(s[i]=='S')count=0;
    else count++;
    Max=max(Max,count);
  }
  cout << Max << endl;
  return 0;
}


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

const int N = 1e5 + 5;

int deg[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1, x; i <= m + m; i ++) {
    scanf("%d", &x); deg[x] ++;
  }
  for (int i = 1; i <= n; i ++)
    if (deg[i] & 1) return 0 * puts("NO");
  puts("YES");
  return 0;
}


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

int main(){
int A, B, X;
  cin >> X >> A >> B;
  
  if(B - A > X) cout << "dangerous" << endl;
  else if(B - A <= 0) cout << "delicious" << endl;
  else cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    int a,b;
    cin>>a>>b;
    int sum=a+b,diff=a-b,mul=a*b;
    int ans=max(mul,max(sum,diff));
    cout<<ans;
    return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.5
#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[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int XOR(int a,int b){bitset<64>z(a),x(b),c;c=z^x;return c.to_ullong();}  //  XOR

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(8);
  int n,k;
  cin >> n >> k;
  int maxx=0,memo,G;
  rep(i,0,n){
    cin >> memo;
    maxx = max(maxx,memo);
    if(i==0) G = memo;
    else G = gcd(G,memo);
  }
  
  if(k > maxx) cout << "IMPOSSIBLE" << endl;
  else if(k%G==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


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

int main(){
  int ans, N, K;
  cin >> N >> K;
  vector<int> a(N + K, 10E5);
  
  for(int i = 0; i < N; i++) cin >> a.at(i);
  
  vector<int> dp(N + K, 10E8);
  dp.at(0) = 0;
  for(int i = 0; i < N; i++){
    for(int j = 1; j <= K; j++){
      dp.at(i + j) = min(dp.at(i + j), dp.at(i) + abs(a.at(i) - a.at(i + j)));
    }
  }
  
  ans = dp.at(N - 1);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    int N, X, T; cin >> N >> X >> T;
    cout << ((N+X-1)/X)*T << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

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

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

int main(){
  char S[3];
  cin >> S;
  
  for(int i=0; i<2; i++){
    if(S[i] != S[i+1]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 50000000

int parent(int i) {return i / 2;}
int left(int i) {return 2*i;}
int right(int i){return 2*i + 1;}
int H;
int A[MAX];

void maxHeap(int idx){
    int l = left(idx);
    int r = right(idx);
    int large;
    if(l <= H && A[idx] < A[l]){
        large = l;
    } else {
        large = idx;
    }

    if(r <= H && A[large] < A[r]){
        large = r;
    }

    if(large != idx){
        int tmp = A[idx];
        A[idx] = A[large];
        A[large] = tmp;
        maxHeap(large);
    }

}

void exec(){
    for(int i = H/2; i >= 1; i--) maxHeap(i);
}

int main(){
    int i;
    scanf("%d", &H);
    for(i = 1; i <= H; i++){
        scanf("%d", &A[i]);
    }

    exec();

    for(i = 1; i <= H; i++){
        printf(" %d", A[i]);
    }

    printf("\n");

    return 0;
}



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


int main(void) {
    int N;
    int A[100000];
    int X[100000];
    long tmp, sum;

    tmp = 0;
    sum = 0;
    scanf("%d", &N);
    for (int i=0;i<N;i++) {
        scanf("%d", &(A[i]));
        sum += A[i];
        if (i%2 == 0)
            tmp += A[i];
    }

    X[0] = tmp - sum/2;
    for (int i=1;i<N-1;i++) {
        X[i] = A[i-1] - X[i-1];
    }
    X[N-1] = A[N-1] - X[0];

    for (int i=0;i<N;i++) {
        printf("%d", 2*X[i]);
        if (i != N-1)
            printf(" ");
    }


    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<math.h>
#define ll long long 
using namespace std;
int main ()
{   ll  A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    ll dis=abs(A-B);
    //cout<<dis;
    if(V<=W)
      printf("NO");
     else
	 {   if(dis<=T*(V-W))
	    printf("YES");
	    else
	    printf("NO");
	  } 
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INF = 1ll << 60;

int main() {
  string s;
  cin >> s;
  int l = s.size() - 7;
  string t;
  for (int i = 0; i < l; i++) t = t + "*";
  string key = "keyence";
  vector<string> v(8);
  for (int i = 0; i < 8; i++)
    v[i] = key.substr(0, i) + t + key.substr(i, 7 - i);

  for (int i = 0; i < 8; i++) {
    bool can = true;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != v[i][j] && v[i][j] != '*') { can = false; }
    }
    if (can) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256