akhauriyash/Code-Regression huggingface dataset:
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-13 03:53:36
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

constexpr int64 MOD = 1e9 + 7;

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

  int n; cin >> n;
  vector<int> t(n), a(n);
  for (int i = 0; i < n; ++i) cin >> t[i];
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<int> res1(n, -1), res2(n, -1);

  for (int i = 0; i < n; ++i) {
    if (i == 0 || t[i] > t[i - 1]) {
      res1[i] = t[i];
    }
  }
 
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1 || a[i] > a[i + 1]) {
      res2[i] = a[i];
    }
  }

  debug(res1);
  debug(res2);

  if (*max_element(res1.begin(), res1.end()) != *max_element(res2.begin(), res2.end())) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> res(n, -1);

  for (int i = 0; i < n; ++i) {
    if (res1[i] == -1 && res2[i] == -1) {
      res[i] = -1;
    } else if (res1[i] == -1 && res2[i] != -1) {
      if (res2[i] > t[i]) {
        cout << 0 << endl;
        return 0;
      }
      res[i] = res2[i];
    } else if (res2[i] == -1 && res1[i] != -1) {
      if (res1[i] > a[i]) {
        cout << 0 << endl;
        return 0;
      }
      res[i] = res1[i];
    } else if (res1[i] != -1 && res2[i] != -1) {
      if (res1[i] == res2[i]) {
        res[i] = res1[i];
      } else {
        cout << 0 << endl;
        return 0;
      }
    }
  }

  debug(res);

  int64 ans = 1;
 
  int beg = 0;
  int last = res[0];
 
  while (beg < n) {
    if (res[beg] != -1) {
      ++beg;
    } else {
      last = res[beg - 1];
      assert(last != -1);
      int end = beg;
      while (end + 1 < n && res[end + 1] == -1) {
        ++end;
      }
      int len = end - beg + 1;
      for (int i = 0; i < len; ++i) {
        ans *= static_cast<int64>(min(last, res[end + 1]));
        ans %= MOD;
      }
      beg = end + 1;
    }
  }
 
  cout << ans << endl;

  return 0;
}

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

#define pi 3.141592653589

int main(){
	double r,S,R;
	cin >> r;
	S = r*r*pi;
	R = 2 * r*pi;
	cout << fixed << setprecision(5) << S << " " << R << endl;
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair

#define vlll vector<vll>

int main() {
	ll n;
	cin >> n;
	int keta;
	for (keta = 62; keta >= 0; keta--) {
		if ((n & (1LL << keta))) {
			break;
		}
	}
	
	vlll dp(keta + 2, vll(2, vl(2)));
	dp[0][1][0] = 1;
	rep(keta, dp.size() - 1) {
		rep(ika, 2) {
			rep(kuri, 2) {
				int nketa = keta + 1;
				ll mask = 1LL << keta;
				int wa = kuri;
				int nkuri = wa / 2; wa = wa % 2;
				int nika = ika;
				if ((n & mask) && !wa) {
					nika = 1;
				}
				else if (!(n & mask) && wa) {
					nika = 0;
				}
				dp[nketa][nika][nkuri] += dp[keta][ika][kuri];
				dp[nketa][nika][nkuri] %= MOD;
				wa = kuri + 1;
				nkuri = wa / 2; wa = wa % 2;
				nika = ika;
				if ((n & mask) && !wa) {
					nika = 1;
				}
				else if (!(n & mask) && wa) {
					nika = 0;
				}
				dp[nketa][nika][nkuri] += dp[keta][ika][kuri];
				dp[nketa][nika][nkuri] %= MOD;
				wa = kuri + 2;
				nkuri = wa / 2; wa = wa % 2;
				nika = ika;
				if ((n & mask) && !wa) {
					nika = 1;
				}
				else if (!(n & mask) && wa) {
					nika = 0;
				}
				dp[nketa][nika][nkuri] += dp[keta][ika][kuri];
				dp[nketa][nika][nkuri] %= MOD;
			}
		}
	}
	ll ans = (dp[dp.size() - 1][1][0]);
	cout << ans << endl;
}

Measured memory_bytes: 256
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(arr[K-1])

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  string S;
  getline(cin, S);

  i64 i = 0;
  i64 ans = 0;

  while(i != sz(S)) {
    i64 C1 = 0, C2 = 0;

    C1 = 0;
    while(i != sz(S) && S[i] == '<') {
      ++C1;
      ++i;
    }
    ans += C1 * (C1 + 1) / 2;

    while(i != sz(S) && S[i] == '>') {
      ++C2;
      ++i;
    }
    ans += C2 * (C2 + 1) / 2;
    ans -= min(C1, C2);
  }
  
  cout << ans << endl;

  return 0;
}


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

using namespace std;
int main(void){

    int n;
    cin >> n;
    
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    int alice = 0;
    int bob = 0;
    for(int i=0; i<n; i++) {
        if(i%2==0) alice += a[i];
        else bob += a[i];
    }
    
    cout << alice-bob << endl;

    return 0;
    
}


Measured memory_bytes: 256
n = STDIN.gets.to_i
input = STDIN.gets.split.map(&:to_i)
@count = 0
def merge_sort(array)
  return array if array.size == 1
  mid_index = array.size/2
  left = array[0..mid_index-1]
  right = array[mid_index..-1]
  sorted_left = merge_sort(left)
  sorted_right = merge_sort(right)
  merge(sorted_left, sorted_right)
end
def merge(left, right)
  result = []
  until left.empty? && right.empty? do
    @count += 1
   if left.empty?
     result << right.shift
   elsif right.empty?
     result << left.shift
   elsif left[0] < right[0]
     result << left.shift
   else
     result << right.shift
   end
  end
  result
end
puts merge_sort(input)*" "
p @count



Measured memory_bytes: 71012
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        scan.close();
        String[] b = a.split("");
        for (String s : b) {
            if (s.equals("7")) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
    }

}


Measured memory_bytes: 35644
dic = {}
while True:
    try:
        word, page = map(str,raw_input().split())
        if word in dic:
            dic[word].append(int(page))
        else:
            dic[word] = [int(page)]
    except:
        for word in sorted(dic):
            print word
            for page in sorted(dic[word]):
                print page,
            print
        break

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

int main(){
	int D,N,answer;
    cin >> D >> N;
    answer = 0;
    if(D == 0){
        if(N==100){
            cout << 101;
            
        }else{
            cout << N*1 <<endl;
        }
        return 0;

    }else if(D == 1){
        if(N==100){
            cout << 10100<<endl;
        }else {
            cout << 100*N <<endl;
        }return 0;
    }else if(D == 2){
        if(N==100){
            cout << 1010000 ;
        }else{
            cout << 10000*N <<endl;
        }
        return 0;
    }
    
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define inf (1<<29)
int H,W;
bool G[51][51];
int d[51][51];
string s[51];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
queue<P> q;
int main()
{
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	int cnt=0;
	rep(i,H) rep(j,W){
		if(s[i][j]=='.'){
			G[i][j]=0;
			cnt++;
		}
		else{
			G[i][j]=1;
			//cnt++;
		}
		d[i][j]=inf;
	}
	d[0][0]=0;
	q.push(P(0,0));
	while(!q.empty()){
		P p=q.front();
		q.pop();
		rep(i,4){
			if(0<=p.fr+dy[i]&&p.fr+dy[i]<H&&0<=p.sc+dx[i]&&p.sc+dx[i]<W&&!G[p.fr+dy[i]][p.sc+dx[i]])
			if(d[p.fr][p.sc]+1<d[p.fr+dy[i]][p.sc+dx[i]]){
				d[p.fr+dy[i]][p.sc+dx[i]]=d[p.fr][p.sc]+1;
				q.push(P(p.fr+dy[i],p.sc+dx[i]));
			}
		}	
	}
	if(d[H-1][W-1]==inf) puts("-1");
	else cout<<cnt-d[H-1][W-1]-1<<endl;
}

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

using namespace std;
static const int MAX = 10;

int factorial(int n) {
    int sum = 1;
    for (int i = 1; i <= n; ++i) {
        sum *= i;
    }
    return sum;
}

double distance(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1;
    int dy = y2 - y1;
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    int N, X[MAX], Y[MAX], R[MAX];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        cin >> Y[i];
        R[i] = i;
    }

    double D[MAX][MAX];
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            // i - j 間距離 (i > j)
            double d = distance(X[i], Y[i], X[j], Y[j]);
            D[i][j] = d;
        }
    }

    double sum = 0;
    int f = factorial(N);
    for (int i = 0; i < f; ++i) {
        int prev = R[0];
        for (int j = 1; j < N; ++j) {
            sum += D[min(prev, R[j])][max(prev, R[j])];
        }
        next_permutation(R, R + N);
    }

    cout.precision(10);
    cout << sum / f << endl;

    return 0;
}


Measured memory_bytes: 512
a,b,x=map(int,input().split())

import math
if x>(a**2)*b/2:
  theta=math.atan((2*(a**2)*b-2*x)/(a**3))*180/math.pi
else:
  theta=math.atan((a*b**2)/(2*x))*180/math.pi

print(theta)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n,k;
void input()
{
	n=read<int>(),k=read<int>();
}
ll cal1()
{
	ll num=n/k;
	return num*num*num;
}
ll cal2()
{
	if(n<k/2)return 0;
	ll num=(n-k/2)/k+1;
	return num*num*num;
}
void work()
{
	ll ans=cal1();
	if(k%2==0)ans+=cal2();
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
string k;
int D;
ll memo[10010][2][110];

ll dp(int i, int f, int d){
    if(i == k.size()) return d==0?1:0;
    if(memo[i][f][d] != -1) return memo[i][f][d];

    ll res = 0;
    int now = k[i] - '0';

    for(int di = 0; di <= (f?9:now); di++){
        res += dp(i + 1, (f||(di<now)), (d + di) % D) % MOD;
        res %= MOD;
    }

    return memo[i][f][d] = res;
}

void init(){
    for(int i = 0; i <= k.size(); i++){
        for(int j = 0; j < 2; j++){
            for(int l = 0; l <= D; l++){
                memo[i][j][l] = -1;
            }
        }
    }
}


int main(void){
    cin >> k >> D;

    init();
    ll ans = dp(0, 0, 0) + ((-1)%MOD);
    if(ans < 0) ans += MOD;
    cout << ans % MOD << endl;
}

Measured memory_bytes: 18432
#include <cstdio>
int n, c, v[100005];
int main() {
	int i, t;
	scanf("%d", &n);
	for(i=0; i<n; i++) {
		scanf("%d", &t);
		if(v[t]) c++;
		v[t] = 1;
	}
	printf("%d", n-c-c%2);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

#define Max 1000

void  swap(int *x, int *y)
{
    int  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

int bubbleSort(int A[Max], int N) {
	int i, j;
	int flag = 1;
	int count = 0;

	while (flag) {
		flag = 0;
		for (j = N - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				swap(&A[j], &A[j - 1]);
				flag = 1;
				count++;
			}
		}
	}

	return count;
}

int main( ) {
	int N, i, count;
	int num[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &num[i]);

	count = bubbleSort(num, N);

	for (i = 0; i < N - 1; i++)
		printf("%d ", num[i]);
	printf("%d\n", num[N - 1]);

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 604
n, y = map(int, input().split())
a = True
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            a = False
            print(i,j,(n-i-j), sep=" ")
            exit()
if a:
    print(-1, -1, -1, sep=" ")

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum=0,c=0,f=0;
    cin>>a>>b;
    if((a==1 ||a==8 ||a==3 ||a==5 ||a==7 ||a==10||a==12 ) &&(b==1 ||b==8 ||b==3 ||b==5 ||b==7 ||b==10||b==12 ))
    {
    cout<<"Yes"<<endl;
    }
   else if((a==4 ||a==6 ||a==9 ||a==11  ) &&(b==4 ||b==6 ||b==9 ||b==11  ))
    {
    cout<<"Yes"<<endl;
    }
    else
    {cout<<"No"<<endl;}





    }


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

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

int main(){
    int x;
    cin >> x;
    int ans = 0;
    for(int i = x;;i++){
        if(is_prime(i)){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  string S;
  cin >> S;
  N = S.size();
  if(S.at(N-1) == 's'){
    S = S + "es";
  }else{
    S = S + "s";
  }
  cout << S << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std ;
using ll = long long ;

int main(){
	ll n,l ;
	cin >> n >> l ;
	l-- ;
	if(l>=0) cout << (n-1)*(n+2)/2+l*(n-1) << endl ;
	else if(-1*l>=n) cout << (n-1)*n/2+l*(n-1) << endl ;
	else cout << n*(n+1)/2+l*n << endl ;
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(A, B):
    return (A * B) // fractions.gcd(A, B)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = [int(input()) for _ in range(N)]

print(lcm(T))

Measured memory_bytes: 5176
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
vector<LL> pos, neg;
LL zcnt = 0;

bool check(LL N, LL K, LL ans) {
    LL sum = 0;
    if (ans >= 0) {
        for (int i = 0; i < zcnt; i++)
            sum += N - 1 - i;
    }
    int l = (int)neg.size() - 1;
    for (int i = (int)pos.size() - 1; i >= 0; i--) {
        LL cur = pos[i];
        while (l >= 0 && neg[l] * cur > ans) l--;
        sum += l + 1;
    }
    if (ans > 0) {
        int posN = (int)pos.size();
        int l = posN - 1;
        for (int i = 0; i < posN; i++) {
            LL cur = pos[i];
            while (l >= 0 && pos[l] * cur > ans) l--;
            if (l > i) sum += (l - i);
        }
        int negN = (int)neg.size();
        l = 0;
        for (int i = negN - 1; i >= 0; i--) {
            LL cur = neg[i];
            while (l < negN && neg[l] * cur > ans) l++;
            if (l < i) sum += (i - l);
        }
    }
    return sum >= K;
}

int main() {
    LL N, K;
    scanf("%lld %lld", &N, &K);
    for (int i = 0; i < N; i++) {
        LL tmp;
        scanf("%lld", &tmp);
        if (tmp < 0) neg.push_back(tmp);
        else if (tmp == 0) zcnt++;
        else pos.push_back(tmp);
    }
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());
    LL l = -(LL)1e18, r = (LL)1e18, ans = (LL)1e18;
    while (l <= r) {
        LL mid = (l + r) / 2;
        if (check(N, K, mid)) {
            r = mid - 1;
            ans = mid;
        } else l = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);

		int n=sc.nextInt();
		int x,count=0;

		for(int i=0;i<n;i++) {

			x=sc.nextInt();

			if(judge_prime(x)) count++;

		}

		System.out.println(count);

	}


	private static  boolean judge_prime(int x) {
		
		if(x<=2) return true;
		
		else if(x%2==0) return false;

		for(int i=3;i<=Math.sqrt(x);i+=2)
			if(x%i==0) return false;

		return true;
	}
}


Measured memory_bytes: 41044
int main(){
    double pai=3.141592653589;
    int n;
    scanf("%d",&n);
    for(int i=3;i<=n;i++){
        int x=i;
        if(i%3==0){
            printf(" %d",i);
        }else{
            do{
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
                x/=10;
            }
            while(x);
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2052
import math
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(it):
    return sum(1 for _ in it)


def solve():
    N = read_int()
    A = read_ints()
    A.sort()
    grouped = [(a, ilen(v)) for a, v in groupby(A)]
    max_count = -math.inf
    for i in range(len(grouped)):
        count = grouped[i][1]
        if i > 0 and grouped[i][0]-1 == grouped[i-1][0]:
            count += grouped[i-1][1]
        if i < len(grouped)-1 and grouped[i][0]+1 == grouped[i+1][0]:
            count += grouped[i+1][1]
        max_count = max(max_count, count)
    return max_count


if __name__ == '__main__':
    print(solve())


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

double kyori(pii x, pii y) {
  return sqrt(pow(x.first - y.first, 2) + pow(x.second - y.second, 2));
}

inline void Main() {
  // code
  int n,h[(int)1e5];
  cin>>n;
  rep(i,n)cin>>h[i];

  int r = 0, s = 0;
  rep(i, n-1) {
    if(h[i] >= h[i+1]) {
      s++;
    } else {
      r = max(r, s);
      s = 0;
    }
  }

  r = max(r, s);
  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 640
import fractions
a,b,c,d=list(map(int, input().split()))
lcm=int(c*d/fractions.gcd(c,d))
could_divide=(b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm-(a-1)//lcm)
#print("could divide by "+str(c)+" : "+str(b//c-(a-1)//c))
#print("could divide by "+str(d)+" : "+str(b//d-(a-1)//d))
print(b-a+1-could_divide)

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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

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

int cnt[10001];

int main()
{
    int n;
    cin >> n;
    map<int,int> m;
    int sub = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        m[a]++;
    }
    for(auto i : m){
        if(i.second % 2 == 0) sub++;
    }
    if(sub % 2 == 0) cout << m.size() << endl;
    else cout << m.size() - 1 << endl;
}


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

int main() {
	string s;
	cin >> s;
	int left = 0, right = s.size();
	while (left < right) {
		int mid = (left + right) / 2;
		bool flag = false;
		for (int base = 0; !flag && base <= 1; base++) {
			int low = base;
			int high = mid;
			if ((high - low) & 1) {
				high--;
			}
			bool ok = high >= low;
			for (int i = 0; ok && i < s.size(); i++) {
				if (s[i] == '1') {
					low++;
					high++;
				}
				else if (s[i] == '0') {
					low--;
					high--;
				}
				else {
					low--;
					high++;
				}
				if (low < 0) {
					low += 2;
				}
				if (high > mid) {
					high -= 2;
				}
				ok = high >= low;
			}
			flag = ok;
		}
		if (flag) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	cout << left << endl;
}

Measured memory_bytes: 4464
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>

#define INF (int)(1e9)

using namespace std;

using Magic = pair<int, int>;

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

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

int dp[20005];

int main()
{
  int H;
  int N;
  vector<Magic> magic_array;

  cin >> H >> N;

  for (int i = 0; i < N; i++) {
    int a;
    int b;
    cin >> a >> b;
    magic_array.push_back(Magic(a, b));
  }

  auto max_magic_itr = max_element(magic_array.begin(), magic_array.end());
  int max_a = max_magic_itr->first;

  int min_mana_consumption = INF;

  for (int i = 0; i <= H + max_a; i++) {
    dp[i] = INF;
    for (auto &&magic_itr : magic_array) {
      if (i == magic_itr.first) {
        chmin(dp[i], magic_itr.second);
      }
      else if (i - magic_itr.first > 0) {
        chmin(dp[i], dp[i - magic_itr.first] + magic_itr.second);
      }
    }
    if (i >= H) {
      chmin(min_mana_consumption, dp[i]);
    }
  }

  cout << min_mana_consumption;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key) {
    A[n] = key;
    int i = 0;
    while (A[i] != key) i++;
    return i != n;
}


int main(int argc, char const *argv[])
{
    int key, n, q, A[10000 + 1], sum = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key)) {
            sum++;
        }
    }

    printf("%d\n", sum);

    return 0;
}




Measured memory_bytes: 2104
#include <iostream>
#include <string>

int main(){
	std::string s;
	std::string os = "";
	std::cin >> s;

	for(unsigned int i = 0; 2 * i <= s.size(); ++i){
		os += s.substr(2 * i, 1);
	}

	std::cout << os << std::endl;

	return 0;
}


Measured memory_bytes: 640
from math import cos, sin, radians
def koch(n, a, b):
        if n == 0:
                return
        s = [0, 0]
        t = [0, 0]
        u = [0, 0]
        s[0] = (2 * a[0] + 1 * b[0]) / 3
        s[1] = (2 * a[1] + 1 * b[1]) / 3
        t[0] = (1 * a[0] + 2 * b[0]) / 3
        t[1] = (1 * a[1] + 2 * b[1]) / 3
        u[0] = (t[0] - s[0]) * cos(radians(60)) - (t[1] - s[1]) * sin(radians(60)) + s[0]
        u[1] = (t[0] - s[0]) * sin(radians(60)) + (t[1] - s[1]) * cos(radians(60)) + s[1]
        koch(n - 1, a, s)
        print('{:.08f} {:.08f}'.format(s[0], s[1]))
        koch(n - 1, s, u)
        print('{:.08f} {:.08f}'.format(u[0], u[1]))
        koch(n - 1, u, t)
        print('{:.08f} {:.08f}'.format(t[0], t[1]))
        koch(n - 1, t, b)

a = [0, 0]
b = [100, 0]
n = int(input())
print('{:.08f} {:.08f}'.format(a[0], a[1]))
koch(n, a, b)
print('{:.08f} {:.08f}'.format(b[0], b[1]))



Measured memory_bytes: 5764
#include<stdio.h>

void print(int a[],int n){ 
    int i;
    printf("%d",a[0]);
    for(i=1;i<n;i++){
        printf(" %d",a[i]);
    }   
    puts("");
}

void insertionsort(int a[],int n){ 
    int temp,i,j;
    print(a,n);
    for(i=1;i<n;i++){
        temp=a[i];
        j=i-1;
        while(j>=0&&a[j]>temp){
            a[j+1]=a[j];
            j--;
        }   
        a[j+1]=temp;
        print(a,n);
    }   
}

int main(){
    int n,a[100]={0},i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }   
    insertionsort(a,n);
    return 0;
}

Measured memory_bytes: 612
def test():
    s = list(input())

    if s[0] == s[1]:
        print("Bad")
        return
    elif s[1] == s[2]:
        print("Bad")
        return
    elif s[2] == s[3]:
        print("Bad")
        return

    print("Good")


if __name__ == "__main__":
    test()


Measured memory_bytes: 2940
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll h, w, n;
  cin >> h >> w >> n;
  ll ans = 0;
  while(1){
    ans++;
    n -= max(h, w);
    if(n <= 0) break;
  }
  print(ans);
}


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

typedef long long ll;

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = (a*(n/(a+b)));
    if(n%(a+b)<=a) ans += n%(a+b);
    else ans += a;
    cout << ans;
}

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

const long long mod = 1000000007;

class mint {
public:
    long long v;
    mint(long long v = 0) : v((v % mod + mod) % mod) {}
    mint operator+(mint t) {return mint((v + t.v) % mod);}
    mint operator-(mint t) {return mint((v - t.v + mod) % mod);}
    mint operator*(mint t) {return mint((v * t.v) % mod);}
    mint operator+=(mint t) {return *this = *this + t;} 
    mint operator-=(mint t) {return *this = *this - t;}
    mint operator*=(mint t) {return *this = *this * t;}
    mint operator-() {return mint(-v);}
    mint mpow(long long t) {
        if (t == 0) return mint(1);
        mint a = mpow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() {mpow(mod - 2);}
    mint operator/(mint t) {return mint(v) * inv();}
    mint operator/=(mint t) {return *this = *this / t;}
};

int main() {
    int n, m;
    cin >> n >> m;
    cout << mint(n).mpow((long long)m).v << endl;
}


Measured memory_bytes: 3104
using System;
using System.Linq;

namespace AtCoderBeginnerContest153
{
	class Program
	{
		static void Main(string[] args)
		{
			var hp = ReadLong();

			Console.WriteLine(CulculateMinimum2Pow(hp));
		}

		private static long CulculateMinimum2Pow(long number)
		{
			var tmp = 1L;
			var result = 0L;
			while (number >= tmp)
			{
				result += tmp;
				tmp *= 2;
			}
			return result;
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


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

using namespace std;


typedef long long int64;

int main()
{
  int X, Y, Z, A, B, C, N;
  int64 a[1000] = {}, b[1000] = {}, c[1000] = {};

  cin >> X >> Y >> Z >> A >> B >> C >> N;
  for(int i = 0; i < X; i++) ++a[abs(i - A) % N];
  for(int i = 0; i < Y; i++) ++b[abs(i - B) % N];
  for(int i = 0; i < Z; i++) ++c[abs(i - C) % N];

  int64 d[1000] = {}, ret[1000] = {};
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) d[(i + j) % N] += a[i] * b[j];
  }

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      ret[(i + j) % N] += d[i] * c[j];
    }
  }

  for(int i = 0; i < N; i++) {
    if(i > 0) cout << " ";
    cout << ret[i];
  }
  cout << endl;

}

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

public class Main {

	/** 左括弧 */
	private static final char LEFT = '(';

	/** 右括弧 */
	private static final char RIGHT = ')';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			// 現在までの閉じていない左括弧と右括弧の数
			int noRight = 0, noLeft = 0;
			for (char c : s) {
				if (LEFT == c) {
					if (noRight >= 0) {
						noRight++;
					} else {
						noLeft -= noRight;
						noRight = 1;
					}
				} else {
					noRight--;
				}
			}
			if (noRight < 0) {
				noLeft -= noRight;
				noRight = 0;
			}
			System.out.println(repeat(LEFT, noLeft) + String.valueOf(s) + repeat(RIGHT, noRight));
		}
	}

	/**
	 * @param c 文字
	 * @param n 数
	 * @return 文字をn回繰り返した文字列
	 */
	private static String repeat(char c, int n) {
		StringBuilder sb = new StringBuilder();
		IntStream.range(0, n).forEach(i -> sb.append(c));
		return sb.toString();
	}
}


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


int main()
{   
    int n;
    cin>>n;
    map <string,int> mp;  //key:string  value:int
    rep(i,n)
    {
        string s;
        cin>>s;
        mp[s]++;
    }

    int mx=0;

    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(mx<it->second)
        {
            mx = it->second;
        }
    }

    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==mx)
        {
            cout<<it->first<<endl;
        }
    }

    return 0;
}

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

int main()
{
	int n;
	string s;
	cin>>n>>s;
	
	int c=0;
	for(int i=1;i<n;i++){
		int v=0;
		for(int j=0;'a'+j<='z';j++){
			int ff=0,fb=0;
			for(int k=0;k<i;k++) if(s[k]=='a'+j) ff=1;
			for(int k=i;k<n;k++) if(s[k]=='a'+j) fb=1;
			if(ff==1&&fb==1) v++;
		}
		if(v>c) c=v;
	}
	
	cout<<c<<endl;
	
	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ls=[list(input().split()) for _ in range(M)]
AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for i in range(M):
  a=int(ls[i][0])
  b=ls[i][1]
  if b=="AC":
    if AC[a]!=1:
      AC[a]=1
      ans+=WA[a]
  else:
    if AC[a]!=1:
      WA[a]+=1
else:
  print(sum(AC),ans)

Measured memory_bytes: 27456
#include <iostream>

using namespace std;

int main(){
        int n,m,k,a,ans=0;
        cin>>n>>m;
        int keep[m];
        for(int i=0;i<m;i++)keep[i]=0;

        for(int i=0; i<n; i++){
                cin>>k;
                for(int j=0; j<k; j++){
                        cin>>a;
                        keep[a-1]++;
                }
        }

        for(int i=0;i<m;i++) if(keep[i]==n) ans++;
        cout<< ans<<endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int S,h,m,s;
	cin>>S;
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(h*3600)-(m*60);
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define push_back pb

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    int v[n+1]={0};
    //処理

    for(int i = 1 ; i < n ; i++){
        for(int j = i+1 ; j <= n ; j++){
            int dis = 0;
            int a = j - i;
            int b = abs(x-i)+1+abs(y-j);
            int c = abs(x-j)+1+abs(y-i);
            dis = min({a,b,c});
            v[dis]++;
        }
    }
    repn(i, 1, n-1){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, ans = 0, f;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    vector<int> b(a[n-1]+1, 1);
    for (int i = 0; i < n; i++) {
        if (b[a[i]] == 1) {
            if ((i == 0 || a[i-1] != a[i])
                    && (i == n-1 || a[i+1] != a[i])) {
                ans++;
            }
            for (int j = a[i]; j <= a[n-1]; j += a[i]) {
                b[j] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;


const int MOD = 1e9 + 7;
const int N = 1e5;
const long long INF = 1e9;


int main() {
  	int n, k, x, s = 0;
  	cin >> n >> k;
  	for (int i = 0; i < n; i++) {
      cin >> x;
      if (x >= k)
        	s++;
    }
  	cout << s;
}


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

int main(){
       int n;
       int a;
       int min = 1000000;
       int max = -1000000;
       long long sum = 0;

       cin>>n;

       for(int i=1;i<=n;i++){
	      cin>>a;

	      if(a>max) max = a;
	      if(a<min) min = a;

	      sum += a;
       }

       cout<<min<<' '<<max<<' '<<sum<<endl;
       
       return 0;
}

Measured memory_bytes: 3104
EMPTY = 0
BLACK = 1
WHITE = 2
N = input()
G = {i: [] for i in range(1, N+1)}
for i in range(N-1):
    a, b = map(int, raw_input().split())
    G[a].append(b)
    G[b].append(a)

parent = {}
dist = [N] * (N+1)
dist[1] = 0
que = [1]
while len(que) > 0:
    s = que.pop(0)
    for t in G[s]:
        if dist[t] > dist[s]+1:
            dist[t] = dist[s]+1
            parent[t] = s
            que.append(t)

s = N
path = [s]
while s in parent:
    path.append(parent[s])
    s = parent[s]
path = path[::-1]

colors = [EMPTY] * (N+1)
n = len(path)
que_black, que_white = [], []
for i in range(n):
    if i % 2 == 0:
        v = path[i/2]
        colors[v] = BLACK
        que_black.append(v)
    else:
        v = path[n-i/2-1]
        colors[v] = WHITE
        que_white.append(v)

def paint(que, c):
    while len(que) > 0:
        s = que.pop(0)
        for t in G[s]:
            if colors[t] == EMPTY:        
                colors[t] = c
                que.append(t)
paint(que_black, BLACK)
paint(que_white, WHITE)
score = 0
for c in colors:
    if c == BLACK:
        score += 1
    elif c == WHITE:
        score -= 1
print "Fennec" if score > 0 else "Snuke"

Measured memory_bytes: 43048
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

bool acgt(char x) {
    return (x == 'A' || x == 'C' || x == 'G' || x == 'T');
}

int main() {
    string S;
    cin >> S;
    // if (S.size() == 1) {
    //     if (acgt(S[0])) cout << 1 << endl;
    //     else cout << 0 << endl;
    //     return 0;
    // }
    int maxlen = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = 1; j <= S.size(); j++) {
            bool ok = true;
            for (int k = i; k < j; k++) {
                if (!acgt(S[k])) {
                    ok = false;
                    break;
                }
            }
            if (ok && (j - i) > maxlen) {
                maxlen = j - i;
            } 
        }
    }
    cout << maxlen << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#define ll long long
using namespace std;


int main()
{
    string num;
    cin>>num;
    int len = (int)num.length();
    int sum =0;
    for(int i=0;i<len;i++)
    {
        sum+=num[i]-'0';
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    
}







Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=5010; //check the limits, dummy
ll a[N], b[N];
ll n, k;
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=0; i<n; ++i){
		scanf("%lld",a+i);
		--a[i];
	}
	for(int i=0; i<n; ++i){
		scanf("%lld",b+i);
	}
	ll ans=-1e9, tmp, sm, cnt, tmp1, tmp2;
	for(int i=0; i<n; ++i){
		sm=0;
		tmp=i;
		for(int j=1; j<=min(k, 3*n); ++j){
			sm+=b[tmp];
			tmp=a[tmp];
			ans=max(ans, sm);
		}
		if(k>3*n){
			tmp=i;
			sm=0;
			cnt=0;
			for(int j=0; 1; ++j){
				++cnt;
				sm+=b[tmp];
				tmp=a[tmp];
				if(tmp==i){
					break;
				}
			}
			auto sm1=sm;
			sm=0;
			tmp2=0;
			for(int j=1; j<=k%cnt; ++j){
				sm+=b[tmp];
				tmp=a[tmp];
				tmp2=max(tmp2, sm);
			}
			tmp2+=k/cnt*sm1;
			tmp2=0;
			for(int j=1; j<=cnt; ++j){
				sm+=b[tmp];
				tmp=a[tmp];
				tmp2=max(tmp2, sm);
			}
			tmp2+=(k/cnt-1)*sm1;
			ans=max(ans, tmp2);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3848
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]

# body
if $debugFlag
end

if nn % 2 == 1
  puts ((nn.to_f-1)/2 + 1)/nn.to_f
else
  puts (nn.to_f/2)/nn.to_f
end


Measured memory_bytes: 1788
#include <cstdio>
int main()
{
    int ans1 = 0, ans2 = 0, f = 0;
    char c;
    while ((c = getc(stdin)) != '\n')
    {
        if (c - '0' == f) ans1++;
        else ans2++;
        f = !f;
    }
    printf("%d\n", ans1 < ans2 ? ans1 : ans2);
    return 0;
}


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

void calc(ll m){
  if(m == 0){
    return;
  }
  ll n = (ll)floor(sqrt(m*2));
  if((n*(n+1)*0.5) < m &&
     m <= (n*(m+2)*0.5)){
    ++n;
  }
  cout << n << endl;
  calc(m - n);
}
 
int main(void){
  ll m;
  cin >> m;
  calc(m);
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 200005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

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

#define Mo 1000000007

using namespace std;

int i,j,m,n,p,k,s[N],q,l,r,g[N];

vector<int>v[N];

int f[N],tree[N*4];

int ask(int ll,int l,int r,int t)
{
		if (l==r) return tree[t];
		else 
		{
				if (ll<=mid) return min(tree[t],ask(ll,l,mid,ls));
				else return min(tree[t],ask(ll,mid+1,r,rs));
		}
}

void insert(int ll,int rr,int c,int l,int r,int t)
{
		if (ll<=l&&r<=rr) tree[t]=min(tree[t],c);
		else 
		{
				if (ll<=mid) insert(ll,rr,c,l,mid,ls);
				if (rr>mid)  insert(ll,rr,c,mid+1,r,rs);
		}
}


void build_tree(int l,int r,int t)
{
		tree[t]=(int)1e9;
		if  (l==r) return;
		build_tree(l,mid,ls);
		build_tree(mid+1,r,rs);
}

int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i) scanf("%d",&s[i]),s[i]+=s[i-1];
		scanf("%d",&q);
		for (i=1;i<=q;++i) 
			scanf("%d%d",&l,&r),v[r].pb(l);
		memset(f,60,sizeof(f));
		memset(g,60,sizeof(g));
		f[0]=0; g[0]=0;
		build_tree(0,n,1);
		for (i=1;i<=n;++i)
		{
				g[i]=min(g[i-1],f[i-1])+(s[i]-s[i-1]==1);
				int G;
				for (j=0;j<(int)v[i].size();++j)
					G=min(g[v[i][j]-1]+(i-s[i])-(v[i][j]-1-s[v[i][j]-1]),(i-s[i])+ask(v[i][j]-1,0,n,1)),
					insert(v[i][j],i,-(i-s[i])+G,0,n,1),
					f[i]=min(f[i],G);
		}
		printf("%d\n",min(f[n],g[n]));
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
#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 all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<31;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

// dijkstra(O((E+V)log(v)))
template<class T>
struct dijkstra {
    struct edge{int to, cost;};
    vector<T> d;
    vector<vector<edge>> G;
    T init_v;

    dijkstra(int n, T init_v) : init_v(init_v) {init(n);} 

    void init(int n) {
        G.resize(n);
        d.resize(n);
        rep(i,n) d[i] = init_v;
    }

    void add_edge(int s, int t, int cost) {
        edge e;
        e.to = t; e.cost = cost;
        G[s].push_back(e);
    }

    void run(int s) {
        priority_queue<pair<T,int>, vector<pair<T,int>>, greater<pair<T,int>>> q;
        d[s] = 0;
        q.push(pair<T,int>(0,s));
        while (!q.empty()) {
            pair<T,int> e = q.top(); q.pop();
            int v = e.second;
            if (d[v] < e.first) continue;
            for (auto e: G[v]) {
                if (chmin(d[e.to],d[v]+e.cost)) {
                    q.push(pair<T,int>(d[e.to],e.to));
                }
            }
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    dijkstra<ll> dj(n,inf_l);
    rep(i,m) {
        int l, r, c; cin >> l >> r >> c;
        l--; r--;
        dj.add_edge(l,r,c);
    }
    rep(i,n-1) dj.add_edge(i+1,i,0);
    dj.run(0);
    ll ans = dj.d[n-1];
    printf("%ld\n",ans==inf_l?-1:ans);
}

Measured memory_bytes: 10764
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s)
        .expect("failed");
    let s = s.trim();
    let ans = if s == "A" { "T" } else if s == "T" { "A" } else if s == "G" { "C" } else { "G" };
    println!("{}", ans);
}



Measured memory_bytes: 4352