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

int n;
int d[200010];
int m;
int t[200010];
bool f = true;;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i) scanf("%d", &d[i]);
	scanf("%d", &m);
	for(int i=0; i<m; ++i) scanf("%d", &t[i]);
	std::sort(d, d+n);
	std::sort(t, t+m);
	if(n < m) f = false;
	else{
		int p = 0;
		d[n] = 1e9+7;
		for(int i=0; i<m; ++i){
			while(d[p] < t[i]) ++p;
			if(p == n || t[i] < d[p]){
				f = false;
				break;
			}
			++p;
		}
	}
	if(f) printf("YES\n");
	else printf("NO\n");
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int x, y;
    x = A*N;
    y = B;
    if(x>y) {
        cout << y << endl;
    } else {
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iomanip>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long LL;
template <typename S, typename T> ostream& operator<<(ostream& os, const pair<S,T>& x);
template <typename T> ostream& operator<<(ostream& os, const vector<T>& x);
template <typename T> ostream& operator<<(ostream& os, const set<T>& v);
template <typename T> ostream& operator<<(ostream& os, const multiset<T>& v);
template <typename S, typename T> ostream& operator<<(ostream& os, const unordered_map<S,T>& v);
template <typename S, typename T> ostream& operator<<(ostream& os, const map<S,T>& v);

vector<LL> readvec(LL length, LL off = 0);
#define ALL(x) x.begin(), x.end()
#define REP(x) for(LL repvar = 0; repvar < x; repvar++)


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    LL n; cin >> n;
    vector<LL> v = readvec(n);
    sort(ALL(v));
    LL ans = 0;
    for(LL i = 0; i < n; i++){
        for(LL j = i+1; j < n; j++){
            for(LL k = j+1; k < n; k++){
                if(v[i] != v[j] && v[j] != v[k] && v[i] != v[k]){
                    if(v[i] + v[j] > v[k]) ans++;
                }
            }
        }
    }
    cout << ans << "\n";
}

















/*
Utilities
*/

template <typename S, typename T>
ostream& operator<<(ostream& os, const unordered_map<S,T>& v){
    os << "[";
    for(auto it = v.begin(); it != v.end(); it++) {
        if(it != v.begin()) os << ", ";
        os << it->first << ": " << it->second;
    }
    os << "]";
    return os;
}


template <typename S, typename T>
ostream& operator<<(ostream& os, const map<S,T>& v){
    os << "{";
    for(auto it = v.begin(); it != v.end(); it++) {
        if(it != v.begin()) os << ", ";
        os << it->first << ": " << it->second;
    }
    os << "}";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
    os << "[";
    for(auto it = v.begin(); it != v.end(); it++) {
        if(it != v.begin()) os << ", ";
        os << *it;
    }
    os << "]";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v){
    os << "[";
    for(auto it = v.begin(); it != v.end(); it++) {
        if(it != v.begin()) os << ", ";
        os << *it;
    }
    os << "]";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v){
    os << "[";
    for(auto it = v.begin(); it != v.end(); it++) {
        if(it != v.begin()) os << ", ";
        os << *it;
    }
    os << "]";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S,T>& x){
    os << "(" << x.first << ", " << x.second << ")";
    return os;
}

vector<LL> readvec(LL length, LL off){
    vector<LL> v;
    for(LL i = 0; i < length; i++){
        LL x; cin >> x; v.push_back(x + off);
    }
    return v;
}


Measured memory_bytes: 3648
import sys
readline = sys.stdin.buffer.readline

from collections import deque
from copy import copy,deepcopy
from itertools import permutations

def myinput():
    return map(int,readline().split())

def mycol(data,col):
    return [ row[col] for row in data ]

n,m = myinput()
ab = [ list(myinput()) for _ in range(m) ]

v = list(range(1,n+1))
p = list(permutations(v))
# print(p)

count = 0
for s in p:
    # print(s)
    if s[0]!=1:
        pass
    else:
        flag = True
        for j in range(n-1):
            v_tmp = s[j]
            v_next = s[j+1]
            c = [v_tmp,v_next]
            d = [v_next,v_tmp]
            if ( c in ab ) or ( d in ab ):
                pass
            else:
                flag = False

        if flag:
            count += 1
        else:
            pass
    # print(count)

print(count)

Measured memory_bytes: 46956
#include <iostream>

using namespace std;

int a,b;
char op;
int main(){
 while(true){
  cin>>a>>op>>b;
  if(op=='+'){
   cout<<a+b<<endl;
  }else if(op=='-'){
   cout<<a-b<<endl;
  }else if(op=='*'){
   cout<<a*b<<endl;
  }else if(op=='/'){
   cout<<a/b<<endl;
  }else{
   break;
  }
 }
}

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

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

int arr1[n],arr2[n],arr3[n];

for (int i = 1; i <=n; i++){
	cin >> arr1[i];
}
for (int i = 1; i <=n; i++){
	cin >> arr2[i];
}
for(int i =1; i <= n-1; i++){
	cin >> arr3[i];
}
int sum = 0;
for(int i =1; i <= n; i++){
	int val = arr1[i];
	sum = sum + arr2[val];
	if(i <= n-1){
		if((arr1[i + 1] - arr1[i]) == 1){
			sum = sum + arr3[val];
		}
	}
}
cout << sum << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
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...));
}

// level i : patty: 2**(n+1) - 1
vector<ll> patty, all;

ll solve(ll level, ll x) {
    if (level == 0) {
        return 1;
    }

    if (x <= 1) {
        return 0;
    } else if (x <= 1 + all[level - 1]) {
        return solve(level - 1, x - 1);
    } else if (x == 2 + all[level - 1]) {
        return 1 + patty[level - 1];
    } else if (x <= 2 + 2 * all[level - 1]) {
        return 1 + patty[level - 1] + solve(level - 1, x - 2 - all[level - 1]);
    } else if (x == 3 + 2 * all[level - 1]) {
        return patty[level];
    }

    cout << "error\n";
    return -1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x;
    cin >> n >> x;

    patty.push_back(1);
    all.push_back(1);
    REP(i, 55) {
        patty.push_back(2 * patty[i] + 1);
        all.push_back(2 * all[i] + 3);
    }

    cout << solve(n, x) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int N; cin >> N;
  vector<pair<string, pair<int,int> > > R;
  rep(i,0,N-1) {
      string s; int p; cin >> s >> p;
      R.push_back({s,{-p, i}});
  }
  sort(R.begin(), R.end());
  rep(i,0,N-1) cout << R[i].second.second +1<< endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
d = []
s = 0
for ai, bi in zip(a, b):
    if ai < bi:
        ans += 1
        s += bi - ai
    else:
        d.append(ai - bi)
if ans:
    d.sort(reverse=True)
    ds = 0
    for di in d:
        ds+=di
        ans+=1
        if ds >= s:
            break
    if ds < s:
        print(-1)
    else:
        print(ans)
else:
    print(0)


Measured memory_bytes: 24356
#include<stdio.h>

int main(void)
{
	int x,y,i,j;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		if(x<0 || y<0);
		else if(x<=300 && y<=300){
			for(i=0;i<x;i++){
				for(j=0;j<y;j++){
					if((i+j)%2==0) printf("#");
					else printf(".");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;
ll fact(ll n)
{
ll    res=1;
    for(int i = 1; i <= n;i++){
    res = res * i ;
}
return res;
}



int main()
{   IOS;
    int n; cin >> n; vector<ll> A; ll a;
    for (int i=0;i<n;i++)
    {
        cin >> a;
        A.push_back(a);
    }
    vector<ll> A2;
    A2=A;
    sort(A.begin(),A.end());
    vector <ll> ans(n,0);
    for (int i=0;i<n;i++)
    {
        if (A2[i]<A[n/2] )cout << A[n/2]; else cout << A[(n-1)/2]; cout << "\n";
    }




    cout.precision(30);
    return 0;
}


Measured memory_bytes: 7024
#include<stdio.h>
#include<cmath>

using namespace std;
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    double af=a,bf=b,cf=c;
    double pi=acos(-1);
    double rad=pi*cf/180;
    double S,L,h,x;
    S=0.5*af*bf*sin(rad);
    x=sqrt(af*af+bf*bf-2*af*bf*cos(rad));
    L=af+bf+x;
    h=bf*sin(rad);
    printf("%.5lf\n%.5lf\n%.5lf\n",S,L,h);
    
}


Measured memory_bytes: 2880
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

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

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	int h,n; cin >> h >> n;
    int sum = 0;
    REP(i,n){
        int tmp; cin >> tmp;
        sum += tmp;
    }
    
    if(sum >= h)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    V nums;
    
    cin>>N;
    rep(i,N*2){
        int x; cin>>x;
        nums.push_back(x);
    }
    
    sort(all(nums));
    
    int sum=0;
    rep(i,N) sum+=nums[i*2];
    
    cout1(sum);
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

// shell sort
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		shellSort(A, N);
		for (int i = 0; i < A.length; i++) {
			System.out.println(A[i]);
		}
		scan.close();
	}

	static int cnt = 0;

	public static void shellSort(int[] A, int N) {
		// ????????????G
		// G(n+1)=3G(n)+1 n=0,1,2,,,
		// g = G(i) ??¨????????¨ g=1, 4, 13, 40, 121,,,,,,
		ArrayList<Integer> list = new ArrayList<>();
		int h = 1;
		do{
			list.add(h);
			h = 3 * h + 1;
		}while(N > h);
		
		int[] G = new int[list.size()];
		for (int i = 0; i < G.length; i++) {
			G[i] = list.get(i);
		}
		
		// output first row
		System.out.println(G.length);
		
		// output and call insertionSort by using array G
		for (int i = G.length - 1; i >= 0; i--) {
			// output second row
			System.out.print(G[i]);
			if (i != 0) {
				System.out.print(" ");
			} else {
				System.out.println();
			}
			insertionSort(A, N, G[i]);
		}
		System.out.println(cnt);
	}

	// ????????????????????????????°?????????¢????????????????????¨?????????????????????
	public static void insertionSort(int[] A, int N, int g) {
		for (int i = g; i < N; i++) {
			int v = A[i];
			int j = i - g;
			// ?????§???????????????????????°???????????????????????\????????????????????????????????§??????
			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}
			A[j + g] = v;
		}
	}
}

Measured memory_bytes: 298748
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    string a[3];
    for(int i=0;i<3;i++)
    cin>>a[i];
    cout<<a[0][0]<<a[1][1]<<a[2][2];

    return 0;
}      

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        int count = 0;
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String[] b = a.split("");
        for (int i = 0; i <= 2; i++) {
            for (int j =i+1; j <= 4; j++) {
                if(j==4){
                    continue;
                }
                if (b[i].equals(b[j])) {
                    count++;
                }
            }
        }
        if (count == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22356
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  int one;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    if(tmp == 1){
      one = i + 1;
    }
  }
  int ans = 0;
  k--;
  n--;
  ans = (n + k - 1) / k;

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int main() {
	int N; cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}
	int ans = 0;
	for (int t = 0; t <= N; ++t) {
		int num = count_if(v.begin(), v.end(), [=](const int a) {return a >= t; });
		if (num >= t)ans = t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    string s;
    cin >> s;
    int n = s.size(), cnt_b = 0, index = n;
    char c[n + 1];
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'B') cnt_b++;
        else if (!cnt_b) {
            c[--index] = s[i];
        } else cnt_b--;
    }
    for (; index <= n - 1; index++) cout << c[index];
    cout << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    ll H, N;
    cin >> H >> N;

    for(ll i=0; i<N; i++)
    {
        ll a;
        cin >> a;

        H -= a;
    }

    if(H > 0)
        cout << "No" << endl;

    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}

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;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    for(int i=1; i<n; ++i){
        a[i]=__gcd(a[i-1],a[i]);
    }
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long x,y,n,i;
int main()
{
    cin>>x>>y>>n;
    if((abs(y-x)+1)<=(n*2)){
     for(i=x;i<=y;i++){
      cout<<i<<endl;
     }
    }
    else{
     for(i=x;i<=(x+n-1);i++)cout<<i<<endl;
     for(i=(y-n+1);i<=y;i++)cout<<i<<endl;
    }
}


Measured memory_bytes: 256
N=int(input())
ls=[int(input()) for _ in range(N)]

fromL=[0 for _ in range(N)]
for i in range(1,N):
  fromL[i]=max([fromL[i-1],ls[i-1]])

fromR=[0 for _ in range(N)]
for i in range(1,N):
  fromR[N-1-i]=max([fromR[N-i],ls[N-i]])

for i in range(N):
  print(max([fromL[i],fromR[i]]))

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();

  vector< vector<int> > dp(n + 1, vector<int>(m + 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
  }
  
  string lcs;
  int i = n, j = m;
  while (i > 0 && j > 0) {
    if (s[i - 1] == t[j - 1]) {
      i--; j--;
      lcs += s[i];
    } else {
      (dp[i - 1][j] > dp[i][j - 1]) ? i-- : j--;
    }
  }
  reverse(lcs.begin(), lcs.end());
  cout << lcs << '\n';
  return 0;
}

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

int main() {
    long long int A,B,C,K;
    cin >> A>> B >> C >> K;
    long long int first,ans = 0;
    first = min(A,K);
    ans += first;
    long long int second,third;
    K = K - first;
    if (K > 0) {
        second = min (B,K);
        K = K - second;
        if (K > 0) {
            third = min (C,K);
            K = K - third;
            ans -= third;
            cout << ans << endl;
        }
        else {
            cout << ans << endl;
        }
    }
    else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
k = int(input())

lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def gene_lunlun(x):
    last = x % 10
    if last - 1 >= 0:
        yield x * 10 + last - 1
    yield x * 10 + last
    if last + 1 <= 9:
        yield x * 10 + last + 1

p = 0
while len(lunlun) < k:
    for new_lunlun in gene_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k-1])

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



int main(){
    string s;
    cin>>s;

    int len = s.length();
    int ans = 0;
    rep(i,len){
        rep2(j,i, len){
            if(s[j]=='A' || s[j]=='T' || s[j]=='G' || s[j]=='C'){
                ans = max(ans, j-i+1);
            }
            else break;
        } 
    } 

    cout <<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		char[]in=s.nextLine().toCharArray();
		long r=1;
		int[]c=new int[26];
		for(int i=0;i<in.length;++i)
			r+=i-c[in[i]-'a']++;
		System.out.println(r);
	}
}

Measured memory_bytes: 28676
/***************************************************

@author: vichitr
Compiled On: 19th Mar 2020

*****************************************************/
#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define ip pair<int, int>
#define F first
#define S second

#define loop(i,n) for(int i=0;i<n;i++)
#define loops(i,s,n) for(int i=s;i<=n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
// const ll M = 2e5+7;

ll pwr(ll x, ll y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r;
}

int inv(int x)
{
    return pwr(x, MOD-2ll);
}

// int fact[N];

// int nCr(int x, int y){
//     int ans= fact[x];
//     ans *= inv(fact[y]);
//     ans %= MOD;
//     ans *= inv(fact[x-y]);
//     ans %= MOD;
//     return ans;
// }

// bool prim(int n){
//     for(int i=2;i*i<=n;i++){
//         if(n%i==0)
//             return 0;
//     }
//     return 1;
// }
bool ispal(string s){
    int n = s.size();
    for(int i=0;i<n/2;i++)
        if(s[i]!=s[n-1-i])
            return 0;
    return 1;
}

void solve()
{ 
    int n; cin>>n;
    double l = n*1.0/3;
    double ans = l*l*l;
    cout<<fixed<<setprecision(10)<<ans;
}

signed main()
{
    fast;
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
// #endif
    int t=1;
    // cin >>t;

    // fact[0] =1;
    // for(int i=1;i<N;i++){
    //     fact[i] = fact[i-1]*i;
    //     fact[i] %= MOD;
    // }
    // int i  =1;
    while(t--){
        // int n = i++;
        solve();
        
    }
    return 0;
}

/*****************************

1
10 3
1 5 1
3 6 1
6 9 1


**************************/

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

int main() {
  int H, N, sum = 0;
  cin >> H >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  if (sum >= H)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
    

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int k;
const int INF = 1001001001;



int main(){
  int h, w;
  cin >> h >> w >> k;

  vector<vector<int>> a(h);
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      a[i].push_back(s[j] - '0');
    }
  }
  int ans = INF;

  rep(div, 1<<(h - 1)) {
    int g = 0;
    vector<int> id(h);
    rep(i, h) {
      id[i] = g;
      if(div>>i&1) ++g;
    }
    ++g;

    vector<vector<int>> c(g, vector<int>(w));
    rep(i, h)rep(j, w) c[id[i]][j] += a[i][j];

    int num = g - 1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i, g) now[i] += c[i][j];
      rep(i, g) if (now[i] > k) return false;
      return true;
    };
    
    rep(i, w) {
      if (!(add(i))) {
        ++num;
        now = vector<int>(g);
        if (!add(i)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(ans, num);

  }
  cout << ans << endl;

}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = int64_t;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
 //cout << setprecision(15) << std::fixed;

int main() {

    int n,m;
    cin >> n >> m;

    vecvec A(100001);
    ll ans = 0;
    priority_queue<int> que;

    for (int i = 0;i < n;i++) {
        int a, b;
        cin >> a >> b;
        A[a].push_back(b);
    }

    for (int i = 1;i <= m;i++) {
        for (auto a : A[i]) que.push(a);
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }

    print(ans);
}



Measured memory_bytes: 5632
# -*- coding: utf-8 -*-

yomikata = {"hon": [2, 4, 5, 7, 9], "pon": [0, 1, 6, 8], "bon": [3]}


# 整数の入力
number = input()

# 最後のの数字を取得
last = number[-1:]

for k, v in yomikata.items():
    if int(last) in v:
        print(k)
    #print(k, v)


Measured memory_bytes: 9048
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int n = sc.nextInt();
		String s = sc.next();
		char[] c = s.toCharArray();
		int len = n;
		for(int i = 1; i < n; i++) {
			if(c[i - 1] == c[i])len--;
		}
		System.out.println(len);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 28076
#include <stdio.h>

int main(){
  int N,M;
  int map[50][50]={0,};
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--;b--;
    map[a][b]++;
    map[b][a]++;
  }
  for(int i=0;i<N;i++){
    int cnt=0;
    for(int j=0;j<N;j++){
      cnt+=map[i][j];
    }
    printf("%d\n",cnt);
  }
}


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

int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (size_t i = 0; i < n; i++) cin >> h[i];

    if (n <= k) {
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(), h.end(), greater<int>());
    long long ans = 0;
    for (size_t i = k; i < n; i++) ans += h[i];

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


Measured memory_bytes: 3988
X,N = map(int,input().split())
P = list(map(int,input().split()))

a = list(range(102))
for i in range(N):
    a[P[i]] = -2
m = 102
for i in range(102):
    if m > (abs(X - a[i])):
        m = (abs(X - a[i]))
        ans = a[i]
print(ans)

Measured memory_bytes: 9204
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<int> cnt(N);
    rep(i,K) {
        int d; cin >> d;
        rep(j,d) {
            int a; cin >> a;
            a--;
            cnt[a]++;
        }
    }
    int ans = 0;
    rep(i,N) if (!cnt[i]) ans++;
    cout << ans << ln;
}

Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;

	bool AC[100001] = {};
	int WA[100001] = {};

	rep(i, M) {
		int p;
		string S;
		cin >> p >> S;

		if (S == "AC") {
			AC[p] = 1;;
		}
		else {
			if (!AC[p]) WA[p]++;
		}
	}

	int kotae1 = 0;
	int kotae2 = 0;
	rep1(i, N) {
		kotae1 += AC[i];
		if(AC[i]) kotae2 += WA[i];
	}
	cosp(kotae1);
	co(kotae2);




	Would you please return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 2e5 + 52;

int n, k, a[N], l[N], p[N];
void rm(int x) { x[l][p] = x[p], x[p][l] = x[l]; }
int main() {
	scanf("%d%d", &n, &k);
	if (k == 1 || k == 2 * n - 1) return puts("No"), 0;
	puts("Yes");
	if (n == 2) return puts("1\n2\n3"), 0;
	for (int i = 0; i < 2 * n; i++) i[p] = i - 1, i[l] = i + 1;
	if (k == 2) {
		rm(a[n - 1] = 3);
		rm(a[n + 0] = 2);
		rm(a[n + 1] = 1);
		rm(a[n + 2] = 4);
	} else {
		rm(a[n - 1] = k - 1);
		rm(a[n + 0] = k + 0);
		rm(a[n + 1] = k + 1);
		rm(a[n + 2] = k - 2);
	}
	n = n * 2 - 1;
	for (int i = 1, c = 0 [l]; i <= n; printf("%d\n", a[i++]))
		if (!a[i]) a[i] = c, c = c[l];
}

Measured memory_bytes: 3712
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,M = gets.chomp.split(' ').map{|n| n.to_i}
row=N
col=M
A=Array.new(row){Array.new(col)}
0.upto(row-1){|i|
	A[i]=gets.chomp.split(' ').map{|n| n.to_i}
}
F=Array.new(col+1){true}

def calc(a,f)
	h = {}
	a.each{|l|
		l.each{|v|
			if(f[v])
				h[v].nil? ? h[v]=1 : h[v]+=1
				break
			end
		}
	}
	h.max{|a,b| a[1] <=> b[1]}
end

minval = N+1
for i in 0..(M-1)
	key,val = calc(A,F)
	minval > val ? minval = val : val
	F[key] = false
	dputs "#{key},#{val}"
end
puts minval



Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];
	sort(all(p)); reverse(all(p));
	sort(all(q)); reverse(all(q));
	vector<int> use;
	rep(i, x) use.pb(p[i]);
	rep(i, y) use.pb(q[i]);
	rep(i, c) use.pb(r[i]);
	sort(all(use)); reverse(all(use));
	int ans = 0;
	rep(i, x + y) ans += use[i];
	cout << ans << endl;
}

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

using namespace std;

int main(){
  int V,E,K;
  cin>>V>>E>>K;
  vector<vector<int> > d[99];
  d[0]=vector<vector<int> >(V,vector<int>(V,-1));
  for(int i=0;i<E;i++){
    int v1,v2,c;
    cin>>v1>>v2>>c;
    d[0][v1][v2]=max(d[0][v1][v2],c);
  }
  for(int i=0;i<V;i++){
    d[0][i][i]=0;
  }
  int mx=-1;
  for(int i=0;i<20;i++){
    d[i+1]=vector<vector<int> >(V,vector<int>(V,-1));
    for(int j=0;j<V;j++){
      for(int k=0;k<V;k++){
	for(int l=0;l<V;l++){
	  if(d[i][k][j]>=0&&d[i][j][l]>=0){
	    d[i+1][k][l]=max(d[i+1][k][l],d[i][k][j]+d[i][j][l]);
	    mx=max(mx,d[i+1][k][l]);
	  }
	}
      }
    }
  }
  if(mx<K){
    cout<<-1<<endl;
  }else{
    int l=0,h=1<<20;
    while(h-l>1){
      int m=(h+l)/2;
      vector<int> v(V);
      int mmx=-1;
      for(int i=0;i<20;i++){
	if(m>>i&1){
	  vector<int> org=v;
	  for(int j=0;j<V;j++){
	    for(int k=0;k<V;k++){
	      if(d[i][k][j]>=0){
		v[j]=max(v[j],org[k]+d[i][k][j]);
		mmx=max(mmx,v[j]);
	      }
	    }
	  }
	}
      }
      ((mmx<K)?l:h)=m;
    }
    cout<<h<<endl;
    if(h<=100){
      int c[101][150];
      fill(*begin(c),*end(c),-1);
      int p[101][150];
      for(int i=1;i<=h;i++){
	for(int j=0;j<V;j++){
	  for(int k=0;k<V;k++){
	    if(d[0][k][j]>=0&&c[i][j]<c[i-1][k]+d[0][k][j]){
	      c[i][j]=c[i-1][k]+d[0][k][j];
	      p[i][j]=k;
	    }
	  }
	}
      }
      int x[101];
      x[h]=max_element(begin(c[h]),end(c[h]))-begin(c[h]);
      for(int i=h;i-1>=0;i--){
	x[i-1]=p[i][x[i]];
      }
      for(int i=0;i<=h;i++){
	cout<<x[i]<<" \n"[i==h];
      }
    }
  }
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         pi             3.14159265359
#define         nl             printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int ll;

int main()
{

    FIO;
    int i,j,k,temp,n,f=0,x;
    cin>>n;
    int a[n+1],b[n+1],c[n],ans=0;
    rep(i,n)
        cin>>a[i];
    rep(i,n){
        cin>>b[i];
        ans+=b[i];
    }
    //cout<<ans<<endl;
    for(i=0;i<n-1;i++)
        cin>>c[i];
    for(i=1;i<n;i++)
    {
        if((a[i]-1)==a[i-1])
            ans+=c[a[i]-2];
         //cout<<ans<<endl;
    }
     cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#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 a, b, c;
  cin >> a >> b >> c;
  set<int> mp;
  mp.insert(a);
  mp.insert(b);
  mp.insert(c);
  if(mp.size() == 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ok = True
    for a in A:
        if a%2 == 0 and a%3 != 0 and a%5 != 0:
            ok = False
            break
    
    if ok:
        print("APPROVED")
    else:
        print("DENIED")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <stdlib.h>
#include <stdio.h>    
#define INIT_BH_SIZE 16  
#define MAX_CMD_SIZE 8                          
#define ROOT_IDX 1                 
#define P_KEY(i) (i / 2)   
#define L_KEY(i) (i * 2)
#define R_KEY(i) (i * 2 + 1)
     
static void max_heapify(int *bh, int i, int n) {
  int l, r, m, tmp; 
 
  l = L_KEY(i);                            
  r = R_KEY(i);
  m = i;
  if (l <= n && bh[l] > bh[i]) m = l;
  if (r <= n && bh[r] > bh[m]) m = r;
  if (m != i) {
    tmp = bh[i];
    bh[i] = bh[m];
    bh[m] = tmp;
    max_heapify(bh, m, n);
  }
}

static void insert(int *bh, int i, int k) {
  int j, tmp;

  bh[i] = k;
  for (j = i; j > 0; j = P_KEY(j)) {
    if (P_KEY(j) < ROOT_IDX || bh[j] < bh[P_KEY(j)]) break;
    tmp = bh[j];
    bh[j] = bh[P_KEY(j)];
    bh[P_KEY(j)] = tmp;
  }
}

static int remove_root(int *bh, int i) {
  int root;

  root = bh[ROOT_IDX];
  bh[ROOT_IDX] = bh[i];
  max_heapify(bh, ROOT_IDX, i);
  return root;
}

int main(int argc, char **argv) {
  int n, i, k;
  int *bh;
  char cmd[MAX_CMD_SIZE];

  n = INIT_BH_SIZE;
  i = ROOT_IDX;
  bh = (int *) malloc(sizeof(int) * n);
  while (1) {
    scanf("%s", cmd);
    if (cmd[0] == 'i') {
      if (i == n) {
        bh = (int *) realloc(bh, sizeof(int) * n * 2);
        n *= 2;
      }
      scanf("%d", &k);
      insert(bh, i++, k);
    } else if (cmd[0] == 'e' && cmd[1] == 'x') {
      printf("%d\n", bh[ROOT_IDX]);
      remove_root(bh, --i);
    } else {
      break;
    }
  }
  free(bh); exit(0);
}


Measured memory_bytes: 5564
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int cnt=0;
        while(true){
            cnt++;
            int a=sc.nextInt();
            if(a==0) break;
            System.out.println("Case "+cnt+": "+a);
        }
        sc.close();
    }
}


Measured memory_bytes: 40504
n=int(input())
a=list(map(int,input().split()))
ans=1
keta=1
a.sort()
for i in a:
    
    #print(keta)
    if(i==0):
        ans=0
        break
    
    ans=ans*i
    if(ans>1000000000000000000):
        ans=-1
        break

print(ans)

Measured memory_bytes: 21640
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	ll n, m, ans = 1;
	cin >> n >> m;
	for (ll i = 1; i*i <= m; ++i)
	{
		if (m%i) continue;

		ll j = m / i;
		if (i * n <= m) ans = max(ans, i);
		if (j * n <= m) ans = max(ans, j);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>      
#include<cstdio>    
#include<stdio.h>    
#include<cstring>      
#include<cstdio>      
#include<climits>      
#include<cmath>     
#include<vector>    
#include <bitset>    
#include<algorithm>      
#include <queue>    
#include<map>    
#include<stack>  
using namespace std;  
  
long long int ans1, ans2, sum1, sum2;  
int n, i;  
long long int a[100005];  
int main()  
{  
    cin >> n;  
    for (i = 1; i <= n; i++)  
    {  
        cin >> a[i];  
    }  
    if (a[1] >0)  
    {  
        sum1 = a[1];  
        ans2= a[1] + 1;  
        sum2 = -1;  
    }  
    else if (a[1] == 0)  
    {  
        sum1 = 1;  
        ans1 = ans2 = 1;  
        sum2 = -1;  
    }  
    else   
    {  
        sum1 = 1;  
        ans1 = abs(a[1]) + 1;  
        sum2 = a[1];  
    }  
    for (i = 2; i <= n; i++)  
    {     
        if (sum1 > 0)  
        {  
            if (a[i] + sum1 >= 0)  
            {  
                ans1 += a[i] + sum1 + 1;  
                sum1 = -1;  
            }  
            else  
            {  
                sum1 += a[i];  
            }  
        }  
        else  
        {  
            if (a[i] + sum1 <= 0)  
            {  
                ans1 += abs(sum1 + a[i]) + 1;  
                sum1 = 1;  
            }  
            else  
            {  
                sum1 += a[i];  
            }  
        }  
    }  
    if (sum1 == 0)  
    {  
        ans1++;  
    }  
    for (i = 2; i <= n; i++)  
    {  
        if (sum2 > 0)  
        {  
            if (a[i] + sum2 >= 0)  
            {  
                ans2 += a[i] + sum2 + 1;  
                sum2 = -1;  
            }  
            else  
            {  
                sum2 += a[i];  
            }  
        }  
        else  
        {  
            if (a[i] + sum2 <= 0)  
            {  
                ans2 += abs(sum2 + a[i]) + 1;  
                sum2 = 1;  
            }  
            else  
                sum2 += a[i];  
        }  
    }  
    if (sum2 == 0)  
    {  
        ans2++;  
    }  
    cout << min(ans1, ans2) << endl;  
} 

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void){

	double a,b;
	double h,m;
	double ax,ay;
	double bx,by;
	double ret;
//	double M_PI = 3.141592653589793;

	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);


	ax = sin( ( h * 30 + m / 2)  / 360 * 2 * M_PI) * a;
	ay = cos( ( h * 30 + m / 2)  / 360 * 2 * M_PI) * a;
	bx = sin( m *  6 / 360 * 2 * M_PI) * b;
	by = cos( m *  6 / 360 * 2 * M_PI) * b;

	ret = sqrt((ax - bx)*(ax - bx) + (ay - by) *(ay - by));

	printf("%10.10lf\n",ret);




	
	return 0;
}

Measured memory_bytes: 2472
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vec<string> s(n);
    rep(i,n)cin>>s[i];
    ll m=0,a=0,r=0,c=0,h=0;
    ll d[5];
    ll se1[10]={0,0,0,0,0,0,1,1,2,1};
    ll se2[10]={1,1,1,3,2,2,2,2,3,3};
    ll se3[10]={2,3,4,4,3,4,3,4,4,4};

    rep(i,n){
      if(s[i][0]=='M')m++;
      if(s[i][0]=='A')a++;
      if(s[i][0]=='R')r++;
      if(s[i][0]=='C')c++;
      if(s[i][0]=='H')h++;
    }

    d[0]=m;
    d[1]=a;
    d[2]=r;
    d[3]=c;
    d[4]=h;

    ll ans=0;
    rep(i,10){
      ans+=d[se1[i]]*d[se2[i]]*d[se3[i]];
    }

    cout<<ans<<endl;
}

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

int main()
{
	int a,b;
    cin >> a >> b;
    int cnt=0;
  	if(b==1)	cout << "0";
    else if(b<=a)    cout << "1";
    else 
    {
        cnt=1;
        int sa=a;
        while(b>sa)
        {
            //cout << b << " " << a << " " << cnt << "\n";
            sa+=(a-1);
            cnt++;
        }
        cout << cnt;
    }
  	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N, M;
vector<pair<int, int>> cities,sorted;

int main() {

	cin >> N >> M;

	int prefecture, year;
	for (int i = 0; i < M; i++) {
		cin >> prefecture >> year;
		cities.push_back(make_pair(prefecture, year));
		sorted.push_back(make_pair(prefecture, year));
	}
	for (int i = 0; i <= N; i++)
		sorted.push_back(make_pair(i, -1));

	sort(sorted.begin(), sorted.end());

	for (int i = 0; i < M; i++) {
		auto lower = lower_bound(sorted.begin(), sorted.end(), make_pair(cities[i].first, -1));
		auto upper = lower_bound(sorted.begin(), sorted.end(), cities[i]);
		
		printf("%06d%06d\n", cities[i].first, upper - lower);
	}

	return 0;
}

Measured memory_bytes: 4072
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static int K;
    static List<long> lunlun;
    static void Main()
    {
        K = int.Parse(Console.ReadLine());
        lunlun = new List<long>();
        for(int i = 1; i <= 9; i++)
        {
            Search(i, i);
        }
        lunlun.Sort();
        Console.WriteLine(lunlun[K-1]);
    }
    static void Search(long num,int last)
    {
        lunlun.Add(num);
        if(num<= 3234566667)
        {
            for(int i = -1; i <= 1; i++)
            {
                int nlast = last + i;
                if (0 <= nlast && nlast <= 9)
                    Search(num * 10 + nlast, nlast);
            }
        }
    }
}

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

int main(){
  int h,w,inf = 1000000007;
  cin >> h >> w;
  char a[w][h];
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> a[j][i];
    }
  }
  int dp[w][h];
  for(int i = 0;i < w;i++){
    for(int j = 0;j < h;j++){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  //cout << dp[0][2] << endl;
  for(int i = 1;i < w;i++){
    if(a[i][0] == '#'){
      break;
    }
    if(a[i][0] == '.'){
      dp[i][0] = 1;
    }
  }
  for(int i = 1;i < h;i++){
    if(a[0][i] == '#'){
      break;
    }
    if(a[0][i] == '.'){
      dp[0][i] = 1;
    }
  }
  for(int i = 1;i < h;i++){
    for(int j = 1;j < w;j++){
      if(a[j][i] == '.'){
        dp[j][i] = (dp[j][i-1]%inf + dp[j-1][i]%inf)%inf;
        //cout << dp[j][i] << " " << j << " " << i << endl;
      }
    }
  }
  cout << dp[w-1][h-1] << endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int x,y;

int gcd(int a,int b,int& t){
	t++;
	if(!b) return a;
	return gcd(b,a%b,t);
}

int main(){
	while(1){
		cin>>x>>y;
		if(!x&&!y) break;
		int t=0;
		if(x<y) swap(x,y);
		cout<<gcd(x,y,t)<<' ';
		cout<<t-1<<endl;
	}
}

Measured memory_bytes: 1156