akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

string s;

int a,b,c,d;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
   cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>s;
  a=s[0]-'0';
  b=s[1]-'0';
  c=s[2]-'0';
  d=s[3]-'0';
  for(int i=0;i<2;i++){
   for(int j=0;j<2;j++){
    for(int k=0;k<2;k++){
     int now=a;
     if(i==0)now+=b;
     else now-=b;
     if(j==0)now+=c;
     else now-=c;
     if(k==0)now+=d;
     else now-=d;
     if(now==7){
      cout<<a;
      cout<<(i==0?'+':'-');
      cout<<b;
      cout<<(j==0?'+':'-');
      cout<<c;
      cout<<(k==0?'+':'-');
      cout<<d;
      cout<<'=';
      cout<<7<<endl;
      return 0;
     }
    }
   }
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll x, n, p;
bool exist[105] = {};

int main() {
	cin >> x >> n;
	rep(i, n) {
		cin >> p;
		exist[p] = true;
	}
	rep(i, 105) {
		if (x - i >= 0 && !exist[x - i]) {
			cout << x - i << endl;
			return 0;
		}
		if (x + i < 105 && !exist[x + i]) {
			cout << x + i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;


string s;
bool ju = true;

int main() {
	
	cin >> s;
	for (int i = 0; i < 3; i++){
		if(s[i] == s[i + 1]) ju = false;
	}
	if(ju) cout << "Good" << endl;
	else cout <<"Bad" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e9+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;

ll n, mod = 998244353;
const ll MAX = 1e7 + 1;
vector<ll> v(MAX);

ll inv[MAX];

int main()
{
    ll N;
    cin >> N;
    ll D[100000 + 5];
    ll max = 0;
    
    
    rep(i,N){
        cin >> D[i];
        if (max < D[i]){
            max = D[i];
        }
    }
    if (D[0] != 0){
        cout << 0;
        return 0;
    }
    
    ll cnt[100000 + 5];
    rep(i, N)cnt[i] = 0;
    rep(i, N)cnt[D[i]]++;
    
    if (cnt[0] != 1){
        cout << 0;
        return 0;
    }
    ll ans = 1LL;
    ll prev = 1LL;
    for (int i = 1; i <= max; i++){
        if (cnt[i] == 0){
            cout << 0;
            return 0;
        }
        for (int j = 0; j < cnt[i]; j++){
            //(ans *= prev) %= mod;
            ans = (ans * prev) % mod;
        }
        prev = cnt[i];
    }
    cout << ans << endl;
    return 0;    
}


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

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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;

    rep(i, n) {
        mp[a[i]] ++;
    }

    ll ans = 0;
    for(auto v : mp) {
        if(v.second > v.first) {
            ans += v.second - v.first;
        } else if(v.second != v.first) {
            ans += v.second;
        }
    }
    cout << ans << endl;
    return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x=nil->next;
  while(x!=nil&&x->key!=key)
    {
      x=x->next;
    }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t=nil->prev;
  deleteNode(t);
}

void delete(int key){
  NodePointer t= listSearch(key);
  if(t==nil) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#include<stdio.h>
int main(){
  char s[11];
  char l;
  char longest = 0;
  char i;
  scanf("%s", s);
  for(i=0;i<11;i++){
    l=0;
    while(s[i+l]=='A'||s[i+l]=='T'||s[i+l]=='C'||s[i+l]=='G'){
      l++;
    }
    if(longest < l){
      longest = l;
    }
  }
  printf("%d",longest);
  return 0;
}

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

void solve() {
  string s;
  cin >> s;
  bool b = true;
  rep(i, s.length()) {
    if (i%2 == 0 && s[i] == 'L') b = false;
    else if (i%2 == 1 && s[i] == 'R') b = false;
    else continue;
  }
  if (b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  solve();
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a.begin(), a.end())

int main(){
    char ch;
    vector<int> cnt(26, 0);
    while(cin >> ch){
        if(ch >= 'a' && ch <= 'z')cnt[ch - 'a']++;
        else if(ch >= 'A' && ch <= 'Z')cnt[ch - 'A']++;
    }

    rep(i,26)
        printf("%c : %d\n", 'a'+i, cnt[i]);

    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 998244353;

ll solve(){
    int n;
    cin >>n;
    vector<int> d(n);
    rep(i,n) cin >>d[i];

    if(d[0] != 0) return 0;
    for(int i=1; i<n; ++i)if(d[i] == 0) return 0;

    vector<ll> ct(n);
    int md = 0;
    rep(i,n){
        ++ct[d[i]];
        md = max(md, d[i]);
    }

    ll ret = 1;
    for(int i=1; i<=md; ++i){
        rep(j,ct[i]) (ret *= ct[i-1]) %= mod;
    }
    return ret;
}

int main(){
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 1408
S = input()
res = "Yes"
if S.count('N') and not S.count('S'):
    res = "No"
if not S.count('N') and S.count('S'):
    res = "No"
if S.count('E') and not S.count('W'):
    res = "No"
if not S.count('E') and S.count('W'):
    res = "No"
print(res)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

double theta=M_PI/3;

struct P{
    double x,y;
};

void kochCurve(P p1, P p2, int iter){
    P s={p1.x+(p2.x-p1.x)/3,p1.y+(p2.y-p1.y)/3};
    P t={p1.x+2*(p2.x-p1.x)/3,p1.y+2*(p2.y-p1.y)/3};
    P u={s.x+(t.x-s.x)*cos(theta)-(t.y-s.y)*sin(theta),
         s.y+(t.x-s.x)*sin(theta)+(t.y-s.y)*cos(theta)};

    if(iter==0){
        printf("%.8lf %.8lf\n",p2.x,p2.y);
    }
    else if(iter==1){
        printf("%.8lf %.8lf\n",s.x,s.y);
        printf("%.8lf %.8lf\n",u.x,u.y);
        printf("%.8lf %.8lf\n",t.x,t.y);
        printf("%.8lf %.8lf\n",p2.x,p2.y);
    }
    else{
        kochCurve(p1,s,iter-1);
        kochCurve(s,u,iter-1);
        kochCurve(u,t,iter-1);
        kochCurve(t,p2,iter-1);
    }
}

int main()
{
    int n;
    cin >> n;
    P p1={0,0},p2={100,0};
    printf("%.8lf %.8lf\n",p1.x,p1.y);
    kochCurve(p1,p2,n);
    return 0;
}


Measured memory_bytes: 3340
#include <stdio.h>

#define MAX_COINS 20
#define MAX_DENOMINATIONS 50000
#define INF (1 << 30)

int main(int argc, char **argv) {
  int n, m, i, j, c[MAX_COINS], d[MAX_DENOMINATIONS+1];

  scanf("%d %d", &n, &m);
  for (i = 0; i < m; ++i) scanf("%d", &c[i]);
  for (i = 0; i <= n; ++i) d[i] = i > 0 ? INF : 0;
  for (i = 0; i < m; ++i) {
    for (j = c[i]; j <= n; ++j) {
      if (d[j] < d[j-c[i]]+1) continue;
      d[j] = d[j-c[i]] + 1;
    }
  }
  printf("%d\n", d[n]);
}


Measured memory_bytes: 2148
X = int(input())
if 400 <= X < 600:
   print(8)
elif 600 <= X < 800:
   print(7)
elif 800 <= X < 1000:
   print(6)
elif 1000 <= X < 1200:
   print(5)
elif 1200 <= X < 1400:
   print(4)
elif 1400 <= X < 1600:
   print(3)
elif 1600 <= X < 1800:
   print(2)
else:
   print(1)

Measured memory_bytes: 9112
#include <stdio.h>
#include <string.h>

int main(void){
  int i,j,k=0;
  char s[12],t[12];
  
  scanf("%s",s);
  scanf("%s",t);
  
  j=strlen(s);
  
  for(i=0;i<j;i++){
    if(s[i]==t[i])k++;
  }
  
  if(k==j){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}
  
  

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

int main(){
  long n;
  cin >> n;
  long keta = 0;
  long nn = n;
  rep(i,1000){
    if(nn<=pow(26,i+1)){
      keta = i+1;
      break;
    }
    nn -= pow(26,i+1);
  }
  int i = 1;
  while(n>pow(26,i)){
    n -= pow(26,i);
    i++;
  }
  n -= 1;
  string ans;
  rep(j,keta){
    ans.push_back('a'+n%26);
    n /= 26;
  }
  rep(i,int(ans.size()))cout << ans[int(ans.size())-1-i];
  return 0;
}

Measured memory_bytes: 4040
import java.lang.Math.hypot

fun main(args: Array<String>) = p15()

fun p15() {
    data class Xy(val x: Double, val y: Double)

    val n = readLine()!!.toInt()
    val xyList = Array(n) {
        val (x, y) = readLine()!!.split(' ').map { it.toDouble() }
        Xy(x, y)
    }

    val permutations = permutations((0 until n).toList())
    var answer = 0.0

    for (permutation in permutations) {
        var (currX, currY) = xyList[permutation.first()]
        for ((x, y) in permutation.drop(1).map { xyList[it] }) {
            answer += hypot(currX - x, currY - y)
            currX = x
            currY = y
        }
    }

    answer /= permutations.size

    println(answer)
}

private fun permutations(src: List<Int>): List<List<Int>> {
    if (src.size == 1) return listOf(src)
    val perms = mutableListOf<List<Int>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for (i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}


Measured memory_bytes: 46236
#include <iostream>

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll dp[1 << 21] = {};

int bitcnt(int x){
    int ret = 0;
    for(int i = 0; i < 21; i++) {
        if(x & 1) ret++;
        x >>= 1;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    dp[0] = 1;
    int a[n][n];
    ll i, j;
    for(i = 0; i < n;i++){
        for(j = 0; j < n;j++){
            cin >> a[i][j];
        }
    }

    for(i = 1; i < (1 << n);i++){
        int x = bitcnt(i);
        for(j = 0; j < n;j++){
            if(i >> j & 1 && a[x - 1][j]) dp[i] = (dp[i] + dp[i ^ (1 << j)]) % MOD;
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> ID(N);
    vector<map<int, int>> out(N);
    REP(i, 0, M) {
        int p, y;
        cin >> p >> y;
        ID[p - 1].push_back(y);
        out[p - 1][y] = i;
    }
    REP(i, 0, N) {
        sort(begin(ID[i]), end(ID[i]));
    }
    vector<lli> res(M);
    REP(i, 0, N) {
        REP(j, 0, ID[i].size()) {
            res[out[i][ID[i][j]]] = 1000000LL * (i + 1) + (j + 1);
        }
    }
    REP(i, 0, M) {
        lli tmp = res[i];
        vector<int> t(12);
        REP(j, 0, 12) {
            t[j] = tmp % 10;
            tmp /= 10;
        }
        reverse(begin(t), end(t));
        REP(j, 0, 12) {
            cout << t[j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int w,a,b;
  cin>>w>>a>>b;
  cout<<max(0,max(b-a-w,a-b-w))<<endl;
  return 0;
}


Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_8_A: Binary Search Tree I

#include <cstdio>

#define NDEBUG
#include <cassert>

class BinaryTree {
  struct Node {
    int key;
    Node* parent;
    Node* left = nullptr;
    Node* right = nullptr;
    Node(const int key, Node* parent) : key(key), parent(parent) { }
  };

  Node* root_ = nullptr;;
  
public:
  void insert_node(const int key)
  {
    Node** node_p = &root_;
    Node* parent = nullptr;
    while (*node_p) {
      parent = *node_p;
      if ((*node_p)->key > key) {
        node_p = &(*node_p)->left;
      } else if ((*node_p)->key < key) {
        node_p = &(*node_p)->right;
      } else {
        assert(!"duplicate key?");
      }
    }
    (*node_p) = new Node(key, parent);
  }

  void print_nodes() const
  {
    print_in_order(root_);
    std::puts("");
    print_pre_order(root_);
    std::puts("");
  }

private:
  void print_in_order(const Node* node) const
  {
    if (node == nullptr)
      return;
    print_in_order(node->left);
    std::printf(" %d", node->key);
    print_in_order(node->right);
  }

  void print_pre_order(const Node* node) const
  {
    if (node == nullptr)
      return;
    std::printf(" %d", node->key);
    print_pre_order(node->left);
    print_pre_order(node->right);
  }
};

int main()
{
  unsigned int n;
  std::scanf("%u", &n);
  BinaryTree tree;

  for (auto i = 0u; i < n; ++i) {
    char buf[6+1]; // "insert".size() + 1('\0')
    int k;
    std::scanf("%6s", buf);
    if (buf[0] == 'p') { // print
      tree.print_nodes();
    } else { // insert k
      std::scanf("%d", &k);
      tree.insert_node(k);
    }
  }
}

// eof

Measured memory_bytes: 26020
#include<bits/stdc++.h>
using namespace std;
int n,k;
int l[51];
int main(){
  int ans=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  sort(l,l+n);
  for(int i=n;i>=n-k;i--){
    ans+=l[i];
  }
  cout<<ans<<endl;
  return 0;

}


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

#define ll long long 
const ll MOD = 1e9 + 7;
ll ans[51][51][2510];
bool found[51][51][2510];
int n, k;

ll mul(ll a, ll b){
	return (a*b)%MOD;
}

ll dp(int pos, int open, int rem){
	if(open < 0 || rem < 0)
		return 0LL;
	if(pos == n){
		return (open == 0 && rem == 0) ? 1LL: 0LL;
	}
	if(found[pos][open][rem])
		return ans[pos][open][rem];
	found[pos][open][rem] = true;

	// Transisi 1: Pos ke pasangan pos
	ll tmpAns = dp(pos+1, open, rem-open);
	// Transisi 2: Pos ke kanan, pasangan ke kanan
	tmpAns = (tmpAns+dp(pos+1, open+1, rem-open-1))%MOD;
	// Transisi 3: Pos ke kanan, pasangan ke kiri
	if(open > 0)
		tmpAns = (tmpAns+mul(dp(pos+1, open, rem-open), open))%MOD;
	// Transisi 4: Pos ke kiri, pasangan ke kanan
	if(open > 0)
		tmpAns = (tmpAns+mul(dp(pos+1, open, rem-open), open))%MOD;
	// Transisi 5: Pos ke kiri, pasangan ke kiri
	if(open > 0)
		tmpAns = (tmpAns+mul(dp(pos+1, open-1, rem-open+1), open*open))%MOD;
	return ans[pos][open][rem] = tmpAns;
}

void reset(){
	memset(found, 0, sizeof found);
	memset(ans, 0, sizeof ans);
}

void work(){
	reset();
	if(k%2 == 0)
		printf("%lld\n", dp(0, 0, k/2));
	else
		printf("0\n");
}

int main(){
	scanf("%d %d", &n, &k);
	work();
}

Measured memory_bytes: 57728
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
const int C = 20000;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (auto &ai: a) for (auto &aij: ai) cin >> aij;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        int b; cin >> b;
        a[i][j] = abs(a[i][j] - b);
    }
    vector<vector<bitset<C * 2>>> dp(h, vector<bitset<C * 2>>(w));
    dp[0][0].set(C + a[0][0]);
    dp[0][0].set(C - a[0][0]);
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (i + 1 < h) {
            dp[i + 1][j] |= dp[i][j] << a[i + 1][j];
            dp[i + 1][j] |= dp[i][j] >> a[i + 1][j];
        }
        if (j + 1 < w) {
            dp[i][j + 1] |= dp[i][j] << a[i][j + 1];
            dp[i][j + 1] |= dp[i][j] >> a[i][j + 1];
        }
    }
    for (int k = 0; k < C; k++) if (dp[h - 1][w - 1][C + k]) {
        cout << k << endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 32000
ans = Array.new(4, 0)
gets(p).split("\n").map do |line|
    ta, tb, tc = line.split.map(&:to_i)
    c = [ta, tb, tc].max
    a = [ta, tb, tc].min
    b = ta + tb+ tc - a - c
    if a + b > c and b + c > a and c + a > b then
        ans[0] += 1
        if a ** 2 + b ** 2 == c ** 2 then
            ans[1] += 1
        elsif a ** 2 + b ** 2 > c ** 2 then
            ans[2] += 1
        elsif a ** 2 + b ** 2 < c ** 2 then
            ans[3] += 1
        end
    else
        puts "%d %d %d %d" % ans
        exit
    end
end

puts "%d %d %d %d" % ans


Measured memory_bytes: 6892
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            long A = scanner.nextLong();
            long B = scanner.nextLong();
            long xor = A;

            if (B - A < 0) {
                for (long i = A + 1; i <= B; i++) {
                    xor = xor ^ i;
                }
                System.out.println(xor);
            } else {
                long skipL = ((A / 4) + 1) * 4;
                long skipR = (B / 4) * 4 - 1;
                for (long i = A + 1; i < skipL; i++) {
                    xor = xor ^ i;
                }
                for (long i = skipR + 1; i <= B; i++) {
                    xor = xor ^ i;
                }
                System.out.println(xor);
            }
        }
    }
}


Measured memory_bytes: 23252
def isPos(p,x,y):
    return ((x-p).conjugate()*(y-p)).imag>0

try:
    while True:
        X=list(map(float,input().split()))
        a,b,c,p=map(lambda x:complex(*x),[X[:2],X[2:4],X[4:6],X[6:]])
        print(['NO','YES'][isPos(p,a,b)==isPos(p,b,c)==isPos(p,c,a)])
except EOFError: pass


Measured memory_bytes: 5596
/*
  Contest 067
  C - Splitting Pile
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

using ll = long long int;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);
    ll n = 0;
    std::cin >> n;
    std::vector<ll> v;
    ll total = 0;
    while (n--) {
        ll e = 0;
        std::cin >> e;
        v.emplace_back(e);
        total += e;
    }

    ll min = (1e+16) + 1;
    ll left_sum = v[0];
    for (std::size_t i = 1; i < v.size(); ++i) {
        ll right_sum = total - left_sum;
        min = std::min(min, std::abs(right_sum - left_sum));
        left_sum += v[i];
    }
    std::cout << min << std::endl;

    return 0;
}


Measured memory_bytes: 5296
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

struct Vertex{
	int parent;
	int depth;
	string type;
	list<int> children;
};

int main(){
	int n, k, tmp, num, parnt;
	Vertex u[100000];
	scanf("%d", &n);
	REP(i, n){
		u[i].parent = -1;
	}
	REP(i, n){
		scanf("%d %d", &num, &k);
		REP(j, k){
			scanf(" %d", &tmp);
			u[num].children.push_back(tmp);
			u[tmp].parent = num;
		}
	}

	

	REP(i, n){
		if (u[i].parent == -1){
			u[i].type = "root";
			parnt = i;
		}
		else if (u[i].children.size() == 0){
			u[i].type = "leaf";
		}
		else{
			u[i].type = "internal node";
		}
	}

	

	REP(i, n){
		int d = 0, p = i;
		while (p != parnt){
			d++;
			p = u[p].parent;
		}
		u[i].depth = d;
	}

	
	//node id : parent = p, depth = d, type, [c1...ck]
	REP(i, n){
		printf("node %d: parent = %d, depth = %d, ", i, u[i].parent, u[i].depth);
		cout << u[i].type << ", [";
		for(auto j = u[i].children.begin(); j != u[i].children.end(); ++j){
			if (j != u[i].children.begin()){
				printf(", ");
			}
			cout << *j;
		}
		printf("]\n");
	}

	return 0;
}


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

int main() {
	int A, B, C, D;
 	cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
  	cout << "Left" << endl;
  }
  else if (A + B == C + D) {
  	cout << "Balanced" << endl;
  }
  else {
  	cout << "Right" << endl;
  }
}

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

int main() {

    string s;
    int cnt = 0; 

    cin >> s;

    for (int i = 0; i < s.size(); i++) {

        if (s[i] == '1'){
            cnt = cnt + 1;
        }
    }

    cout << cnt << endl;

    return 0;

}

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

int main(){
  int a,b,c,d,e;
  map<int ,int> data,result;
  cin>>a>>b;
  //データの読み込み
  for(int i=1;i<a+1;i++){
    cin>>c;
    data[i]=c;
    result[i]=1;
  }
  //データの処理
  for(int i=0;i<b;i++){
    cin>>c>>d;
    
    if(data[c]>data[d]){

      result[d]=0;
    }
    else if(data[c]<data[d]){

      result[c]=0;
    }
    else if(data[c]==data[d]){

      result[c]=0;
      result[d]=0;
    }
    
  }
  
  e=0;
  for(int i=1;i<a+1;i++){
    if(result[i]==1)e+=1;
  }
  cout<<e<<endl;
}

Measured memory_bytes: 12916
import java.util.Scanner;

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

        String s = sc.next();
        String t = sc.next();

        StringBuilder sb = new StringBuilder();
        sb.append(t);
        sb.setLength(t.length() - 1);

        if(sb.toString().equals(s)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

int h[100004],n,ans,k,dp[100003];
int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		cin>>h[i];
	}
    dp[1]=0;
	for (int i=2;i<=n;i++){
	   dp[i]= 1e9; 
	   for (int j=max(1,i-k);j<i;j++){
	       dp[i]=min(dp[i],(dp[j]+abs(h[i]-h[j])));
	   }
	}
	cout<<dp[n]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		for(int i = 0; i < k; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int min = a-1;
			min = Math.min(min, b-1);
			
			min = Math.min(min, n - a);
			min = Math.min(min, n - b);
			
			System.out.println((min % 3)+1);
			
		}
		
		
		
	}

	
	
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);

  ll a, b;
  if (X == 1) {
    a = 300000;
  } else if (X == 2) {
    a = 200000;
  } else if (X == 3) {
    a = 100000;
  } else {
    a = 0;
  }
  if (Y == 1) {
    b = 300000;
  } else if (Y == 2) {
    b = 200000;
  } else if (Y == 3) {
    b = 100000;
  } else {
    b = 0;
  }
  if (X == 1 && Y == 1) {
    a += 400000;
  }
  put(a + b);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
io = STDIN
def check(s)
  size=s.size
  (1..size).each do |i|
    pos=size-i
      ss = s[0...(pos)]
      sz = ss.size
      if sz.even?
      return ss if ss[0...sz/2]==ss[(sz/2)..-1]
    end
  end
end
s=io.gets.chomp
puts check(s).size

Measured memory_bytes: 1788
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

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

    string a, b;
    cin >> a >> b;

    const auto n1 = a.size();
    const auto n2 = b.size();
    vector<vector<int>> dp(n1 + 1, vector<int>(n2 + 1));
    vector<vector<pair<int, int>>> path(n1 + 1, vector<pair<int, int>>(n2 + 1));

    for (size_t i = 1; i <= n1; ++i) {
        for (size_t j = 1; j <= n2; ++j) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] += dp[i - 1][j - 1] + 1;
                path[i][j] = {i - 1, j -1};
            }
            else {
                if (dp[i - 1][j] > dp[i][j]) {
                    dp[i][j] = dp[i - 1][j];
                    path[i][j] = {i - 1, j};
                }
                if (dp[i][j - 1] > dp[i][j]) {
                    dp[i][j] = dp[i][j - 1];
                    path[i][j] = {i, j - 1};
                }
            }
        }
    }

    string res;
    size_t i = n1, j = n2;
    while (i >= 1 and j >= 1) {
        int k = path[i][j].first;
        int m = path[i][j].second;
        if (dp[i][j] == dp[k][m]) {
            i = k;
            j = m;
        }
        else {
            i = k;
            j = m;
            res.push_back(a[i]);
        }
    }

    reverse(res.begin(), res.end());
    cout << res;
}


Measured memory_bytes: 105984
// https://atcoder.jp/contests/abc154/tasks/abc154_a
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn main() {
    input! {
        s: chars, t: chars,
        a: i32, b: i32,
        u: chars
    };

    if s == u {
        println!("{} {}", a-1, b);
    } else {
        println!("{} {}", a, b-1);
    }
}


Measured memory_bytes: 4352
H, W, M = map(int, input().split())
HW = [list(map(int, input().split())) for i in range(M)]

g_h = [0] * (H+1)
g_w = [0] * (W+1)

for h, w in HW:
    g_h[h] += 1
    g_w[w] += 1

mxh = max(g_h)
mxw = max(g_w)

cnt = 0
for h, w in HW:
    if g_h[h] == mxh and g_w[w] == mxw:
        cnt += 1
if cnt == g_h.count(mxh) * g_w.count(mxw):
    print(mxh + mxw - 1)
else:
    print(mxh + mxw)

Measured memory_bytes: 68172
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include <assert.h>

int main(void){
		long long int a,b;
		long long int c;

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

long long int d = a/b;
		a = a-(d*b);

long long int tmp2;
	while(1){
			tmp2 = llabs(a);
			a = a-b;
			if(tmp2 <=llabs(a)){
				c = tmp2;
				break;
			}
		}



printf("%lld\n",llabs(c));

		return 0;
}


Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var arr1=Arr[1].split(" ").map(Number);
var arr2=Arr[3].split(" ").map(Number);

const linearSearch = (key, arr) => typeof arr.find(e => e == key) !== 'undefined' ? 1 : 0;
console.log(arr2.map(e => linearSearch(e, arr1)).reduce((a, b) => a + b, 0));





Measured memory_bytes: 19856
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& u : a) cin >> u;
  int cnt = 0;
  rep(i, n) if (a[i] != i + 1) cnt++;
  if(cnt==0||cnt==2)cout<<"YES"<<endl;
  else
    cout << "NO" << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    int wf[10][10];
    rep(i, 10){
        rep(j, 10){
            int num; cin >> num;
            wf[i][j] = num;
        }
    }
    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, H){
        rep(j, W){
            int num; cin >> num;
            if(num != -1) ans += wf[num][1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int x = 0;
    for(int i=0; i<N; ++i) {
        cin >> a[i];
        x ^= a[i];
    }

    int res = 0;
    for(int k=30; k>0; --k) {
        if((x >> (k - 1)) & 1) {
            bool flag = true;
            for(int i=0; i<N; ++i) {
                if((a[i] ^ (a[i] - 1)) == ((1 << k) - 1)) {
                    ++res;
                    x ^= a[i] ^ (a[i] - 1);
                    flag = false;
                    break;
                }
            }
            if(flag) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
const int mod=(int)1e9+7;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    int N,m=0,max,ctr=0;
    cin>>N; 
    for(int x=1;x<=N;x++){
        ctr=0;
        if(x%2==0){ int i=x;
            while(i%2==0){
                ctr++;
                i/=2;
            }
            if(ctr>m){
                m=ctr;
                max=x;
            }
        }
    }
    if(N!=1)
    cout<<max;
    else cout<<1;
	return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	if (b > 0) {
		cout << ((2*b + a - 1) * a / 2) - b << endl;
	}
	else if (a + b - 1 < 0) {
		cout << ((2*b + a - 1) * a / 2) - (a + b - 1) << endl;
	}
	else {
		cout << (2*b+a-1)*a/2 << endl;
	}
}

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

using namespace std;

int main() {
    int a,b;
    string ans = "";
    cin >> a;
    cin >> b;
    if(a < b){
        for(int i = 0; i < b; i++){
            ans += to_string(a);
        }
    }
    else{
        for(int i = 0; i < a; i++){
            ans += to_string(b);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x)  // cout << #x << " = " << (x) << endl;

int main() { IO;
  int n, x, y, z;
  cin >> n >> x >> y >> z;

  vector<int> v(n);
  for (auto &x : v) cin >> x;

  int limit = 1;
  for (int k = 1; k <= n; ++k) limit *= 4;

  int ans = numeric_limits<int>::max();
  for (int mask = 0; mask < limit; ++mask) {
    D(mask);
    vector<int> a, b, c;
    int t = mask;
    for (int i = 0; i < n; ++i) {
      int index = t % 4;
      t /= 4;
      D(index);

      switch (index) {
      case 1: a.push_back(v[i]); break;
      case 2: b.push_back(v[i]); break;
      case 3: c.push_back(v[i]); break;
      }
    }

    if (!a.size() or !b.size() or !c.size()) {
      continue;
    }

    int A = accumulate(a.begin(), a.end(), 0);
    int B = accumulate(b.begin(), b.end(), 0);
    int C = accumulate(c.begin(), c.end(), 0);

    D(A); D(B); D(C);

    int cost = 10 * (a.size() - 1 + b.size() - 1 + c.size() - 1);
    cost += abs(A - x) + abs(B - y) + abs(C - z);
    D(cost);

    ans = min(ans, cost);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

int main()
{
    int n;
	db ans;
	sc(n);
	if(n%2==0)ans=1.0/2;
	else ans=(n/2+1)*1.0/n;
	printf("%.10f\n",ans);
    return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int N, A, B;
  string s;
  cin >> N >> A >> B >> s;

  int a = 0, b = 0;

  forr(c, s) {
    if (c == 'c') {
      puts("No");
    }
    else if (c == 'a') {
      if (a < A+B) {
        puts("Yes");
        a++;
      }
      else {
        puts("No");
      }
    }
    else if (c == 'b') {
      if (a < A+B && b < B) {
        puts("Yes");
        a++;
        b++;
      }
      else {
        puts("No");
      }
    }
  }
  
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 848
#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>;

const int codei[4] = {1, 1, -1, -1};
const int codej[4] = {-1, 1, -1, 1};

int main() {
    vector<int> num = {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};
    ll K;
    cin >> K;
    cout << num.at(K-1) << endl;
}


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

int main(){
  string S; cin >> S;
  
  for(int i = 0; i < S.size(); i++){
    if(i%2 == 0){ //偶数
      if(S[i] == 'L') {cout << "No"; return 0;}
    }
    else{ //奇数
      if(S[i] == 'R') {cout << "No"; return 0;}
    }
    
  }
  
  cout << "Yes";
  
  return 0;
}

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

const int MOD = 1e9 + 7;

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

	ll p = 1;
	rep(i, 1, n + 1) {
		p *= i; p %= MOD;
	}

	cout << p % MOD << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
k = [0]
result = [0] * N

for i in range(N-1):
  if S[i] != S[i+1]:
    k.append(i+1)
l = [k[i+1] - k[i] for i in range(len(k) - 1)] + [N - k[-1]]

for i in range(1, len(k), 2):
  result[k[i]] += (l[i] + 1) // 2 + l[i-1] // 2
  result[k[i]-1] += l[i] // 2 + (l[i-1] + 1) // 2
print(*result)


Measured memory_bytes: 50252
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  int K,i;scanf("%d",&K);
  int now = 0;
  for(i=1;i<=1000000;i++){
    now = (now*10+7)%K;
    if(now == 0){
      printf("%d\n",i);
      return 0;
    }
  }
  printf("-1\n");
}

Measured memory_bytes: 3824
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

n =inp[0]
a = [0]+inp
t = na(n+1,0)
ft = na(n+1,false)
ans = []
(1..n).reverse_each do |i|
  d = i*(n/i)
  d += i
  c = 0
  while d > i
    d -= i
    c += t[d]
    next if(ft[d])
    ft[d] = true
    if(c % 2 != a[i])
      t[i] = 1
      ans.push(i)
    end
  end
end
puts ans.size
puts ans.join(" ") if(ans.size > 0)

Measured memory_bytes: 27084
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
print(((-1)*n)%1000)

Measured memory_bytes: 72716
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
#define ALL(x) (x).begin(),(x).end()

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

void solve(long long N, long long K, long long Q, std::vector<long long> A){
  REP(i, N) {
    cout << ((((K - Q) + A[i]) > 0) ? YES : NO) << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> A(N,0);
  long long tmp;
  for(int i = 0 ; i < Q ; i++){
    cin >> tmp;
    A[tmp-1]++;
  }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 1408
class fenwick_tree_2d:
    def __init__(self, h, w):
        self.H = h
        self.W = w
        self.tree = [[0]*(w+1) for _ in range(h+1)]

    def init_array(self, A):
        for i in range(self.H):
            for j in range(self.W):
                self.add(i+1, j+1, A[i][j])

    def add(self, i, j, x):
        if i <= 0 or j <= 0:
            raise IndexError
        while i <= self.H:
            k = j
            while k <= self.W:
                self.tree[i][k] += x
                k += k & -k
            i += i & -i

    def sum_until(self, i, j):
        if i < 0 or j < 0:
            raise IndexError
        s = 0
        while i > 0:
            k = j
            while k > 0:
                s += self.tree[i][k]
                k -= k & -k
            i -= i & -i
        return s

    def sum_acc(self, h1, h2, w1, w2):
        """
        0 <= h1 < h2 <= H
        0 <= w1 < w2 <= W
        [h1,h2) * [w1,w2) の長方形区域の値の総和を返す
        """
        return self.sum_until(h2, w2) - self.sum_until(h2, w1) \
            - self.sum_until(h1, w2) + self.sum_until(h1, w1)


def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import deque
    H, W, T, Q = (int(i) for i in input().split())
    taikaki_set = fenwick_tree_2d(H, W)
    taikaki_baked = fenwick_tree_2d(H, W)

    Query_t = deque([])
    Query_h = deque([])
    Query_w = deque([])
    for _ in range(Q):
        t, c, *A = (int(i) for i in input().split())
        while Query_t and Query_t[0] <= t:
            Query_t.popleft()
            th = Query_h.popleft()
            tw = Query_w.popleft()
            taikaki_set.add(th, tw, -1)
            taikaki_baked.add(th, tw, 1)
        if c == 0:
            (h, w) = A
            taikaki_set.add(h, w, 1)
            Query_t.append(t+T)
            Query_h.append(h)
            Query_w.append(w)
        elif c == 1:
            (h, w) = A
            cur = taikaki_baked.sum_acc(h-1, h, w-1, w)
            if 0 < cur:
                taikaki_baked.add(h, w, -1)
        else:
            (h1, w1, h2, w2) = A
            baked = taikaki_baked.sum_acc(h1-1, h2, w1-1, w2)
            t_set = taikaki_set.sum_acc(h1-1, h2, w1-1, w2)
            print(baked, t_set)


if __name__ == '__main__':
    main()



Measured memory_bytes: 80036
OP = {'+': lambda a,b: a+b, '-': lambda a,b: a-b, '*': lambda a,b: a*b, '/': lambda a,b: a//b}

while True:
    a, op, b = [s for s in input().split()]
    if op == '?':
        break
    print(OP[op](int(a), int(b)))



Measured memory_bytes: 5604