akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int k[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int a;
	cin >> a;
	cout << k[a - 1]<<endl;
}

Measured memory_bytes: 3588
n=int(input())
d=[]
for i in range(n):
    d.append(list(map(int,input().split())))
for i in range(n-2):
    if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define sz size()
#define pb push_back
#define ve vector<int>
#define pii pair < int,int >
#define pll pair < ll,ll >
#define ll long long
#define Graph vector<vector < int > >
#define Fp cout << fixed <<  setprecision(9)
#define Fast  ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
const ll M = 109, N= 101000, MOD = 1e9+7, OO = 1e7;
ll m,n,k, x, y, dp[M][N], bla,c=1,cnt,ans,sum, a[M][N], ok=1 ;

int main()
{

    cin >> n >> m ;
    for(int i=1; i<=n; i++)
    {
        for(int j=0; j<2; j++)
        {

            cin >> a[i][j] ;
        }
    }


memset(dp, 0);
dp[1][a[1][0]] = a[1][1];
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){

        if(j < a[i][0]) dp[i][j] = dp[i-1][j];
        else{

            dp[i][j] = max(dp[i-1][j] , a[i][1] + dp[i-1][j- a[i][0]]);

        }
    }


}
ll mx=0;
for(int j=1;j<=m;j++)
    mx = max(mx , dp[n][j] );

cout << mx ;
     return 0;
}
/*
6 15
6 5
5 6
6
6 6
3 5
7 2
*/


Measured memory_bytes: 166272
import java.util.*;

public class Main {

    static List<ban> bans;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int C = scan.nextInt();
        bans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            bans.add(new ban(scan.nextInt() * 2,scan.nextInt() * 2,scan.nextInt()));
        }
        bans.sort(Comparator.comparingInt(x -> x.s));

        for (int i = 1; i <= C; i++) {
            boolean success = func(i);
            if (success) {
                System.out.println(i);
                return;
            }
        }
    }

    private static boolean func(int num) {
        List<tv> tvs = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            tvs.add(new tv(-1, -1));
        }
        for (int i = 0; i < bans.size(); i++) {
            int now = bans.get(i).s;
            int can = bans.get(i).c;
            Optional<tv> tmp = tvs.stream().filter(x -> x.c == -1 || (x.c == can && x.t <= now) || x.t <= now - 1).findAny();
            if(tmp.isPresent()) {
                tv temp = tmp.get();
                temp.t = bans.get(i).t;
                temp.c = can;
            }
            else {
                return false;
            }
        }
        return true;
    }

    static class tv{
        int t;
        int c;
        public tv(int t, int c) {
            this.t = t;
            this.c = c;
        }
    }

    static class ban{
        int s;
        int t;
        int c;
        ban(int s, int t, int c) {
            this.s = s;
            this.t = t;
            this.c = c;
        }
    }
}


Measured memory_bytes: 98568
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <memory>
#include <sstream>

#include <limits.h>

using namespace std;

class Hoge
{

  public:
    int add(int a, int b);

    static void ABC117B();

    static void ABC117C();

    static int ABC117C_sub_ans1(int n, int m, int idx, std::vector<int> &x);

    static int ABC117C_sub_ans2(int n, int m, int idx, std::vector<int> &x);
};
int Hoge::add(int a, int b)
{
  return a + b;
}

void Hoge::ABC117B()
{
  int n;
  cin >> n;

  int j;
  int max = 0;
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> j;
    max = max < j ? j : max;
    sum += j;
  }

  sum = sum - max;
  if (max < sum)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return;
}

void Hoge::ABC117C()
{
  int n, m, t;
  std::vector<int> x;
  cin >> n;
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    cin >> t;
    x.push_back(t);
  }
  std::sort(x.begin(), x.end());

  int result = ABC117C_sub_ans2(n, m, 0, x);
  cout << result;
  return;
}

int Hoge::ABC117C_sub_ans1(int n, int m, int idx, std::vector<int> &x)
{
  if (m <= n)
  {
    return 0;
  }
  else
  {
    int minSteps = 1000000;
    for (int i = 0; i < m - 1; i++)
    {
      int stepsLeft = std::abs(x[idx + i] - x[idx]);
      if (stepsLeft >= minSteps)
      {
        break;
      }
      int stepsRight = 0;
      if (n > 1)
      {
        stepsRight = ABC117C_sub_ans1(n - 1, m, idx + i + 1, x);
      }
      else
      {
        stepsRight = std::abs(x[m - 1] - x[idx + i]);
      }
      int steps = stepsLeft + stepsRight;
      minSteps = std::min(minSteps, steps);
      //cerr << "n: " << n << ", m: " << m << ", idx: " << idx;
      //cerr << ", minSteps: " << minSteps << ", left:" << stepsLeft << ", right: " << stepsRight << endl;
    }
    return minSteps;
  }
}

int Hoge::ABC117C_sub_ans2(int n, int m, int idx, std::vector<int> &x)
{
  if (m <= n)
  {
    return 0;
  }
  if (n == 1)
  {
    return x[m - 1] - x[0];
  }

  // find (n-1) biggest intervals of x[i]..x[i+1]
  vector<int> intervals(m - 1);
  for (int i = 0; i < m - 1; i++)
  {
    // cerr << "diff x[" << i << "]=" << x[i + 1] - x[i] << endl;
    intervals.push_back(abs(x[i + 1] - x[i]));
  }

  sort(intervals.begin(), intervals.end(), std::greater<int>());
  int exclude = 0;
  int sum = 0;
  for (int i = 0; i < n - 1; i++)
  {
    exclude += intervals[i];
  }
  for (int i = 0; i < m; i++)
  {
    sum += intervals[i];
  }

  // cerr << "sum: " << sum << ", exclude: " << exclude << endl;

  return sum - exclude;
}
int main(int argc, char const *argv[])
{
    Hoge::ABC117C();
    return 0;
}


Measured memory_bytes: 1528
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	vector<pll> a(n);
	for(ll i=0;i<n;i++){
		cin>>a[i].ff;
		a[i].ss=i+1;
	}
	sort(a.begin(),a.end());
	for(ll i=0;i<n;i++){
		cout<<a[i].ss<<' ';
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 2432
N,C = map(int,input().split())

d = []
c = []
for i in range(C):
    raw = list(map(int,input().split()))
    d.append(raw)

for i in range(N):
    raw = list(map(int,input().split()))
    c.append(raw) 

colorNum = [[0] * 3 for _ in range(C)]

for i in range(N):
    for j in range(N):
        colorNum[c[i][j]-1][(i+j)%3] += 1

#print(colorNum)

minimum = 1000*500*500

def calc(i,j,k):
    cost = 0
    for color in range(C):
        c0 = colorNum[color][0]
        c1 = colorNum[color][1]
        c2 = colorNum[color][2]
    
        cost += c0 * d[color][i]
        cost += c1 * d[color][j]
        cost += c2 * d[color][k]
    return cost
        

for i in range(C):
    for j in range(C):
        if i==j:
            continue
        for k in range(C):
            if j==k or i==k:
                continue
            cand = calc(i,j,k)
            minimum = min(minimum,cand)

print(minimum)

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	char x;
	cin >> x;
	if (x == 'A') {
		cout << "T" << '\n';
	}
	else if (x == 'T') {
		cout << "A" << '\n';
	}
	else if (x == 'C') {
		cout << "G" << '\n';
	}
	else {
		cout << "C" << '\n';
	}




}

Measured memory_bytes: 256
import math
str = input().split()
a = int(str[0])
b = int(str[1])
x = int(str[2])
if x > float(a*a*b)/2:
    print(math.degrees(math.atan(float(a*a*b-x)*2/a/a/a)))
else:
    print(math.degrees(math.atan(float(a*b*b)/x /2)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <iterator>
#include <string>
#include <algorithm>
namespace Mylib{
    using namespace std;
    
    
}
int main(void){
    using namespace std;
    int N;
    cin >> N;
    vector<int> vInt;
    int tempInt;
    for(int i=0;i<N;i++){
        cin >> tempInt;
        vInt.push_back(tempInt);
    }
    tempInt=vInt.size();
    
    sort(vInt.begin(),vInt.end());
    vInt.erase(unique(vInt.begin(),vInt.end()),vInt.end());
    if(vInt.size()==tempInt){
        //uniqueで削除されなかった＝重複が無い
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    lint a[2*n], b[2*n];
    rep(i, 2*n) scanf("%lld", &a[i]);
    rep(i, 2*n) scanf("%lld", &b[i]);
    int cnt = 2;
    lint sum = a[0] + a[2*n-1];
    set<pli> S;
    For(i, 1, 2*n-1){
        if(a[i] >= b[i]){
            sum += a[i];
            ++cnt;
        }
        else sum += b[i];
        S.emplace(abs(a[i]-b[i]), i);
    }

    rep(_, q){
        int p;
        lint x, y;
        scanf("%d%lld%lld", &p, &x, &y);
        --p;
        if(p == 0 || p == 2*n-1){
            sum -= a[p];
            sum += x;
        }
        else{
            S.erase({abs(a[p]-b[p]), p});
            S.insert({abs(x-y), p});
            sum -= (a[p]>=b[p] ? a[p] : b[p]);
            if(x >= y){
                sum += x;
                if(a[p] < b[p]) ++cnt;
            }
            else{
                sum += y;
                if(a[p] >= b[p]) --cnt;
            }
        }
        a[p] = x; b[p] = y;
        printf("%lld\n", cnt % 2 == 0 ? sum : sum-S.begin()->fi);
    }
}

Measured memory_bytes: 17280
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

class Edge{
public:
	int to, cap, rev, num;
	Edge(){};
	Edge(int to0, int cap0, int num0){to = to0; cap = cap0; num = num0;}
	Edge(int to0, int cap0, int rev0, int num0){to = to0; cap = cap0; rev = rev0; num = num0;}
};

int main()
{
	static vector<vector<Edge> > edges;
	static vector<bool> used;

	class Func{
	public:
		static int dfs(int s, int t, int f){
			if(s == t)
				return f;
			used[s] = true;
			for(unsigned i=0; i<edges[s].size(); ++i){
				Edge& e = edges[s][i];
				if(!used[e.to] && e.cap > 0){
					int g = dfs(e.to, t, min(f, e.cap));
					if(g > 0){
						e.cap -= g;
						edges[e.to][e.rev].cap += g;
						return g;
					}
				}
			}
			return 0;
		}
	};

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

	edges.assign(n, vector<Edge>());
	for(int i=0; i<m; ++i){
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		edges[a].push_back(Edge(b, 1, edges[b].size(), -1));
		edges[b].push_back(Edge(a, 1, edges[a].size()-1, i+1));
	}

	int s, t;
	cin >> s >> t;
	--s;
	--t;

	int flow = 0;
	for(;;){
		used.assign(n ,false);
		int f= Func::dfs(s, t, INT_MAX);
		if(f == 0)
			break;
		flow += f;
	}

	vector<int> a;
	for(int i=0; i<n; ++i){
		for(unsigned j=0; j<edges[i].size(); ++j){
			if(edges[i][j].num != -1 && edges[i][j].cap == 0)
				a.push_back(edges[i][j].num);
		}
	}
	int num = a.size();

	cout << flow << endl;
	cout << num << endl;
	for(int i=0; i<num; ++i)
		cout << a[i] << endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int n;
vector<ll>a; 
ll solve(){
   ll ans=0;
   int len=a.size();
   if(len==1)return 0;
   if(len==2)return a[0];
   if(len%2==1){
       int d=(len-1)/2;
       rep(i,d){ans+=a[i];ans+=a[i+1];};
   }else{
       int d=len/2;
       rep(i,d-1){
          ans+=a[i];
          ans+=a[i+1];
       }
       ans+=a[d-1];
       
   }

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

    cin>>n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    reverse(all(a));
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 4776
N, = list(map(int, input().split()))
a = [{} for i in range(N)]
for i in range(N-1):
  u, v, w = list(map(int, input().split()))
  u -= 1
  v -= 1
  a[u][v] = w%2
  a[v][u] = w%2
r = [-1 for i in range(N)]
r[0] = 0
q = [0]
while q:
  i = q.pop(0)
  for aj in a[i].keys():
    if r[aj]==-1:
      r[aj] = (r[i]+a[i][aj])%2
      q.append(aj)
for i in range(N):
  print(r[i])

Measured memory_bytes: 41968
import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
const int mx = 1e6 + 9;

inline void normal(ll &a) { if (a >= MOD) a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) {normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) {normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) {normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } //if MOD is prime, modPow(b, p % (MOD-1))
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll N, M;
ll f[mx];
ll dp[mx];

ll nCr(ll n, ll r) {
    return modDiv(f[n], modMul(f[r], f[n - r]));
}

ll solve(int n, int m) {
    ll& ans = dp[n];
    if (ans != -1) return ans;

    ans = 0;
    if (n == 1) {
        return ans = m - 1;
    }

    if (n == 2) {
        return ans = (m - 1 + modMul(m - 2, m - 2)) % MOD;
    }

    ll t1 = modMul(n - 1, solve(n - 2, m - 2));
    ll t2 = modMul(m - 1, solve(n - 1, m - 1));

    ans = modAdd(t1, t2);
    return ans;
} 

int main() {
    memset(dp, -1, sizeof dp);
    f[0] = 1;
    for (int i = 1; i < mx; i++) f[i] = modMul(i, f[i - 1]);

    scanf("%lld %lld", &N, &M);
    
    ll ans = solve(N, M);
    ans = modMul(ans, nCr(M, N));
    ans = modMul(ans, f[N]);

    printf("%lld\n", ans);
}

Measured memory_bytes: 35020
#include<iostream>
#include<string>
using namespace std;
string s,ans;
int main()
{
	cin >> s;
	s+='A';
	unsigned len=s.size();
	for(unsigned i=0;i<len;i++)
	{
		if(s[i]=='A') break;
		if(s[i]=='0' || s[i]=='1') ans+=s[i];
		else if(s[i]=='B' && ans.size()) ans.erase(ans.size()-1,1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	int M=N*(N-1)/2-N/2;
	prin(M);
	if(N%2==0){
		rep1(i,N-1){
			for(int j=i+1;j<=N;j++){
				if(i+j!=N+1){
					printf("%d %d\n",i,j);
				}
			}
		}
	}
	else{
		rep1(i,N-1){
			for(int j=i+1;j<=N;j++){
				if(i+j!=N){
					printf("%d %d\n",i,j);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535838797323;
const ld E=2.71828183;
const int MOD=1e9+7;
vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();

int main() {
    //  int t;
    //cin >> t;
    //while(t--)
    solve();
}
void solve(){
    ll n,k;
    cin >> n >> k;
    if(n<=k){
        cout << min(n,abs(n-k) ) << "\n";
        return;
    }
    ll div=n/k;
    cout <<min( n-k*div,abs(n-k*div-k) ) << "\n";


}

Measured memory_bytes: 3568
#include <stdio.h>
int main ()
{
	int n, k;
	scanf ("%d %d", &n, &k);
	int x[n];
	for (int i = 0; i < n; i++){
		scanf ("%d", &x[i]);
	} 
	
	for (int i = k; i < n; i++){
		if (x[i - k] < x[i]){
			printf ("Yes\n");
		} else {
			printf ("No\n");
		}
	}
return 0;
}

Measured memory_bytes: 2392
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ld l;
    cin >> l;
    cout << fixed << sp(10) << (l/3)*(l/3)*(l/3) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  int N,K;
  cin>>N>>K;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int tmp=gcd(A[0],A[1]);
  for(int i=0;i<N;i++){
    tmp=gcd(tmp,A[i]);
  }
  sort(A,A+N);
  bool ok=false;
  for(int i=0;A[N-1]>0;i++){
    if(A[N-1]==K){
      ok=true;
      break;
    }
    A[N-1]-=tmp;
  }
  if(ok){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }



  
}





  
  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a,b,k,h;

int main(){

    cin>>h>>n;
    int sm=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        sm+=x;
    }
    cout<<(sm>=h?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
ll Abs(ll x) {
	return x < 0 ? -x : x;
}
int main() {
	int a, b, q;
	cin >> a >> b >> q;
	VL s(a), t(b);
	rep(i, a) {
		cin >> s[i];
	}
	rep(i, b) {
		cin >> t[i];
	}
	while (q--) {
		ll x;
		cin >> x;
		// それ以上の寺もしくはそれ以下の寺をまわり、そこからそれ以上の神社もしくはそれ以下の神社を回る
		// 逆もしかり、二分探索こんなにして大丈夫なのか？
		ll ans = UPPER;
		
		//初めに寺を回るほう
		auto itr1 = lower_bound(all(s), x);
		if (itr1 != s.end()) { 
			auto nitr1 = lower_bound(all(t), *itr1);
			if (nitr1 != t.end()) chmin(ans, Abs(x - *itr1) + Abs(*itr1 - *nitr1));
			if (nitr1 != t.begin()) chmin(ans, Abs(x - *itr1) + Abs(*itr1 - *--nitr1));
		}
		if (itr1 != s.begin()) {
			--itr1;
			auto nitr2 = lower_bound(all(t), *itr1);
			if (nitr2 != t.end()) chmin(ans, Abs(x - *itr1) + Abs(*itr1 - *nitr2));
			if (nitr2 != t.begin()) chmin(ans, Abs(x - *itr1) + Abs(*itr1 - *--nitr2));
		}

		//初めに神社を回るほう
		auto itr2 = lower_bound(all(t), x);
		if (itr2 != t.end()) {
			auto nitr3 = lower_bound(all(s), *itr2);
			if (nitr3 != s.end()) chmin(ans, Abs(x - *itr2) + Abs(*itr2 - *nitr3));
			if (nitr3 != s.begin()) chmin(ans, Abs(x - *itr2) + Abs(*itr2 - *--nitr3));
		}
		if (itr2 != t.begin()) {
			--itr2;
			auto nitr4 = lower_bound(all(s), *itr2);
			if (nitr4 != s.end()) chmin(ans, Abs(x - *itr2) + Abs(*itr2 - *nitr4));
			if (nitr4 != s.begin()) chmin(ans, Abs(x - *itr2) + Abs(*itr2 - *--nitr4));
		}
		cout << ans << endl;
	}
	return 0;
}

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

void Main() {
  long long N, A, B;
  cin >> N >> A >> B;
  long long h[N];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  auto enough = [&](int t) {
    long long sum = 0;
    for (int i = 0; i < N; i++) {
      long long tmp = h[i] - B * t;
      if (tmp > 0) {
        if (tmp % (A - B) == 0) sum += tmp / (A - B);
        else sum += tmp / (A - B) + 1;
      }
    }
    if (sum <= t) return true;
    else return false;
  };

  int l = 0, r = 1000000000;
  while (r - l != 1) {
    int c = (r + l) / 2;
    if (enough(c)) r = c;
    else l = c;
  }

  cout << r << endl;
}

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



Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line

inline void solve(void){
  string N;
  in(N);
  int n=N[N.size()-1]-'0';
  if(n==3)out("bon");
  else if(n==0||n==1||n==6||n==8)out("pon");
  else out("hon");
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(c<=a+b){
		printf("Yes\n");
	}
	else if(c>=a+b){
		printf("No\n");
	}
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A;
    int a; cin >> a;
    int pred = a;
    A.push_back(a);
    for (int i = 1; i < N; i++) {
        cin >> a;
        if (pred != a) A.push_back(a);
        pred = a;
    }
    if (A.size() == 1) {
        cout << 1000 << endl;
        return 0;
    } else {
        vector<int> K;
        K.push_back(A[0]);
        for (int i = 1; i < (int)A.size() - 1; i++) {
            if (A[i-1] < A[i] && A[i] > A[i+1]) K.push_back(A[i]);
            if (A[i-1] > A[i] && A[i] < A[i+1]) K.push_back(A[i]);
        }
        K.push_back(A[A.size()-1]);
        if (K[0] < K[1]) {
            ll money = 1000;
            for (int i = 1; i < (int)K.size(); i+=2) {
                money = money % K[i-1] + (money / K[i-1]) * K[i];
            }
            cout << money << endl;
        } else {
            ll money = 1000;
            for (int i = 2; i < (int)K.size(); i+=2) {
                money = money % K[i-1] + (money / K[i-1]) * K[i];
            }
            cout << money << endl;
        }
    }

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> w[120001];
int n,m,s,d[120001],f[120001],cnt[120001],need[120001];
void dfs(int u,int p,int dep)
{
	if(dep&1)s++,cnt[u]++;
	else need[u]++;
	d[u]=dep;f[u]=p;
	for(int v:w[u])
		if(v!=p)dfs(v,u,dep+1),cnt[u]+=cnt[v],need[u]+=need[v];
}
inline void add(int u,int k){while(u)cnt[u]+=k,u=f[u];}
int p[120001],b,e;
int find(int x){return p[x]==x?x:p[x]=find(p[x]);}
inline int eval(int k)
{
	if(k)add(b,k),add(e,-k);
	int ans=0;
	for(int i=2;i<=n;i++)ans+=abs(need[i]-cnt[i]);
	if(k)add(b,-k),add(e,k);
	return ans;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)p[i]=i;
	for(int i=0;i<m;i++)
	{
		int u,v;
		scanf("%lld%lld",&u,&v);
		int x=find(u),y=find(v);
		if(x==y)b=u,e=v;
		else w[u].push_back(v),w[v].push_back(u),p[x]=y;
	}
	dfs(1,0,0);
	if(m==n-1)printf("%lld\n",s*2!=n?-1:eval(0));
	else if((d[b]-d[e])&1)
	{
		if(s*2!=n)return puts("-1"),0;
		int l=-n,r=n,ans=1<<30;
		while(l+5<=r)
		{
			int l3=(l+r)/2,r3=(l3+r)/2,vl=eval(l3)+abs(l3),vr=eval(r3)+abs(r3);
			if(vl<vr)r=r3;
			else l=l3;
		}
		for(int i=l;i<=r;i++)ans=min(ans,eval(i)+abs(i));
		printf("%lld\n",ans);
	}
	else
	{
		if((n-s-s)%2)return puts("-1"),0;
		int k=(n-s-s)/2;
		add(b,k);add(e,k);
		printf("%lld\n",abs(k)+eval(0));
	}
	return 0;
}


Measured memory_bytes: 16640
N = int(input())

def get_divisor_num(n):
    cnt = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            cnt += 1
            if n // i != i:
                cnt += 1

    return cnt

cnt = 0
for i in range(1, N+1, 2):
    if get_divisor_num(i) == 8:
        cnt += 1

print(cnt)


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

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

	int X, A, B;
	cin >> X >> A >> B;
	
	if( B <= A ) {
		cout << "delicious\n";
	}
	else if( B <= A+X ) {
		cout << "safe\n";
	}
	else {
		cout << "dangerous\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

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

    REP(i, N){
        int k, p;
        std::cin >> k >> p;

        if(k % p == 0){
            printf("%d\n", p);
        }else{
            printf("%d\n", k%p);
        }
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

bool judge(int x, vector<int> &D){
	bool flag = true;
	REP(i, D.size()){
		if(D[i]==x) flag = false;
	}
	return flag;
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> D(K);
	REP(i, K) cin >> D[i];
	int i=N;
	while(1){
		int x = i;
		bool flag = true;
		while(x>0){
			int y = x%10;
			x /=10;
			if (!judge(y, D)) flag = false;
		}
		if(flag) break;
		i++;
	}	
	cout << i << endl;

    return 0;
}

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

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

int main() {
  string s; cin >> s; 
  int moves = ((s.size() & 1) ? 3 : 2) - 
              (s[0] == s.back() ? 1 : 0); 
  puts((moves & 1) ? "First" : "Second");
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<algorithm>

using namespace std;

int main(){
    
    int a, b, k;
    set<int> hoge;

    cin >> a >> b >> k;

    for(int i = a; i < a + k && i <= b; i++) hoge.insert(i);
    for(int i = b; i > b - k && i >= a; i--) hoge.insert(i);

    for(const auto& e : hoge) cout << e << endl;
    
    return 0;
}


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

int main() {
 
  int n;
  cin >> n;
  
  if ( n % 2 == 0 ){
    cout << n / 2 << endl;
  }else{
    cout << ( n / 2 ) + 1 << endl;
  }
  
  
}



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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);

  int N; cin >> N;
  vector<ll> v(N);
  ll sum = 0;
  int num = 0;

  for(int i = 0; i < N; i++){
    cin >> v[i];

    if(v[i] < 0){
      num++;
      v[i] = abs(v[i]);
    }
  }

  if(num % 2 == 0){
    for(int i = 0; i < N; i++){
      sum += v[i];
    }
  } else { 
    sort(v.begin(), v.end());
    for(int i = 0; i < N; i++){
      if(i==0){
        sum -= v[i];
      } else {
        sum += v[i];
      }
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 4048
H,W,D = map(int,input().split())
posi = [[]] * (H * W)

for _ in range(H):
  a = list(map(int,input().split()))
  for i,j in enumerate(a):
    posi[j - 1] = [_ + 1,i + 1]

Q = int(input())

acdist = [0] * (H * W)

for _ in range(0,H * W - D):
  acdist[_ + D] += acdist[_] + abs(posi[_ + D][0] - posi[_][0]) + abs(posi[_ + D][1] - posi[_][1])

for i in range(Q):
  l,r = map(int,input().split())
  print(acdist[r - 1] - acdist[l - 1])

Measured memory_bytes: 17572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

class edge{
public:
    ll x, y, w;
};

int main(){
    FIO;
    ll n, m, p;
    cin >> n >> m >> p;
    edge e[m];
    for(ll i = 0 ; i < m ; i++){
        cin >> e[i].x >> e[i].y >> e[i].w;
        e[i].w -= p;
    }
    ll arr[n+1];
    for(ll i = 0 ; i <= n ; i++){
        arr[i] = INT_MIN;
    }
    arr[1] = 0;
    for(ll i = 1 ; i <= 2 * n ; i++){
        for(ll j = 0 ; j < m ; j++){
            ll x = e[j].x, y = e[j].y, w = e[j].w;
            if(arr[x] == INT_MIN){
                continue;
            }
            if(arr[x] + w > arr[y]){
                arr[y] = arr[x] + w;
                if(i > n){
                    arr[y] = INT_MAX;
                }
            }
        }
    }
    if(arr[n] == INT_MAX || arr[n] == INT_MIN){
        cout << -1 << endl;
        return 0;
    }
    cout << max((ll)0, arr[n]) << endl;

}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;

  vector <int> record(N);  

  int now = 0;
  int left = 0, right = N - 1;
  for (int i = 0; i < 20; i++){
    if (i == 0){
      now = 0;
    }else if(i == 1){
      now = N - 1;
    }else{
      now = (left + right) / 2;
    }

    cout << now << endl;
    
    string S; cin >> S;

    if (S == "Vacant"){
      break;
    }else if(S == "Male"){
      record[now] = 1;
    }else{
      record[now] = 2;
    }

    if (i >= 2){
      if (record[left] == record[now] && (now - left) % 2 == 0){
        left = now;
      }else if(record[left] != record[now] && (now - left) % 2 != 0){
        left = now;
      }else{
        right = now;
      }
    }
  }
  
  
  return 0;
}


Measured memory_bytes: 1236
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;

const ll mod = 1000000007;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  int n;
  cin >> n;
  int a[n][n];
  rep(i, n) rep(j, n) cin >> a[i][j];

  vector<vector<ll>> dp(n + 1, vector<ll>(1 << n, 0));
  dp[0] = vector<ll>(1 << n, 1);
  rep(i, n) rep(j, n) {
    if (a[i][j] == 0) continue;
    ll res = 1 << j;
    rep(k, 1 << n) {
      if ((res | k) == k) continue;
      dp[i + 1][res | k] += dp[i][k];
      dp[i + 1][res | k] %= mod;
    }
  }
  cout << dp[n][(1 << n) - 1] << endl;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;

int main()
{
	FLASH
	ll n,k;
	cin >> n >> k;
	ll a[n + 1];
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = k + 1; i <= n; i++){ 
		if(a[i - k] < a[i]){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}
	return 0;
}


Measured memory_bytes: 5212
# coding: utf-8
# Your code here!
def divisor_list(N): #素因数分解
    res = []
    i = 1
    while i*i < N:
        if N%i == 0:
            res.append(i)
            res.append(N//i)
        i += 1
    if i*i == N: res.append(i)
    return sorted(res)

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,k = [int(i) for i in readline().split()]
aaa = [int(i) for i in readline().split()]


l = list(reversed(divisor_list(sum(aaa))))


def check(x):
    res = []
    for ai in aaa:
        c = ai%x
        d = ai%x-x
        if abs(c) > abs(d): res.append(d)
        else: res.append(c)
    res.sort(key = abs)
    
    d = sum(res)
    if d > 0:
        idx = -1
        while d > 0:
            if res[idx]>0:
                d -= x
                res[idx] -= x
            idx -= 1
    elif d < 0:
        idx = -1
        while d < 0:
            if res[idx]<0:
                d += x
                res[idx] += x
            idx -= 1
                
    c = sum([i for i in res if i > 0])        

#    print(x,c,res)
    return (c <= k)



for x in l:
    if check(x):
        print(x)
        exit()



















Measured memory_bytes: 45020
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    string n;
    cin >> n;
    if (n[0] == '9' || n[1] == '9')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int N;

void dfs(string S,int n){
  if(S.size()==N){
    cout<<S<<endl;
    return ;
  }
  for(int i=0;i<=n;i++){
    char c=(char)('a'+i);
    S.push_back(c);
    dfs(S,max(n,i+1));
    S.pop_back();
  }
}

int main(){
  string S;
  cin>>N;
  dfs(S,0);
}


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

int main(void){
  
  int n, k, ansdays[100] = {0};

  cin >> n;
  for(k = 0; k < n; k++) {
    int byear, bmonth, bday, i, j, days;
    cin >> byear >> bmonth >> bday;

    if (byear % 3 != 0 && bmonth % 2 == 0) {
      days = 19 - bday;
    } else {
      days = 20 - bday;
    }

    if (byear % 3 == 0) {
      days += (10 - bmonth) * 20;
    } else {
      for (i = bmonth+1; i <= 10; i++) {
	if (i % 2 == 0) {
	  days += 19;
	} else {
	  days += 20;
	}
      }
    }

    for (j = byear+1; j < 1000; j++) {
      if (j % 3 == 0) {
	days += 200;
      } else {
	days += 195;
      }
    }
    ansdays[k] = days + 1;
  }

  for (k = 0; k < n; k++) {
    cout << ansdays[k] << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int cnt = 0;
        String ABC = "ABC";
        for (int i = 0; i < n - 2; i++) {
            char a = s.charAt(i);
            char b = s.charAt(i + 1);
            char c = s.charAt(i + 2);
            String tmp = String.valueOf(a) + String.valueOf(b) + String.valueOf(c);
            if (tmp.equals(ABC) ) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> ans(n, -1);
	queue<pair<ll, ll>> q;
	vector<vector<ll>> v(n);
	for (ll i = 0; i < m; ++i) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	q.push({ 0,-1 });
	while (!q.empty()) {
		auto p = q.front();
		q.pop();
		if (ans[p.first] != -1)continue;
		ans[p.first] = p.second;
		for (auto x : v[p.first]) {
			q.push({ x,p.first });
		}
	}
	cout << "Yes" << endl;
	for (ll i = 1; i < n; ++i) {
		cout << ans[i] + 1 << endl;
	}
}


Measured memory_bytes: 18540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,d,eachS,TABLE[2010][2010];double dd;
  cin >> N;
  //if(N==1) {cout << "No";return 0;}
  if(N==1) {cout << "Yes"<< endl << 2 <<endl << 1 << " " << 1 <<endl << 1 << " " << 1 ;return 0;}
  dd = (sqrt(1+8*N)+1.00000001)/2;
  K = (int)dd;
  if((dd-K)*(dd-K) > 0.00000001) {cout << "No"; return 0;}
  eachS = 2 * N / K;
  int cnt = 0;
  for(int i = 1; i < K; i++){
    for(int j = i+1; j<=K;j++){
      cnt++;
      TABLE[i][TABLE[i][2000]]=cnt;
      TABLE[j][TABLE[j][2000]]=cnt;
      TABLE[i][2000]++;
      TABLE[j][2000]++;
    }
  }
  cout << "Yes" << endl << K << endl;
  for(int i = 1; i <=K;i++){
    cout << TABLE[i][2000] << ' ';
    for(int j = 0; j < TABLE[i][2000];j++){
      cout << ' ' << TABLE[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
    int a,b,sum;
    cin>>a>>b;
    sum=b*2;

    if(a>sum)
    {
        cout<<a-sum<<endl;
    }
    else
    {
        cout<<0<<endl;
    }

    return 0;
}


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



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n, q;
  cin >> n >> q >> s;
  
  vector<int> ac(n, 0);
  rep(i, 0, n-1) {
    if(s[i] == 'A' and s[i+1] == 'C') {
      ac[i] = 1;
      ac[i+1] = 2;
    }
  }
  vector<int> AC(n+1, 0);
  AC[1] = ac[0];
  rep(i, 1, n+1) {
    AC[i] += AC[i-1];
    AC[i] += ac[i-1];
  }
  
  rep(i, 0, q) {
    int l, r;  cin >> l >> r;
    int ans = (AC[r]-AC[l-1])/3;
    if(ac[l-1]==2 and ac[r-1]==1) ans--;
    cout << ans << "\n";
  }
}

Measured memory_bytes: 1872
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
struct li
{
	int l,x;
	int next;
}L[666];
int pl=333;
void insert(int l,int r,int x)
{
	L[pl]=(li){l,x,L[r].next};
	L[r].next=pl++;
}
const int M=1000000007;
int f[333][333][333];
int main()
{
	int n=io::F(),m=io::F();
	for(register int i=1;i<=m;++i)
	{
		int l=io::F(),r=io::F(),x=io::F();
		insert(l,r,x);
	}
	f[0][0][0]=1;
	for(register int i=0;i<=n;++i)
		for(register int j=0;j<=n;++j)
			for(register int k=0;k<=n;++k)
			{
				int a[3]={i,j,k};
				if(a[0]<a[1])std::swap(a[0],a[1]);
				if(a[1]<a[2])std::swap(a[1],a[2]);
				if(a[0]<a[1])std::swap(a[0],a[1]);
				for(register int p=L[a[0]].next;p;p=L[p].next)
					if(L[p].x==1)L[p].l>a[1]?0:f[i][j][k]=0;
						else if(L[p].x==2)L[p].l<=a[1]&&L[p].l>a[2]?0:f[i][j][k]=0;
								else L[p].l<=a[2]?0:f[i][j][k]=0;
				(f[a[0]+1][j][k]+=f[i][j][k])%=M;
				(f[i][a[0]+1][k]+=f[i][j][k])%=M;
				(f[i][j][a[0]+1]+=f[i][j][k])%=M;
			}
	int ans=0;
	for(register int i=0;i<n;++i)
		for(register int j=0;j<n;++j)
			ans=((long long)ans+f[n][i][j]+f[i][n][j]+f[i][j][n])%M;
	printf("%d\n",ans); 
	return 0;
}




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


int waru(int n){
    int sum;
    sum = 0;
    while(n > 0){
        sum += n%10;
        n /= 10;
    }

    return sum;
}

int main(){
    int N, M, min, sum1, sum2;
    cin >> N;
    min = 99999;
    for(int i = 1; i < N; i++){
        M = N - i;
        sum1 = waru(i);
        sum2 = waru(M);
        if(min > sum1 + sum2){
            min = sum1 + sum2;
        }
    }

    cout << min << endl;
}

Measured memory_bytes: 256