akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int N, M,C;
int D[30][30];
int c[500][500];
vector<int>v;

int sumcolor[3][30];
int changecost[3][30];
int main() {
	cin >> N >> C;
	for (int i = 0; i < C; i++){
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
		sumcolor[0][i] = sumcolor[1][i] = sumcolor[2][i] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> c[i][j];
			sumcolor[(i + j) % 3][c[i][j]-1]++;
		}
	}
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < 3; j++) {
			int tmp = 0;
			for (int k = 0; k < C; k++) {
				tmp += sumcolor[j][k] * D[k][i];
			}
			changecost[j][i] = tmp;
		}
	}
	int ans = 1000000000;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if (i == j || i == k || j == k)continue;
				ans = min(ans,changecost[0][i]+changecost[1][j]+changecost[2][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
//#define _GLIBCXX_DEBUG
#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 ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

class STM{//maximum
    const int MXN=1<<18;
    ll n;vl seg;
public:
    void seg_init(int n_){
        n=1;
        while(n<n_){
            n*=2;
        }
        seg.assign(2*n-1,-INF);
    }
    void update(int k,ll a){
        k+=n-1;
        seg[k]=a;
        while(k>0){
            k=(k-1)/2;
            seg[k]=max(seg[2*k+1],seg[2*k+2]);
        }
    }
    ll get_max(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0){
            return get_max(a,b,k,0,n);
        }
        if(r<=a||b<=l){
            return -INF;
        }
        if(a<=l&&r<=b){
            return seg[k];
        }
        else{
            ll maxl=get_max(a,b,2*k+1,l,(l+r)/2);
            ll maxr=get_max(a,b,2*k+2,(l+r)/2,r);
            return max(maxl,maxr);
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vP p(N);
    vl x(N);
    rep(i,N){
        cin >> p[i].first >> p[i].second;
        x[i]=p[i].first;
    }
    p.pb({INF,INF});
    x.pb(INF);
    sort(p.begin(),p.end());
    sort(x.begin(),x.end());
    vl dp(N+1,1);
    STM st;
    st.seg_init(N+1);
    rep(i,N){
        ll maxd=lower_bound(p.begin(),p.end(),make_pair(p[N-1-i].second+p[N-1-i].first,-INF))-p.begin()-1;
        //cerr << maxd << endl;
        st.update(N-i-1,maxd);//cerr << N-i-1 << ' ' << maxd << endl;
        ll y=st.get_max(0,maxd+1);//cerr << y << endl;
        st.update(N-i-1,y);//cerr << N-y << ' ' << i << endl;
        dp[i+1]=(dp[i]+dp[N-y-1]>=MOD2?dp[i]+dp[N-y-1]-MOD2:dp[i]+dp[N-y-1]);
    }
    cout << dp[N] << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 13620
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=1e6+69;
const int mod = 1e9+7;
string s;
int n,m,k;
int a[MAXN],sum[MAXN];
int ans;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    if(n>=10){
        cout<<m;
        return 0;
    }
    int ans = 100*(10-n);
    ans+=m;
    cout<<ans;
}


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

int main() {
	ios::sync_with_stdio(false);
	// freopen("in.txt", "r", stdin);
	int flg = 0;
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; i++) {
		int j = x - i;
		if (2 * i + 4 * j == y) flg = 1;
	}
	puts((flg ? "Yes" : "No"));
	return 0;
}

Measured memory_bytes: 3692
S = input()
W = {S[0]: 1}
cnt = 1
for i in range(1, 4):
    if S[i] in W:
        W[S[i]] += 1
        if W[S[i]] == 3:
            print("No")
            break
    else:
        W[S[i]] = 1
        cnt += 1
        if cnt == 3:
            print("No")
            break
else:
    print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n; cin >> n;
	vector<int> v(n);
	map<int, int> cnt[2];
	for (int i = 0; i < n; ++i) cin >> v[i];
	for (int i = 0; i < n; ++i) {
		cnt[i % 2][v[i]]++;
	}
	vector<pair<int, int>> pairs[2];
	for (int i = 0; i < 2; ++i) {
		cnt[i][0] = 0;
		for (auto&& x : cnt[i]) pairs[i].push_back( { x.second, x.first });
		sort(pairs[i].rbegin(), pairs[i].rend());
	}
	int64 ans = 0;
	if (pairs[0][0].second != pairs[1][0].second) {
		ans = n - (pairs[0][0].first + pairs[1][0].first);
	} else {
		ans = n - max(pairs[0][1].first + pairs[1][0].first,  pairs[0][0].first + pairs[1][1].first);
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 9264
#include <iostream>
using namespace std;
int main(void){
    int i,s[10];
    for(i=1;i<=10;i++){
        cin>>s[i];
    }
    cout<<s[1]+s[2]+s[3]+s[4]+s[5]+s[6]+s[7]+s[8]+s[9]+s[10]<<endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

#define DEP_SIZE(n) (n * n)

const int MAX_N = 1000;
const int MAX_DEP_SIZE = MAX_N * MAX_N;

vector<int> edges[MAX_N];
vector<int> dependencies[MAX_DEP_SIZE];
map<int, int> memo;
bool visited[MAX_DEP_SIZE];
int n;

int solve(int match, int count) {
    if (memo.find(match) != memo.end()) {
        // cout << "from memo[" << match << "]: " << memo[match] << endl;
        return memo[match];
    }
    if (visited[match]) {
        return -1;
    }

    visited[match] = true;

    vector<int> depends = dependencies[match];

    int max = count;
    for (int i = 0; i < (int) depends.size(); i++) {
        int res = solve(depends[i], 1);
        if (res < 0) {
            return -1;
        } else if (res + count > max) {
            max = res + count;
        }
    }

    memo[match] = max;
    // cout << "memo[" << match << "]: " << memo[match] << endl;

    return max;
}

#define MATCH(p1, p2, n) (((p1) - 1) * (n) + ((p2) - 1))

int main(void) {
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            int x;
            cin >> x;
            edges[i].push_back(x);
        }
    }

    for (int i = 0; i < n; i++) {
        int prev_match = -1;
        for (int j = 0; j < n - 1; j++) {
            int p1 = i + 1;
            int p2 = edges[i][j];

            int cur_match = MATCH(p1, p2, n);

            if (prev_match >= 0) {
                dependencies[cur_match].push_back(prev_match);
            }

            // search from opposite edges
            int k;
            for (k = n - 1; k >= 0; k--) {
                if (edges[p2 - 1][k] == p1) {
                    break;
                }
            }
            if (k > 0) {
                int match = MATCH(p2, edges[p2 - 1][k - 1], n);
                dependencies[cur_match].push_back(match);
            }

            prev_match = cur_match;
        }
    }

    // to debug dependencies
    // for (int i = 0; i < DEP_SIZE(n); i++) {
    //     cout << "dependency for " << i << ": ";
    //     for (int j = 0; j < (int) dependencies[i].size(); j++) {
    //         cout << dependencies[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    int ans = 0;
    for (int i = 0; i < DEP_SIZE(n); i++) {
        int res = solve(i, 1);
        if (res < 0) {
            ans = -1;
            break;
        } else if (res > ans) {
            ans = res;
        }
    }

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


Measured memory_bytes: 106880
#include<iostream>
 #include<cstdio>
 using namespace std;
 int main(void)
 {
	 int h[2]={0};int k[2]={0};int a=0;int b=0;int c=0;int d=0;int j=0;
	 scanf("%d %d",&h[0],&h[1]);
	 scanf("%d %d",&k[0],&k[1]);
	 scanf("%d %d %d %d",&a,&b,&c,&d);
	 j=(h[0]*a+h[1]*b+h[0]/10*c+h[1]/20*d)-(k[0]*a+k[1]*b+k[0]/10*c+k[1]/20*d);
	 if(j==0)
	 {printf("even\n");}
	else if(j>0)
	{printf("hiroshi\n");}
else if(j<0)
	{printf("kenjiro\n");}
 }


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

void insertion_sort_print(vector<int> a, int n) {

  for (int i = 1; i < n; i++) {

    for (int k=0; k < a.size(); k++) {
      cout << a[k] << (k == n - 1 ? "\n" : " ");
    }

    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;

  }

  for (int k=0; k < a.size(); k++) {
    cout << a[k] << (k == n - 1 ? "\n" : " ");
  }
  
}

int main(void) {
  int n, num;
  vector<int> a;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    a.push_back(num);
  }

  insertion_sort_print(a, n);

}


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

int main(){
    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }

    int flag = 0;

    int n;
    cin >> n;

    int b[n];
    rep(i,n){
        cin >> b[i];
    }

    int c[3][3];
    rep(i,3){
        rep(j,3){
            c[i][j] =0;
        }
    }

    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(a[j][k] == b[i]){
                    c[j][k] = 1;
                }
            }
        }
    }

    
    if(c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1){
                flag = 1;
    }
    if(c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1){
                flag = 1;
    }
    if(c[0][0] == 1 && c[0][1] == 1 && c[0][2] == 1){
                flag = 1;
    }
    if(c[1][0] == 1 && c[1][1] == 1 && c[1][2] == 1){
                flag = 1;
    }
    if(c[2][0] == 1 && c[2][1] == 1 && c[2][2] == 1){
                flag = 1;
    }
    if(c[0][0] == 1 && c[1][0] == 1 && c[2][0] == 1){
                flag = 1;
    }
    if(c[0][1] == 1 && c[1][1] == 1 && c[2][1] == 1){
                flag = 1;
    }
    if(c[0][2] == 1 && c[1][2] == 1 && c[2][2] == 1){
                flag = 1;
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main() {
	string pred, actual;

	cin >> pred >> actual;

	int c = 0;

	for (int i = 0; i < 3; ++i)
	{
		if (pred[i] == actual[i])
		{
			++c;
		}
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 100010
int n, k, a[MAXN], ans = 0x3F3F3F3F;
inline int dis(int x, int y) {
	if (1LL * x * y >= 0) {
		return std::max(std::abs(x), std::abs(y));
	} else {
		return std::min(std::abs(x), std::abs(y)) * 2 + std::max(std::abs(x), std::abs(y));
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) {
		if (i + k - 1 <= n)
			ans = std::min(ans, dis(a[i + k - 1], a[i]));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  unordered_map<char, ll> charCount;
  for (int i = 0; i < n; i++) charCount[s[i]]++;

  ll ans = 1;
  for (auto &x: charCount) {
    ans = (ans * (x.second + 1)) % mod;
  }
  ans--;
  if (ans < 0) ans += mod;

  cout << ans << endl;

  return 0;
}


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

int main(){
    int64_t X;
    cin >> X;
    
    int64_t num = 1000;
    vector<int64_t> A(num+10);
    vector<int64_t> B(2*num+10);
    for ( int i = 1 ; i <= num; ++i){
        int64_t A_sub = i * i;
        int64_t B_sub = A_sub * A_sub * i;
        A.at(i) = B_sub;
        B.at(i) = B_sub;
        B.at(num+i) = -B_sub;
    }
    
    int64_t A_ans = 0;
    int64_t B_ans = 0;
    for ( int i = 0 ; i <= num; ++i){
        for ( int j = 0; j <= num; ++j){
            int64_t Y;
            Y = A.at(i) - B.at(j);
            if ( X == Y ){
                A_ans = i;
                B_ans = j;
            }
        }
    }
    for ( int i = 0 ; i <= num; ++i){
        for ( int j = 0; j <= num; ++j){
            int64_t Y;
            Y = A.at(i) - B.at(num+j);
            if ( X == Y ){
                A_ans = i;
                B_ans = -j;
            }
        }
    }
    
    cout << A_ans << " " <<  B_ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 3616
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/11/20 21:59:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll INF = 1e13;

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

  int n,k; cin>>n>>k;
  vector<int> H(n); for (auto& h:H) cin>>h;
  H.insert(H.begin(), 0);
  vector<vector<ll>> dp(k+1, vector<ll>(n+1, INF));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int t = min(k, i); t >= 0; t--) {
      for (int j = i-1; j >= 0; j--) {
        dp[t][i] = min(dp[t][i], dp[t][j] + max(H[i]-H[j], 0));
        dp[t][j] = t>0 ? dp[t-1][j] : INF;
      }
    }
  }
  ll ans = INF;
  for (int i = 0; i <= k; i++) {
    ans = min(ans, *min_element(dp[i].begin(), dp[i].end()));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class ARedOrNot {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int a;
    string s;
    cin >> a >> s;

    cout << (a >= 3200 ? s : "red") << endl;

}
};

int main() {
	ARedOrNot solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>
#include<iomanip>
#include<unordered_map>
#include<algorithm>

using namespace std;


int main(void)
{
    long int n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    
    long int min=a;
    if(b<min) min=b;
    if(c<min) min=c;
    if(d<min) min=d;
    if(e<min) min=e;
    
    long int x;
    
    if(n%min==0){
        x=n/min;
    }
    else{
        x=n/min+1;
    }
    
    cout<<4+x<<endl;
    
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
import numpy as np

n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n-1)]
es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

class TREE(object):
    def __init__(self, G, root=0):
        self.G = G
        self.root = root
        self.n = len(G)
        self.logn = (self.n - 1).bit_length()
        self.depth = [-1 if i != root else 0 for i in range(self.n)]
        self.parent = [[-1] * self.n for _ in range(self.logn)]
        self.dfs()

    def dfs(self):
        que = [self.root]
        while que:
            u = que.pop()
            for v in self.G[u]:
                if self.depth[v] == -1:
                    self.depth[v] = self.depth[u] + 1
                    self.parent[0][v] = u
                    que += [v]


depth = np.array(TREE(es).depth)

ans = [0]*n

zero = one = two = n // 3
if n % 3 == 1: one += 1
if n % 3 == 2:
    one+=1
    two+=1

num_odd = np.count_nonzero(depth %2 == 1)

if num_odd <= n/3:
    for i in range(n):
        if depth[i] % 2 == 1:
            if zero > 0:
                ans[i] = zero*3
                zero -= 1
        else:
            if two > 0:
                ans[i] = two*3 - 1
                two -= 1
            elif one > 0:
                ans[i] = one*3 - 2
                one -= 1
            elif zero > 0:
                ans[i] = zero*3
                zero -= 1
            else:
                break
    else:
        print(*ans, sep=' ')
        exit()

if num_odd >= n/3*2:
    for i in range(n):

        if depth[i] % 2 == 0:
            if zero > 0:
                ans[i] = zero*3
                zero -= 1
        else:
            if two > 0:
                ans[i] = two*3 - 1
                two -= 1
            elif one > 0:
                ans[i] = one*3 - 2
                one -= 1
            elif zero > 0:
                ans[i] = zero*3
                zero -= 1
            else:
                break
    else:
        print(*ans, sep=' ')
        exit()


for i in range(n):
    if depth[i] % 2 == 0:
        if one > 0:
            ans[i] = one*3 - 2
            one -= 1
        elif zero > 0:
            ans[i] = zero*3
            zero -= 1
        else:
            break
    else:
        if two > 0:
            ans[i] = two*3 - 1
            two -= 1
        elif zero > 0:
            ans[i] = zero*3
            zero -= 1
        else:
            break
else:
    print(*ans, sep=' ')
    exit()




Measured memory_bytes: 107556
input_S_T = list(input().split())
input_count = list(map(int,input().split()))
input_trash = input()

total_list = []

for i in range(input_count[0]):
    total_list.append(input_S_T[0])

for i in range(input_count[1]):
    total_list.append(input_S_T[1])

total_list.remove(input_trash)

print(total_list.count(input_S_T[0]),total_list.count(input_S_T[1]),end=' ')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;
void swp(int* x, int* y){
    int t = *x;
    *x = *y;
    *y = t;
}

int main(void){
    int MAX_N = 100001;
    int n;
    cin >> n;
    int p[MAX_N];
    int c = 0;


    for(int i=1; i<=n; i++){
        cin >> p[i];
    }

    for(int i = 1; i+1 <= n; i++){
        if(p[i] == i){
            swp(&p[i], &p[i+1]);
            c++;
        }
    }
    if(p[n] == n){
        c++;
    }

    cout << c << endl;
}


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

int data[99];

int solve(int n, int a, int b){

  if(!n) return abs(a-b);

  return min(solve(n-1, a+data[n], b), solve(n-1, a, b+data[n]));
}

int main(){

  int n;
  while(cin >> n, n){
    for(int i=1;i<=n;i++) cin >> data[i];
    cout << solve(n, 0, 0) << endl;
  }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	int a, b;
	
	cin >> a >> b;
	cin >> s;
	
	for (int i=0; i<s.size(); i++){
		if (i==a){
		   if (s[i]!='-'){
		      cout<< "No";
		      return 0;
		   }
		}
		else if (!isdigit(s[i])) {
		   cout << "No";
		   return 0;
	    }
	} 
	
	cout << "Yes";
	return 0;
}

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

int main(){
    int a;
    int b;
    char op;

    cin >> a >> op >> b;

    while(op != '?'){
        if (op == '+'){
          cout << a+b << endl;
        }else if(op == '-'){
          cout <<  a-b << endl;
        }else if(op == '*'){
          cout << a*b << endl;
        }else if(op == '/'){
          cout << a/b << endl;
        }
        cin >> a >> op >> b;
    }

    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int main(void)
{
  int H, W, h, w;
  cin >> H >> W;
  cin >> h >> w;
  
  int field = H * W;
  int spread = h * W + H * w;
  int dup = h * w;
  
  cout << field - spread + dup << endl;
  
  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    vector<int> group1 = {1, 3, 5, 7, 8, 10, 12};
    vector<int> group2 = {4, 6, 9, 11};
   
    int count1 = 0;
    for(int i = 0; i < group1.size(); i++)
    {
        if(group1[i] == x || group1[i] == y)
        {
            count1++;
        }
    }

    int count2 = 0;
    for(int i = 0; i < group2.size(); i++)
    {
        if(group2[i] == x || group2[i] == y)
        {
            count2++;
        }
    }

    if(count1 == 2 || count2 == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    string s;
    cin>>s;
    int ans=0;
    if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        ans=1;
    if((s[0]=='R' && s[1]=='R')||(s[1]=='R' && s[2]=='R'))
        ans=2;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        ans=3;
    cout<<ans<<"\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3572
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=200000+10;
int a[maxn];
int i,j,k,l,t,n,m;
ll ans;
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&a[i]);
		if (a[i]>i-1){
			printf("-1\n");
			return 0;
		}
		if (i>1&&a[i-1]<a[i]-1){
			printf("-1\n");
			return 0;
		}
		if (i>1){
			if (a[i]<=a[i-1]) ans+=(ll)a[i];
			else ans++;
		}
	}
	printf("%lld\n",ans);
}

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

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	double n = 0;
	std::vector<double> ans;

	while (std::cin >> n) {
		double sum = 0;
		double div = 600 / n;
		for (int i = 1; i < div; i++) {
			sum += n*(n*i)*(n*i);
		}
		ans.push_back(sum);
	}

	std::for_each(ans.begin(), ans.end(), [](int i) {std::cout << i << std::endl; });
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, x, m;
    cin >> n >> x >> m;
    vector<int> a;
    set<int> a_st;
    a.push_back(x);
    a_st.insert(x);
    for(int i=0; i<m; i++){
        x = (x*x) % m;
        if(a_st.find(x) != a_st.end()){
            break;
        }
        a.push_back(x);
        a_st.insert(x);
    }

    int start = 0;
    while(x != a[start]) start++;
    int ans = 0;
    if(n < start){
        for(int i=0; i<n; i++){
            ans += a[i];
        }
    }
    else{
        for(int i=0; i<start; i++){
            ans += a[i];
        }
        int fac = (n-start) / (a.size() - start);
        for(int i=start; i<a.size(); i++){
            ans += a[i] * fac;
        }
        for(int i=start; i<start+(n-start) % (a.size() - start); i++){
            ans += a[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5988
// =================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// =================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=2000+10;

struct Edge { int v,nxt; } e[N];
int head[N];

inline void addEdge(int u,int v) {
    static int cnt=0;
    e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
}

int n;
int a[N],vis[N],deg[N];
int G[N][N];

inline void dfs(int u) {
    vis[u]=1;
    for (re int i=1;i<=n;++i) {
        if (vis[i]||!G[u][i]) continue;
        ++deg[i],addEdge(u,i);
        dfs(i);
    }
}

inline void topsort() {
    priority_queue<int> Q;
    for (re int i=1;i<=n;++i)
        if (!deg[i]) Q.push(i);
    while (!Q.empty()) {
        int u=Q.top(); Q.pop();
        printf("%d ",a[u]);
        for (re int i=head[u];i;i=e[i].nxt) Q.push(e[i].v);
    }
}

int main() {
    n=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1);
    for (re int i=1;i<=n;++i)
        for (re int j=i+1;j<=n;++j) {
            if (__gcd(a[i],a[j])==1) continue;
            G[i][j]=G[j][i]=1;
        }
    for (re int i=1;i<=n;++i)
        if (!vis[i]) dfs(i);
    topsort();
    return 0;
}


Measured memory_bytes: 16256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll k, n; cin >> k >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a);

  ll ans = a[n-1]-a[0];
  for (int i = 1; i < n; i++) {
    // debug3(abs(a[i]-a[n-1]), abs(a[n-1]-k), a[i-1]);
    ans = min(ans, abs(a[i]-a[n-1]) + abs(a[n-1]-k) + a[i-1]);
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    char aTop, bTop,cTop;
    
    aTop=a.at(0);
    bTop=b.at(0);
    cTop=c.at(0);
    
    cout << aTop << bTop << cTop<< endl;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include"bits/stdc++.h"
using namespace std;
 
#define input_from_file freopen("inp.txt","r",stdin)
#define output_to_file freopen("out.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)

int main() {
	#ifdef LOCAL 
	input_from_file; 
	output_to_file; 
	#endif
   
    fastio;cin.tie(0);cout.tie(0);
	long long int h,n;
	cin >> h>>n;

	vector<long long int>A(n);

	for(int i=0;i<n;i++)
		cin>>A[i];

	long long int c=0,i=0;

	for(i=0;i<n;i++)
	{
		c+=A[i];
		if(c>=h)
			break;
	}

	if(i<n)
		cout<<"Yes";
	else cout<<"No";

	
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

typedef struct node_t {
	int val;
	struct node_t *prev, *next;
} node;

node* new_node(int val) {
	static int it = 0;
	static node pool[500100];
	pool[it] = (node){ val, NULL, NULL };
	return &pool[it++];
}

int main(void)
{
	int q, com, x, cnt = 0;
	node *st = new_node(0), *it = st, *tmp;
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &com);
		if (com == 0) {
			scanf("%d", &x);
			tmp = new_node(x);
			if (it == st) st = tmp;
			tmp->next = it;
			tmp->prev = it->prev;
			if (it->prev) it->prev->next = tmp;
			it->prev = tmp;
			it = tmp;
			++cnt;
		}
		else if (com == 1) {
			scanf("%d", &x);
			if (x >= 0) {
				while (x--) it = it->next;
			}
			else {
				x = -x;
				while (x--) it = it->prev;
			}
		}
		else {
			tmp = it;
			it = it->next;
			if (tmp == st) st = it;
			if (tmp->prev) tmp->prev->next = it;
			it->prev = tmp->prev;
			--cnt;
		}
	}
	while (st->next) {
		printf("%d\n", st->val);
		st = st->next;
	}
	return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&i:a)cin>>i;
	sort(a.begin(),a.end());
	int ai=a.back(),aj=a.front(); double abm=abs(ai-aj*2);
	for(auto&taj:a){
		int tmp=abs(ai-taj*2);
		if(tmp>=abm)continue;
		aj=taj,abm=tmp;
	}
	cout<<ai<<" "s<<aj<<"\n"s;
}

Measured memory_bytes: 640
// Problem : D - Friend Suggestions
// Contest : AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define MAXN 100000

int id = 0, component[MAXN], compSz[MAXN];
vector<int> fri[MAXN], block[MAXN];

void dfs(int u) {
    component[u] = id;
    compSz[id]++;
    for (int v : fri[u])
        if (component[v] == -1)
            dfs(v);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n, m, k;
    cin >> n >> m >> k;
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        fri[a-1].push_back(b-1);
        fri[b-1].push_back(a-1);
    }
    for (int i=0; i<k; i++) {
        int c, d;
        cin >> c >> d;
        block[c-1].push_back(d-1);
        block[d-1].push_back(c-1);
    }
    
    memset(component, -1, sizeof(component));
    for (int i=0; i<n; i++) {
        if (component[i] == -1) {
            dfs(i);
            id++;
        }
        int ret = compSz[component[i]] - 1;
        for (int v : fri[i])
            if (component[v] == component[i])
                ret--;
        for (int v : block[i])
            if (component[v] == component[i])
                ret--;
        cout << ret << (i == n - 1 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 12288
#include <iostream>                                                              
#include <algorithm>                                                             
#include <cstring>                                                               
#include <vector>                                                                
#include <numeric>                                                               
#include <cstdlib>                                                               
#include <queue>                                                                 
#include <stack>                                                                 
#include <climits>                                                               
using namespace std;                                                             
                                                                                 
typedef long long ll;                                                            
#define pb push_back                                                             
                                                                                 
#define rep(i, n) for (int i=0;i<(n);++i)                                        
#define rep2(i, s, n) for (int i=s;i<(n);++i)                                    
#define rev(i, n) for (int i=(n);i>0;--i)                                        
#define INF (1e9+1e9)                                                            
                                                                                 
int main() {                                                                     
    string s; cin >> s;                                                          
                                                                                 
    for (int i =0; i < s.length()-8; ++i) {                                      
        cout << s[i];                                                            
    }                                                                            
    cout << endl;                                                                
}                                                                                
   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n;
	while(cin >> n && n) {
		string t = "I";

		rep(i, n) t += "OI";
		
		int m;
		cin >> m;

		string s;
		cin >> s;

		vector<string> res;
		rep(i, m) {
			if(s[i] == 'I') {
				string l = "I";
				REP(j, i, m-2) {
					if(s[j+1] == 'O' && s[j+2] == 'I') {
						i += 2;
						j++;
						l += "OI";
					} else break;
				}

				if(l == "I") continue;
				res.push_back(l);
			}
		}

		int ans = 0;
		rep(i, res.size()) {
			if(res[i].size() >= t.size()) {
				int cnt = res[i].size() - t.size();
				ans += cnt / 2 + 1;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<string, int> mp;
  rep(i, n) {
    string ss = s[i];
    sort(ss.begin(), ss.end());
    mp[ss]++;
  }
  ll anaCount = 0;
  for (auto m : mp) {
    ll cnt = m.second;
    anaCount += (cnt * (cnt - 1) / 2);
  }
  cout << anaCount << endl;

  return 0;
}


Measured memory_bytes: 18176
s = input()

t, a = 0, 1
mod = [0]*2019
mod[0] = 1
s = s[::-1]
n = len(s)
for i in range(n):
    t += int(s[i]) * a
    t %= 2019
    a *= 10  #a *= 2019 <- TLE
    a %= 2019
    mod[t] += 1
ans = 0

for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

Measured memory_bytes: 9268
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#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, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

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;

int dig_sum(int x){

    int sum=0;
    while(x){
        sum += (x%10);
        x /= 10;
    }
    return sum;
}

int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int mini=INT_MAX;
    for(int a=1;a<n;a++){
        int b = n-a;
        mini = min(mini, dig_sum(a)+dig_sum(b));
    }
    cout<<mini<<endl;
    return 0;
}



Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n;
  cin >> n;
  vector<int> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  vector<int> front(n + 1), back(n + 2);
  for (int i = 0; i < n; i++) {
    front[i + 1] = __gcd(front[i], in[i]);
  }
  reverse(in.begin(), in.end());
  for (int i = 0; i < n; i++) {
    back[i + 1] = __gcd(back[i], in[i]);
  }
  reverse(back.begin(), back.end());
  for (int i = 0; i <= n; i++) {
    cerr << front[i] << " ";
  }
  cerr << endl;
  for (int i = 0; i <= n; i++) {
    cerr << back[i] << " ";
  }
  cerr << endl;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, __gcd(front[i - 1], back[i + 1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
 
int main(void)
{
    long N, i, total=0;

    scanf("%ld", &N);

    for(i=1; i<=N; i++) {
        if(i%3 == 0 || i%5 == 0) {
            continue;
        } else {
            total += i;
        }
    }

    printf("%ld\n", total);
    
    return 0;
}

Measured memory_bytes: 1696
import java.util.*;
public class Main {
	static int a[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 public static void main(String args[])
 {
	 Scanner input=new Scanner(System.in);
	 int k=input.nextInt();
	 System.out.println(a[k-1]);
 }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair <int, int> pii;

const int INF = 0x3f3f3f3f;
int n, m, r, t1, t2, t3, d[100005];
pii p1;
vector <pii> v[100005];
priority_queue <pii, vector <pii>, greater <pii>> q;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> r;
	for (int i = 0; i < n; i++) d[i] = INF;
	for (int i = 0; i < m; i++) {
		cin >> t1 >> t2 >> t3;
		v[t1].pb(mp(t2, t3));
//		v[t2].pb(mp(t1, t3));
	}
	d[r] = 0;
	q.push(mp(0, r));
	while (!q.empty()) {
		p1 = q.top(); q.pop();
		int &w = p1.fi, &u = p1.se;
		if (d[u] != w) continue;
		for (pii i : v[u]) {
			if (w + i.se < d[i.fi]) {
				d[i.fi] = w + i.se;
				q.push(mp(d[i.fi], i.fi));
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (d[i] == INF) cout << "INF" << endl;
		else cout << d[i] << endl;
	}
}



Measured memory_bytes: 12976
/*Author : Prokash
           JU CSE 48
           CF: epiprokash
           UVa: epiprokash
*/

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,in,match=1,brick=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>in;
        if(match==in)
        {
            match++;
        }
        else
        {
            brick++;
        }
    }
    if(match==1&&brick!=0)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<brick<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        int odd = (N + 1) / 2;
        double ans = (odd * 1.0) / N;

        System.out.printf("%.10f", ans);
    }
}


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

stack<char>a,b,c;

int func(char ch){
    if(ch=='a'){
            if(a.empty()==true){
            return 1;
        }
        char x=a.top();
        a.pop();

        func(x);
    }else if(ch=='b'){
        if(b.empty()==true){
            return 2;
        }
        char x=b.top();
        b.pop();

        func(x);
    }else{
        if(c.empty()==true){
            return 3;
        }
        char x=c.top();
        c.pop();

        func(x);
    }
}

int main(){
    string alice,bob,charlie;
    cin>>alice>>bob>>charlie;
    int x,y,z,r=0;
    x=alice.length();
    y=bob.length();
    z=charlie.length();
    for(int i=x-1;i>=0;i--){
        a.push(alice[i]);
    }
    for(int i=y-1;i>=0;i--){
        b.push(bob[i]);
    }
    for(int i=z-1;i>=0;i--){
        c.push(charlie[i]);
    }

       char n=a.top();
        a.pop();
        r=func(n);

    if(r==1){
        cout<<"A\n";
    }else if(r==2){
        cout<<"B\n";
    }else if(r==3){
        cout<<"C\n";
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
	int W, a, b;
	cin >> W >> a >> b;
	
	int ans = max(a, b) - (min(a, b) + W);

	if (ans < 0) ans = 0;

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int>G[10010];
vector<int>c(10010,0);
int num[10010];
bool used[10010];
int now_c=0;
int dfs(int s){
    if(used[s]){
        return 0;
    }else{
        used[s]=true;
    }

    num[s]=c[now_c];
    now_c++;

    for(int i=0; i<G[s].size(); i++){
        dfs(G[s][i]);
    }
    return 0;
}

int main() {
    int N; cin >> N;
    vector<int>h(N);
    string ans="Yes";
    rep(i,N){
        cin >> h[i];
    }

    int pre_h=0;

    for(auto &h_i : h){
        if(h_i>pre_h){
            h_i--;
        }
        pre_h=h_i;
    }

    pre_h=0;
    for(auto h_i : h){
        if(h_i<pre_h){
            ans="No";
            break;
        }
        pre_h=h_i;
    }


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

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
    if(i%2==1){
      a[i]=-a[i];
    }
  }
  vector<int> s(n);
  s[0]=a[0];
  repo(i, n-1){
    s[i]=a[i]+s[i-1];
  }
  vector<ll> ans(n);
  rep(i, n){
    if(i==0){
      ans[i]=s[n-1];
    } else if(i%2==1) {
      ans[i]=2*s[i-1]-s[n-1];
    } else {
      ans[i]=-2*s[i-1]+s[n-1];
    }

  }
  rep(i, n){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2944
n = int(input())

nums = list(map(int,input().split()))

nums.sort()
# print(n,nums)

index = 0
while index < n-1:
    nums.append((float)(nums.pop(0)+nums.pop(0))/2)
    nums.sort()
    index = index + 1

print(nums.pop(0))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

const int H = 1e6;
vector <int> gen(int N, int W) {
	if(W == N || W == 1) return {-1};
	vector <int> ret(N);
	for(int i = 0; i < N; i++) {
		if(i < W - 1) {
			ret[i] = H;
		} else if(i == W - 1) {
			ret[i] = -(W - 1) * H - 1;
		} else {
			ret[i] = ret[i % W];
		}
	}
	if(accumulate(all(ret), 0) <= 0) return {-1};
	return ret;
}
int main() {fio;
	ll H, W, h, w;
	cin >> H >> W >> h >> w;
	vector <int> G = gen(H, h);
	vector <int> R = gen(W, w);
	vector <vector <int> > ans(H, vector <int> (W, -1));
	bool r = (R[0] != -1), g = (G[0] != -1);
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			if(r) {
				ans[i][j] = R[j];
			} else if(g) {
				ans[i][j] = G[i];
			}
		}
	}

	if(!r && !g) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
		for(auto u : ans) {
			for(auto v : u) {
				cout << v << ' ';
			}
			cout << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 4228