akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,a[210000],lc,rc;
long long s[210000],ans,miv,mav,te[4];
inline long long abs(long long x){//int x!!!!!!!!!!!!!!!
	return x>0?x:-x;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i];
	}
	ans=s[n];
	lc=1;rc=3;
	fo(mi,2,n-2){
		if (rc<=mi) rc++;//!!
		while (lc+1<mi&&abs(s[lc+1]-(s[mi]-s[lc+1]))<abs(s[lc]-(s[mi]-s[lc]))) lc++;
		while (rc+1<n&&abs((s[n]-s[rc+1])-(s[rc+1]-s[mi]))<abs((s[n]-s[rc])-(s[rc]-s[mi]))) rc++;
		//te=abs(s[lc]-(s[mi]-s[lc]))+abs((s[n]-s[rc])-(s[rc]-s[mi]));
		te[0]=s[lc];
		te[1]=s[mi]-s[lc];
		te[2]=s[rc]-s[mi];
		te[3]=s[n]-s[rc];
		miv=mav=te[0];
		fo(i,1,3){
			if (te[i]<miv) miv=te[i];
			if (te[i]>mav) mav=te[i];
		}
		if (mav-miv<ans) ans=mav-miv;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B; cin >> A >> B;
  int ans = 0;
  for(int i = A; i <= B; i++){
    string S = to_string(i);
    bool flag = true;
    REP(j, 2){
      if(S[j] != S[4-j]) flag = false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3808
/*
ID: htc9811
LANG: C++
TASK: 
*/

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

const int N=2e5+5;
int n;
int a[N],poi[N],dp[N],ans;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) poi[a[i]]=i;
	for(int i=0;i<n;i++){
		dp[i]=1;
		if(a[i]!=1&&poi[a[i]-1]<i) dp[i]+=dp[poi[a[i]-1]];
		ans=max(ans,dp[i]);
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int p1,p2,p3,j1,j2,x,y;
	scanf("%d %d %d %d %d",&p1,&p2,&p3,&j1,&j2);
	if(p1<=p2&&p1<=p3)	x=p1;
	if(p2<p1&&p2<=p3)	x=p2;
	if(p3<p1&&p3<p2)	x=p3;
	if(j1<=j2)	y=j1;
	else	y=j2;
	printf("%d\n",x+y-50);
	return 0;
}



Measured memory_bytes: 2696
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	string s; cin >> s;
	ll ans = 0;
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i]) ans += 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define INF 2147483647
#define Vmax 100000

struct Edges{
  int edges_to;
  int edges_cost;
};
std::vector<Edges>V_info[Vmax];
int main()
{
  int v,e,r,i;
  std::cin >> v>> e >> r;
  int si,ti,di;
  for(i=0;i<e;i++)
    {
      std::cin >> si >> ti>> di; 
      V_info[si].push_back( (Edges){ti,di} );
    }
  std::priority_queue< std::pair <int,int> > queue;
  int d[v];
  for(i=0;i<v;i++)
    d[i] = INF;
  d[r] = 0;
  queue.push(std::make_pair(0,r));
  int t_first;
  int t_second;
  Edges temp;
  while(!queue.empty())
    {
      t_first = queue.top().first;
      t_second = queue.top().second;
      queue.pop();
      for(i=0;i<V_info[t_second].size();i++)
	{
	  temp = V_info[t_second][i];
	  if(t_first + d[temp.edges_to] > temp.edges_cost)
	    {
	      d[temp.edges_to] = temp.edges_cost - t_first;
	      queue.push(std::make_pair(-d[temp.edges_to],temp.edges_to));
	    }
	}
    }
  for(i=0; i<v; i++)
    {
      if(d[i] == INF ) std::cout << "INF" << std::endl;
      else std::cout << d[i] << std::endl;
    }
  return 0;
}


Measured memory_bytes: 13044
N = int(input())
A = [int(_) for _ in input().split()] + [0]
dist = []
tmp = 0
alldist = 0

for i in A:
    dist.append(i-tmp)
    tmp = i

for i in dist:
     alldist += abs(i)

for i in range(N):
    print(alldist - (abs(dist[i])+abs(dist[i+1])-abs(dist[i]+dist[i+1])))

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

int main()
{
  int n;cin>>n;
  vector<int> p(n+1);
  for (int i=1;i<=n;i++)
     cin>>p[i];
  
  int count=0;
  for (int i=1;i<n;i++)
  {
    if (i==p[i])
    {
      count++;
      swap(p[i],p[i+1]);
    }
  }
  
  if (p[n]==n)
  {
    swap(p[n],p[n-1]);
    count++;
  }
  //for (int i=1;i<=n;i++)
     //cout<<"p["<<i<<"]="<<p[i]<<endl;
  cout<<count<<endl;
}

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

int main(void)
{
    int N;
    scanf("%i", &N);
    int L[N];
    for (int i = 0; i < N; i++)
    {
        scanf("%i", &L[i]);
    }
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                if (L[i] == L[j] || L[k] == L[i] || L[j] == L[k])
                {
                    continue;
                }

                if ((L[i] + L[j] > L[k]) && (L[k] + L[i] > L[j]) && (L[j] + L[k] > L[i]))
                {
                    count++;
                }
            }
        }
    }
    printf("%i\n", count);
}


Measured memory_bytes: 2116
#include <stdio.h>
int main(){
  int a,b,d,r;
  double f;

  scanf("%d %d",&a,&b);

  d=a/b;
  r=a%b;
  f=(double)a/(double)b;

  printf("%d %d %6.5f\n",d,r,f);





  return 0;
}

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


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(M+1,0);
    for(ll i=0;i<N;++i){
        ll K;
        cin >> K;
        for(ll j=0;j<K;++j){
            ll a;
            cin >> a;
            A[a]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=M;++i){
        if(A[i]==N)ans++;
    }
    prt(ans)fl

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  string s[N];
  // read
  for (int i=0; i < N; ++i) cin >> s[i];

  int M;
  cin >> M;
  string t[M];
  // read
  for (int i=0; i < M; ++i) cin >> t[i];

  int res = 0, cnt = 0;
  // caliculate
  for (int i=0; i < N; ++i) {
    cnt = 0;
    for (int j=0; j < N; ++j) if (s[i] == s[j]) ++cnt;
    for (int k=0; k < M; ++k) if (s[i] == t[k]) --cnt;
    cnt = max(cnt,0);
    res = max(cnt,res);
  }
  cout << res << endl;
  return 0;
}
//      cout << " i:" << i << " j:" << j << " s[i]:" << s[i] << " cnt:" << cnt << endl;
//      cout << " i:" << i << " k:" << k << " s[i]:" << s[i] << " cnt:" << cnt << endl;








Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int leftmost_bit(unsigned int x) {
  int l = 31 - __builtin_clz(x);
  return 1 << l;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<i64>> a(N, vector<i64>(N));
  REP(i, N) REP(j, N) { cin >> a[i][j]; }

  vector<i64> scores(1 << N);
  REP(s, 1 << N) {
    i64 score = 0;
    REP(i, N) {
      if (~s & 1 << i) continue;
      REP(j, i) {
        if (s & 1 << j) score += a[i][j];
      }
    }
    scores[s] = score;
  }

  vector<i64> dp(1 << N);
  vector<bool> done(1 << N);
  done[0] = true;
  auto maximize = [&](auto rec, int state) -> i64 {
    if (done[state]) return dp[state];
    int b = leftmost_bit(state);
    i64 res = 0;
    for (int s = b; s < (b << 1); ++s) {
      if ((s & state) == s) {
        i64 r = rec(rec, state & ~s) + scores[s];
        res = max(res, r);
      }
    }
    dp[state] = res;
    done[state] = true;
    return res;
  };
  i64 ans = maximize(maximize, (1 << N) - 1);
  cout << ans << endl;
}


Measured memory_bytes: 4248
n = int(input())
count=0
#p = [input() for i in range(n)]
p=list(map(int,input().split()))
for i in range(n-2):
    if (p[i]<p[i+1]<p[i+2]) or (p[i]>p[i+1]>p[i+2]):
        count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<int> v;
	for (int i=0; i<n; ++i) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	long snuke_ = accumulate(v.begin(), v.end(), (long) 0);
	long raccoon = 0;
	long res = LONG_MAX;
	for (int i=n-1; i>0; --i) {
		int a = v[i];
		snuke_ -= a;
		raccoon += a;
		res = min(res, abs(snuke_-raccoon));
	}
	cout << res << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;

	vector<int> t(N), x(N), y(N);
	for(int i=0; i<N; i++){
		cin >> t.at(i) >> x.at(i) >> y.at(i);
	}

	int min_move;
	min_move = x.at(0)+y.at(0);
	if(min_move > t.at(0) || (t.at(0)-min_move)%2!=0){
		cout << "No" << endl;
		return 0;
	}

	for(int i=1; i<N; i++){
		min_move = x.at(i)-x.at(i-1) + y.at(i)-y.at(i-1);
		if(min_move > t.at(i)-t.at(i-1) || (t.at(i)-t.at(i-1)-min_move)%2!=0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

#define ll long long

const int N = 1e5+15;

ll pre[N];
int in[N];
void solve() {
    int n,m;
    scanf("%d%d",&n,&m);
    ll sum = 0;
    for(int i=1;i<=n;++i) {
        scanf("%d",&in[i]);
        sum += in[i];
    }
    sort(in+1,in+n+1);
    for(int i=1;i<=n;++i) {
        pre[i] = pre[i-1] + in[i];
    }
    vector<pair<int,int> >query;
    for(int i=0;i<m;++i) {
        int b,c;
        scanf("%d%d",&b,&c);
        query.push_back(make_pair(c,b));
    }
    sort(query.begin(),query.end());
    ll maxi = 0;
    int pos = 0;
    ll cur = 0;

    for(int i=query.size()-1;i>=0;--i) {
        int b = query[i].second;
        int c = query[i].first;
        while(pos+1<=n && b>0) {
            cur += c;
            maxi = max(maxi, cur - pre[pos+1]);
            ++pos;
            --b;
        }
    }
    printf("%lld\n", sum + maxi);
}

int main()
{
    //freopen("input.txt","r",stdin);
    solve();
}

Measured memory_bytes: 2552
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let dp = Array.make_matrix (n + 1) 2 0 in
  dp.(0).(0) <- 0;
  dp.(0).(1) <- -12345678901234;
  for i = 0 to n - 1 do
    dp.(i + 1).(0) <- max (dp.(i).(0) + as_.(i)) (dp.(i).(1) - as_.(i));
    dp.(i + 1).(1) <- max (dp.(i).(0) - as_.(i)) (dp.(i).(1) + as_.(i))
  done;
  Printf.printf "%d\n" dp.(n).(0)


Measured memory_bytes: 7808
#include<stdio.h>
#define A 100


int main(){
  int i,j,tmp,minj,n,a[A],sw=0;

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

  for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]) minj=j;
      }
	tmp=a[i];
	a[i]=a[minj];
	a[minj]=tmp;
	if(i!=minj) sw++;
    }

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

  
  return 0;
}



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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
} 

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, K; cin >> N >> K;
	ll l[50];
	rep(i, 0, N) {
		cin >> l[i];
	}
	sort(l, l + N);
	reverse(l, l + N);
	ll sum = 0;
	rep(i, 0, K) {
		sum += l[i];
	}
	cout << sum << endl;

	return 0;
}

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

int main() {
    uint64_t a, b, k;
    cin >> a >> b >> k;

    auto c = MIN(a, k);
    a -= c; k -= c;
    b -= MIN(k, b);
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,K,arr[100001],ss,asz=1;
	char ipt,ns;
	scanf("%d %d\n",&N,&K);
	scanf("%1c",&ipt);
	if(ipt=='1') ss=1,ns='1',arr[1]++;
	else ss=0,ns='0',arr[1]++;
	for(int i=2;i<=N;i++){
		scanf("%1c",&ipt);
		if(ipt!=ns){
			if(ns=='1') ns='0';
			else ns='1';
			asz++;
			arr[asz]=1;
		}
		else arr[asz]++;
	}
	int k=0,ans=0,imsi=0;
	for(int i=1;i<=asz;i++){ //010 101
		if((i-ss)%2==1){// 현재 0 
			if(k==K){
				if(ss==0 && (i-2*k)==1){
					imsi-=arr[1];
					imsi+=arr[i];
					ans=max(imsi,ans);
				}
				else{
					imsi-=(arr[i-2*k]+arr[i-2*k-1]);
					imsi+=arr[i];
					ans=max(imsi,ans);
				}
			}
			else{
				k++;
				imsi+=arr[i];
				ans=max(ans,imsi);
			}
		}
		else{//현재 1 
			imsi+=arr[i];
			ans=max(ans,imsi);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static char[][] grid;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point[] red = new Point[n], blue = new Point[n];
		for (int i = 0; i < n; i++) {
			red[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		for (int i = 0; i < n; i++) {
			blue[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		System.out.println(solve(red, blue));
	}

	public static int solve(Point[] red, Point[] blue) {
		V = red.length + blue.length + 2;
		adjList = new ArrayList[V];
		res = new int[V][V];
		for (int i = 0; i < V; i++)
			adjList[i] = new ArrayList<Integer>();
		s = 0;
		t = V - 1;
		for (int i = 0; i < red.length; i++) {
			addEdge(s, i + 1, 1);
		}
		for (int i = 0; i < blue.length; i++) {
			addEdge(red.length + 1 + i, t, 1);
		}
		for (int i = 0; i < red.length; i++) {
			for (int j = 0; j < blue.length; j++) {
				if (red[i].x >= blue[j].x || red[i].y >= blue[j].y)
					continue;
				addEdge(i + 1, red.length + 1 + j, 1);
			}
		}
		return edmondKarp();

	}

	static void addEdge(int u, int v, int c) {
		adjList[u].add(v);
		adjList[v].add(u);
		res[u][v] = c;
	}

	static ArrayList<Integer>[] adjList;
	static int[][] res;
	static int[] p;
	static int s, t, V, INF = (int) 1e9;

	static int edmondKarp() {
		int maxFlow = 0;
		while (bfs()) {
			maxFlow += augment(t, INF);
		}
		return maxFlow;
	}

	static boolean bfs() {
		p = new int[V];
		Arrays.fill(p, -1);
		Queue<Integer> q = new LinkedList<>();
		q.add(s);
		p[s] = s;
		while (!q.isEmpty()) {
			int u = q.poll();
			if (u == t)
				break;
			for (int v : adjList[u]) {
				if (res[u][v] > 0 && p[v] == -1) {
					p[v] = u;
					q.add(v);
				}
			}
		}
		return p[t] != -1;
	}

	static int augment(int u, int flow) {
		if (u == s)
			return flow;
		flow = augment(p[u], Math.min(flow, res[p[u]][u]));
		res[p[u]][u] -= flow;
		res[u][p[u]] += flow;
		return flow;
	}

}


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

int main() {
    cout<<fixed<<setprecision(12);
    int n;
    double sum = 0, m = 0; 
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0;  i < n; i++) {
        cin >> x.at(i);
    }
    for (int i = 0;  i < n; i++) {
        cin >> y.at(i);
    }
    for(double p = 1; p < 4; p++) {
        for(int j = 0; j < n; j++) {
            sum += pow(fabs(x.at(j) - y.at(j)), p);
        }
        cout << pow(sum, 1.0/p) << endl;
        sum = 0;
    }
    for(int i = 0; i < n; i++) {
      if(abs(x.at(i) - y.at(i)) > m) {
        m = abs(x.at(i) - y.at(i));
      }
    }
  cout << m;
}


Measured memory_bytes: 3480
def main():
    N, M = map(int, raw_input().split())
    original = []
    for i in range(N):
        original.append(map(int, raw_input().split()))
    # print original
    def postrunk(a):
        return a
        # if a > 0:
        #     return a
        # else:
        #     return -a
    def negtrunk(a):
        return -a
        # if a < 0:
        #     return -a
        # else:
        #     return a
    def ppp(list):
        return sum([postrunk(list[0]), postrunk(list[1]), postrunk(list[2])])
    def npp(list):
        return sum([negtrunk(list[0]), postrunk(list[1]), postrunk(list[2])])
    def pnp(list):
        return sum([postrunk(list[0]), negtrunk(list[1]), postrunk(list[2])])
    def ppn(list):
        return sum([postrunk(list[0]), postrunk(list[1]), negtrunk(list[2])])
    def nnp(list):
        return sum([negtrunk(list[0]), negtrunk(list[1]), postrunk(list[2])])
    def pnn(list):
        return sum([postrunk(list[0]), negtrunk(list[1]), negtrunk(list[2])])
    def npn(list):
        return sum([negtrunk(list[0]), postrunk(list[1]), negtrunk(list[2])])
    def nnn(list):
        return sum([negtrunk(list[0]), negtrunk(list[1]), negtrunk(list[2])])
    pppl = sum(sorted(map(ppp, original), reverse=True)[:M])
    nppl = sum(sorted(map(npp, original), reverse=True)[:M])
    pnpl = sum(sorted(map(pnp, original), reverse=True)[:M])
    ppnl = sum(sorted(map(ppn, original), reverse=True)[:M])
    nnpl = sum(sorted(map(nnp, original), reverse=True)[:M])
    pnnl = sum(sorted(map(pnn, original), reverse=True)[:M])
    npnl = sum(sorted(map(npn, original), reverse=True)[:M])
    nnnl = sum(sorted(map(nnn, original), reverse=True)[:M])
    # print(map(pnn, original))
    print max([pppl,nppl,pnpl,ppnl,nnpl,pnnl,npnl,nnnl])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2948
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == -1){
				break;
			}
			String str = "0000000";
			String tStr = "";
			for(int i = 0;i < n;i++){
				int t = scan.nextInt();
				switch(t){
				case 0:
					tStr = "0111111";
					break;
				case 1:
					tStr = "0000110";
					break;
				case 2:
					tStr = "1011011";
					break;
				case 3:
					tStr = "1001111";
					break;
				case 4:
					tStr = "1100110";
					break;
				case 5:
					tStr = "1101101";
					break;
				case 6:
					tStr = "1111101";
					break;
				case 7:
					tStr = "0100111";
					break;
				case 8:
					tStr = "1111111";
					break;
				case 9:
					tStr = "1101111";
					break;
				}
				for(int j = 0;j < 7;j++){
					System.out.print(Integer.parseInt(str.charAt(j)+"")^Integer.parseInt(tStr.charAt(j)+""));
				}
				System.out.println();
				str = tStr;
			}
		}
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 string s;
 cin >> s;
 if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
 cout << "Bad";
 else
 cout << "Good";
 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


void disp(vll&a, int n)
{
	for(int i=0;i+1<n;i++) printf("%lld ", a[i]);
	printf("%lld\n", a[n-1]);
}

int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi a(n);
		vll t(n+1);

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

		for(int j=0;j<10;j++)
		{
			for(int i=0;i<n;i++)
			{
				t[i+1]=(a[i]*2-t[i]);
			}
			if(t[0]==t[n]) break;
//			disp(t, n+1);
			t[0]=(t[0]+t[n])/2;
		}

		disp(t, n);
	}
	return 0;
}


Measured memory_bytes: 2432
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// 出力
      	if(a == 1) {
          System.out.println(0);
        } else {
          System.out.println(1);
        }
	}
}

Measured memory_bytes: 35740
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<utility>
#include<stack>

using namespace std;





int main(){
	int a;
	int b;
	bool first=true;
	
	while(cin>>a>>b,a*b){
		if(first!=true){
			cout<<endl;
		}else{
			first=false;
		}
		bool j=false;
		for(int i=a;i<b+1;i++){
			if(i%4==0){
				if(i%400==0){
					j=true;
					cout<<i<<endl;
				}else if(i%100==0){
				}else{
					j=true;
					cout<<i<<endl;
				}
			}else{
			}
		}
		
		if(j==false)cout<<"NA"<<endl;
		
	}
	
	
	
	
	
	return 0;
}

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

int work(int n, int s, int x){
	if(n == 1 && s == x)
		return 1;

	if(x<0)
		return 0;

	if(n>0)
		if(s>=0)
			return work(n-1,s-x,x-1) + work(n,s,x-1);
		
	return 0;
}

int main(){
	int n,s,ans;
	while(cin>>n>>s){
		if(n==0 && s==0) break;
		ans = work(n, s, 9);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
val = [int(x) for x in input().split()]

aaa = "#"
for i in range(val[1]+1):
    aaa = aaa + "#"

array = []
for i in range(val[0]):
    val = input()
    array.append("#" + val + "#")
print(aaa)
for j in array:
    print(j)
print(aaa)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,k;
    cin>>n>>k;
    cout<<(n%k!=0)<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
d.sort()
for i in range(1, n, 2): d[i] = 24 - d[i]
d.sort()
d = [0] + d + [24]
ans = 24
for i in range(1, n+2):
    ans = min(ans, d[i] - d[i-1])
print(ans)


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

int A, B;
int main(){
	cin>>A>>B;
	int hasil;
	if(A<10){
		if(B<10){
		hasil=A*B;
		}else{
		hasil=-1;
		}
	}else{
	hasil=-1;
	}
	cout<<hasil;
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
ans=1
m=p[0]
for i in range(1,len(p)):
    if p[i]==1:
        ans=ans+1
        break
    elif p[i]>m:
        continue
    else:
        ans=ans+1
        m=p[i]
print(ans)

Measured memory_bytes: 24744
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define all(a) a.begin(), a.end()

int N, M;
vector<int> x, y;

int input() {
    int a;
    cin>>a;
    return a;
}

bool check1() {
    for(int Z=-100; Z <= 100; ++Z) { // 条件を満たすZがあるか全て試す
        bool flag = true;

        for(int v : x) {
            if(Z <= v) {
                flag = false;
                break;
            }
        }

        for(int v : y) {
            if(v < Z) {
                flag = false;
                break;
            }
        }

        if(flag)return false; // 条件を満たすZが存在した
    }
    return true;
}

bool check2() {
    return *max_element( all(x) ) >= *min_element( all(y) );
}

int main() {
    
    cin >> N >> M;
    x.pb(input());
    y.pb(input());
    for(int i=0; i < N; ++i)x.pb(input());
    for(int i=0; i < M; ++i)y.pb(input());

    if(check1())cout << "War" << endl;
    else cout << "No War" <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  double r; cin >>r;
  cout << 2*r*PI << endl;

  return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>

int main(void){
    int a,b;
    char op;
    while ( scanf("%d %c %d", &a, &op, &b) ){
        switch ( op ){
            case '+':
                printf("%d\n", a+b);
                break;
            case '-':
                printf("%d\n", a-b);
                break;
            case '*':
                printf("%d\n", a*b);
                break;
            case '/':
                printf("%d\n", a/b);
                break;
            case '?':
                return 0;
                break;
        }
    }
}


Measured memory_bytes: 2068
import java.util.Arrays;
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int N = scanner.nextInt();
            int[] a= new int[N]; 
            
            for (int i=0; i<N; i++){
                a[i] = scanner.nextInt();
            }
            Arrays.sort(a);
            
            int t = a[0];
            int numt = 1;
            int nomitt = 0;
            int i = 1;
            while (i < N){
                if (t == a[i]){
                    numt++;
                }else{
                    if (numt < t){
                        nomitt += numt;
                    } else if (t < numt){
                        nomitt+= numt - t;
                    }
                    t = a[i];
                    numt = 1;
                }
                i++;
            }
            if (numt < t){
                nomitt += numt;
            } else if (t < numt){
                nomitt+= numt - t;
            }
            System.out.println(nomitt);
        };
}

Measured memory_bytes: 51864
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val age: Int = scn.nextLine().toInt()

    if (age == 1) {
        println("Hello World")
    } else {
        val numberOne: Int = scn.nextLine().toInt()
        val numberTwo: Int = scn.nextLine().toInt()
        println(numberOne + numberTwo)
    }

}

Measured memory_bytes: 31384
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6+1;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// 試作中
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

int main(){
  COMinit();
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  vi lcm(1e6+1,0);

  rep(i,n) {
    int num = a[i];
    for(int j = 2; j*j < a[i]+1; j++) {
      int cnt = 0;
      while(num%j == 0){
        num /= j;
        cnt++;
      }
      chmax(lcm[j],cnt);
    }
    if(num != 1) chmax(lcm[num],1);
  }

  ll ans = 0;
  ll LCM = 1;
  for(int i = 2; i < 1e6+1; i++){
    LCM *= POW(i, lcm[i]);
    LCM %= MOD;
  }
  rep(i,n) {
    //printf("i:%d\n", i);
    ll tmp = LCM;
    int num = a[i];
    for(int j = 2; j*j < a[i]+1; j++) {
      int cnt = 0;
      while(num%j == 0){
        num /= j;
        cnt++;
      }
      if(cnt != 0)
      //printf("%d^%d = %lld\n", j, -cnt, POW(j, -cnt));
      tmp *= POW(j, -cnt);
      tmp %= MOD;
    }
    if(num != 1){
      tmp *= POW(num,-1);
      tmp %= MOD;
      //printf("%d^%d = %lld\n", num, -1, POW(num, -1));
    }
    tmp %= MOD;
    //printf("tmp:%lld\n", tmp);
    ans += tmp;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 27648
S=input()
T=input()
t=len(T)
for i in range(len(S)-t,-1,-1):
    for j in range(t):
        k=S[i+j]
        if k !=T[j] and k!="?" :break
    else:
        print((S[:i]+T+""+S[i+t:]+"").replace("?","a"))
        exit()
print("UNRESTORABLE")







Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 998244353;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  i64 a, b, c;
  cin >> a >> b >> c;

  if(a + b >= c) return cout << "No\n", 0;

  if(4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int N; cin >> N;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];

    ll ans1 = 0, sum1 = 0;
    ll ans2 = 0, sum2 = 0;

    REP(i,N) {
        sum1 += a[i];
        if (i % 2 == 0) {
            if (sum1 <= 0) {
                ans1 += abs(1 - sum1);
                sum1 = 1;
            }
        } else {
            if (sum1 >= 0) {
                ans1 += abs(sum1 + 1);
                sum1 = -1;
            }
        }
    }

    REP(i,N) {
        sum2 += a[i];
        if (i % 2 == 0) {
            if (sum2 >= 0) {
                ans2 += abs(sum2 + 1);
                sum2 = -1;
            } 
        } else {
            if (sum2 <= 0) {
                ans2 += abs(1 - sum2);
                sum2 = 1;
            }
        }
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint k,n;
	cin>>k>>n;
	vector<lint>a(n),res(n);
	rep(i,n)cin>>a.at(i);
	rep(i,n){
		if(i==0)res.at(i)=a.at(0)+k-a.at(n-1);
		else res.at(i)=a.at(i)-a.at(i-1);
	}
	cout<<k-*max_element(all(res))<<endl;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	while(scanf("%d%d", &a, &b) != EOF){
		int sa = a, sb = b;
		int c;
		while(b){
			c = a % b;
			a = b;
			b = c;
		}
		printf("%d %d\n", a, sa / a * sb);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;
ll INF = 1e30;

int main() {
    int n; cin >> n;
    vector<vector<ll>> f(n+1, vector<ll>(11));
    rep(i, n){
        rep(j,10) cin >> f.at(i).at(j);
    }

    vector<vector<ll>> p(n+1, vector<ll>(11));
    rep(i, n){
        rep(j,11) cin >> p.at(i).at(j);
    }

    ll ans = -INF;
    for(int i=0; i<(1<<10); i++){
        ll tmp = 0;
        vector<int> cnt(n,0);
        for(int j=0; j<10; j++){
            if(i&1<<j){
                for(int k=0; k<n; k++){
                    if(f.at(k).at(j)) cnt.at(k)++; 
                }
            }
        }

        bool no = false;
        for(int l=0; l<n; l++){
            if(cnt.at(l)!=0) break;

            if(l==n-1){
                no =true;
            }
        }     
        if(no) continue;

        for(int l=0; l<n; l++){
            if(cnt.at(l)!=0) tmp += p.at(l).at(cnt.at(l));
            else tmp += p.at(l).at(0);
        }

        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
      break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Measured memory_bytes: 8280
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll gcd(ll a, ll b) {
  ll v0=a, v1=b, v2=v0%v1;
  while(v2>0) {
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

int main() {
  int N;
  cin>>N;
  ll ans;
  ll tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(i==0) ans = tmp;
    else ans = gcd(ans, tmp);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5+7;
const ll mod = 1e9+7;
int a[N];
int n,ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int mx=0,mi=1e9+7;
    for(int i=1;i<=n;i++){
        mx=max(mx,a[i]);
        mi=min(mi,a[i]);
    }
    printf("%d\n",mx-mi);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2002;
const int B=4000000+1;
int n,a[N],sum=0;
bitset<B> f;
int main(){
	scanf("%d",&n);
	f[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		f=f|(f<<a[i]);
		sum+=a[i];
	}
	for(int i=(sum+1)/2;;i++)if(f[i]){
		return !printf("%d\n", i);
	}

}
/*
1 3
0 1 3 4
*/

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int n = int.Parse(s.Split(' ')[0]);
            int i = int.Parse(s.Split(' ')[1]);

            Console.WriteLine(n - i + 1);

        }
    }
}


Measured memory_bytes: 27372
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

#define PI 3.141592653589

int main() {
    cout << fixed << setprecision(10);
    double a, b, x;
    cin >> a >> b >> x;

    if(a * a * b <= x * 2) {
        //半分以上
        cout << atan(2 * (a * a * b - x) / a / a / a) * 180 / PI;
    } else {
        //半分以下
        //x=b*b*tan(t)*a
        cout << atan(b * b * a / x / 2) * 180 / PI;
    }
    return 0;
}

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

int main(){
  string S; cin >> S;
  int exist[27]={};
  exist[26]=-1;
  for(int i=0; i<S.size(); i++){
    exist[S[i]-'a']++;
  }
  for(int i=0; i<27; i++){
    if(exist[i]==0){
      cout << (char)(i+'a') << endl;
      return 0;
    }else if(exist[i]==-1){
      cout << "None" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
int dp[100][100005];
int main()
{
    int n,k;
    cin>>n>>k;
      int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=0;i<=a[0];i++)
      dp[0][i] = 1;
    
    for(int i=1;i<n;i++){
      vector<int>pref(k+1);
      pref[0] = dp[i-1][0];
      for(int j=1;j<=k;j++){
        pref[j] = (pref[j-1]+dp[i-1][j])%MOD;
      }

      for(int j=0;j<=k;j++){
        if(j>a[i])
        dp[i][j] = (pref[j]+MOD - pref[j-a[i]-1])%MOD;
        else
        {
          dp[i][j] = pref[j];
        }
        
      }
    }

    cout<<dp[n-1][k];

    return 0;
}

Measured memory_bytes: 43000
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    LL n, k;
    cin >> n >> k;

    if (k == 1) {
        cout << 1.000000000000 << endl;
        return 0;
    }
    if (n == 1) {
        LL x = ceil(log2(k));
        double ans =  (1./n) * (1.0 / pow(2, x));
        printf("%.12f\n", ans);
        return 0;
    }
    double ans = 0.;
    for (LL i = 1; i <= n; i++) {
        if (i >= k) {
            ans += 1.0/n;
            continue;
        }
        LL x = ceil(log2(k) - log2(i));
        ans += (1.0/n) * (1.0 / pow(2, x));
    }
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, X, Y = in.next().toInt

  //
  val done = new Array[Int](N+1)
  val ans = new Array[Int](N)
  val q = Queue[(Int, Int)]()

  for (i <- 1 until N) {
    q.enqueue((i, 0))
    while (!q.isEmpty) {
      val (now, cnt) = q.dequeue()

      if (now <= N) {
        if (done(now) != i) {
          done(now) = i
          if (now > i)
            ans(cnt) += 1

          if (now == X) {
            q.enqueue((Y, cnt+1))
          }
          if (now == Y) {
            q.enqueue((X, cnt+1))
          }

          if (now > 1)
            q.enqueue((now-1, cnt+1))
          q.enqueue((now+1, cnt+1))
        }
      }
    }

  }

  println(ans.drop(1).mkString("\n"))
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 58908
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

#define MAX_V 300
int V;
struct edge{int to, cost;};
vector<edge> G[MAX_V];

void add_edge(int from, int to, int cost){
    G[from].push_back(edge({to, cost}));
}

void add_edge2(int v1, int v2, int cost){
    G[v1].push_back(edge({v2, cost}));
    G[v2].push_back(edge({v1, cost}));
}

int d2[MAX_V][MAX_V];
void waeshall_floyd(){
    REP(i, V){
        REP(j, V){
            if(i == j){
                d2[i][j] = 0;
            }else{
                d2[i][j] = INF;
            }
        }
    }
    REP(v, V){
        REP(i, G[v].size()){
            edge e = G[v][i];
            d2[v][e.to] = e.cost;
        }
    }
    REP(k, V){
        REP(i, V){
            REP(j, V){
                d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
            }
        }
    }
}

signed main(){

    int N;
    cin >> N;
    V = N;
    vector< vector<int> > A(N, vector<int>(N));
    REP(i, N) readvec(A[i]);

    REP(i, N){
        FOR(j, i + 1, N)add_edge2(i, j, A[i][j]);
    }

    waeshall_floyd();

    int ans = 0;
    REP(i, N){
        FOR(j, i + 1, N){
            if(d2[i][j] < A[i][j]){
                cout << -1;
                return 0;
            }
            bool will_use = true;
            REP(k, N){
                if(k != i && k != j && d2[i][j] == d2[i][k] + d2[k][j]) will_use = false;
            }
            if(will_use) ans += d2[i][j];
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 4096
import java.util.*;

public class Main{

    int max = 1121;
    boolean[] notp;

    void solve(){
        Scanner sc = new Scanner(System.in);

        notp = new boolean[max];
        for(int i=2; i<Math.sqrt(max)+1; i++){
            for(int j=i*2; j<max; j+=i) notp[j] = true;
        }

        int[][] dp = new int[max][15];
        dp[0][0] = 1;
        for(int i=2; i<max; i++){
            if(notp[i]) continue;
            for(int j=max; j>=0; j--){
                if(i+j>=max) continue;
                for(int k=1; k<15; k++){
                    dp[j+i][k] += dp[j][k-1];
                }
            }
        }

        while(true){
            int n = sc.nextInt();
            int k = sc.nextInt();
            if(n==0 && k==0) break;
            System.out.println(dp[n][k]);
        }
    }

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];

    sort(a,a+n,greater<int>());
    if(n==2){
        cout << a[0] << " " << a[1] << endl;
        return 0;
    }
    int b = a[0], c=a[0];
    REP(i,n){
        if(abs(a[i]-a[0]/2)<b){
            b = abs(a[i]-a[0]/2);
            c = a[i];
        }else break;
    }

    cout << a[0] << " " << c << endl;

    return 0;
}


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


int main() {
  int a,b; cin >> a >> b;
  cout << (a+b) % 24 << endl;
}

Measured memory_bytes: 256
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad 

main :: IO ()
main = breads >>= main'
    where
        main' [_, _, x, y] = replicateM 2 breads >>= putStr . solve x y >> putStrLn "War"

solve :: Int -> Int -> [[Int]] -> String 
solve x y [xs, ys]
    | maximum (x : xs) < minimum (y : ys) = "No "
    | otherwise = ""

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 508
op :: (Double -> Double -> Double) -> [String] -> [String]
op e (s0:s1:ss) =
  let s0' = read s0 :: Double
      s1' = read s1 :: Double
      re  = e s1' s0'
      r'  = show re
  in
    r':ss

ans s [] = head s
ans s (x:xs) =
  let s' = case x of
             "+" -> op (+) s
             "*" -> op (*) s
             "-" -> op (-) s
             "/" -> op (/) s
             otherwise -> (x:s)
  in
    ans s' xs

main = do
  c <- getContents
  let i = map words $ lines c
      o = map (ans []) i
  mapM_ putStrLn o

Measured memory_bytes: 4384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void){
    int N,Q;
    string s;
    cin >> N >> Q >> s;
    vector<int> vec(N,0);

    for(int i=0;i<N-1;i++){
        if(s.substr(i,2) == "AC") vec[i+1] = vec[i] + 1;
        else                      vec[i+1] = vec[i];
    }

    int l,r;
    for(int i=0;i<Q;i++){
        cin >> l >> r;
        l--; r--;
        cout << vec[r] - vec[l] << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int A[1000010];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &A[i]);
	ll ans = 5e18, nw = 0;
	for(int i = 1; i <= n; i++) nw += A[i];
	for(int i = 1; i < n; i++) {
		nw -= 2 * A[i];
		ans = min(ans, abs(nw));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024