akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int id = s.size()-1;
    while (id > 0) {
        string tmp;
        if (s[id] == 'r') {
            tmp = s.substr(id-5,6);
            if (tmp == "eraser") id -= 6;
            else {
                tmp = s.substr(id-6,7);
                if (tmp == "dreamer") id -= 7;
                else {cout << "NO" << endl; return 0;}
            }
        } 
        else if (s[id] == 'e') {
            tmp = s.substr(id-4,5);
            if (tmp == "erase") id -= 5;
            else {cout << "NO" << endl; return 0;}
        }
        else if (s[id] == 'm') {
            tmp = s.substr(id-4,5);
            if (tmp == "dream") id -= 5;
            else {cout << "NO" << endl; return 0;}
        }
        else {cout << "NO" << endl; return 0;}
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
a_list = [int(i) for i in input().split()]
A = [0, a_list[0]]
for i in range(1, N):
    A.append(A[-1] + a_list[i])
A_combination = []
for i in range(N + 1):
    for j in range(i + 1, N + 1):
        A_combination.append(A[j] - A[i])
x = 0
for i in range(40, 0, - 1):
    cnt = 0
    t = pow(2, i - 1)
    for A_i in A_combination:
        if ((x + t) & (A_i)) == (x + t):
            cnt += 1
        if cnt >= K:
            x += t
            break
print(x)

Measured memory_bytes: 107368
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    long long int N;
    cin >> N;
    vector<string> S(N);
    for(long long int i=0; i<N; ++i){
        cin >> S[i];
    }
    long long int num_M=0;
    long long int num_A=0;
    long long int num_R=0;
    long long int num_C=0;
    long long int num_H=0;
     for(long long int i=0; i<N; ++i){
        if(S[i][0]=='M'){
            ++num_M;
        }
        if(S[i][0]=='A'){
            ++num_A;
        }
        if(S[i][0]=='R'){
            ++num_R;
        }
        if(S[i][0]=='C'){
            ++num_C;
        }
        if(S[i][0]=='H'){
            ++num_H;
        }
    }
    int num=0;
    if(num_M>0){
            ++num;
        }
        if(num_A>0){
            ++num;
        }
        if(num_R>0){
            ++num;
        }
        if(num_C>0){
            ++num;
        }
        if(num_H>0){
            ++num;
        }
        long long int a[5];
        a[0]=num_M;
        a[1]=num_A;
        a[2]=num_R;
        a[3]=num_C;
        a[4]=num_H;
        sort(a,a+5,greater<int>());
        long long int x=0;
        int P [10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
        int Q [10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
        int R [10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};
        for(int i=0;i<10;++i){
            x+=a[P[i]]*a[Q[i]]*a[R[i]];
        }
    cout << x;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
bool check(string n){
  int l = n.length();
  int ans = 0;
  for(int i=0;i<l;i++) ans+=n[i]-'0';
  if(ans%9==0)return true;
  return false;
}
int32_t main(){
 
string n;
  cin>>n;
  if(check(n)) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3836
n = gets.to_i
b = gets.split(' ').map(&:to_i)
a = []
n.times do |i|
  if (i==0)
    a[i] = b[i]
  elsif (i == n-1)
    a[i] = b[i-1]
  else
    a[i] = b[i-1] < b[i] ? b[i-1] : b[i]
  end
end

puts a.inject(:+)

Measured memory_bytes: 1788
// In the name of God

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define Size(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<int , int>pii;
const int INF = 1e9 + 10;

int main(){
	ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	int A , B , C;
	cin >> A >> B >> C;
	if(A > B) swap(A , B);
	if(B > C) swap(B , C);
	if(A > B) swap(A , B);
	int ans = C-B;
	A += C-B;
	B = C;
	while(A < B) A += 2 , ans++;
	if(A ^ C) ans++;
	cout << ans << '\n';
	return 0;
}



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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << endl;
	return 0;
}

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

int main() {
    int n,a,b;cin>>n>>a>>b;
    int ans=0;
    for (int i=1;i<=n;i++) {
        int t=i,sum=0;
        while (t) {
            sum+=t%10;
            t/=10;
        }
        if (a<=sum&&sum<=b)
            ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;

ll a[1005][1005]; // 0-> # , 1-> .
ll dx[] = {0,0,-1,1};
ll dy[] = {-1,1,0,0};
bool vis[1005][1005];
ll n,m;

bool valid (ll i,ll j)
{
    if(i>=0 && i<n && j>=0 && j<m) return true;
    else return false;
}

int main() {
  cin>>n>>m; ll ans=0;
  ll a1,b,c,d;
  cin>>a1>>b>>c>>d;
  a1--,b--,c--,d--;
  for(ll i=0;i<n;i++)
  {
      string s;
      cin>>s;
      for(ll j=0;j<m;j++)
      {
          if(s[j]=='.') a[i][j]=1;
      }
  }
  deque<pair<pair<ll,ll>,ll>> q;
  q.push_front(mp(mp(a1,b),0));
  while(!q.empty())
  {
      pair <pair<ll,ll>,ll> p;
      p = q.front();
      pair <ll,ll> pos = p.fi;
      q.pop_front();
      ll x = pos.fi; ll y = pos.se;
      //if(q.empty()) cout<<"hi"<<endl;
      if(vis[x][y]) continue;
      if(x==c && y==d)
      {
          ans=1;
          cout<<p.se<<endl;
          break;
      }
      vis[x][y]=1;
      for(ll i=0;i<4;i++)
      {
          ll cx = x+dx[i]; ll cy = y+dy[i];
          if(valid(cx,cy) && !vis[cx][cy] && a[cx][cy])
          {
              //cout<<cx<<" "<<cy<<endl;
              q.push_front(mp(mp(cx,cy),p.se+0));
          }
      }
      for(ll i=-2;i<=2;i++)
      {
          for(ll j=-2;j<=2;j++)
          {
              ll cx = x+i; ll cy = y+j;
              if(valid(cx,cy) && !vis[cx][cy] && a[cx][cy])
            {
                //cout<<cx<<" "<<cy<<endl;
              q.push_back(mp(mp(cx,cy),p.se+1));
            }
          }
      }
  }
  if(ans==0) cout<<"-1"<<endl;
}


Measured memory_bytes: 13972
#include <stdio.h>

int main(void)
{
	int h,w,n,i,j,h1,w1;
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	int a[h][w],b[n];
	for(i=0;i<n;i++)
	  scanf("%d",&b[i]);
	
	h1=w1=0;
	for(i=0;i<n;i++)
	{
		while(b[i])
		{
			a[h1][w1]=i+1;
			if(w1==(w-1))
			{
				h1++;
				w1=0;
			}
			else
			  w1++;
			b[i]--;
		}
	}
	
	for(i=0;i<h;i++)
	  {
	    if(i%2==0)
	      for(j=0;j<w;j++)
	        printf("%d ",a[i][j]);
		else
		  for(j=w-1;j>=0;j--)
		    printf("%d ",a[i][j]);
		printf("\n");
	     
      }
      
    return 0;  	
}

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

int main(){
    ll k,x; cin >> k >> x;
    for(int i=x-(k-1);i<=x+(k-1);++i){
        cout << i << " ";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    int ans = n;
    set<int> s;
    for(int i = 0; i < m; i++)
    {
        map<int, int> tmp;
        for(int j = 0; j < n; j++)
        {
            for(int k = 0; k < m; k++)
            {
                if(s.count(a[j][k]) == 0)
                {
                    tmp[a[j][k]]++;
                    break;
                }
            }
        }
        int count = 0;
        int target = 0;
        for(auto itr = tmp.begin(); itr != tmp.end(); itr++)
        {
            if(itr->second > count)
            {
                count = itr->second;
                target = itr->first;
            }
        }
        ans = min(ans, count);
        s.insert(target);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {

	for (int i = 1; i <= 5;i++) {
		ll a;
		cin >> a;
		if (a==0) {
			cout << i;
		}
	}

	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int l = -2000000000;
        int r = 2000000000;
        long anss = 0;
        while (l < r) {

            int tmp = (l + r) / 2;

            int b = tmp;
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += Math.abs(a[i] - 1 - i - b);
            }

            b = tmp + 1;
            long ans2 = 0;
            for (int i = 0; i < n; i++) {
                ans2 += Math.abs(a[i] - 1 - i - b);
            }

            b = tmp - 1;
            long ans3 = 0;
            for (int i = 0; i < n; i++) {
                ans3 += Math.abs(a[i] - 1 - i - b);
            }

            if (ans3 >= ans && ans2 >= ans) {
                anss = ans;
                break;
            }
            if (ans2 < ans) {
                l = tmp;
            } else if (ans3 < ans) {
                r = tmp;
            }

            if (l >= r) {
                anss = Math.min(ans, Math.min(ans2, ans3));
            }
        }

        System.out.println(anss);

    }

}


Measured memory_bytes: 92260
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    string a[h];
    rep(i,h){
        cin>>a[i];
    }
    rep(i,w+2){
        cout<<"#";
    }
    cout<<endl;
    rep(i,h){
        cout<<"#"<<a[i]<<"#"<<endl;
    }
    rep(i,w+2){
        cout<<"#";
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>

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

using namespace std;

char s[1024],s_tmp[1024];
int x,y;

int idx,cnt;
string ans;
void parse(){
	int p;
	for(p=idx;s[p]!='>';p++);
	s[p]='\0';
	string tag=s+idx+1;
	idx=p+1;

	for(p=idx;s[p]!='<';p++);
	s[p]='\0';
	int t,l,b,r; sscanf(s+idx,"%d,%d,%d,%d",&l,&t,&r,&b);
	idx=p;

	if(t<=y && y<=b && l<=x && x<=r) ans=tag;

	int c=0;
	while(s[idx+1]!='/'){
		parse();
		c++;
	}
	if(ans==tag) cnt=c;

	for(;s[idx]!='>';idx++);
	idx++;
}

int main(){
	for(int q;scanf("%d%s",&q,s),q;){
		while(q--){
			strcpy(s_tmp,s);

			scanf("%d%d",&x,&y);
			idx=0;
			ans="";
			parse();
			if(ans=="") puts("OUT OF MAIN PANEL 1"); else printf("%s %d\n",ans.c_str(),cnt);

			strcpy(s,s_tmp);
		}
	}
	return 0;
}

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

int main() {
  int n;cin>>n;
  string hon[10];rep(i,10)hon[i]="hon";
  hon[0]="pon";
  hon[1]="pon";
  hon[6]="pon";
  hon[8]="pon";
  hon[3]="bon";
  cout<<hon[n%10];

}


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <array>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
#include <numeric>
#include <cassert>
using namespace std;

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

template <typename T>
constexpr T INF = "Undefined";
template <>
constexpr int INF<int> = 1e9;
template <>
constexpr ll INF<ll> = 1e18;
template <>
constexpr ld INF<ld> = 1e30;

constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    int W, H;
    cin >> H >> W;
    int cnt = 0;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            string S;
            cin >> S;
            if(S == "snuke") {
                cout << (char)('A' + j) << i+1 << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int a=Integer.parseInt(x);



		System.out.println((a/3600)+":"+(a%3600/60)+":"+(a%3600%60));
	}}

Measured memory_bytes: 26220
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int a[250010],p[510],s[510];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<=n;++i)a[p[i]=gi()]=i,s[i]=i;
	std::sort(s+1,s+n+1,[&](int a,int b){return p[a]<p[b];});
	int k=1;
	for(int _=1,i;_<=n;++_){
		i=s[_];
		for(int j=1;j<i;++j){
			while(k<p[i]&&a[k])++k;
			if(k==p[i])return puts("No"),0;
			a[k]=i;
		}
	}
	k=n*n;
	for(int _=n,i;_;--_){
		i=s[_];
		for(int j=i;j<n;++j){
			while(k>p[i]&&a[k])--k;
			if(k==p[i])return puts("No"),0;
			a[k]=i;
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;++i)printf("%d ",a[i]);
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>

using namespace std;

int main(){
        string a,b;
        cin>>a>>b;
        if(a.length()!=b.length()){
        	if(a.length()>b.length()){
        		cout<<"GREATER"<<endl;
        		return 0;
        	}else{
        		cout<<"LESS"<<endl;
        	}
        }else{
        	for(int i=0;i<a.length();i++){
        		if(a[i]==b[i]){
        			continue;
        		}else if(a[i]>b[i]){
        			cout<<"GREATER"<<endl;
        			return 0;
        		}else if(a[i]<b[i]){
        			cout<<"LESS"<<endl;
        			return 0;
        		}
        	}
        	cout<<"EQUAL"<<endl;
        	return 0;
        }
        return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
d = []
for i in range(10):
  d.append(list(map(int,input().split())))
la = []
for i in range(H):
  la.append(list(map(int,input().split())))
#最短距離更新
for k in range(10):
  for s in range(10):
    for g in range(10):
      d[s][g] = min(d[s][g],d[s][k]+d[k][g])
#合計
ans = 0
for i in range(H):
  for j in range(W):
    a = la[i][j]
    if a != -1:
      ans += d[a][1]
print(ans)      

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int n;
    cin >> n;
    vector<int> a(n * 2);
    rep(i, n) {
        cin >> a[i];
        a[n+i] = a[i];
    }
    //rep(i, n*2) cout << a[i] << endl;
    sort(all(a), greater<>());
    int ans = 0;
    REP(i, 1, n) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6368
from functools import reduce
while True:
    n = input()
    if n == '0000': break
    if len(n) < 4: n = n.zfill(4)
    if reduce(lambda x,y: x and y, [n[0] == s for s in n]):
        print('NA')
    else:
        cnt = 0
        while n != '6174':
            l = ''.join(sorted(n, reverse=True))
            s = ''.join(sorted(n))
            n = str(int(l)-int(s))
            if len(n) < 4: n = n.zfill(4)
            cnt += 1
        print(cnt)

Measured memory_bytes: 6724
#include <cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;++i)

const int N=2005;
const int P=924844033;
int n,k,a[N],fac[N];
long long f[N][N][2][2];
bool vis[N];

int main() {
	scanf("%d%d",&n,&k);
	fac[0]=1;
	FOR(i,1,n) fac[i]=1LL*fac[i-1]*i%P;
	int tot=0;
	FOR(i,1,n) if(!vis[i]) for(int j=i;j<=n;j+=k) vis[j]=1,a[++tot]=j;
	f[0][0][0][0]=1;
	a[0]=-(1<<30);
	FOR(i,1,n) {
		f[i][0][0][0]=1;
		FOR(j,1,i) {
			f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%P;
            f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%P;
            f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%P;
            f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%P;
		}
	}
	int ans=0;
	FOR(i,0,n) {
		int sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%P;
		if(i&1) (ans+=P-1LL*sum*fac[n-i]%P)%=P;
		else (ans+=1LL*sum*fac[n-i]%P)%=P;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 123648
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto x = new double[](3);
    auto y = new double[](3);
    iota(3).each!(i => scan(x[i], y[i]));
    auto l = iota(3).map!(i => hypot(abs(x[(i+1) % 3] - x[i]), y[(i+1) % 3] - y[i])).array;
    l.sort();
    debug {
        writeln(l);
    }
    auto s = (l[0] + l[1] + l[2]) / 2;
    auto m = sqrt(s * (s - l[0]) * (s - l[1]) * (s - l[2]));
    auto R = 2 * m / (l[0] + l[1] + l[2]);

    double ok = 0, ng = 1000;

    bool check(double r) {
        double x = l[2] * (1 - r / R);
        return 2*r <= x;
    }

    foreach (i ; 0 .. 1000) {
        double mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    writefln("%.12f", ok);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char
import Data.Bits


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las



main = do
    n <- readInt
    as <- readInts
    let s = S.fromList as
    putStrLn $ if S.size s == n then "YES" else "NO"






Measured memory_bytes: 31100
#include<iostream>

int main(){
  int a,b;
  std::cin>>a>>b;
  if(a==2||b==2){
    std::cout<<"No"<<std::endl;
  }
  else if((a==4||a==6||a==9)&&(b==6||b==9||b==11)){
    std::cout<<"Yes"<<std::endl;
  }
  else if((a==1||a==3||a==5||a==7||a==8||a==10||a==12)&&(b==1||b==3||b==5||b==7||b==8||b==10||b==12)){
    std::cout<<"Yes"<<std::endl;
  }
  else std::cout<<"No"<<std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N,K; cin >> N >> K;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    vector<ll> sum(N+1);
    rep(i,N) sum[i+1] = sum[i]+a[i];
    vector<ll> b;
    rep(i,N)repr(j,i+1,N+1){
        b.push_back(sum[j]-sum[i]);
    }
    ll ans = 0;
    for(int i = 40; i >= 0; i--){
        int cnt = 0;
        rep(j,N*(N+1)/2){
            if((ans&b[j]) == ans && (1LL<<i)&b[j]) cnt++;
        }
        if(cnt >= K){
            ans += 1LL<<i;
        }
    }
    cout << ans << endl;

}

    



Measured memory_bytes: 6388
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int x = scanner.nextInt();
		Set<Integer> xList = new TreeSet<Integer>();
		xList.add(x);
		for (int i = 0; i < n; i++) {
			int xi = scanner.nextInt();
			xList.add(xi);
		}

		Iterator<Integer> xIter = xList.iterator();
		int prev = xIter.next();
		int next = xIter.next();
		int d = next - prev;
		while (xIter.hasNext()) {
			prev = next;
			next = xIter.next();
			d = calc(d, next - prev);
		}
		System.out.println(d);
	}

	private static int calc(int a, int b) {
		if (a==1 || b== 1) {
			return 1;
		}
		if (a == b) {
			return a;
		} if (a < b) {
			return calc(b, a);
		} else {
			if (a % b == 0) {
				return b;
			} else {
				return calc(b, a % b);
			}
		}
	}

}


Measured memory_bytes: 64116
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int diviser(int n) {
    int res = 0;

    for (int i=1; i*i<=n; i++) {
        if (n%i==0) {
            if (i != n/i) res+=2;
            else res+=1;
        }
    }
    return res;
}

int main() {
    int n;
    int ans = 0;
    cin >> n;

    for (int i=1; i<=n; i+=2) {
        if (diviser(i) == 8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())



print(0)
S_0 = input() #椅子0の性別を確認

start = -1
goal= N
m = (start+ goal) //2



while True:
    print(m)
    q = (input())
    if q == "Vacant":
        exit(0)

    if m %2 == 0: #偶数番目の椅子だったら→S_0と一致
        if q == S_0:
            start = m
        else:
            goal = m
    else:
        if q == S_0:
            goal = m
        else:
            start = m
    m = (start+ goal) //2


Measured memory_bytes: 38852
X = int(input())

if X <= 99:
  print("0")
else:
  keta = X % 100  
  mai = keta // 5
  betu_mai = keta - mai * 5
  if betu_mai == 0:
    min = 105 * mai
  else:
    min = 105 * mai + int(str("10" + str(betu_mai)))
  
  if X >= min:
    print("1")
  else:
    print("0")


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int n,i,a[1000],m;
    while((n=in())){
        rep(i,n)a[i]=in();
        sort(a,n);
        m=inf;
        rep(i,n-1)m=min(m,abs(a[i]-a[i+1]));
        print(m);
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


const double PI = acos(-1);
const int M = 1000005;

int n,w;

vector<int> a;

bool rec(int i, int sum){
    
    if(i == n){
        if(sum == w)return true;
        else return false;
    }
    
    if(rec(i+1, sum + a[i])){
        return true;
    }
    if(rec(i, sum)){
        return true;
    }
    
    return false;
}

int main(){
    ll x;
    cin>>x;
    
    if (x >= 30)puts("Yes");
    else puts("No");
    
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> b(n-1);
  REP(i,n-1) cin >> b[i];
  ll ans = 0;
  ans += b[0] + b[n-2];
  FOR(i,1,n-1){
    ans += min(b[i-1],b[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h1,m1,h2,m2,k = na()

a = (h2-h1)*60+(m2-m1)-k

print(a)

Measured memory_bytes: 9176
n,k,s=map(int,input().split())
a=[0]*n
for i in range(n):
  if 2<s:
    if i<k:
      a[i]=s
    else:
      a[i]=s-1
  else:
    if i<k:
      a[i]=s
    else:
      a[i]=s+1
print(' '.join(map(str,a)))

Measured memory_bytes: 15140
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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 bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N, K;
	cin >> N >> K;
	vector<ll> A(N, 0LL);
	vector<ll> imos(N + 1, 0LL);
	rep(i, N){
		cin >> imos[i];
	}
	vector<ll> imos2(N + 1, 0LL);
	rep(i, min(1000LL, K)){
		rep(j, N){
			ll l = j - imos[j];
			ll r = min(j + imos[j] + 1, N);
			l = max(l, 0LL);
			// print(l, r);
			imos2[l]++;
			imos2[r]--;
		}
		rep(j, N){
			imos2[j+1] += imos2[j];
		}
		rep(j, N+1){
			imos[j] = imos2[j];
			imos2[j] = 0;
		}
	}

	rep(j, N){
		if(j) cout << " ";
		cout << imos[j];
	}
	cout << endl;



	return 0;
}


Measured memory_bytes: 7944
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	string s;
	cin >> s;
	int sum = 0, i;
	rep(i, 0, sz(s))
	{
		sum += s[i] - '0';
		sum %= 9;
	}
	sum %= 9;
	cout << (sum == 0 ? "Yes" : "No");
}

Measured memory_bytes: 3780
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

int main(void)
{
	char str[9];
	int n;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%s", str);
		
		int m;
		sort(str, str + 8);
		m = atoi(str);
		
		sort(str, str + 8, greater<char>());
		m = atoi(str) - m;
		
		printf("%d\n", m);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<cstdio>
#include<queue>
#include<utility>
 
using namespace std;
 
typedef pair<int, int> P;
 
const int MAX_N = 400;
 
const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};
 
bool color[MAX_N][MAX_N];
int H, W;
 
char ch[MAX_N + 1];
 
void input(){
	scanf("%d%d", &H, &W);
	for(int i = 0; i < H; ++i){
		scanf("%s", ch);
		for(int j = 0; j < W; ++j){
			color[i][j] = (ch[j] == '#');
		}
	}
}
 
bool isin_(int i, int j){
	return i >= 0 && i < H && j >= 0 && j < W;
}
 
bool check_(int i, int j, int d){
	int ni = i + di[d];
	int nj = j + dj[d];
	if(!isin_(ni, nj)) return false;
	if(color[i][j] == color[ni][nj]) return false;
	return true;
}
 
bool used[MAX_N][MAX_N];
 
long long solve(){
	long long ans = 0;
	long long b = 0, w = 0;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(used[i][j]) continue;
			b = 0;
			w = 0;
			queue<P> que;
			used[i][j] = true;
			que.push(P(i, j));
			while(!que.empty()){
				P p = que.front();
				que.pop();
				int ci = p.first, cj = p.second;
				if(color[ci][cj]) b++;
				else w++;
				for(int d = 0; d < 4; ++d){
					if(!check_(ci, cj, d)) continue;
					int ni = ci + di[d], nj = cj + dj[d];
					if(used[ni][nj]) continue;
					used[ni][nj] = true;
					que.push(P(ni, nj));
				}
			}
			ans += b * w;
		}
	}
	return ans;
}
 
int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt();

        if (r <= x && x <= (W - r) && r <= y && y <= (H - r)) {
        	System.out.println("Yes");
        }

        else {
        	System.out.println("No");
        }
	}
}


Measured memory_bytes: 26384
#include <stdio.h>

 
int main(void)
{
	int  x, y, r, W, H;
	
	scanf("%d" , &W);
	scanf("%d" , &H);
	scanf("%d" , &x);
	scanf("%d" , &y);
	scanf("%d" , &r);
	
	if((W<x) || (H<y)) {
		printf("No\r\n");
	}
	else{
		if(((x-r)<0) || ((y-r)<0)){
			printf("No\r\n");
		}
		else if((W-x >= r) && (H- y>= r)){
			printf("Yes\r\n");
		}
		else{
			printf("No\r\n");		
		}
	}

	 return 0;	 
}

Measured memory_bytes: 584
package main

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

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

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func isPalindrome(s string, n int) bool {
	for i, j := 0, n-1; i < j; i, j = i+1, j-1 {
		if s[i:i+1] == s[j:j+1] {
			continue
		}
		return false
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	s := scanText()
	n := len(s)

	if isPalindrome(s, n) && isPalindrome(s[0:(n-1)/2], len(s[0:(n-1)/2])) && isPalindrome(s[(n+3)/2-1:n], len(s[(n+3)/2-1:n])) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 1776
//ex7_1
//TKC001

#include<stdio.h>
//pointの宣言
typedef struct point
{
    int x_elem;
    int y_elem;
}point;

//点Pをx軸方向にx_diff, y軸方向にy_diffだけずらす
point shift_point(point p, int x_diff, int y_diff){
    p.x_elem += x_diff;
    p.y_elem += y_diff;

    return p;
}


int main(void){
    point poi1, poi2, poi3, poi4;
    int x_diff, y_diff;
    //入力
    scanf("%d %d %d %d", &poi1.x_elem, &poi1.y_elem, &poi2.x_elem, &poi2.y_elem);

    //(x1, y1)と(x2, y2)はx軸方向にx_diff, y軸方向にy_diffだけずらせばそれぞれ(x3, y3), (x4, y4)になる。
    x_diff = poi1.y_elem-poi2.y_elem;
    y_diff = poi2.x_elem-poi1.x_elem;

    //ずらす処理
    poi3 = shift_point(poi2, x_diff, y_diff);
    poi4 = shift_point(poi1, x_diff, y_diff);

    //出力
    printf("%d %d %d %d", poi3.x_elem, poi3.y_elem, poi4.x_elem, poi4.y_elem);

    return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		if(n%2==0)
		System.out.println((double)(n/2)/n);
		else
		System.out.println((double)(n/2+1)/n);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int MAX=1e5;
int a[MAX];

signed main()
{
	int n;
	cin >> n;
	int dem=0;
	for (int i=1;i<=n;i++) cin >> a[i];
	sort (a+1,a+n+1);
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			for (int k=j+1;k<=n;k++){
				if (a[i]+a[j]>a[k]&&a[k]-a[j]<a[i]&&a[i]!=a[j]&&a[j]!=a[k]){
					dem++;
				}
			}
		}
	}
	cout << dem;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, l[N], r[N];
int main()
{
	ll i;
	cin >> n;
	l[0] = r[0] = 0;
	for (i = 1; i <= n; i++) {
		scanf ("%lld %lld", &l[i], &r[i]);
	}
	sort(l, l + n + 1, greater<ll>());
	sort(r, r + n + 1);
	for (i = 0; i <= n; i++) {
		if(l[i] - r[i] < 0) break;
		s += l[i] - r[i];
	}
	cout << s * 2;
    return 0;
}

Measured memory_bytes: 1792
using System;

class MainClass {
    static void Main() {
        Scanner cin=new Scanner();

        int a=cin.nextInt();
        int b=cin.nextInt();
        int h=cin.nextInt();

        Console.WriteLine((a+b)*h/2);
    }
}

class Scanner {
    string[] buf;
    int i;
    char[] SplitChar=new char[] {' '};
    public Scanner() {
        buf = new string[0];
        i = 0;
    }
    public string next() {
        if (i < buf.Length) return buf[i++];

        string tmp=Console.ReadLine();
        while (tmp == "")
            tmp = Console.ReadLine();

        buf = tmp.Split(SplitChar, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return buf[i++];
    }
    public int nextInt() {
        return int.Parse(next());
    }
    public long nextLong() {
        return long.Parse(next());
    }
    public double nextDouble() {
        return double.Parse(next());
    }
}


Measured memory_bytes: 2776
require 'pp'

# サイズが H, W の文字の2次元配列を返却する
def gets_HW_char
  h, w = gets.split.map(&:to_i)
  board = h.times.map { gets.chomp.chars }
  return h, w, board
end
H, W, board = gets_HW_char

posH = 0
posW = 0

while posH < H && posW < W
  board[posH][posW] = "."
  if posH + 1 < H && board[posH + 1][posW] == "#"
    posH += 1
  else posH + 1 < W && board[posH][posW + 1] == "#"
    posW += 1
  end
end

puts board.flatten.include?("#") ? "Impossible" : "Possible"

Measured memory_bytes: 2044
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfsVisit(int);
void dfs();

int n,M[N][N];
int color[N],d[N],f[N],tt;

int main(){
  int u,v,k,i,j;

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

  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}

void dfsVisit(int u){
  int v;

  color[u] = GRAY;
  
  d[u] = ++tt;

  for(v = 0;v < n;v++){
    if(M[u][v] == 0)continue;
    if(color[v] == WHITE){
      dfsVisit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u = 0;u < n;u++){
    color[u] = WHITE;
  }
  tt = 0;

  for(u = 0;u < n;u++){
   if(color[u] == WHITE){
      dfsVisit(u);
    }
  }
  for(u = 0;u < n;u++){
    printf("%d %d %d\n",u + 1,d[u],f[u]);
  }
}



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

const int MAXN=2005;
const int INF=0x3f3f3f3f;

int n,K,ans=INF,now,extra;
int head[MAXN],ecnt;
int dep[MAXN],siz[MAXN];
struct node{
    int v,nex;
}edge[MAXN*2];

void addedge(int u,int v){
    node &p=edge[++ecnt];
    p.v=v;
    p.nex=head[u];
    head[u]=ecnt;
}

int dfs(int u,int fa=0){
    dep[u]=dep[fa]+1;
    siz[u]=1;
    int cnt=0,t=0,sum=0;
    for(int i=head[u];i;i=edge[i].nex){
        int v=edge[i].v;
        if(v==fa) continue;
        t=dfs(v,u);
        if(fa==0) extra=max(extra,t);
        sum+=t;
        siz[u]+=siz[v];
        if((K&1)&&dep[u]==K/2) cnt++;
    }
    if(fa==0&&!(K/2)) extra=max(extra,1);
    if(dep[u]==K/2+1) now+=siz[u];
    return sum+cnt;
}

int main(){

    scanf("%d%d",&n,&K);
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    dep[0]=-1;
    for(int i=1;i<=n;i++){
        now=extra=0;
        dfs(i);
        now-=extra;
        ans=min(ans,now);
    }
    printf("%d\n",ans);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 384
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)
x4 = x3 + (x1 - x2)
y4 = y3 + (y1 - y2)

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, d, a;
    cin >> n >> d >> a;
    akari<pair<i64, i64>> ps(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i].first >> ps[i].second;
    }
    sort(ps.begin(), ps.end());
    i64 cur = 0, ans = 0;
    queue<pair<i64, i64>> ia;
    for (auto &p : ps)
    {
        i64 x = p.first, h = p.second;
        while (!ia.empty() && ia.front().first < x)
        {
            cur -= ia.front().second;
            ia.pop();
        }
        if (cur >= h)
        {
            continue;
        }
        i64 y = (h - cur + a - 1) / a;
        ia.push(make_pair(x + 2 * d, y * a));
        ans += y;
        cur += y * a;
    }
    cout << ans << endl;
}

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


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

int main(){
	int x , y ;
	
	 while( 1 ){
		 cin >> x >> y ;
		 if( x==0 && y==0 ){
			 break ; 
		 }else if( x<=y ){
			 cout << x << " " << y << endl ;
			 
		 }else if( x>=y ){
			 cout << y << " " << x << endl ;
			 
		 }
		 
		 
	 }
	
	
	return 0 ;
} 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  int n, k;  cin >> n >> k;
  vector<int> v(n);
  rep (i, n) cin >> v[i];

  sort(v.begin(), v.end());

  ll ans=0;
  rep (i, k) {
    ans += v[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 3600
'use strict'
function Main(input){
  input=readAsNumArray(input);
  var N=parseInt(input.shift());
  var reversedBinary=[];
  for(let i=0;i<N;i++){
    reversedBinary[i]=parseInt(input[i]).toString(2).split('').reverse().join('');
  }
  var counter=0;
  for(let i=0;i<N;i++){
    while(reversedBinary[i][0]==='0'){
      reversedBinary[i]=reversedBinary[i].replace('0','');
      counter++;
    }
  }
  console.log(counter);
} 

function readAsNumArray(input){

var I=[],i=0;

var checkNum=/^\d+/;

var checkSpace=/ +|\n+/;

while(input.length>0){

if(input.match(checkNum)!==null){

I[i]=input.match(checkNum)[0];

input=input.replace(checkNum,""); 

i++;

continue;

}

input=input.replace(checkSpace,"");

continue;

}

return input=I;
}

Main(require('fs').readFileSync('/dev/stdin','utf8'))


Measured memory_bytes: 16180