akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double x[300];
double y[300];
double X[90000];
double eps=0.000000001;
double Y[90000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
		
		int at=0;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				double d=sqrt(1.0-((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))/4)/sqrt(((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
				X[at]=(x[i]+x[j])/2-d*(y[j]-y[i]);
				Y[at++]=(y[i]+y[j])/2+d*(x[j]-x[i]);
				X[at]=(x[i]+x[j])/2+d*(y[j]-y[i]);
				Y[at++]=(y[i]+y[j])/2-d*(x[j]-x[i]);
			}
		}
		int ret=1;
		for(int i=0;i<at;i++){
			int val=0;
			for(int j=0;j<a;j++){
				if((X[i]-x[j])*(X[i]-x[j])+(Y[i]-y[j])*(Y[i]-y[j])<1.0+eps)val++;
			}
			ret=max(ret,val);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 2484
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 1e6+2;

vi find_prime(int val)
{
    vi ret;

    for(int i = 2; i * i <= val; i ++) {
        if(val % i == 0) {
            ret.pb(i);
            while(val % i == 0)
                val /= i;
        }
    }

    if(val > 1)
        ret.pb(val);

    return ret;
}

void solve()
{   
    int n;
    scn(n);

    vi a(n), fa(maxN, 0);

    bool pairwise = 1;

    rep(i, 0, n) {
        scn(a[i]);

        vi here = find_prime(a[i]);

        for(int it : here) {
            if(fa[it] != 0)
                pairwise = 0;
            fa[it] = 1;
        }
    }

    if(pairwise) {
        puts("pairwise coprime");
        exit(0);
    }

    int g = a[0];

    rep(i, 1, n)
    g = __gcd(g, a[i]);

    if(g == 1) {
        puts("setwise coprime");
        exit(0);
    }

    puts("not coprime");
} 

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11488
#include <iostream>
#include <vector>

using namespace std;


int main()
{
  static int INF = 1000000000;
  int N, K;
  cin >> N >> K;
  vector <int> h(N);
  vector <int> dp(N, INF);
  for( int i=0;i<N;i++ )
    cin >> h[i];

  dp[0] = 0;
  for( int i=1;i<N;i++ )
    {
      for( int j=1;j<K+1;j++ )
	  if( i-j>=0 )
	    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i]);
    }

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1152
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))

ans = 0
mod = int(1e9+7)

for i in range(61):
    tmp = np.sum((A>>i)&1)
    p = (N-tmp)*tmp
    for j in range(i):
        p = (p*2)%mod
    ans += p
print(ans%mod)

Measured memory_bytes: 48840
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int T = sc.nextInt();
			int L = sc.nextInt();
			int B = sc.nextInt();
			boolean[] lose = new boolean[N + 1];
			boolean[] back = new boolean[N + 1];
			for (int i = 0; i < L; ++i) {
				lose[sc.nextInt()] = true;
			}
			for (int i = 0; i < B; ++i) {
				back[sc.nextInt()] = true;
			}
			double ans = 0;
			double[][] dp = new double[N + 1][T + 2];
			dp[0][0] = 1;
			for (int i = 0; i < T; ++i) {
				for (int j = 0; j < N; ++j) {
					for (int k = 1; k <= 6; ++k) {
						int pos = j + k;
						if (pos > N) pos = N - (pos - N);
						if (lose[pos]) {
							dp[pos][i + 2] += dp[j][i] / 6;
						} else if (back[pos]) {
							dp[0][i + 1] += dp[j][i] / 6;
						} else {
							dp[pos][i + 1] += dp[j][i] / 6;
						}
					}
				}
				ans += dp[N][i + 1];
			}
			System.out.printf("%.7f\n", ans);
		}
	}

}

Measured memory_bytes: 22348
using System;
using System.Collections.Generic;

namespace AOJ.Volume0
{
    public class SearchEngine
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var data = input.Split(new char[] { ' ', '.', ',' });
                var word = new List<string>();
                foreach(var d in data)
                {
                    if (d.Length <= 2 || d.Length >= 7) { continue; }
                    word.Add(d);
                }

                string line = "";
                foreach(var w in word) { line += w + " "; }
                Console.WriteLine(line.Trim());
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9032
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S; cin >> S;
    string vals[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    F0R(i, 7) {
        if (S == vals[i]) {
            cout << 7-i << endl;
        }
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
using System;

public static class Solution
{
  public static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    int nMod1000 = n % 1000;
    if (nMod1000 == 0)
    {
      Console.WriteLine(0);
    }
    else
    {
      Console.WriteLine(1000 - nMod1000);
    }
  }
}

Measured memory_bytes: 27480
#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);
	int n,ans=0;
	cin>>n;
	map<int,int>a;
	rep1(i,n){
		int tmp;
		cin>>tmp;
		a.insert(make_pair(i,tmp));
	}
	int button = 1;
	rep(i,n-1){
		ans++;
		button=a.at(button);
		if(button==2){
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int len = s.size() - 1;

    len -= len % 2;

    int i, j;
    string ss;
    for (i = len; i >= 0; i -= 2)
    {
        ss = "";
        for (j = 0; j < i / 2; j++)
        {
            ss += s[j];
        }
        for (; j < i; j++)
        {
            if(s[j] != ss[j - i / 2])break;
        }
        if(j == i)break;
    }
    cout << ss.size() * 2 << endl;
}


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

uint64_t mem[87];

uint64_t lucas(const int n)
{
    if (mem[n] != 0) return mem[n];
    if (n == 0) return mem[n] = 2;
    if (n == 1) return mem[n] = 1;
    return (mem[n] = (lucas(n - 1) + lucas(n - 2)));
}

int main()
{
    int n;
    std::cin >> n;
    std::memset(mem, 0, sizeof mem);
    std::cout << lucas(n) << std::endl;
    return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
A=map(int,list(input().split()))
countA=0
countB=0
for i in A:
    if i>X:
        countA+=1
    if i<X:
        countB+=1
if countA<countB:
    print(countA)
else:
    print(countB)


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

typedef long long ll;
const int N = 2e5;
typedef pair <int,int> pii;
const ll MOD = 998244353;

ll dmod(ll x){
	return x%MOD;
}

int n;

pii li[N+5];
int ST[4*N+5];

void update(int node, int l, int r, int pos, int val){
	if(pos > r || pos < l) return;
	if(l == r){
		ST[node] = val;
		return;
	}
	int mid = (l+r)/2;
	update(node*2,l,mid,pos,val);
	update(node*2+1,mid+1,r,pos,val);
	ST[node] = max(ST[node*2], ST[node*2+1]);
	return;
}

int query(int node, int l, int r, int ql, int qr){
	if(l > qr || r < ql) return 0;
	if(l >= ql && r <= qr) return ST[node];
	int mid = (l+r)/2;
	return max(query(node*2,l,mid,ql,qr),query(node*2+1,mid+1,r,ql,qr));
}

void build(int node, int l, int r){
	if(l == r){
		ST[node] = l;
		return;
	}
	int mid = (l+r)/2;
	build(node*2,l,mid);
	build(node*2+1,mid+1,r);
	ST[node] = max(ST[node*2],ST[node*2+1]);
	return;
}

int cari(int x, int id){
	int ret = id;
	int l = id+1;
	int r = n;
	while(l<=r){
		int mid = (l+r)/2;
		if(li[mid].first <= x){
			l = mid + 1;
			ret = mid;
		} else {
			r = mid - 1;
		}
	}
	return ret;
}

ll fe(ll x, ll p){
	if(p==0) return 1ll;
	ll ret = fe(x,p/2);
	ret = dmod(ret*ret);
	if(p&1) ret = dmod(ret*x);
	return ret;
}

ll p2[N+5];

ll memo[N+5];
int kanan[N+5];

ll dp(int x){
	if(x > n) return 1;
	ll &ret = memo[x];
	if(ret != -1) return ret;
	ret = dp(x+1);
	ret = dmod(ret+dp(kanan[x]+1));
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	p2[0] = 1;
	for(int i=1;i<=N;i++){
		p2[i] = dmod(p2[i-1]*2ll);
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&li[i].first,&li[i].second);
	}
	sort(li+1,li+n+1);
	build(1,1,n);
	for(int i=n;i>=1;i--){
		int smpe = li[i].first + li[i].second - 1;
		int id = cari(smpe,i);
		int ujung = query(1,1,n,i,id);
		update(1,1,n,i,ujung);
		kanan[i] = ujung;
	}
	ll ans = dp(1);
//	ans = dmod(ans*fe(p2[n],MOD-2));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> x(N, 0);
  rep(i, N)
  {
    cin >> x[i];
  }
  int ans = INT32_MAX;
  rep(i, N - K + 1)
  {
    int dist = x[i] - x[i + K - 1];
    if (x[i] >= 0)
      dist = x[i + K - 1];
    else if (x[i + K - 1] <= 0)
      dist = -x[i];
    else
    {
      int l = abs(x[i]);
      int r = x[i + K - 1];
      dist = 2 * min(l, r) + max(l, r);
    }
//    cout << dist << endl;
    ans = min(ans, dist);
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int h = sc.nextInt();
		int swipeMax = 0;
		int[] throwW = new int[n];
		
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			swipeMax = Math.max(swipeMax, a);
			throwW[i] = b;
		}
		
		Arrays.sort(throwW);
		
		int cnt = 0;
		int throwWPos = n - 1;
		
		while (h > 0) {
			int damage = swipeMax;
			
			if (throwWPos >= 0 && throwW[throwWPos] > swipeMax) {
				damage = throwW[throwWPos];
				throwWPos--;
			}
			h -= damage;
			cnt++;
		}
		System.out.println(cnt);
		
	}

	static class FastReader { 
      BufferedReader br; 
      StringTokenizer st; 
  
      public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
      } 

      String next() { 
        while (st == null || !st.hasMoreElements()) { 
          try { 
            st = new StringTokenizer(br.readLine()); 
          } catch (IOException  e) { 
            e.printStackTrace(); 
          } 
       } 
       return st.nextToken(); 
      } 
  
      int nextInt() { 
        return Integer.parseInt(next()); 
      } 
 
      long nextLong() { 
        return Long.parseLong(next()); 
      } 
  
      double nextDouble() { 
        return Double.parseDouble(next()); 
      } 
  
      String nextLine() { 
        String str = ""; 
        try{ 
          str = br.readLine(); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
        return str; 
      } 
    } 
}


Measured memory_bytes: 41512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010
typedef long int li;

typedef struct{
  int s;
  int t;
  li cost;
}data;
data edge[5010];
int reach_s[2510]={};
int reach_t[2510]={};
int *adj[2510]={};
int odeg[2510]={};
int *radj[2510]={};
int ideg[2510]={};

long int road[2510];

void dfs(int v,int** adj,int* deg,int* reach);

int main(){
  if(df)printf("*** debug mode ***\n");
  int n,m,p;
  scanf("%d%d%d",&n,&m,&p);
  int i;
  for(i=0;i<n;i++){
    adj[i]=NULL;
    radj[i]=NULL;
  }
  for(i=0;i<m;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(df)printf("(%d %d %d)",a,b,c);
    a--;b--;
    edge[i].s=a; edge[i].t=b; edge[i].cost=c-p;
    adj[a]=(int*)realloc(adj[a],sizeof(int)*(odeg[a]+1));
    radj[b]=(int*)realloc(radj[b],sizeof(int)*(ideg[b]+1));
    adj[a][odeg[a]++]=b;
    radj[b][ideg[b]++]=a;
    if(df)printf("(%d,%d):%d  ",radj[b][ideg[b]-1],adj[a][odeg[a]-1],edge[i].cost);
  }
  if(df){
    printf("\n");
    for(i=0;i<n;i++){
      printf("%d: [ ",i);
      int j;
      for(j=0;j<odeg[i];j++){
	printf("%d ",adj[i][j]);
      }
      printf("]\n");
    }
  }
  dfs(0,adj,odeg,reach_s);
  dfs(n-1,radj,ideg,reach_t);
  if(df){
    for(i=0;i<n;i++){
      printf("%d ",i);
    }
    printf("\n");
    for(i=0;i<n;i++){
      printf("%d ",reach_s[i]);
    }
    printf("\n");
    for(i=0;i<n;i++){
      printf("%d ",reach_t[i]);
    }
    printf("\n");
  }
  for(i=0;i<n;i++){
    reach_s[i] &= reach_t[i];
  }

  int flag;
  road[0]=0;
  for(i=1;i<n;i++)road[i]=-6000000000;
  for(i=0;i<n;i++){
    flag=0;
    int j;
    for(j=0;j<m;j++){
      int s=edge[j].s, t=edge[j].t;
      if(reach_s[s]==0 || reach_s[t]==0) continue;
      if(road[t]<road[s]+edge[j].cost){
	flag=1;
	road[t]=road[s]+edge[j].cost;
      }
      if(df) {
	int k;
	for(k=0;k<n;k++){
	  printf("%ld ",road[k]);
	}
	printf("\n");
      }
    }

    if(flag==0)break;
  }
  if(flag==1)printf("-1\n");
  else printf("%ld\n",road[n-1]>0?road[n-1]:0);
  return 0;
}
void dfs(int v,int** adj,int* deg,int* reach){
  reach[v]=1;
  int i;
  for(i=0;i<deg[v];i++){
    int u=adj[v][i];
    if(reach[u])continue;
    dfs(u,adj,deg,reach);
  }
}


/// confirm df==0 ///


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n, m;
int G[55][55] = {0};
int flag[55];

void dfs(int v){
    if(flag[v]) return;
    flag[v] = 1;
    rep(i, n){
        // if(i == v) continue;
        if(G[v][i]) dfs(i);
    }
}

int main(int argc, char *argv[]){
    cin >> n >> m;
    vec a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }
    int res = 0;
    rep(i, m){
        int edge = 0;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 0;
        rep(i, n) flag[i] = 0;
        dfs(0);
        rep(i, n){
            if(flag[i] == 0) edge = 1;
        }
        if(edge) res++;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	char str[10];
	scanf("%s", str);
	if((str[2]==str[3])&&(str[4]==str[5])){
		printf("Yes\n");
	}
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    ll n, sum=0;
    
    cin>>n;
    vector<ll> b(n);
    rep(i,n-1)cin>>b[i];
    
    vector<ll> a(n);
    
    a[0] = b[0];
    Rep(i,1,n-1){
        a[i] = min(b[i-1], b[i]);
    }

    a[n-1] = b[n-2];
    
    rep(i,n) sum+=a[i];
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	int Q;
	cin >> Q;
	for(int i=0; i<Q; i++){
		int c, a, n; // <=1000
		cin >> c >> a >> n;
		//cca ccc can
		int ans = 0;
		for(int j=0; j<=1000; j++){
			if(c < j*2 || a < j) break;
			for(int k=0; k<=1000; k++){
				if(c < j*2 + k*3) break;
				ans = max(ans, j+k+min({ c-j*2-k*3, a-j, n }));
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    long H = nextLong();
	    long N = nextLong();
	    if(H%2==1 && N%2==1 && H!=1 && N!=1){
	        out.println(H*N/2+1);
	    }else if(H!=1 && N!=1){
	        out.println(H*N/2);
	    }else{
	        out.println(1);	        
	    }
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

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

int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    
    if(a < b){
        cout << "a < b" << endl;

    }else if(a > b){
        cout << "a > b" << endl;

    }else if(a == b){
        cout << "a == b" << endl;

    }

    return 0;
}


Measured memory_bytes: 3080
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

long double fun(int i, int k) {
	int cnt = 0;
	long double ans = 1;

	while (i < k) {
		i = i * 2;
		ans = ans * 2;
	}

	return 1 / ans;
}

int main() {
	long double pr = 0;
	long double n, k;
	cin >> n >> k;

	if (n >= k) {
		pr += n - k  + 1;

		for (int i = 1; i <= k - 1; ++i) {
			pr += fun(i, k);
		}
	}
	else {
		for (int i = 1; i <= n; ++i) {
			pr += fun(i, k);
		}
	}

	printf("%.10Lf", pr / n);

	return 0;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for(ll i = 0; i < (n); i++)
#define fori(i, b, e) for(ll i = (b); i < (e); i++)
#define forr(i, b, e) for(ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, d;
    cin >> n >> d;
    d = (d << 1) | 1;
    cout << ((n + d - 1) / d) << endl;
    return 0;
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll N,M;
	cin>>N>>M;
    priority_queue<ll> que;
    rep(i,N){
        ll a;
        cin>>a;
        que.emplace(a);
    }
    ll ans = 0;
    while(M>0){
        ll tmp_a;
        tmp_a = que.top();que.pop();
        tmp_a = tmp_a/2;--M;
        que.emplace(tmp_a);
    }

    while(!que.empty()){
        ll tmp_a;
        tmp_a = que.top();que.pop();
        ans+=tmp_a;
        
    }
    
    cout<<ans<<"\n";
    
    return 0;
}



Measured memory_bytes: 1400
#include<stdio.h>
  
int main(){
  
int t[10],i,j,tmp;
  
for(i=0;i<=9;i++)
    scanf("%d",&t[i]);
  
  
    for (i = 0; i < 9; i++) {
        for (j = 9; j > i; j--) {
            if (t[j - 1] < t[j]) {  
                tmp = t[j];        
                t[j] = t[j - 1];
                t[j - 1]= tmp;
            }
        }   
  
    }
  
for(i=0;i<=2;i++)
    printf("%d\n",t[i]);
  
  
    return 0;
}

Measured memory_bytes: 600
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
struct Node{
    int x;
    int y;
    char c;
}path[3005][3005];
char s[3005],c[3005],ans[3005];
int f[3005][3005];
int main(){
    scanf("%s",s+1);
    scanf("%s",c+1);
    int n=strlen(s+1),m=strlen(c+1);
    for(int i=1;i<=n+1;i++){
        for(int j=1;j<=m+1;j++){
            if(f[i-1][j]>f[i][j-1]){
                f[i][j]=f[i-1][j];
                path[i][j].x=path[i-1][j].x;
                path[i][j].y=path[i-1][j].y;
                path[i][j].c=path[i-1][j].c;
            }
            else{
                f[i][j]=f[i][j-1];
                path[i][j].x=path[i][j-1].x;
                path[i][j].y=path[i][j-1].y;
                path[i][j].c=path[i][j-1].c;
            }
            if(s[i]==c[j]){
                if(f[i-1][j-1]+1>f[i][j]){
                    f[i][j]=f[i-1][j-1]+1;
                    path[i][j].x=i-1;
                    path[i][j].y=j-1;
                    path[i][j].c=s[i];
                }
            }
        }
    }
    int x=n,y=m,z=f[n][m];
    while(x>=1&&x<=n&&y>=1&&y<=m){
        ans[f[n][m]]=path[x][y].c;
        f[n][m]--;
        int dx=path[x][y].x;
        int dy=path[x][y].y;
        x=dx;
        y=dy;
    }
    for(int i=1;i<=z;i++)printf("%c",ans[i]);
    puts("");
	return 0;
}


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

namespace ABC125B
{
    class Program
    {
        static void Main(string[] args)
        {

            Int32 n = Int32.Parse(Console.ReadLine());

            Int32[] v = Console.ReadLine().Split().Select(s => Int32.Parse(s)).ToArray();
            Int32[] c = Console.ReadLine().Split().Select(s => Int32.Parse(s)).ToArray();

            Int32 a = 0;
            for(Int32 i = 0;i < n; ++i)
            {
                if(v[i] / c[i] >= 1)
                {
                    a += v[i] - c[i];
                }
            }



            Console.WriteLine(a);



        }
    }
}


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

int main(){
  int q;
  string s;
  cin >> s >> q;
  int flag = 1;
  string front="", back ="";
  rep(i,q){
    int num;
    cin >> num;
    if(num == 1){
      flag *= -1;
    }else{
      cin >> num;
      string c;
      cin >> c;
      if((num==1 && flag==1) || (num==2 && flag==-1)){
        front += c;
      }else{
        back += c;
      }
    }
  }
  reverse(front.begin(), front.end());
  s = front + s + back;
  if(flag==1)cout << s << endl;
  else{
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cmath>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define UP(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

string s;
ll x, y;
ll off = 20005;
ll N = 10000;
int dp[40010], dpx[40010], dpy[40010];

int main(int argc, char const *argv[]) {
  cin >> s;
  cin >> x >> y;
  vector<ll> lx, ly;
  ll d = 0, l = 0;
  REP(i,s.size()) {
    if(s[i]=='F') l++;
    else {
      if(d%2==0) lx.push_back(l);
      else ly.push_back(l);
      l = 0;
      d++;
    }
  }
  if(d%2==0) lx.push_back(l);
  else ly.push_back(l);
  // priv(lx);
  // priv(ly);
  if(lx.size() > 0) dpx[off+lx[0]]=true;
  FOR(i,1,lx.size()) {
    UP(j,off-N,off+N) dp[j] = dpx[j-lx[i]] | dpx[j+lx[i]];
    UP(j,off-N,off+N) dpx[j] = dp[j];
  }
  dpy[off]=1;
  FOR(i,0,ly.size()) {
    UP(j,off-N,off+N) dp[j] = dpy[j-ly[i]] | dpy[j+ly[i]];
    UP(j,off-N,off+N) dpy[j] = dp[j];
  }
  // REP(i,10) cerr<<dpx[off-i]<<((i==9?"\n":" "));
  // REP(i,10) cerr<<dpx[off+i]<<((i==9?"\n":" "));
  // REP(i,10) cerr<<dpy[off-i]<<((i==9?"\n":" "));
  // REP(i,10) cerr<<dpy[off+i]<<((i==9?"\n":" "));
  if(dpx[off+x] && dpy[off+y]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#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 big=1e18;
const double PI=2*asin(1);

ll N, X;
ll length[55];

ll solve(ll L, ll t) {
  if(L==0) {
    if(t==1) return 1;
    else return 0;
  }
  if(t==0) return 0;
  else if(t<=1+length[L-1]) {
    return solve(L-1, t-1);
  }
  else if(t<=2+length[L-1]) {
    return 1 + solve(L-1, length[L-1]);
  }
  else if(t<=2+2*length[L-1]) {
    return solve(L-1, length[L-1]) + 1 + solve(L-1, t-2-length[L-1]);
  }
  else {
    return 1 + 2*solve(L-1, length[L-1]);
  }
}

int main() {
  length[0] = 1;
  for(int i=1;i<55;++i) {
    length[i] = 2*length[i-1]+3;
  }
  cin>>N>>X;
  cout<<solve(N, X)<<endl;
}



Measured memory_bytes: 3596
from collections import defaultdict as dd
primes = dd(int)
n = int(input())
for i in range(2,n+1):
  for j in range(2,int(i**.5)+2):
    while i%j == 0:
      i //= j
      primes[j] += 1
  if i > 1:
    primes[i] += 1
cnt = 1
mod = 10**9+7
for x in primes:
  cnt *= primes[x]+1
  cnt %= mod
print(cnt)

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

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

using namespace std;

const int MAX_N=2000,INF=1e8;

typedef pair<int,int> P;

int N,K;
P edge[MAX_N];
vector<int> G[MAX_N];

int d[MAX_N];
bool used[MAX_N];

void bfs(int s){
	fill(used,used+N,false);
	d[s]=0;
	used[s]=true;
	queue<int> q;
	q.push(s);
	while (!q.empty()){
		int v=q.front();
		q.pop();
		REP(i,G[v].size()){
			int to=G[v][i];
			if (!used[to]){
				used[to]=true;
				d[to]=d[v]+1;
				q.push(to);
			}
		}
	}
}

void bfs(int s,int t){
	fill(used,used+N,false);
	d[s]=0;
	d[t]=0;
	used[s]=used[t]=true;
	queue<int> q;
	q.push(s);
	q.push(t);
	while (!q.empty()){
		int v=q.front();
		q.pop();
		REP(i,G[v].size()){
			int to=G[v][i];
			if (!used[to]){
				used[to]=true;
				d[to]=d[v]+1;
				q.push(to);
			}
		}
	}
}

int main(){
	scanf("%d %d",&N,&K);
	REP(i,N-1){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;
		b--;
		edge[i]=P(a,b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans=INF;
	if (K%2==0){
		REP(i,N){
			bfs(i);
			int s=0;
			REP(j,N){
				if (d[j]>K/2){
					s++;
				}
			}
			ans=min(ans,s);
		}
	}else{
		REP(i,N-1){
			bfs(edge[i].first,edge[i].second);
			int s=0;
			REP(j,N){
				if (d[j]>(K-1)/2){
					s++;
				}
			}
			ans=min(ans,s);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
n = int(input())
H = [int(x) for x in input().split()]
res = 0
right = 0
for left in range(n):
  while right+1 < n and H[right] >= H[right+1]:
    right += 1
  res = max(res, right - left)
  if right == left:
    right += 1
print(res) 

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

int main(){

  int N,T,A;
  cin >> N >> T >> A;

  int H[1000];

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

  int fav = 0;

  for(int i = 1;i < N;i++)
    if(abs(A - (T - H[fav] * 0.006)) > abs(A - (T - H[i] * 0.006))) fav = i;

  cout << fav + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool T=false;
int main(){
    long long N,K;cin>>N>>K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin>>A[i];
    }

    for (int i = K; i < N; i++)
    {
        if(A[i-K]<A[i])cout<<"Yes";
        else cout<<"No";
        cout<<endl;
    }
}

Measured memory_bytes: 4784
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,ww;
vector<map<ll,ll>> dp;
vector<Vi> d;
Vi w,v;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>ww;
    w.resize(n);
    v.resize(n);
    dp.resize(n);
    d.resize(n);
    rep(i,n){
        cin>>w[i]>>v[i];
    }
    dp[0][w[0]]+=v[0];
    dp[0][0]=0;
    d[0].pb(0);
    d[0].pb(w[0]);
    rep(i,n){
        if(i==n-1)continue;
        rep(j,d[i].size()){
            if(d[i][j] == 0 && d[i+1].empty())d[i+1].pb(0);
            if(dp[i+1].count( d[i][j] + w[i+1] ) == 0)d[i+1].pb(d[i][j]+w[i+1]);
            if(d[i][j] != 0)if(dp[i+1].count( d[i][j]  ) == 0)d[i+1].pb(d[i][j]);
            ll tmp = dp[i+1][d[i][j] + w[i+1] ];
            chmax(tmp,dp[i][d[i][j]] + v[i+1] );
            dp[i+1][d[i][j]+w[i+1]] = tmp;
            tmp = dp[i+1][d[i][j]];
            chmax(tmp,dp[i][d[i][j]]);
            dp[i+1][d[i][j]] = tmp;
        }
    }
    ll ans = 0;
    rep(i,d[n-1].size()){
        ll tmp = dp[n-1][d[n-1][i]];
        if(d[n-1][i] <= ww)chmax(ans,tmp);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <math.h>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int n,x,y;
  cin >> n >> x >> y;
  int a[n];

  REP(i,n){
    cin >> a[i];
  }

  if(n == 1){
    cout << abs(a[0] - y) << endl;
    return 0;
  }

  int ans1 = abs(a[n-1] - y);
  int ans2 = abs(a[n-2] - a[n-1]);

  cout << max(ans1,ans2) << endl;
       
  
  return 0;
}


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

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int N_165, M_165, Q_165;
vector<int> a_165, b_165, c_165, d_165;
int ans_165;

void dfs_165(vector<int> A)
{
  if (A.size() == N_165 + 1)
  {
    int now = 0;
    for (int i = 0; i < Q_165; ++i)
    {
      if (A[b_165[i]] - A[a_165[i]] == c_165[i]) now += d_165[i];
    }
    ans_165 = max(ans_165, now);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= M_165)
  {
    dfs_165(A);
    A.back()++;
  }
}

int main()
{
  cin >> N_165 >> M_165 >> Q_165;
  a_165 = b_165 = c_165 = d_165 = vector<int>(Q_165);
  ans_165 = 0;

  for (int i = 0; i < Q_165; ++i) 
    cin >> a_165[i] >> b_165[i] >> c_165[i] >> d_165[i];

  dfs_165(vector<int>(1, 1));
  cout << ans_165 << endl;
}

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

struct Node {
	int key;
	Node *parent, *right, *left;
public:
	Node(Node *r, Node *l, Node *p, int k) : right(r), left(l), parent(p), key(k) {};
};

Node *root, *NIL;

void insert(int key) {
	Node *z = new Node(NIL, NIL, NIL, key);
	Node *y = NIL;
	Node *x = root;
	while (x != 0) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else if (z->key < y->key) {
		y->left = z;
	}
	else {
		y->right = z;
	}
	return;
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
	return;
}

void preorder(Node *u) {
	if (u == NIL)return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
	return;
}

void print(Node *u) {
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
	return;
}

int main() {
	int n,key;
	string order;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> order;
		if (order == "insert") {
			cin >> key;
			insert(key);
		}
		else if (order == "print") {
			print(root);
		}
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int calc(int ab, int b, int a) {
    if (b == 0 && a == 0) {
        return max(ab - 1, 0);
    }
    return ab + min(b, a);
}

int main() {
    int N;
    cin >> N;
    vector<string> s(N);

    map<int, int> mp;
    int ans = 0;
    rep(i, N) {
        string s;
        cin >> s;
        rep(i, s.size() - 1) {
            if (s[i] == 'A' && s[i + 1] == 'B') ans++;
        }
        bool beginB = s[0] == 'B';
        bool endA = s[s.size() - 1] == 'A';
        if (beginB && endA) {
            mp[0]++;
        } else if (beginB) {
            mp[1]++;
        } else if (endA) {
            mp[2]++;
        }
    }

    ans += calc(mp[0], mp[1], mp[2]);
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int S = 100010;
char buf[S];

int main() {
  scanf("%s",buf);
  int N=strlen(buf), K=N;
  for(int i=1; i<N; i++) {
    if(buf[i-1] != buf[i]) {
      K=min(K,max(i,N-i));
    }
  }
  printf("%d\n",K);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"s=input()\n"
"n=len(s)-1\n"
"a=0\n"
"for i in range(1<<n):\n"
"  l=[]\n"
"  for x,y in zip(s,[''for _ in[0]*10]):\n"
"    l.append(x)\n"
"    l.append(y)\n"
"  for j in range(n):\n"
"    if i>>j&1:\n"
"      l[j*2+1]='+'\n"
"  a+=eval(''.join(l))\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include<stdio.h>

void run(void){
  int cnt[10]={0};
  int n=4;
  while(n--){
    int v;
    scanf("%d",&v);
    cnt[v]++;
  }
  printf("%s\n",cnt[1]==1 && cnt[9]==1 && cnt[7]==1 && cnt[4]==1?"YES":"NO");
}

int main(void){
  run();
  return 0;
}

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

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

    int A[N];
    for(int i = 0;i<N;i++){
        cin >> A[i];
    }
    int max_dist = 0;
    for(int i = 1;i<N;i++){
        if(A[i] - A[i-1] > max_dist){
            max_dist = A[i] - A[i-1];
        }
    }
    if(A[0] + K - A[N-1] > max_dist){
        max_dist = A[0] + K - A[N-1];
    }

    cout << K -max_dist << endl;
}

Measured memory_bytes: 1024
import java.util.*;

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

    public static void solve(int[] value){
        double result = 0;
        for(int an : value){
            result += (double) 1/an;
        }
        result = 1/result;
        System.out.println(result);
    }
}

Measured memory_bytes: 23892
N = input()
A = list(map(int, input().split()))
 
l = sorted([ x - (idx+1) for x,idx in enumerate(A)])
#print(l)
 
import statistics
median = statistics.median(l)
#print(median)
 
ans = 0
for x in l:
  ans += abs(x - median)
  
print(int(ans))

Measured memory_bytes: 26708
#include<bits/stdc++.h>
#define ll long long
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
using namespace std;
int main()
{
    string s,t;
    int ans=0;
    getline(cin,s);
    getline(cin,t);
    for(int i=0;i<s.size();i++)
        ans += (s[i]!=t[i]);
    cout<<ans;
    return 0;
}



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

int main() {
  int N, X, Y, Z, B;
  cin >> N;
  X = 0;
  B = 0;
  for (int i = 0;i < N;i++){
    cin >> Y >> Z;
    X = Z - Y + 1;
    B = B + X;
  }
    cout << B << endl;
}

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

int main(){
  long int X, K;
  cin >> X >> K;
  
  if(X > K){
    X = K - X % K;
  }
  
  if(X > K / 2){
    X = K - X;
  }
      
  cout << X << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m, l := nextInt(), nextInt(), nextInt()
	a := make([][]int, n)
	b := make([][]int, m)
	c := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		c[i] = make([]int, l)
		for j := 0; j < m; j++ {
			a[i][j] = nextInt()
		}
	}
	for i := 0; i < m; i++ {
		b[i] = make([]int, l)
		for j := 0; j < l; j++ {
			b[i][j] = nextInt()
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < l; j++ {
			for k := 0; k < m; k++ {
				c[i][j] += a[i][k] * b[k][j]
			}
			fmt.Printf("%d", c[i][j])
			if j != l-1 {
				fmt.Printf(" ")
			}
		}
		fmt.Printf("\n")
	}

}



Measured memory_bytes: 1572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<vi> v(n, vi(m));
    REP(i, n){
        REP(j, m) {
            cin >> v[i][j];
            v[i][j] --;
        }
    }
    set<int> s;
    REP(i, m) s.insert(i);
    int ans = n;
    while(!s.empty()){
        vi c(m);
        REP(i, n){
            REP(j, m){
                if(s.count(v[i][j])){
                    c[v[i][j]] ++; break;
                }
            }
        }
        int ma = max_element(ALL(c)) - c.begin();
        ans = min(ans, c[ma]);
        s.erase(ma);
    }
    cout << ans << endl;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string t;
  cin >> t;
  for(const auto& c : t)
  {
    cout << ((c == '?') ? 'D' : c);
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3776
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut sum = 0;
    for _ in 0..n {
        let x:usize = read();
        sum += x;
    }
    println!("{}", sum - n);
}

Measured memory_bytes: 2120