akhauriyash/Code-Regression huggingface dataset:
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP1[SIZE];
bool finished[SIZE3][SIZE3][SIZE3];
LL DP2[SIZE2][SIZE2];
ld DP3[SIZE3][SIZE3][SIZE3];
ld solve2(int one,int two,int three) {
	if (finished[one][two][three]) return DP3[one][two][three];
	if (one + two + three == 0) return 0;
	finished[one][two][three] = true;
	ld ans = 0;
	ld sum = one + two + three;
	ld n = N;
	if(one){
		ans += (solve2(one - 1, two, three))*one;
	}
	if (two) {
		ans += (solve2(one +1, two-1, three))*two;
	}
	if (three) {

		ans += (solve2(one , two + 1, three-1))*three;
	}
	return DP3[one][two][three] = (ans+n)/(sum);
}
LL solve() {
	cin >> N;
	REP(i, N) {
		int x;
		cin >> x;
		vals[x]++;
	}
	cout << solve2(vals[1], vals[2],vals[3])<<endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 305408
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
  //エラトステネスのふるい
  int MAX = 100100;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0; is_prime[1] = 0;
  for(int i = 2; i < MAX; i++){
    if(!(is_prime[i])) continue;
    for(int j = i*2; j < MAX; j += i){
      is_prime[j] = 0;
    }
  }
  // 2017-likeかどうかの判定結果
  vector<int> res(MAX, 0);
  for(int i = 1; i < MAX; i += 2){
    if(is_prime[i] && is_prime[(i + 1)/2]) res[i] = 1;
  }
  
  //累積和
  vector<int> sum(MAX+1, 0); //s[0] = 0, s[1] = res[0], s[2] = res[0] + res[1]
  for(int i = 0; i < MAX; i++){
    sum[i + 1] = res[i] + sum[i];
  }
  
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int l, r; cin >> l >> r;
    r++;
    cout << sum[r] - sum[l] << endl;
  }
}
    

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 50;
ll n;
ll a[MAX_N];


int main()
{
  cin >> n;
  forn(i,n) cin >> a[i];

  ll c = 0;
  while (any_of(a,a+n,[](ll v) { return v >= n; })) {
    ll total = accumulate(a,a+n,0LL,[](ll a, ll b) { return a+b/n; });
    forn(i,n) {
      a[i] += (total-a[i]/n) - (a[i]/n)*n;
    }
    c += total;
  }

  cout << c << endl;

  return 0;
}


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


int main(){
  int room[5][4][11];
  for(int b=1;b<=4;++b){
    for(int s=1;s<=3;++s){
      for(int i=1;i<=10;++i){
        room[b][s][i] = 0;
      }
    }
  }
  int N; cin>>N;
  REP(i,N){
    int b,f,r,v; cin>>b>>f>>r>>v;
    room[b][f][r] += v;
  }
  
  for(int b=1;b<=4;++b){
    for(int s=1;s<=3;++s){
      for(int i=1;i<=10;++i){
        printf(" %d",room[b][s][i]);
      }
      cout <<"\n";
    }
    if(b<4){ cout << string(20,'#') <<"\n";}
  }
}


Measured memory_bytes: 3224
N,M,Q = map(int,input().split())
req_ls = []
l_ind_ls = [0] * Q
r_ind_ls = [0] * Q
diff_ls = [0] * Q
point_ls = [0] * Q
for i in range(Q):
    l_ind_ls[i], r_ind_ls[i], diff_ls[i], point_ls[i] = map(int, input().split())
    l_ind_ls[i] -= 1
    r_ind_ls[i] -= 1

def score(ls):
    tmp = 0
    for l_ind, r_ind, diff, point in zip(l_ind_ls,r_ind_ls,diff_ls,point_ls):
        if ls[r_ind] - ls[l_ind] == diff:
            tmp += point
    return tmp

def dfs(ls):
    if len(ls) == N:
        return score(ls)
    res = 0
    last = ls[-1] if len(ls) > 0 else 1
    for nex in range(last, M+1):
        ls.append(nex)
        res = max(res, dfs(ls))
        ls.pop()
    return res
print(dfs([]))




Measured memory_bytes: 9228
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int alice = sc.nextInt();
        int bob = sc.nextInt();
        
        String ans = "";
        
        if(alice < bob){
            if((alice == 1) &&(bob == 13)){
                ans = "Alice";
            }else{
                ans = "Bob"; 
            }
            
        }else if(alice == bob){
            ans = "Draw";
        }else{
            if((bob == 1) &&(alice == 13)){
                ans = "Bob";
            }else{
                ans = "Alice"; 
            }
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
int n, m;
vector<int>V;
vector<vector<int>>G(10, vector<int>(10,0));
int ans = 0;
void dfs(int a,int N) {
	if (N == n -1) {
		ans++;
		return;
	}
	if (G[a][V[N]]) {
		dfs(V[N], N + 1);
	}
	return;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a][b] = 1;
		G[b][a] = 1;
	}
	for (int i = 1; i < n; ++i) {
		V.push_back(i);
	}
	sort(V.begin(), V.end());
	do {
		dfs(0, 0);
	} while (next_permutation(V.begin(), V.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n;
vector<int> g[200005];
int d1[100005],d2[100005];
void dfs(int r,int f,int d,int dist[])
{
    dist[r]=d;
    for(int x:g[r])
    {
        if(x!=f)
            dfs(x,r,d+1,dist);
    }
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){ 
        g[i].clear();
    }
    int u,v;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0,-1,0,d1);
    dfs(n-1,-1,0,d2);
    int ans=0;
    for(int i=0;i<n;i++){
        if(d1[i]<=d2[i]){
            ans++;
		}
        else{
        	ans--;
        }
    }
    if(ans>0)
        cout <<"Fennec"<< endl;
    else
        cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 15104
n = int(input())
a = list(map(int, input().split()))

c = [0, 0, 0]
ans = 1
for i in range(n):
    count = 0
    for j in range(3):
        if a[i] == c[j]:
            if count == 0:
                c[j] += 1
            count += 1
    ans = ans * count % 1000000007
print(ans)

Measured memory_bytes: 14396
#include<iostream>  
#include<string> 
using namespace std; 
int main() {
	 
	string a;
	cin >> a;  
	char b = '0';
	char c = '0';
	if (a.size()==3)
	{
		b = a.at(0);
		c = a.at(2);
		a.at(0) = c; 
		a.at(2) = b; 
	} 
	cout << a;
}

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

ll solve() {
    ll N,a ;
    cin >> N;
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( i % 2 == 0 && a % 2 == 1 ) ans++;
    }
    return ans;
}

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

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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(void){
    long long a[100001],n;
    cin >> n;
    for(int i =0;i<n;i++) cin >> a[i];
    sort(a,a+n,greater<int>());
    long long c=0,d=0,i=0;
    while(!c && i<n){
        if(a[i] == a[i + 1]) {
            c = a[i];
            i++;
        }
        i++;
    }
    while(!d && i<n){
        if(a[i] == a[i+1]) d = a[i];
        i++;
    }
    cout<<c*d;
}

Measured memory_bytes: 1024
N=int(input())
A=[int(x) for x in input().split()]
A.sort()
B=sorted(A,key=lambda x:abs(x))
m=0
for i in range(N):
  if A[i]<0:
    m+=1
  else:
    break
ans=0
for i in range(m):
  ans-=A[i]
for i in range(m,N):
  ans+=A[i]
if m%2==1:
  ans-=abs(B[0])*2
print(ans)

Measured memory_bytes: 14412
n, m, l = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(n)]
B = [tuple(map(int, input().split())) for _ in range(m)]
C = [[0] * l for _ in range(n)]
for i in range(n):
    for k in range(m):
        for j in range(l):
            C[i][j] += A[i][k] * B[k][j]
for i in range(n):
    print(*C[i])


Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

int N;

int main() {
    cin >> N;
    vector<int> S(N);
    rep(i,N) cin>>S[i];
    vector<int> v(N);
    ll v0_2 = 0;
    rep(i,N) {
        if (i&1) v0_2 -= S[i];
        else v0_2 += S[i];
    }
    
    v[0] = v0_2/2;
    rep(i,N-1) v[i+1] = S[i] - v[i];
    rep(i,N) cout << 2*v[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3980
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<bool> flag(n + 1, false);

  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a; cin >> a;
      flag[a] = true;
    }
  }

  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!flag[i])
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3196
n, m = map(int, input().split())
wa = [0] * n
cnt = [0] * n
for i in range(m):
    p, s = input().split()
    if s == "WA" and cnt[int(p) - 1] == 0:
        wa[int(p) - 1] += 1
    elif s == "AC" and cnt[int(p) - 1] == 0:
        cnt[int(p) - 1] += 1

for i in range(n):
    if cnt[i] == 0:
        wa[i] = 0
print(sum(cnt), sum(wa))

Measured memory_bytes: 4596
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A, A+N);

    int num = A[0], cnt = 0;
    for (int i = 1; i < N; i++) {
        if (num != A[i]) {
            cnt++;
            num = A[i];
        }
    }

    if (cnt % 2) cout << cnt << endl;
    else cout << cnt + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int x,y;
    int a[2],j,i,key;
    
    while(1){
        
        scanf("%d %d",&x,&y);
        if(x == 0 && y == 0) break;
        a[0] = x;
        a[1] = y;
        for(i = 1;i < 2;i++){
            key = a[i];
            j = i - 1;
            while(j >= 0 && a[j] > key){
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = key;
        }
    
    
    printf("%d %d\n",a[0],a[1]);
    } 
    
    return 0;
}



Measured memory_bytes: 2108
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static inline uint32_t left(uint32_t i)
{
  return i * 2 + 1;
}
static inline uint32_t right(uint32_t i)
{
  return i * 2 + 2;
}

static void max_heapify(vector<int64_t> &vec, uint32_t i)
{
  uint32_t largest = i;
  if (left(i) < vec.size()) {
    if (vec[largest] < vec[left(i)]) {
      largest = left(i);
    }
  }

  if (right(i) < vec.size()) {
    if (vec[largest] < vec[right(i)]) {
      largest = right(i);
    }
  }

  if (largest != i) {
    swap(vec[largest], vec[i]);
    max_heapify(vec, largest);
  }
}

void build_max_heap(vector<int64_t> &vec)
{
  for (int32_t i = (vec.size() + 1) / 2; i >= 0; i--) {
    max_heapify(vec, i);
  }
}

#include <iostream>
static vector<int64_t> vec;

int32_t main()
{
  int32_t num;
  cin >> num;

  for (int32_t i = 0; i < num; i++) {
    int64_t val;
    cin >> val;
    vec.push_back(val);
  }

  build_max_heap(vec);

  for (uint32_t i = 0; i < vec.size(); i++) {
    cout << " " << vec[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 6836
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

#include<math.h>
#include<sstream>
#include<bitset>

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D, 0);
    vector<int> c(D, 0);

    for(size_t i = 0; i < D; i++)
        cin >> p[i] >> c[i];
    int ret = 10000;
    for(size_t i = 0; i < pow(2.0, D); i++)
    {
        stringstream bit;
        bit << bitset<10>(i);
        string bitstr = bit.str();
        int score = 0;
        int highest_0 = -1;
        int probs = 0;
        for(size_t j = 0; j < D; j++)
        {
            if (bitstr[9-j] == '1'){
                score += (j+1) * 100 * p[j] + c[j];
                probs += p[j];
            }
            else{
                highest_0 = j;
            }
        }
        if(score < G){
            if (highest_0 >= 0) {
                int left_score = G - score;
                int prob_add = (G - score + (highest_0+1)*100 - 1) / ((highest_0+1)*100);
                if (prob_add < p[highest_0]){
                    score += (highest_0 + 1) * 100 * prob_add;
                    probs += prob_add;
                }
            }
        }
        if(score >= G && probs < ret)
            ret = probs;        
    }
    cout << ret << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

string S;
void input()
{
    cin>>S;
}

void solve()
{
    string ans="Yes";
    int N=S.length();
    for(int i=0;i<N/2;++i){
        if(S[i]!=S[N-1-i]){
            ans="No"; break;
        }
    }
    for(int i=0;i<N/2;++i){
        if(S[i]!=S[N/2-1-i]){
            ans="No"; break;
        }
    }
    for(int i=0;i<N/2;++i){
        if(S[N/2+1+i]!=S[N-1-i]){
            ans="No"; break;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int main() {

	//数字
	int N,i;
  	int flag=0;
	cin >> N;
	for(i=1;i<=N;i++){
  		if((i*1.08)-N<1.0 && (i*1.08)>=N){
	    cout << i << endl;
        flag=1;
         break;
        }
    }
  if(flag==0){
  	    cout << ":(" << endl;
  }

	
}

Measured memory_bytes: 256
MOD = 10**9+7

def facto(n):
    ans = 1
    for i in range(n,1,-1):
        ans = ans*i%MOD
    return ans

def calc_total(n,m):
    if n == m:
        return (facto(n)*2)*facto(m)%MOD
    elif abs(n-m) == 1:
        return facto(n)*facto(m)%MOD
    elif abs(n-m) >= 2:
        return 0

n,m = map(int,input().split())
ans = calc_total(n,m)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <limits>


template<class T>
T cc(T t)
{
	return t * (t - 1) / 2;
}

const char* YesNo(bool b)
{
	if (b)
	{
		return "Yes";
	}
	else
	{
		return "No";
	}
}

bool is_kaibun(const std::string& S, int left, int right)
{
	for (int i = 0; i < (right - left)/2; i++)
	{
		if (S[left+i] != S[right-i-1])
		{
			return false;
		}
	}
	return true;
}

int main()
{
	std::string S;
	std::cin >> S;

	int N = S.size();
	bool ans0 = is_kaibun(S, 0, N);
	bool ans1 = is_kaibun(S, 0, (N-1)/2);
	bool ans2 = is_kaibun(S, (N+1)/2, N);
	bool ans = ans0 && ans1 && ans2;
	std::cout << YesNo(ans);
}

Measured memory_bytes: 256
import java.util.*;;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextDouble()){
			
			double a=sc.nextDouble();
			double b=sc.nextDouble();
			double c=sc.nextDouble();
			double d=sc.nextDouble();
			double e=sc.nextDouble();
			double f=sc.nextDouble();
			double x=(c*e-b*f)/(a*e-b*d);
	        double y=(c*d-a*f)/(b*d-a*e);
	        if(x==0)x=0;
	        if(y==0)y=0;
	        System.out.printf("%.3f %.3f\n",x,y);
		}
		
		
		
	}
}

Measured memory_bytes: 20544
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
      ll k,x;
      cin>>k>>x;
      ll n = 500*k;
      if(n>=x)
      {
          cout<<"Yes"<<endl;
      }
      else
      {
          cout<<"No"<<endl;
      }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
const int mod=1e9+7;
typedef pair<int,int>pi;
int n,ans;
int z[N];
int l[N],r[N];
int f[N],s[N];
double t[N];
pi q[N];
struct node{
	int x,v,pos,l,r;
}a[N];
bool cmp_v(node a,node b){
	return a.v>b.v;
}
bool cmp_range(node a,node b){
	if(a.r!=b.r)
		return a.r<b.r;
	return a.l<b.l;
}
void Getl(){
	int cnt=n;
	for(int i=1;i<=n;i++)
		q[i]=pi(a[i].x,a[i].pos);
    sort(q+1,q+n+1);
    for(int i=1;i<=n;i++)
		while(cnt){
			if(a[i].x>q[cnt].first)
				break;
			l[q[cnt--].second]=i;
		}
}
void Getr(){
	int cnt=n;
	for(int i=1;i<=n;i++)
		q[i]=pi(a[i].x,a[i].pos);
    sort(q+1,q+n+1);
    reverse(q+1,q+n+1);
    for(int i=n;i>=1;i--)
		while(cnt){
			if(a[i].x<q[cnt].first)
				break;
			r[q[cnt--].second]=i;
		}
}
int dp(){
	for(int i=1;i<=n;i++)
		a[i].l=n-r[i]+1,a[i].r=n-l[i]+1;
	sort(a+1,a+n+1,cmp_range);
	int ans=0;
	for(int i=1,j=1;i<=n;i++){
		while(a[j].r<a[i].l-1)
			j++;
		f[i]=(s[i-1]-s[j-1]+mod)%mod;
		if(a[i].l==1)
			f[i]++;
		if(a[i].r==n)
			ans=(ans+f[i])%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].v);
		a[i].pos=i;
		z[i]=a[i].v;
	}
	sort(z+1,z+n+1);
	int cnt=unique(z+1,z+n+1)-z-1;
	for(int i=1;i<=n;i++)
		a[i].v=lower_bound(z+1,z+cnt+1,a[i].v)-z;
    sort(a+1,a+n+1,cmp_v);
    Getl();
    Getr();
    int ans=dp();
    printf("%d\n",ans);
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < ((int)n); ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong a, b, c, k;
    cin >> a >> b >> c >> k;

    llong ans = 0;
    if (k <= a) {
        cout << k << endl;
        return 0;
    }
    if (k >= a + b) {
        cout << a - (k - (a + b)) << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N; cin >> N;
  string S; cin >> S;
  int K; cin >> K;

  string result = "";
  rep(i,N) result += (S[i]==S[K-1]) ? S[K-1] : '*';
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;

void MakeaRectangle() {

	int n;
	cin >> n;
	ll t[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> t[i];
	}

	sort(t, t + n);
	reverse(t, t + n);

	ll top = 0;
	ll sec = 0;
	for (size_t i = 0; i < n - 1; i++)
	{
		if (t[i] == t[i + 1] && top == 0) {
			top = t[i];
			i++;
		}
		else if (t[i] == t[i + 1] && sec == 0) {
			sec = t[i];
			i++;
		}
	}

	cout << (top * sec) << endl;
}

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



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    bool flag = false;
    if (S == "KIHBR") {
        flag = true;
    } else if (S == "KIHBRA") {
        flag = true;
    } else if (S == "KIHBAR") {
        flag = true;
    } else if (S == "KIHBARA") {
        flag = true;
    } else if (S == "KIHABR") {
        flag = true;
    } else if (S == "KIHABRA") {
        flag = true;
    } else if (S == "KIHABAR") {
        flag = true;
    } else if (S == "KIHABARA") {
        flag = true;
    } else if (S == "AKIHBR") {
        flag = true;
    } else if (S == "AKIHBRA") {
        flag = true;
    } else if (S == "AKIHBAR") {
        flag = true;
    } else if (S == "AKIHBARA") {
        flag = true;
    } else if (S == "AKIHABR") {
        flag = true;
    } else if (S == "AKIHABRA") {
        flag = true;
    } else if (S == "AKIHABAR") {
        flag = true;
    } else if (S == "AKIHABARA") {
        flag = true;
    }

    if (flag) {
        YES;
    } else {
        NO;
    }
    return 0;
}

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

#define ul unsigned long 
#define ull unsigned long long
#define li long long int


int main()
{
  ul n,r;
  cin >> n;
  cin >> r;

  if (n>=10) cout << r<<endl;
  else cout << (r+100*(10-n))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int w,h,n,l=0,i=1,x[1001],y[1001];
	cin>>w>>h>>n;
	while(i<=n){
		cin>>x[i]>>y[i];
		++i;
	}
	i=1;
	while(i<=n-1){
		if(x[i]<=x[i+1]){
			if(y[i]<=y[i+1]){
				l=l+max(x[i+1]-x[i],y[i+1]-y[i]);
			}else{
				l=l+x[i+1]-x[i]+y[i]-y[i+1];
			}
		}else{
			if(y[i]>y[i+1]){
				l=l+max(x[i]-x[i+1],y[i]-y[i+1]);
			}else{
				l=l+x[i]-x[i+1]+y[i+1]-y[i];
			}
		}
		++i;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <iomanip>
using namespace std;
int N,M;
int main()
{
    cin>>N>>M;
    int x=M*1900+(N-M)*100;
    double rez=0,p=1;
    for(int i=1;i<=100000;i++)
    {
        rez+=x*i*p/(1<<M);
        p*=((1<<M)-1.0)/(1<<M);
    }
    cout<<fixed<<setprecision(0)<<rez;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxint 2147483647//10^13-1
#define maxll 9223372036854775807//10^64
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
int b[100];
int main() {
	int a,b,i = 0;
	cin>>a>>b; 
	do {
		a=a/b;
		i++;
	} while(a!=0);
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())

    ans = 0
    for i in range(1, N + 1): #全ての数字に対して桁和を計算する
        digSum = 0
        k = i
        while k > 0:
            digSum += k % 10
            k //= 10

        if A <= digSum <= B:
            ans += i
    print(ans)

    return  0

if __name__ == "__main__":
    solve()

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

int main(void) {
  int N, i, j;
  char trumps[4][13];
  char mark[4] = {'S', 'H', 'C', 'D'};

  /* 初期化 */
  memset(trumps, 0, 4*13);

  /* かーど枚数読取り */
  scanf("%d\n", &N);

  /* かーど情報格納 */
  for (i = 0; i < N; i++) {
    int num, j;
    char pict;
    scanf("%c %d\n", &pict, &num);
    for (j = 0; pict != mark[j]; j++);
    trumps[j][--num] = 1;
  }

  /* かーど情報確認 */
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (!trumps[i][j])
        printf("%c %d\n", mark[i], j+1);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in();
    if(n%2==0)cout<<(n/2)-1<<endl;
    else cout<<n/2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){
	int n;
	long long tmp,number,r_1,r_2;

	scanf("%d",&n);

	for(int i=0; i < n; i++){
		scanf("%lld",&tmp);
		if(i == 0){
			number = tmp;
		}else{
			if(number >= tmp){
				r_1 = calc(number,tmp);
				number = (number*tmp)/r_1;
			}else{
				r_1 = calc(tmp,number);
				number = (number*tmp)/r_1;
			}
		}
	}

	printf("%lld\n",number);
}



Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  string s;
  cin >> s;

  vector<int> count(3, 0);
  rep(i, s.size()) {
    count[s[i] - 'a']++;
  }

  sort(ALL(count));

  if (count[1] - count[0] <= 1 && count[2] - count[0] <= 1) puts("YES");
  else puts("NO");

  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make(drinks, n)
	for i := range ar {
		fmt.Scan(&ar[i].a, &ar[i].b)
	}
	sort.Sort(ar)
	sum := 0
	for _, v := range ar {
		sum += v.a
		if v.b < sum {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

type drink struct {
	a int
	b int
}

type drinks []drink

func (d drinks) Len() int {
	return len(d)
}

func (d drinks) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}

func (d drinks) Less(i, j int) bool {
	return d[i].b < d[j].b
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n){
    cin >> h.at(i);
  }
  int ans=1,now=k;
  while(now<n){
    now+=k-1;
    ans++;
  }
  cout<< ans;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
#define show(a) for(auto i:a) cout<<i<<" ";cout<<endl
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< int , int > mypair;
typedef priority_queue <int> max_heap;
typedef priority_queue <int, vector<int>, greater<int> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=1e5+10;


int main()
{
	boost;
	int n;
	cin>>n;
	int k;
	cin>>k;
	int ans=0;
	while(n--)
	{
		int x;
		cin>>x;
		if(x>=k) ans++;
	}
	cout<<ans;
   	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;


int main()
{
	char* rank[] = {
		"light fly",
		"fly",
		"bantam",
		"feather",
		"light",
		"light welter",
		"welter",
		"light middle",
		"middle",
		"light heavy",
		"heavy",
	};
	double weight[] = {
		48,
		51,
		54,
		57,
		60,
		64,
		69,
		75,
		81,
		91,
	};

	double w;
	while (scanf("%lf", &w) != EOF)
	{
		int i;
		for (i = 0; i < sizeof(weight)/sizeof(weight[0]); ++i)
		{
			if (w <= weight[i])
				break;
		}
		printf("%s\n", rank[i]);
	}

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=1e5+7;
int a[N],fa[N];
int getf(int x)
{
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri(),k=ri(),i,x,y,cnt=0;
	for(i=1;i<=n;i++)	fa[i]=i,a[i]=ri();
	for(i=1;i<=k;i++)
	{
		x=ri(),y=ri();
		x=getf(x),y=getf(y);
		if(x!=y)	fa[x]=y;
	}
	for(i=1;i<=n;i++)	if(getf(i)==getf(a[i]))	cnt++;
	wi(cnt);
	return 0;
}


Measured memory_bytes: 1024
from collections import deque

h,w = map(int,input().split())
maze = [input() for _ in range(h)]

gx, gy = w-1, h-1

q = deque()
q.appendleft([0,0])
INF = 10**5

dist = [[INF]*w for _ in range(h)]
dist[0][0] = 0

while q:
  x,y = q.pop()
  
  for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:
    nx = x+dx
    ny = y+dy
    
    if 0<=nx<w and 0<=ny<h:
      if dist[ny][nx]==INF and maze[ny][nx] != '#':
        dist[ny][nx] = dist[y][x]+1
        q.appendleft([nx,ny])      

black_num = sum([maze[i].count('#') for i in range(h)])

if dist[gy][gx] == INF:
  print(-1)
else:  
  print( h*w - dist[gy][gx] - black_num -1 )

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    ll x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3648
import sys
from heapq import*
e=sys.stdin.readline
I=float("inf")
def m():
 n=int(e())
 A=[]
 for _ in[0]*n:
  b=list(map(int,e().split()))
  A+=[zip(b[2::2],b[3::2])]
 d=[0]+[I]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 print('\n'.join(f'{i} {d[i]}'for i in range(n)))
m()


Measured memory_bytes: 40140
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acosl(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}


const int ITER = 100;

int N;
vector<Point> v;

DD f(DD x, DD y) {
    DD res = 0;
    for (int i = 0; i < N; ++i) res = max(res, abs(v[i] - Point(x, y)));
    return res;
}

DD g(DD x) {
    DD left = -1000, right = 1000;
    for (int _ = 0; _ < ITER; ++_) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (f(x, m1) > f(x, m2)) left = m1;
        else right = m2;
    }
    return f(x, left);
}

DD solve() {
    DD left = -1000, right = 1000;
    for (int _ = 0; _ < ITER; ++_) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (g(m1) > g(m2)) left = m1;
        else right = m2;
    }
    return g(left);
}

int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) cin >> v[i].x >> v[i].y;
    cout << fixed << setprecision(10) << solve() << endl;
}

Measured memory_bytes: 3832
/*
author : seryu
title : contest
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int k, a, b; cin >> k >> a >> b;
	if(a % k == 0 || b % k == 0)cout << "OK" << endl;
	else if(a / k != b / k)cout << "OK" << endl;
	else cout << "NG" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

struct point
{
	LL x, y;
	point(){}
	point(LL x1, LL y1)
	{
		x = x1;
		y = y1;
	}

	LL d2() const
	{
		return x * x + y * y;
	}

	point operator -(const point& a) const
	{
		return point(x - a.x, y - a.y);
	}

	LL operator *(const point& a) const
	{
		return x * a.y - a.x * y;
	}

	bool operator <(const point& a) const
	{
		if (x == a.x) return y < a.y;
		return x < a.x;
	}

};

const int MAX = 100 + 47;
double const EPS = 1e-8;

point A[MAX];
double ANS[MAX];
int n;
point a, b;

double getAng(point a, point b)
{
	double a1 = atan2(a.y, a.x);
	if (a1 < 0) a1 += 2 * PI;

	double a2 = atan2(b.y, b.x);
	if (a2 < 0) a2 += 2 * PI;

	double alpha = abs(a1 - a2);
	if (alpha > PI) alpha = 2 * PI - alpha;
	return PI - alpha;
}

bool isOk(point a, point b)
{
	bool ccw = false;
	bool cw = false;

	FOR(i, 0, n)
	{
		LL val = (b - a) * (A[i] - a);
		if (val > 0) ccw = true;

		if (val < 0) cw = true;
	}

	if (ccw && cw) return false;

	return true;
}

bool inside(point a, point b, point c)
{
	if (a.x < b.x && b.x < c.x) return true;
	if (a.y < b.y && b.y < c.y) return true;

	return false;
}

bool inOneLine()
{
	FOR(i, 2, n)
	{
		if ((A[i] - A[i - 1]) * (A[i - 1] - A[i - 2]) != 0) return false;
	}

	return true;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	FOR(i, 0, n)
	{
		cin >> A[i].x >> A[i].y;
	}

	if (inOneLine())
	{
		int mn = 0, mx = 0;
		FOR(i, 0, n)
		{
			if (A[i] < A[mn]) mn = i;
			if (A[mx] < A[i]) mx = i;
		}

		ANS[mn] = ANS[mx] = 0.5;
	}
	else
	{
		FOR(i, 0, n)
		{
			point a = A[i];

			FOR(j, 0, n)
			{
				if (i == j) continue;
				point b = A[j];

				if (!isOk(a, b)) continue;
				FOR(k, 0, n)
				{
					if (k == i || k == j) continue;
					point c = A[k];
					if (!isOk(b, c)) continue;
					//cout << i + 1 << " " << j + 1 << " " << k + 1 << endl;

					if ((a - b) * (c - b) == 0) continue;
					double ans = getAng(a - b, c - b) / (2 * PI);
					ANS[j] = ans;
				}
			}
		}
	}

	FOR(i, 0, n)
	{
		cout << fixed << setprecision(12) << ANS[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
const long long mod=1000000007;
long long a[10005],b[10005];
long long yinzi[1000005];
/*快速幂*/
long long pows(long long m,long long n)
{
	long long k=1;
	while(n)
	{
		if(n%2==1)k=k*m%mod;
		m=m*m%mod;
		n/=2;
	}
	return k%mod;
}
int main()
{
	int n,count;
	long long sum=1,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=1000005;i++)yinzi[i]=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		b[i]=a[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=2;j<=sqrt(a[i]);j++)
		{
			count=0;
			if(a[i]%j!=0)continue;
			else
			while(a[i]%j==0)
			{
				count++;
				a[i]/=j;
			}
			if(yinzi[j]<count)yinzi[j]=count;
		}
		if(yinzi[a[i]]<1)yinzi[a[i]]=1;   //自身因子加入 
	}
	for(int i=1;i<=1000005;i++)
	{
		if(yinzi[i]==0)continue;
		sum=(sum*pows(i,yinzi[i]))%mod;
	}
	for(int i=0;i<n;i++)
	{
		/*费马小定理  (a/b)%mod=(a*b')%mod
		其中b'=bi^(mod-2)%mod*/
		ans=(ans+sum*pows(b[i],(mod-2)))%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
//#include <iostream>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

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

    vector<ll> a(N);

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

    vector<ll> ruiseki(N+1,0ll),ruisekip(N+1,0ll);

    for (int i = 0; i < N; ++i) {
        ruiseki[i+1]=ruiseki[i]+a[i];
        ruisekip[i+1]=ruisekip[i]+max(a[i],0ll);
    }

    ll psum=ruisekip[N];
    ll ans=0ll;
    //last black
    for (int i = 0; i <= N - K; ++i) {
        ll tmp=ruisekip[i]-ruisekip[i+K];
        tmp+=ruiseki[i+K]-ruiseki[i];
        ans=max(ans,psum+tmp);
    }

    //last white
    for (int i = 0; i < N - K; ++i) {
        ll tmp=ruisekip[i+K]-ruisekip[i];
        ans=max(ans,psum-tmp);
    }

    cout<<ans<<endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.length();
  int odd[2], even[2];
  odd[0] = odd[1] = 0;
  even[0] = even[1] = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0) {
      if (S[i] == '0')
      {
        odd[0]++;
      } else
      {
        odd[1]++;
      }
    } else
    {
      if (S[i] == '0')
      {
        even[0]++;
      } else
      {
        even[1]++;
      }
    }
  }
  cout << min(odd[0] + even[1], odd[1] + even[0]) << endl; 

  return 0;
}


Measured memory_bytes: 3692