akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> 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;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])out("Yes");
    else out("No");
}

Measured memory_bytes: 256
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n = int(input())
    x = list(map(int, input().split()))
    x2 = sorted(x)
    med1 = x2[n//2-1]
    med2 = x2[n//2]
    for i in x:
        if i <= med1:
            print(med2)
        else:
            print(med1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 93652
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define repi(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)


#define endl '\n'


class Solution {
public:
    const int static MAX = 2e5 + 5;
    ll m[MAX];
    ll pow[MAX];
    void solve(std::istream& in, std::ostream& out) {
        int n, p;
        memset(m, 0, sizeof(m));
        ll ans = 0, x = 0;
        string s;
        in >> n >> p >> s;
        if (p == 2 or p == 5) {
            rep(i, 0, n, 1) if ((s[i] - '0') % p == 0) ans += i+1;
            out << ans << endl;
            return;
        }
        pow[0] = 1;
        rep(i, 1, n+1, 1) pow[i] = (pow[i-1] * 10) % p;
        int k = 0;
        repi(i, n-1, -1, 1) {
            char c = s[i];
            x = (c - '0')* pow[k++] + x;
            x = x % p;
            if (x == 0) ans++;
            ans += m[x];
            m[x]++;
        }
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 3920
n = int(input())
s = int(input())
A = []
if n >= s:
  for i in range(1, int((n-s)**(1/2))+1):
    if (n - s) % i == 0:
      if (n - s) // i != i:
        A.append(i+1)
        A.append((n - s) // i + 1)
      else:
        A.append(i+1)
def digit_sum(b, m):
  if m < b:
    return m
  else:
    return digit_sum(b, m // b) + m % b
B = []
for i in A:
  if digit_sum(i, n) == s:
    B.append(i)
if n < s:
  print(-1)
else:
  if n == s:
    print(n+1)
  else:
    if B == []:
      print(-1)
    else:
      print(min(B))

Measured memory_bytes: 3188
N = 41
A, B = (int(x) for x in input().split())
def function(i, n):
    if i == 0:
        if n % 4 == 0 or n % 4 == 3:
            return 0
        else:
            return 1
    else:
        y, div = n, 1
        for j in range(i):
            div = div * 2

        y = n % (div * 2)
        if y < div:
            return 0
        elif y % 2 == 1:
            return 0
        else:
            return 1

def answer(A, B):
    ret = ''
    list = [0] * N
    for i in range(N):
        if (function(i, A-1) + function(i, B)) % 2 != 0:
            list[i] = 1
    for z in list:
        ret += str(z)
    ret = ret[::-1]
    return int(ret, 2)
print(answer(A, B))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>

using namespace std;

int n,m;
int cx,cy,dx,dy;
char c[1010][1010];
int vis[1010][1010];

struct node{
	int x,y,dis;
	bool operator <( const node& rhs)const{
        return dis>rhs.dis;
    }
};
priority_queue<node> q;

inline int bfs(int x,int y){
	node tmp=(node){x,y,0};
	q.push(tmp);
	while(!q.empty()){
		node now=q.top();q.pop();
		if(now.x==dx&&now.y==dy){printf("%d\n",now.dis);return 0;}
		if(now.x>n||now.y>m||now.x<1||now.y<1||c[now.x][now.y]=='#') continue;
		
		//if(now.dis==1)cout<<"OK:"<<now.x<<' '<<now.y<<' '<<vis[now.x][now.y]<<endl;
		
		if(vis[now.x][now.y]<=now.dis) continue;
		else vis[now.x][now.y]=now.dis;
		//printf("%d %d %d\n",now.x,now.y,now.dis);
		node to;
		to.x=now.x+1,to.y=now.y,to.dis=now.dis;
		q.push(to);
		to.x=now.x,to.y=now.y+1,to.dis=now.dis;
		q.push(to);
		to.x=now.x-1,to.y=now.y,to.dis=now.dis;
		q.push(to);
		to.x=now.x,to.y=now.y-1,to.dis=now.dis;
		q.push(to);
		
		to.x=now.x-2,to.y=now.y-2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x-1,to.y=now.y-2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x,to.y=now.y-2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+1,to.y=now.y-2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+2,to.y=now.y-2,to.dis=now.dis+1;
		q.push(to);
		
		to.x=now.x-2,to.y=now.y-1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x-1,to.y=now.y-1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x,to.y=now.y-1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+1,to.y=now.y-1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+2,to.y=now.y-1,to.dis=now.dis+1;
		q.push(to);
		
		to.x=now.x-2,to.y=now.y,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x-1,to.y=now.y,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x,to.y=now.y,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+1,to.y=now.y,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+2,to.y=now.y,to.dis=now.dis+1;
		q.push(to);
		
		
		to.x=now.x-2,to.y=now.y+1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x-1,to.y=now.y+1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x,to.y=now.y+1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+1,to.y=now.y+1,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+2,to.y=now.y+1,to.dis=now.dis+1;
		q.push(to);
		
		to.x=now.x-2,to.y=now.y+2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x-1,to.y=now.y+2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x,to.y=now.y+2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+1,to.y=now.y+2,to.dis=now.dis+1;
		q.push(to);
		to.x=now.x+2,to.y=now.y+2,to.dis=now.dis+1;
		q.push(to);
	}
	return 1;
}

int main(){
	scanf("%d%d%d%d%d%d",&n,&m,&cx,&cy,&dx,&dy);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++) vis[i][j]=(1<<30);
	for(int i=1;i<=n;i++)
		scanf("%s",c[i]+1);
	if(bfs(cx,cy)) cout<<-1;
	return 0;
}

Measured memory_bytes: 14392
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - 9x9
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (a < 10 && b < 10) ? a * b : -1);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,x;
    cin>>a>>b>>x;
    x/=a;
    

    double maki=(x/b)*2;
    if(maki<=a){
    	doublecout((atan2(b,maki))/(M_PI)*180);
    }else{
    	double ma=a*b;
    	ma-=x;
    	double niko=(ma/a)*2;
    	doublecout((atan2(niko,a))/(M_PI)*180);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	int n, q;
	cin >> n >> q;

	string s;
	cin >> s;

	vector<char> d(q);
	vector<char> t(q);
	rep(i, q) {
		cin >> t[i] >> d[i];
	}

	int l = 0;
	int r = n - 1;

	
	for(int i = q - 1; i >= 0; i--)
	{
		// 左から探す
		if (t[i] == s[l] && d[i] == 'L') {
			l++;
		}
		else if (l != 0) {
			if (t[i] == s[l - 1] && d[i] == 'R') {
				l--;
			}
		}
		// 右から探す
		if (t[i] == s[r] && d[i] == 'R') {
			r--;
		}
		else if (r != n - 1) {
			if (t[i] == s[r + 1] && d[i] == 'L') {
				r++;
			}
		}
	}

	//ll ans = l + n - r - 1;

	cout << max(0, r - l + 1) << endl;

	return 0;
}

Measured memory_bytes: 976
import math
import collections
import fractions
import itertools

def solve():
    a = int(input())
    b = int(input())
    if a > b:
        print("GREATER")
    elif b > a:
        print("LESS")
    else:
        print("EQUAL")
    return 0

if __name__ == '__main__':
    solve()

Measured memory_bytes: 10340
A,B,C,X,Y = map(int,input().split())
Ans = 0
Z = min(X,Y)
if A+B >= C*2:
    Ans = min(C*Z*2 + A*(X-Z) + B*(Y-Z), C*max(X,Y)*2)
else:
    Ans = A*X + B*Y
print(Ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>

using namespace std;

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

    cout << (a + a * a + a * a * a) << endl;    

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b;
  cin>>r>>g>>b;
  int N=100*r+10*g+b;
  if(N%4==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

int main(){

  int i, j, n, v;
  int a[100];

  cin >> n;

  for (i=0;i<n;i++){
    cin >> a[i];
  }

  for (i=1;i<n;i++){

         for (j=0;j<n;j++){
	cout << a[j];
	if (j<n-1){
	  cout << " ";
	}
      }
      cout << endl;

    for (j=0;j<i;j++){
      if (a[j]>a[i]){
	v=a[i];a[i]=a[j];a[j]=v;
      }
    }
 
    }
             for (j=0;j<n;j++){
	cout << a[j];
	if (j<n-1){
	  cout << " ";
	}
      }
      cout << endl;

    return 0;
  }

Measured memory_bytes: 3068
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(N - K + 1);
		
	}
	int N, K;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
	int N;
	while(cin>>N,N){
		int dp[110000],stone,last=-1,ans=0;
		dp[0]=1;
        for(int i=1;i<=N;i++){
            cin>>stone;
            if(stone==0) ans++;
            if(last==stone){
                dp[i]=dp[i-1];
            }
            else{
                if(i%2==1){
                    dp[i]=i;
                }
                else{
                    if(stone==0){
                        ans+=i-dp[i-1];
                    }
                    else{
                        ans-=i-dp[i-1];
                    }
                    dp[i]=dp[dp[i-1]-1];
                }
            }
            last=stone;
        }
        printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#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(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
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

const int N = 100010;
vii G(N);
vi dp(N, -1);

int dfs(int u) {
  if (dp[u] >= 0) return dp[u];
  dp[u] = 0;
  rep (i, G[u].size()) {
    chmax(dp[u], 1 + dfs(G[u][i]));
  }
  return dp[u];
}
  
  
int main() {
  int n, m;
  cin >> n >> m;
  rep (i, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
  }
  rep (i, n) {
    if (dp[i] < 0) {
      dfs(i);
    }
  }
  int ans = 0;
  rep (i, n) {
    chmax(ans, dp[i]);
  }
  cout << ans << endl;
}
    


Measured memory_bytes: 7424
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	int n, i, max;
	scanf("%d", &n);

	unsigned short A[n+1];
	unsigned short B[n+1];

	max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i+1]);
	}
	int C[max+1];
	memset(C, 0, sizeof(C));

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 10556
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(a)  (a).begin(),(a).end()

int main(){
  long n,count=0;
  cin >> n;
  vector<long> a(n+1);
  for(long i=0;i<n+1;i++){
    cin >> a.at(i);
  }
  for(long i=0;i<n;i++){
    long tmp;
    cin >> tmp;
    if(tmp < a.at(i)){
      count+=tmp;
    }
    else{
      count+=a.at(i);
      tmp-=a.at(i);
      if(tmp<=a.at(i+1)){
        a.at(i+1) -= tmp;
        count += tmp;
      }
      else{
        count+=a.at(i+1);
        a.at(i+1) = 0;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln             PIC X(30).
01 A              PIC 9(10).
01 B              PIC 9(10).
01 K              PIC 9(10).
01 Q              PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT K.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B.
  DIVIDE B BY K GIVING Q.
  IF A <= Q * K
      DISPLAY "OK"
  ELSE
      DISPLAY "NG"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3876
import java.util.*;

class Main {
	static int sum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] X = new int[5];
		for (int i=0;i<5;i++) {
			X[i]=sc.nextInt();
		}

		int sum=0;
		for (int i=0;i<5;i++) {
			int x;
			if (X[i]%10==0) {
				x=X[i];
			} else {
				x=X[i]/10*10+10;
			}
			sum+=x;
		}

		for (int i=0;i<5;i++) {
			X[i]=X[i]%10;
		}
		Arrays.sort(X);
		int min=0;
		for (int i=0;i<5;i++) {
			if (X[i]!=0) {
				min=X[i];
				break;
			}
		}
		if (X[0]==0 && X[1]==0 && X[2]==0 && X[3]==0 && X[4]==0) {
			System.out.println(sum);
		} else {
			System.out.println(sum-10+min);
		}
	}

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>a[i];
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, -1));
    function<ll(ll,ll)> solve=[&](ll x, ll y){
        if(dp[x][y]!=-1)return dp[x][y];
        if(x>=y)return dp[x][y]=0LL;
        //Taro first
        else if((y-x)%2==N%2){
            return dp[x][y]=max(a[x]+solve(x+1,y),a[y-1]+solve(x,y-1));
        }
        //Jiro first
        else {
            return dp[x][y]=min(-a[x]+solve(x+1,y),-a[y-1]+solve(x,y-1));
        }
    };
    prt(solve(0,N))

    return 0;
}


Measured memory_bytes: 71168
//Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>
using namespace std;

int main(){
  int t, ac=0, wa=0, tle=0, re=0;
  cin>>t;
  while(t--){
    string s;
    cin>>s;
    if(s[0]=='A') ac++;
    else if(s[0]=='W') wa++;
    else if(s[0]=='T') tle++;
    else if(s[0]=='R') re++;}
  cout<<"AC x "<<ac<<"\n";
  cout<<"WA x "<<wa<<"\n";
  cout<<"TLE x "<<tle<<"\n";
  cout<<"RE x "<<re<<"\n";
}



Measured memory_bytes: 3636
#include <climits>
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int msb(uint64_t in)
{
	for (int i = 63; i >= 0; i--)
	{
		uint64_t digit_mask = ((uint64_t)0x1 << i);
		if (in & digit_mask)
			return i;
	}
	return 0;
}

int main()
{

	uint64_t a, b;
	scanf("%llu", &a);
	scanf("%llu", &b);

	a--;


	uint64_t fa = (a & 1) ^ ((a >> 1) & 1);
	uint64_t fb = (b & 1) ^ ((b >> 1) & 1);
	
	for (int i = msb(a); i > 0; i--)
	{
		uint64_t digit_mask = ((uint64_t)0x1 << i);
		if (a & digit_mask)
		{
			a &= ~digit_mask;
			fa |= (a & 1) ? 0U : digit_mask;
		}
	}
	for (int i = msb(b); i > 0; i--)
	{
		uint64_t digit_mask = ((uint64_t)0x1 << i);
		if (b & digit_mask)
		{
			b &= ~digit_mask;
			fb |= (b & 1) ? 0U : digit_mask;
		}
	}

	printf("%llu\n", fa ^ fb);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int n;

	cin >> n;
	ll ans = 1;
	bool judge = true;
	rep(i, 0, n) {

		ll a;
		cin >> a;
		if (a == 0) {
			cout << 0 << endl;
			return 0;
		}
		if (a <= LINF / ans) {
			ans *= a;
		}
		else {
			judge = false;
		}
	}
	

	if (judge)cout << ans << endl;
	else cout << -1 << endl;
	

}
	

Measured memory_bytes: 3660
#include<iostream>
#include<cmath>
#include<iomanip>
#define ll long long int
using namespace std;

void solve();

int main() {

   solve();

   return 0;
}

void solve() {

   int a,b,c;

   cin >>a >>b >>c;

   if (a < b && b < c) {

      cout << "Yes" << endl;

   }
   else {

      cout << "No" << endl;

   }
}

Measured memory_bytes: 3092
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end


S = s()
len = S.length

min = len
(len-1).times{|i|
  if S[i+1] != S[i]
    max = (i+1) > (len-i-1) ? (i+1) : (len-i-1)
    min = max < min ? max : min
  end
}
puts min

Measured memory_bytes: 2044
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
int m,n;
struct node
{
    int x,y;
};
node e[120000];
int f[120000];
ll S[120000];
ll s[120000];

int find(int x)
{
    if (f[x]==x) return x;
    return f[x]=find(f[x]);
}

int main()
{
    cin>>n>>m;
    for (int i=1; i<=n; ++i)
    {
        f[i]=i;
        S[i]=1;
    }
    for (int i=1; i<=m; ++i)
    {
        scanf("%d %d",&e[i].x,&e[i].y);
    }
    for (int i=m; i>=1; --i)
    {
        if (find(e[i].x)==find(e[i].y))
            s[i]=0;
        else
        {
            s[i]=S[find(e[i].x)]*S[find(e[i].y)];
            S[find(e[i].y)]+=S[find(e[i].x)];
            f[find(e[i].x)]=find(e[i].y);
        }
    }
    ll ans=0;
    for (int i=1; i<=m; ++i)
    {
        ans+=s[i];
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 4096
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define time fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define INF 1LL<<61
#define inf 1<<30
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

const int nn = 1e5 + 10;
int dp[nn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    for(int i=1; i<nn; i++){
        dp[i] = dp[i-1]+1;
        for(int j=6; j<=i; j = j*6){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
        for(int j=9; j<=i; j = j*9){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
    }
    int n;
    cin >> n;
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int h, n;
  cin >> h >> n;
  int sum = 0;
  int tmp;
  REP(i,n){
    cin >> tmp;
    sum += tmp;
  }
  if(sum >= h){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
  int num;
  string ori;
  cin >> num >> ori;

  for(int i = 0; i < (int)ori.size(); ++i){
    int n = ori[i] + num;
    if (n > 90) n -= 26;
    cout << char(n);
  }
  cout << endl;
  return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    int sum = 0;
    int i;
    for(i=1 ;;i++) {
        sum += i;
        if(sum >= N) break;
    }
    

    if(sum == N){
        REP(j,i) pl(j+1)
    } else {
        int g = sum - N;
        REP(j,i) if(g!=j+1) pl(j+1)
    }


    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

unsigned long long int my_f(unsigned long long int N){
  if (N%2==0) {return N/2;}
  return 3*N+1;
}

int main(int argc, char const *argv[]) {
  unsigned long long int S;
  int c_f=0;
  int c_t=0;
  scanf("%llu", &S);
  long int i=1;
  while (S!=1) {
    if (S==2) {c_t=1;}
    if (S==4) {c_f=1;}
    S=my_f(S);
    
    if (S==2) {c_t=1;}
    if (S==4) {c_f=1;}
    i++;
  }
  if (c_f==1) {
    i=i+1;
  }else if(c_t==1){
    i=i+2;
  }else{
    i=i+3;
  }
  printf("%ld", i);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c=='a' |c=='i'|c=='u'|c=='e'|c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll K;
    cin >>K;
    ll cnt = 7;
    ll now=0;
    rep(i,1000000){
        now = (now+cnt)%K;
        cnt = (cnt*10)%K;
        
        if(now==0){
            cout<<i+1<<endl;
            return 0;
        }
    }


    cout << -1 << endl;


    return 0;
    

}

Measured memory_bytes: 3612
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << setprecision(12) << W * H / 2.0 << ' ';
    double centerX = W / 2.0, centerY = H / 2.0;
    if (x == centerX && y == centerY)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
function main()
	s = chomp(readline())
	t = chomp(readline())
	n = length(s)
	flg = 0
	for i in 1:n
		if s == t
			flg = 1
		end
		s = string(s[2:n],s[1])
	end
	if flg == 1
		print("Yes")
	else
		print("No")
	end
end

main()

Measured memory_bytes: 164432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll ans;
  ll n;
  cin >> n;
  string a,b;
  cin >> a >> b;
  ll i=0;
  if(a[0]==b[0]){
    ans=3;
    i=1;
  }
  else{
    ans=6;
    i=2;
  }
  while(i<n){
    if(a[i]!=b[i]&&a[i-1]!=b[i-1]){
      i +=2;
      ans =ans*3%MOD;
    }
    else if(a[i]==b[i]&&a[i-1]!=b[i-1]){
      i +=1;
      ans *=1;
    }
    else if(a[i]!=b[i]&&a[i-1]==b[i-1]){
      i +=2;
      ans =ans*2%MOD;
    }
    else if(a[i]==b[i]&&a[i-1]==b[i-1]){
      i +=1;
      ans =ans*2%MOD;
    }
  }
  cout << ans << endl;
}

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

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

    long long n {};
    cin >> n;

    vector<long long> arr (n);
    for (auto &val: arr) cin >> val;
    sort(arr.rbegin(), arr.rend());

    long long ans {arr.front()};
    long long ind {1};

    long long times {2};
    for (int i {}; i < n-2; ++i) {
        if (!times) {
            ++ind;
            times = 2;
        }
        ans += arr.at(ind);
        // cerr << "TRACK: " << arr.at(ind) << endl;
        --times;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4728
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>
#include <fstream>

typedef long long ll;
const ll INF = (ll)1e18 + 1;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}
template<typename Iterator> void printVecPair(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << it->first << " " << it->second << " ";
    if ((it - begin) % 10 == 9 || it == end - 1) std::cout << std::endl;
  }
}

int main(int argc, char* argv[])
{
  ll N, A, B, C;

  std::vector<ll> vtake(3, 0LL);
  std::cin >> N >> vtake[0] >> vtake[1] >> vtake[2];

  std::vector< ll > vl(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vl[i];
  }

  // 0:A, 1:B, 2:C, 3:No_use
  ll ans = INF;
  for (ll S = 0; S < (ll)std::pow(4, (double)N); S++) {
    ll res = S;
    std::vector< ll > vkind(N, 0LL);
    for (ll i = 0; i < N; i++) {
      vkind[i] = res % 4;
      res /= 4;
    }

    std::vector<ll> vcnt(3, 0LL);
    std::vector<ll> vsum(3, 0LL);
    for (ll i = 0; i < N; i++) {
      if (vkind[i] == 3) continue;
      vsum[vkind[i]] += vl[i];
      vcnt[vkind[i]]++;
    }
    bool judge = true;
    for (ll kind = 0; kind < 3; kind++) {
      if (vcnt[kind] == 0) judge = false;
    }
    ll mp = 0;
    for (ll kind = 0; kind < 3; kind++) {
      mp += std::fabs(vsum[kind] - vtake[kind]);
      mp += 10 * (vcnt[kind] - 1);
    }
    if (judge) ans = std::min(ans, mp);
  }

  print(ans);
  return 0;
}


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

using namespace std;
#define FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)

template<typename T>
bool chmax(T& l,T r){
    bool ret = l<r;
    if(l<r)l=r;
    return ret;
}
template<typename T>
bool chmin(T& l,T r){
    bool ret = l>r;
    if(l>r)l=r;
    return ret;
}

typedef long long LL;
typedef double D;
LL d;
LL n,b;
LL p[32];
LL h[32];



D v(D vx,D vy){
    return vx*vx+vy*vy;
}
D g(D vy,D yard){
    if(vy<=0)return 1e20;
    return v(vy,yard/(2*vy)); 
}
D g(D yard){
    D lb = 0;
    D ub = 1e9;
    REP(i,100){
        const D m1 = (lb+lb+ub)/3.0;
        const D m2 = (lb+ub+ub)/3.0;
        if(g(m1,yard)<g(m2,yard)){
            ub = m2;
        }
        else{
            lb = m1;
        }
    }
    return lb;
}
D f(D m){
    D yard = d/m;
    D need = 0;
    REP(i,n){
        D x = p[i];
        while(x>yard){
            x-=yard;
        }
        D vy = (yard*h[i])
            /
            ((1.0-x/yard)*2*x);
        chmax(need,sqrt(vy));
    }
    D td = g(yard);
    if(td>=need)return g(td,yard);
    else return g(need,yard);
}

//check yard = d/m
bool check(LL m){
    REP(i,n){
        REP(j,m){
            if((j+1)*d == p[i] * m){
                return false;
            }
        }
    }
    return true;
}
        
int main(){
    D ret=1e20;
    cin>>d>>n>>b;
    REP(i,n)cin>>p[i]>>h[i];
    FOR(i,1,b+2)if(check(i)){
        chmin(ret,f(i));
    }
    cout<<fixed<<sqrt(ret)<<endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<string> vec;
  rep(i,n){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  ll count=1;
  ll ans=0;
  rep(i,n-1){
    if(vec[i]==vec[i+1]){
      count++;
    }else{
      ans+=count*(count-1)/2;
      count=1;
    }
  }
  ans+=count*(count-1)/2;
  cout<<ans<<endl;
}
     
      
      
    
    




Measured memory_bytes: 5748
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();

	int x, y, z;
	cin >> x >> y >> z;
	if ((x + y) < (x + z) && (x + y) < (y + z))
		cout << (x + y) << endl;
	else if ((x + z) < (z + y) && (x + z) < (y + x))
		cout << (x + z) << endl;
	else if ((z + y) < (x + z) && (z + y) < (y + x))
		cout << (z + y) << endl;
	else
		cout << x + y << endl;
}

Measured memory_bytes: 3504
N = gets.chomp.to_i
a = Array.new(N){Array.new(N,0)}
if N == 2
    puts -1
    exit
end
if N == 3
    puts "aa."
    puts "..a"
    puts "..a"
    exit
end

i = 0
if N%4 == 1
    a[0][0] = 1
    a[0][1] = 2
    a[0][2] = 2
    a[0][3] = 3
    a[0][4] = 3
    a[1][0] = 1
    a[1][1] = 0
    a[1][2] = 0
    a[1][3] = 2
    a[1][4] = 4
    a[2][0] = 2
    a[2][1] = 0
    a[2][2] = 0
    a[2][3] = 2
    a[2][4] = 4
    a[3][0] = 2
    a[3][1] = 5
    a[3][2] = 5
    a[3][3] = 0
    a[3][4] = 1
    a[4][0] = 3
    a[4][1] = 3
    a[4][2] = 4
    a[4][3] = 4
    a[4][4] = 1
    i = 5
elsif N%4 == 2
    a[0][0] = 1
    a[0][1] = 1
    a[0][2] = 2
    a[0][3] = 2
    a[0][4] = 3
    a[0][5] = 3
    a[1][0] = 2
    a[1][1] = 2
    a[1][2] = 3
    a[1][3] = 3
    a[1][4] = 1
    a[1][5] = 1
    a[2][0] = 4
    a[2][1] = 5
    a[2][2] = 6
    a[3][0] = 4
    a[3][1] = 5
    a[3][2] = 6
    a[4][3] = 4
    a[4][4] = 5
    a[4][5] = 6
    a[5][3] = 4
    a[5][4] = 5
    a[5][5] = 6
    i = 6
elsif N%4 == 3
    a[0][1] = 1
    a[0][2] = 1
    a[0][3] = 2
    a[0][4] = 2
    a[0][5] = 3
    a[0][6] = 3
    a[1][0] = 1
    a[1][1] = 4
    a[1][2] = 4
    a[1][3] = 5
    a[2][0] = 1
    a[2][1] = 5
    a[2][2] = 0
    a[2][3] = 5
    a[3][0] = 2
    a[3][1] = 5
    a[3][2] = 4
    a[3][3] = 4
    a[4][0] = 2
    a[4][4] = 4
    a[4][5] = 4
    a[4][6] = 5
    a[5][0] = 3
    a[5][4] = 5
    a[5][5] = 0
    a[5][6] = 5
    a[6][0] = 3
    a[6][4] = 5
    a[6][5] = 4
    a[6][6] = 4
    i = 7
end
while i < N
    a[i][i] = 1
    a[i][i+1] = 1
    a[i][i+2] = 3
    a[i][i+3] = 4
    a[i+1][i] = 2
    a[i+1][i+1] = 2
    a[i+1][i+2] = 3
    a[i+1][i+3] = 4
    a[i+2][i] = 3
    a[i+2][i+1] = 4
    a[i+2][i+2] = 1
    a[i+2][i+3] = 1
    a[i+3][i] = 3
    a[i+3][i+1] = 4
    a[i+3][i+2] = 2
    a[i+3][i+3] = 2
    i += 4
end
for x in 0...N do
    for y in 0...N do
        b = a[x][y]
        if b == 0
            print "."
        elsif b == 1
            print "a"
        elsif b == 2
            print "b"
        elsif b == 3
            print "c"
        elsif b == 4
            print "d"
        elsif b == 5
            print "e"
        elsif b == 6
            print "f"
        end
    end
    puts
end

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

using namespace std;

typedef long long ll;

struct monotonic_queue
{
	deque<pair<int, ll>> deq;

	void add(int k, ll v)
	{
		while (!deq.empty() && deq.back().second >= v)
			deq.pop_back();
		deq.push_back({k, v});
	}

	void remove(int k)
	{
		while (!deq.empty() && deq.front().first <= k)
			deq.pop_front();
	}

	ll min()
	{
		return deq.front().second;
	}
};

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, l;
	cin >> n >> l;

	ll x;
	monotonic_queue mq;
	for (int i = 1; i < l; ++i)
	{
		cin >> x;
		mq.add(i-1, x);
	}

	for (int i = l-1; i < n; ++i)
	{
		cin >> x;
		mq.add(i, x);
		cout << mq.min() << " \n"[i==n-1];
		mq.remove(i-l+1);
	}

	return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
ll dp[1000][2][5]; //i 桁　ギリギリ攻めてるか　k個
int main()
{
    string n;
    cin >> n;
    int K;
    cin >> K;
    dp[0][0][0] = 0;
    dp[0][1][0] = 1;
    for (int i = 0; i < n.length(); i++)
    {
        rep(k, K)
        {
            int tmp = n[i] - '1';
            dp[i + 1][0][k] += dp[i][0][k];         //０を追加
            dp[i + 1][0][k + 1] += dp[i][0][k] * 9; // ０以外を追加
            if (n[i] != '0')
            {
                dp[i + 1][1][k + 1] += dp[i][1][k];       //ギリギリを追加
                dp[i + 1][0][k + 1] += dp[i][1][k] * tmp; //ギリギリ以外で0じゃない
                dp[i + 1][0][k] += dp[i][1][k];           //ギリギリ以外で0
            }
            else
            {
                dp[i + 1][1][k] += dp[i][1][k]; //ギリギリを追加
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n.length(); i++)
    {
        ans += dp[i][0][K];
        ans += dp[i][1][K];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a]++;
    }

    if(mp.size()<=k) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> t;
    for(auto x : mp) t.push_back(x.second);
    sort(all(t));
    int ch = t.size()-k;
    int ans = 0;
    rep(i,ch) ans += t[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13516
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K, Q;
  while (cin >> N >> K >> Q) {
    vector<int> cnt(N, 0);
    for (int q = 0; q < Q; q++) {
      int x;
      cin >> x;
      --x;
      ++cnt[x];
    }
    for (int i = 0; i < N; i++) {
      int sub = Q - cnt[i];
      if (K - sub <= 0) {
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
      }
    }
  }
  return 0;
}


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

string s;

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

	cin >> s;
	char c = s.back();
	if (c == '2' or c == '4' or c == '5' or c == '7' or c == '9') cout << "hon\n";
	else if (c == '0' or c == '1' or c == '6' or c == '8') cout << "pon\n"; 
	else cout << "bon\n";

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
    ll N;  cin >> N;

    print((N * (N-1)) / 2);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}


int main() {
    fastik();
    ll n;cin>>n;
    vll a(n);
    forn(i,n){
        cin >> a[i];
    }
    ll ans = 1;
    fore(i,1,n-1){
        ll f = 1;
        forn(j,i){
            if(a[j] > a[i]){
                f = 0;
            }
        }
        if(f==1){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256