akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<int> cnt(26,55);
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		vector<int> tmp(26,0);
		for(char j:s) tmp[j-'a']++;
		for(int j=0;j<26;++j)
			cnt[j]=min(cnt[j],tmp[j]);
	}
	for(char c='a';c<='z';++c)
		for(int i=0;i<cnt[c-'a'];++i)
			cout<<c;
	cout<<'\n';
}



Measured memory_bytes: 3616
head=[int(n) for n in input().split()]
list_x=[int(n) for n in input().split()]
list_x.append(head[2])
list_y=[int(n) for n in input().split()]
list_y.append(head[3])
if max(list_x) < min(list_y):
    print("No War")
else:
    print("War")

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

int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool ans=true;
  if(s.at(a)!='-'){
    ans=false;
  }
  for(int i=0;i<a;i++){
    if(s.at(i)=='-'){
      ans=false;
    }
  }
  for(int i=a+1;i<a+b+1;i++){
    if(s.at(i)=='-'){
      ans=false;
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
def main():
    A_checked = [ [False] * 3 for i in range(3) ]
    A_map = {}

    for i in range(3):
        A = list(map(int, input().split()))
        A_map[A[0]] = (i, 0)
        A_map[A[1]] = (i, 1)
        A_map[A[2]] = (i, 2)

    N = int(input())
    for i in range(N):
        b = int(input())
        if b in A_map:
            v = A_map[b]
            A_checked[v[0]][v[1]] = True

    if A_checked[0][0] and A_checked[0][1] and A_checked[0][2]:
        print("Yes")
        return
    if A_checked[1][0] and A_checked[1][1] and A_checked[1][2]:
        print("Yes")
        return
    if A_checked[2][0] and A_checked[2][1] and A_checked[2][2]:
        print("Yes")
        return

    if A_checked[0][0] and A_checked[1][0] and A_checked[2][0]:
        print("Yes")
        return
    if A_checked[0][1] and A_checked[1][1] and A_checked[2][1]:
        print("Yes")
        return
    if A_checked[0][2] and A_checked[1][2] and A_checked[2][2]:
        print("Yes")
        return

    if A_checked[0][0] and A_checked[1][1] and A_checked[2][2]:
        print("Yes")
        return
    if A_checked[0][2] and A_checked[1][1] and A_checked[2][0]:
        print("Yes")
        return

    print("No")

main()


Measured memory_bytes: 62336
#include<cstdio>
#include<bitset>
using namespace std;
int n,i,j,a,sum;
bitset<5000000>f;
int main(){
	scanf("%d",&n);
	f[0]=1;
	for(i=0;i<n;i++){
		scanf("%d",&a);
		f|=f<<a;
		sum+=a;
	}
	for(j=sum/2;!f[j];j--);
	printf("%d",sum-j);
}

Measured memory_bytes: 2048
n=int(input())
a=list(map(int,input().split()))
t,m=0,1000
for i in range(n-1):
    if a[i]<a[i+1]:
        b=m//a[i]
        t+=b
        m-=b*a[i]
    if a[i]>a[i+1]:
        m+=t*a[i]
        t=0
if t==0:
    print(m)
else:
    print(m+t*a[n-1])

Measured memory_bytes: 61868
n, m = gets.chomp.split(" ").map(&:to_i)

ans = Array.new(n, 0)
pen = Array.new(n, 0)

m.times do
  p, s = gets.chomp.split(" ")
  p = p.to_i - 1
  if s == 'AC'
    ans[p] = 1
  else
    if ans[p] != 1
      pen[p] += 1
    end
  end
end

a = 0
p = 0
ans.each.with_index do |an, i|
  if an == 1
    a += 1
    p += pen[i]
  end
end

print "#{a} #{p}\n"

Measured memory_bytes: 3324
#include <stdio.h>
int main(void)
{
  int a,b,c,d,n;
  int count=0;

  while(scanf("%d",&n) != EOF)
    {
      if(n <= 36)
	{
	  for(a = 0 ; a <= 9 ; a++)
	    for(b = 0 ; b <= 9 ; b++)
	      for(c = 0 ; c <= 9 ; c++)
               	for(d = 0 ; d <= 9 ; d++)
		  
		  if(n == a + b + c + d) count++;
	  
	  printf("%d\n",count);
	}
      else
	{
	  printf("0\n");
	}
      count = 0;
      
    }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * a + 2 * b;
        System.out.println(area + " " + length);
        sc.close();

    }
}


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

int main(){
  int n;
  int a[2][100];
  int dp[2][100];

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

  dp[0][0] = a[0][0];
  for(int i=1; i<n; i++){
    dp[0][i] = dp[0][i-1] + a[0][i];
  }

  dp[1][0] = a[0][0] + a[1][0];
  for(int i=1; i<n; i++){
    dp[1][i] = max(dp[0][i] + a[1][i], dp[1][i-1] + a[1][i]);
  }

  cout << dp[1][n-1] << endl;
    
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#define INF (1<<21)
using namespace std;

class State{
public:
  int n,cost,f;
  State(int n = 0,int cost = 0,int f = 0):n(n),cost(cost),f(f){}
  bool operator < (const State &s) const{ return cost > s.cost;}
};

int main(){
  int i,j,n,m,a,b,c,e,x1,x2,ans,y2,G[21][21];
  State d[21];
  priority_queue<State> PQ;
  cin >> n >> m;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++) G[i][j] = INF;
	d[i].cost = INF;
	d[i].n = i;
	d[i].f = 0;
  }

  for(i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&e);
    G[a][b] = c;
    G[b][a] = e;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&ans,&y2);
  ans -= y2;

  d[x1].cost = 0;
  State p = d[x1];
  PQ.push(p);
  while(!PQ.empty()){
    p = PQ.top();
    PQ.pop();
    d[p.n].f = 1;
    
    for(i=0;i<=n;i++){
      if(d[i].f == 0 && G[p.n][i] + p.cost < d[i].cost){
	d[i].cost = G[p.n][i] + p.cost;
	PQ.push(d[i]);
      }
    }
  }
  ans -= d[x2].cost;
  
  for(i=0;i<=n;i++){
    d[i].cost = INF;
    d[i].n = i;
    d[i].f = 0;
  }
  
  d[x2].cost = 0;
  p = d[x2];
  PQ.push(p);
  while(!PQ.empty()){
    p = PQ.top();
    PQ.pop();
    d[p.n].f = 1;
    
    for(i=0;i<=n;i++){
      if(d[i].f == 0 && G[p.n][i] + p.cost < d[i].cost){
	d[i].cost = G[p.n][i] + p.cost;
	PQ.push(d[i]);
      }
    }
  }
  ans -= d[x1].cost;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      string s="",s1="zabcdefghijklmnopqrstuvwxy";
      while(n){
        s+=s1[n%26];
        if(n%26==0)n--;
        n/=26;
      }
      reverse(s.begin(), s.end());
      cout<<s;
}

Measured memory_bytes: 3652
// https://atcoder.jp/contests/dp/tasks/dp_v
// V - Subtree

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

#include <stdio.h>

using namespace std;

vector< vector<int> > adj;
vector< vector<int> > adj_count;
vector< long long > ans;
vector< bool > visited;
int M;

long long dfs1(int u) {
  visited[u] = true;
  long long acc = 1;
  for (auto i=0; i< adj[u].size(); i++) {
    auto v = adj[u][i];

    if (!visited[v]) {
      adj_count[u][i] = (dfs1(v) + 1) % M;
      acc = ( acc *  adj_count[u][i] ) % M;
    }
  }

  return acc;
}

void dfs2(int u, long long father) {
  visited[u] = true;

  int le = adj[u].size();

  vector<long long> l( le+1, 1 );
  vector<long long> r( le+1, 1 );
  long long acc = 1;
  for(auto i=0; i<le; i++) {
    auto v = adj[u][i];
    if (visited[v]) adj_count[u][i] = father+1;
    acc = (acc * adj_count[u][i]) % M;
    l[i] = acc;
  }

  acc = 1;
  for(auto i=le-1; i >=0; i--) {
    acc = (acc * adj_count[u][i]) % M;
    r[i]= acc;
  }

  ans[u] = r[0];

  for(auto i=0; i<le; i++) {
    auto v = adj[u][i];
    auto lv = (i > 0)?(l[i-1]):(1);
    auto rv = (i <le-1)?(r[i+1]):(1);
    if (!visited[v])  dfs2(v,  (lv*rv)%M);
  }
}

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

  adj.assign(N, {});
  adj_count.assign(N, {});
  ans.assign(N, 0);
  visited.assign(N, false);

  for(int i=0; i < N-1; i++) {
    int u, v;
    cin >> u >> v; u--; v--;
    adj[u].push_back(v);
    adj_count[u].push_back(0);
    adj[v].push_back(u);
    adj_count[v].push_back(0);
  }

  dfs1(0);
  visited.assign(N, false);
  dfs2(0, 0);
  for(auto i=0; i<N; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 24320
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

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

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
//#define pp pair<pii,pii>
const int hell=1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}


int solve( ){

int a,b,c;
cin>>a>>b>>c;
int ans=c;
rep(i,0,10)
{
   ans=a*ans-b;
  cout<<ans<<endl;

}


return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    



  clock_t time_req;

    // Without using pow function
                                                                                                                   

   // cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}
/*!* [minmax_assign] *!*/
/*+* 最大値、最小値の代入 *+*/
template<class T>void max_assign(T&x,const T y){x=max(x,y);}
template<class T>void min_assign(T&x,const T y){x=min(x,y);}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    vector2d<int> edge(N);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;
        if(i == 0) {
            if(a[i] != 0) ans++;
            a[i] = 0;
        } else {
            edge[a[i]].push_back(i);
        }
    }

    recursive([&](auto f, int i) -> int {
        int dep = 0;
        for(int j : edge[i]) {
            max_assign(dep, f(f, j));
        }
        if (a[i] != 0 && dep >= K - 1) {
            ans++;
            return 0;
        }
        return dep + 1;
    })(0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(std::string S){
  int result=0;
  int sz=S.size();
  for(int i=0;i<sz/2;i++){
    if(S[i]!=S[sz-1-i]){
      result++;
    }
  }
  cout<<result<<endl;
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d[N];
  
  for(int i = 0; i<N; i++){
    cin >> d[i];
  }
  sort(d,d+N);
  int count = 1;
  
  for(int i = 0; i<N-1; i++){
    if(d[i]<d[i+1]){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main()
{
	char a[3];
	cin>>a;
	int c=0;
	for(int i=0;i<3;i++)
	{
		if(a[i]=='7')
			c++;
	}
	if(c>0)
		cout<<"Yes";
	else
		cout<<"No";	
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S)
{
    if (N % 2 == 1)
    {
        cout << NO << endl;
    }
    else if (S.substr(0, N / 2) == S.substr(N / 2, N / 2))
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
### constant

DELTA = 1.0e-13

### subroutines

def max_time(x, y, n, swts)
  max_t = 0.0
  max_i = nil

  for i in (0...n)
    xi, yi, vi = swts[i]
    t = Math.sqrt((xi - x) ** 2 + (yi - y) ** 2) / vi
    if max_t < t
      max_t = t
      max_i = i
    end
  end

  [max_t, max_i]
end

### main

loop do
  n = gets.to_i
  break if n == 0

  swts = n.times.map{gets.split.map(&:to_f)}

  x0 = 50.0
  y0 = 50.0
  d = 10.0
  r = 0.98

  while d > DELTA
    max_t, max_i = max_time(x0, y0, n, swts)

    xi, yi = swts[max_i]
    dx = xi - x0
    dy = yi - y0
    dlen = Math.sqrt(dx * dx + dy * dy)
    x0 += dx * d / dlen
    y0 += dy * d / dlen
    d *= r
  end

  puts "%.8f" % max_t
end

Measured memory_bytes: 6188
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, d[2000][2000], a[600000], b[60000];
string str, ss;
bool f[202000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost1, cost2; };
vector<Edge>vec[200000];
vector<LL>v;
map<LL, LL>ma;
multiset<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	
	cin >> n >> m >> q;
	list<LL>li(n);
	rep(i, m) {
		cin >> a[i];
	}
	for (auto i = li.begin(); i != li.end(); i++,cnt++) {
		*i = cnt;
	}
	cnt = 0;
	auto num = li.begin();
	rep(i, m) {
		rep(j,a[i]) {
			if (a[i] % 2 == 0) {
				num++;
				if (num == li.end())
					num = li.begin();
			}
			else {
				if (num == li.begin())
					num = li.end();
				num--;
			}
		}
		f[*num] = 1;
		num=li.erase(num);
		if (num == li.end())
			num = li.begin();
	}
	rep(i, q) {
		LL x;
		cin >> x;
		cout << (f[x] == 1 ? 0 : 1) << endl;
	}
	return 0;
}



Measured memory_bytes: 15852
use std::cmp::Ordering;
use whiteread::parse_line;

fn main() {
    let (a, b, c, x, y): (u32, u32, u32, u32, u32) = parse_line().unwrap();
    let mut ans;

    match x.cmp(&y) {
        Ordering::Equal => ans = 2 * c * x,
        Ordering::Greater => ans = 2 * c * y + (a * (x - y)).min(2 * c * (x - y)),
        Ordering::Less => ans = 2 * c * x + (b * (y - x)).min(2 * c * (y - x)),
    }
    ans = ans.min(a * x + b * y);
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define N 100005 
using namespace std;
int head[N],f[N],deg[N],n,tot;
struct edge{int to,next;}e[N*2];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void dfs(int x,int fa){
	int F=0;
	for (int i=head[x];i;i=e[i].next){
		if (e[i].to==fa) continue;
		dfs(e[i].to,x);
		f[x]+=f[e[i].to];
		if (!f[e[i].to]){
			if (!F) F=1;
			else f[x]++;
		}
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
		deg[x]++; deg[y]++;
	}
	int p=-1;
	for (int i=0;i<n;i++)
		if (deg[i]>2){
			p=i;
			break;
		}
	if (p==-1)
		puts("1");
	else{
		dfs(p,-1);
		printf("%d\n",f[p]);
	}
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N; 
int A, B; 
cin >> N; 
if(N == 1){
cout << "Hello World" << endl; 
}
else if(N == 2){
cin >> A >> B; 
cout << A+B << endl; 
}
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    for i in range(H):
        if i == 0 or i == H - 1:
            print('#' * W)
        else:
            print('{0}{1}{0}'.format('#', '.'*(W-2)))
    print()



Measured memory_bytes: 5620
s = str(input())
t = str(input())

if set(t).issubset(set(s)):
    p = -1
    r = 0
    
    for i in t:
        p = s.find(i, p+1)
        if p == -1:
            r += 1
            p = s.find(i)
        
    print(p + 1 + len(s)*r)
    
else:
    print(-1)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define For(i,x,y)for(i=x;i<=y;i++)
#define Down(i,x,y)for(i=x;i>=y;i--)
#define Memc(i,j)memcpy(i,j,sizeof i)
bool bo[N];
int a[N],n;
bool check(int num)
{
	int i;
	For(i,1,(n<<1)-1)bo[i]=a[i]>num/*,printf("%d ",bo[i]);
	printf("\n")*/;
	For(i,1,n-1)
	{
		if(bo[n+i]==bo[n+i-1]&&bo[n+i])return 0;
		if(bo[n+i]==bo[n+i-1]&&!bo[n+i])return 1;
		if(bo[n-i]==bo[n-i+1]&&bo[n-i])return 0;
		if(bo[n-i]==bo[n-i+1]&&!bo[n-i])return 1;
	}
	return bo[n]^(n&1);
}
int main()
{
//	freopen("pyramid.in","r",stdin);
//	freopen("pyramid.out","w",stdout);
	int i,left=0,right,mid;
	scanf("%d",&n);
	right=(n<<1)-1;
	For(i,1,(n<<1)-1)scanf("%d",&a[i]);
	while(left<right)
	{
		/*printf("%d %d\n",left,right);*/
		mid=(left+right)>>1;
		if(check(mid))right=mid;
		else left=mid+1;
	}
	printf("%d",left);
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int
main(void)
{
  int h, m, s;
  scanf("%d", &s);
  h = s / (60 * 60);
  m = (s % (60 * 60)) / 60;
  s = (s % (60 * 60)) % 60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    int rem = a%k;
    if(rem!=0)
        rem=k-rem;
    if(rem>b-a){
        cout<<"NG"<<endl;
    }else{
        cout<<"OK"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3084
import java.util.*;
import java.math.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger A = new BigInteger(sc.next()).subtract(BigInteger.ONE);
        BigInteger B = new BigInteger(sc.next());
        BigInteger C = new BigInteger(sc.next());
        BigInteger D = new BigInteger(sc.next());

        BigInteger cgcd = lcm(C, D);
        BigInteger c = B.divide(C).subtract(A.divide(C));
        BigInteger d = B.divide(D).subtract(A.divide(D));
        BigInteger e = B.divide(cgcd).subtract(A.divide(cgcd));
        System.out.println(
          B.subtract(A).subtract(c.add(d).subtract(e))
        );
    }
    static BigInteger lcm(BigInteger a, BigInteger b){
        return a.multiply(b).divide(a.gcd(b));
    }
  }


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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010


//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ans=(k-a[n-1])+a[0];
    for(int i=0;i<n-1;i++)
    {
        ans=max(ans,a[i+1]-a[i]);
    }
    cout<<k-ans<<"\n";
    return 0;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
// int dy[]={0, 1, 0, -1};
// int dx[]={1, 0, -1, 0};

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

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    int n,t;
    cin >> n >> t;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ma = a[n-1];
    vector<ll> sell(n);
    for(int i = n - 1; i >= 0; i--){
        sell[i] = ma - a[i];
        ma = max(ma,a[i]);
    }
    GRESORT(sell);
    int cnt = 1;
    for(int i = 1; i < n; i++){
        if(sell[0] != sell[i]) break;
        cnt++;
    }
    cout << cnt << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1792
h, w, k = map(int, input().split())

c = [[0 for j in range(w)] for i in range(h)]

black = 0
for i in range(h):
  s = input()
  for j in range(w):
    if s[j] == "#":
      c[i][j] = 1
      black += 1

ans = 0
for i in range(2 ** h):
  for j in range(2 ** w):
    _black = black
    for _i in range(h):
      for _j in range(w):
        if (i & (2 ** _i)) != 0 or (j & (2 ** _j)) != 0:
          _black -= c[_i][_j]
    if _black == k:
      ans += 1

print(ans)

Measured memory_bytes: 9220
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
  int n;
  cin >> n;
  string s;
  switch (n % 10) {
  case 0:
  case 1:
  case 6:
  case 8:
    s = "pon";
    break;
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    s = "hon";
    break;
  case 3:
    s = "bon";
    break;
  }
  cout << s << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
	// your code goes here
     long long int n;
     cin>>n;
     vector<long long int> a;
     for(long long int i=0; i<n; i++)
     {
         long long int temp;cin>>temp;
         a.push_back(temp);
     }
     vector<long long int> b(n,INF);
     b[0] = 0;
     for(long long int i=0; i<n; i++)
     {
         for(long long int j=i+1; j<=i+2; j++)
         {
                if(j<n)
                    b[j] = min(b[j],b[i]+abs(a[j]-a[i]));
         }
     }
     cout<<b[n-1];

}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  ll ans = 0;
  for (int i = 0; i < (n - 1); i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
AB = [[] for _ in range(M)]
que = []
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        AB[a-1].append(b)

ans = 0
for i in range(M):
    for b in AB[i]:
        heapq.heappush(que, -b)
    if len(que) > 0:
        ans += -heapq.heappop(que)
print(ans)


Measured memory_bytes: 18428
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

static int X, A;
int solve();

int solve() {
  int ans;
  if (X < A) {
    ans = 0;
  } else {
    ans = 10;
  }

  return ans;
}

int main() {
  cin >> X >> A;
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {
  string s, t;
  cin >> s >> t;

  string ret = "";
  for (int i = 0; i < s.size() - t.size() + 1; ++i) {
    bool match = true;
    for (int j = 0; j < t.size(); ++j) {
      if (!(s[i + j] == t[j] || s[i + j] == '?')) {
        match = false;
        break;
      }
    }
    if (match) {
      string tmp = s;
      for (int j = 0; j < t.size(); ++j)
        tmp[i + j] = t[j];
      for (int j = 0; j < tmp.size(); ++j)
        if (tmp[j] == '?')
          tmp[j] = 'a';
      if (ret == "")
        ret = tmp;
      else if (lexicographical_compare(tmp.begin(), tmp.end(), ret.begin(), ret.end()))
        ret = tmp;
    }
  }

  if (ret == "")
    cout << "UNRESTORABLE" << endl;
  else
    cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
n,x=map(int,raw_input().split())
if n==2 and x==2:
    print("Yes")
    print(1)
    print(2)
    print(3)
    exit()
elif n==2 and x!=2:
    print("No")
    exit()
ans=[0]*(2*n-1)
if x-1>=1 and x+1<=2*n-1:
    print("Yes")
    ans[(2*n-1)/2]=x
    ans[(2*n-1)/2+1]=x+1
    ans[(2*n-1)/2-1]=x-1
    j=1
    i=0
    while i<2*n-1:
        if j==x or j==x-1 or j==x+1:
            j+=1
            continue
        if ans[i]!=0:
            i+=1
            continue
        else:
            ans[i]=j
            j+=1
            i+=1
    for i in xrange(2*n-1):
        print(ans[i])
else:
    print("No")

Measured memory_bytes: 10244
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };



int main() {
	ll inf = 1e18;
	ll N;
	cin >> N;
	vector<ll> A(N + 2);
	vector<vector<ll>> dp(N + 2);
	REP(i, 0, N + 2)dp[i].resize(N + 2, 0);
	REP(i, 0, N + 2) cin >> A[i];
	reverse(A.begin(), A.end());
	REP(i, 1, N + 2) {
		dp[i][0] = abs(A[i] - A[0]);
		dp[0][i] = abs(A[i] - A[0]);
	}
	REP(i, 1, N + 2) {
		ll mx = -inf, mn = inf;
		REP(x, 0, i) maxs(mx, dp[x][i]);
		REP(y, 0, i) mins(mn, dp[i][y]);
		REP(x, i + 1, N + 2)dp[x][i] = mx;
		REP(y, i + 1, N + 2)dp[i][y] = mn;
	}
	PRI(dp[N + 1][N]);
	return 0;
}

Measured memory_bytes: 34916
#include <bits/stdc++.h>          
using namespace std;               
typedef long double ld;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    ld pi = 3.1415926535897932384626433;
    ld ra = 2*pi/43200;
    ld rb = 2*pi/3600;
    ld ta = 3600*H + 60*M;
    ld tb = 60*M;
    ld theta = abs(ra*ta-rb*tb);
    if (theta>=2/pi) {
        theta = 2*pi-theta;
    }
    ld l = sqrt(A*A+B*B-2*A*B*cos(theta));
    cout << fixed << setprecision(10) << l << endl;
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

int main()
{
    sts(s);int cnt=0;
    rep(i,s.size()){
        if(s.at(i)=='2'){
            cnt++;
        }
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>



using namespace std;


int main()
{
   int s;
   int a,b;
   int a_ans=0;
   int b_ans=0;

   cin >> s;
   a=s/100;
   b=s%100;

   if(a>=1&&a<=12)a_ans+=1;
   if(b>=1&&b<=12)b_ans+=1;



   if(a_ans==1&&b_ans==1){
	   cout << "AMBIGUOUS" << endl;
   }else if(a_ans==1){
	   cout << "MMYY" << endl;
   }else if(b_ans==1){
   	   cout << "YYMM" << endl;
   }else{
	    cout << "NA" << endl;
   }
  
	return 0;
}

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

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

    if (n%2!=0){
        cout << "0" << endl;
        return 0;
    }

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

    sort(d, d + n, greater<int>());
    int middle = n/2;
    int ans = d[middle-1] - d[middle];
//    cout << d[middle-1] << " " <<  d[middle] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

//https://onlinejudge.u-aizu.ac.jp/problems/1153
public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while (true) {
	  int n = sc.nextInt();
	  int m = sc.nextInt();
	  if (n == 0 && m == 0) return;

	  int[] taro = new int[n];
	  int sumOfTaro = 0;
	  for (int i = 0; i < n; i++) {
		sumOfTaro += taro[i] = sc.nextInt();
	  }

	  int[] hanako = new int[m];
	  int sumOfHanako = 0;
	  for (int i = 0; i < m; i++) {
		sumOfHanako += hanako[i] = sc.nextInt();
	  }

	  boolean changePoint = false;
	  for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
		  if (sumOfTaro - sumOfHanako == (taro[i] - hanako[j]) * 2) {
			if (!changePoint) {
			  changePoint = true;
			  System.out.println(taro[i] + " " + hanako[j]);
			}
		  }
		}
	  }
	  if (!changePoint) System.out.println(-1);
	}
  }
}



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

int main(){
  string s;
  cin >> s;
  map<char,int>a;
  int c=0;
  for(int i=s.size()-1;i>=0;i--){
    c=0;
    for(int j=i;j>=0;j--){
      if(s.at(j)==s.at(i)){
        a[s.at(i)]=max(a[s.at(i)],c);
        c=0;
      }else{
        c++;
      }
    }
    a[s.at(i)]=max(a[s.at(i)],c);
  }
  //for(auto x:a)
    //cout << x.first << "#" << x.second << endl;
  int ans=100;
  for(auto x:a){
    int i=0,k;
    while(s.at(s.size()-i-1)!=x.first)
      i++;
    k=max(x.second,i);
    ans=min(ans,k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int N = 1e4;
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}

vector<int> v;
int n,m,q;
vector<int> a(55),b(55),c(55),d(55);
int maxi;

void rec(int i=1,int cnt=0){

      if(cnt==n){
        int sum = 0;
        for(int i=0;i<q;i++){
           if(v[b[i]]-v[a[i]]==c[i])
             sum+=d[i];
        }
        maxi = max(sum,maxi);
        return;
      }

      for(int j=i;j<=m;j++){
         v.pb(j);
         rec(j,cnt+1);
         v.pop_back();
      }

}


int32_t main(){
   
   speed_cubing 
   
   cin>>n>>m>>q;

   for(int i=0;i<q;i++){
      cin>>a[i]>>b[i]>>c[i]>>d[i];
      a[i]--,b[i]--;
   }
   rec(); 
   cout<<maxi;
    
   return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

// 12 -> 1,2,6,3,4
vector<ll> factor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

int main() {
  ll N;
  scanf("%lld", &N);

  ll ans = 0;

  for (ll i = 1; i <= N; i++) {
    if (i % 2 == 0) continue;
    if (factor(i).size() == 7) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3688
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, d; cin >> n >> d;
    double coord[n][d];
    list(i,n){
        list(j,d) cin >> coord[i][j];
    }

    int ans = 0;
    list(i,n){
        rep(j,i+1,n){
            double curr = 0;
            list(k,d){
                curr += ((coord[i][k] - coord[j][k]) * (coord[i][k] - coord[j][k]));
            }
            if(floor(sqrt(curr)) == ceil(sqrt(curr))) ++ans;
        }
    }

    cout << ans << "\n";
    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 = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  double l;
  cin >> l;

  double y = l/3.0;
  double ans = (y*y*y - 2.0*l*y*y + l*l*y)/4.0;
  cout << fixed << setprecision(10) << 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 debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  ll n, s; cin >> n >> s;

  if (n==s) {
    cout << n+1 << endl;
    return 0;
  }

  if (n<s) {
    cout << -1 << endl;
    return 0;
  }

  ll b=2;
  while(b*b<=n) {
    ll tmp = n;
    ll now = 0;
    while(tmp > 0) {
      now += tmp%b;
      tmp /= b;
    }
    if (now == s) {
      cout << b << endl;
      return 0;
    }
    b++;
  }

  ll a = b-1;
  while(a > 0) {
    if ((n-s+a)%a==0) {
      ll k = (n-s+a)/a;
      ll tmp = n;
      ll now = 0;
      while(tmp > 0) {
        now += tmp%k;
        tmp /= k;
      }
      if (now == s) {
        cout << k << endl;
        return 0;
      }
    }
    a--;
  }

  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s;
bool ans = true;
int N;
int Max;
int Min;

int main() {
  cin >> s;
  N = s.length();
  for (int i = 0; i < N; i++) {
    if (s[i] != s[N - i - 1]) {
      ans = false;
      break;
    }
  }
  if (ans) {
    Max = (N - 1) / 2;
    for (int i = 0; i < Max; i++) {
      if (s[i] != s[Max - i - 1]) {
        ans = false;
        break;
      }
    }
  }
  if (ans) {
    Min = (N + 3) / 2;
    Max = N;
    for (int i = Min; i < Max; i++) {
      if (s[i] != s[Max - i - 1]) {
        ans = false;
        break;
      }
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
    while (true) {
        string x;
        cin >> x;
        if (x == "0") {
            break;
        }
        int sum = 0;
        for (int i = 0; i < x.size(); i++) {
            sum += x[i] - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		for (int i = 0; i < N; i++) {
			String[] str = br.readLine().split(" ");
			int[] sides = new int[str.length];
			for (int j = 0; j < str.length; j++) {
				sides[j] = Integer.parseInt(str[j]);
			}
			Arrays.sort(sides);
			if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) == Math.pow(sides[2], 2)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 26472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int h, w, ans;
char b[305][305];
int main(){
	scanf("%d%d", &h, &w);
	rep(i,h) scanf("\n%s", b[i]);
	rep(i,w-1){
		int c[305][305] = {}, ac[305][305] = {};
		rep(j,h) rep(k,h){
			c[j][k] = (j&&k ? c[j-1][k-1] : 0) + (b[j][i] == b[k][i+1]);
			ac[j][k] = min(j?ac[j-1][k]:0, k?ac[j][k-1]:0) + c[j][k];
		}
		ans += ac[h-1][h-1];
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds_;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;


int binomialCoeff(int n,int r){
    int res=1;
    if(r>n-r)r=n-r;
    for(int i=0;i<r;i++){
        res*=(n-i);
        res/=(i+1);
    }
    return res;
}



int power(int x,int n,int mod){
//(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){

return power(x,mod-2,mod);
}


int32_t main() {

    simplify
    int n,k;
    cin>>n>>k;
    vector<int>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=arr[i];
    }
    cout<<ans;



    return 0;
}


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

int main(){
    int x=0,num=0,max=0;
    int i,temp;
    scanf("%d",&num);

    char str[num];
    scanf("%s",str);

    for(i=0;i<num;i++){
        temp = x;
        if(str[i]=='I')
            x += 1;
        else
            x += -1;
            if(x > max)
                max =x;
    }

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

    return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define max(a,b) (a>b?a:b)

int main(){
    int n;scanf("%d",&n);
    char s[105];scanf("%s",s);
    int tmpa=0;
    rep(i,n-1){
        int cl[30]={0},cr[30]={0};
        rep(j,i+1){
            cl[s[j]-'a']++;
        }
        rep(j,n-(i+1)){
            cr[s[j+i+1]-'a']++;
        }
        int tmp = 0;
        rep(j,'z'-'a'+1){
            if(cl[j]&&cr[j])tmp++;
        }
        tmpa=max(tmpa,tmp);
    }
    printf("%d",tmpa);
}


Measured memory_bytes: 1736
#include <iostream>

using namespace std;

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

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        if (is_prime(d)) { ans++; }
    }
    cout << ans << endl;
    return 0;
}

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

const int MOD = 1000000007;
const long long INF = 1LL << 60;

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

    s.at(3) = '8';

    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010], b[100010], c[100010], n;
map<ll, ll> mc, mb;
int main()
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &b[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &c[i]);
	sort(a, a+n);
	sort(b, b+n);
	sort(c, c+n);
	for (ll i = n-1; i >= 0; i--)
	{
		mc[c[i]] = n-i; 
	}
	ll sum = 0;
	for (ll i = n-1; i >= 0; i--)
	{
		auto it = mc.upper_bound(b[i]);
		if (it != mc.end())
		sum+=it->second;
		mb[b[i]] = sum;
	}
	sum = 0;
	for (ll i = n-1; i >= 0; i--)
	{
		auto it = mb.upper_bound(a[i]);
		if (it != mb.end())
		sum+=it->second;
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#include <cmath>
#define pb  push_back
int32_t main()
{
       int a,b,c,d,e,f,g,h,m,n,z;
       cin>>a>>b>>c>>d;
       e=a*d;f=b*c,g=a*c;h=b*d;
       m=max(e,f);
       n=max(g,h);
       z=max(m,n);
       cout<<z;
       return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int N = 50;
int mod = 1e9+7, n;
ll m;

struct matrix{
    int m[N][N], r, c;
    
    matrix(int _r = N, int _c = N, bool iden = false){
        r = _r;
        c = _c;
        memset(m, 0, sizeof m);
        if(iden) while(_c--) m[_c][_c] = 1;
    }

    matrix operator * (const matrix &B){
        matrix C(r, B.c);
        forn(i, 0, r){
            forn(k, 0, c){
                if(m[i][k]){
                    forn(j, 0, B.c){
                        C.m[i][j] = (1ll*C.m[i][j] + 1ll*m[i][k]*B.m[k][j]) % mod;
                    }
                }
            }
        }
        return C;
    }
};

matrix pow(matrix A, ll e){
    matrix ANS(A.r, A.c, true);
    while(e){
        if(e&1)ANS = ANS*A;
        A = A*A;
        e >>= 1;
    }
    return ANS;
}


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

  cin >> n >> m;

  matrix M(n, n);

  forn(i, 0, n){
    forn(j, 0, n){
        cin >> M.m[i][j];
    }
  }

  matrix ans = pow(M, m);

  int r = 0;

forn(i, 0, n){
    forn(j, 0, n){
        r = (r+ans.m[i][j])%mod;
    }
}
cout << r << endl;




}





Measured memory_bytes: 3684