akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def calc_point(T):
    cnt = 0
    for i in range(N):
        if T[i] == "r":
            cnt += P
        elif T[i] == "s":
            cnt += R
        elif T[i] == "p":
            cnt += S
    return cnt

r_cnt = 0
s_cnt = 0
p_cnt = 0
dic = {}
for i in range(N-K):
    if i in dic:
        continue
    if T[i] == T[i+K]:
        if T[i] == "r":
            r_cnt += 1
        elif T[i] == "s":
            s_cnt += 1
        elif T[i] == "p":
            p_cnt += 1
        dic[i+K] = 1


print(calc_point(T) - ((r_cnt)*P + (s_cnt)*R + (p_cnt)*S))


Measured memory_bytes: 44912
import java.util.*;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String weather = sc.next();
      	if(weather.equals("Sunny")){
        	System.out.println("Cloudy");
        }else if(weather.equals("Cloudy")){
        	System.out.println("Rainy");
        }else if(weather.equals("Rainy")){
        	System.out.println("Sunny");
        }
	}
 
}

Measured memory_bytes: 21844
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**9

cta = 0
ctb = 0
a = [0]*n
b = [0]*n
for i in range(n):
    if s[i] == '.':
        cta += 1
    else:
        ctb += 1
    a[i] = cta
    b[i] = ctb
for i in range(n):
    res = min(res,b[i]+a[-1]-a[i])
res = min(res,a[-1],b[-1])
print(res)  

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s, zs;
	int q;
	cin >>s >>q;
	int hts = 0;
	rep(i, q){
		int t; cin>>t;
		if(t==1){
			hts++;
		}else{
			int f; char c;
			cin >>f >>c;
			if((hts%2==0 && f==2) || (hts%2==1 && f==1)) s += c;
			else  zs += c;
		}
	}
	reverse(all(zs));
	s = zs + s;
	if(hts%2==1) reverse(all(s));
	cout << s <<"\n";
	
	
	
	
	
	return 0;
}


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

int main(){
    int yoko,tate,N;
    cin>>yoko>>tate>>N;
    int ans;
    if(yoko<tate){
        ans=N/tate;
        if(N%tate!=0){
            ans++;
        }
    }
    else if(tate<=yoko){
        ans=N/yoko;
        if(N%yoko!=0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = fs.nextInt();
        int m = fs.nextInt();
        long sum = 0 ;
        for(int i=0 ; i<m ; i++){
            sum+=fs.nextInt();
        }
        if(n-sum>=0){
            out.println(n-sum);
        }else{
            out.println("-1");
        }

        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  for (int i = 0; i < N-1; i++) cin >> C.at(i);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += B.at(A.at(i) - 1);
    if (i < N - 1) {
      if (A.at(i+1) - A.at(i) == 1) {
        sum += C.at(A.at(i) - 1);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <utility>
#include <string>
#include <vector>
using namespace std;
int main(){
  int N, p, a, b, c, d, e, f, s, m;
  string l;
  double t;
  while (cin >> N, N){
    vector< pair<double, string> > V;
    for (int i = 0; i < N; ++i){
      cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      t = (double)(s*f*m-p)/(a+b+c+(d+e)*m);
      V.push_back(make_pair(-t, l));
    }
    sort(V.begin(),V.end());
    for (int i = 0; i < N; ++i){
      cout << V[i].second << endl;
    }
    cout << "#" << endl;
  }
  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	vector<ll> l(n);
	rep(i, n)cin>>l[i];
	SORT(l);
	int ans = 0;
	map<tuple<int, int, int>, int> mp;
	rep(i,n){
		For(j,i+1,n){
			For(k,j+1,n){
				if(l[i] == l[j]) continue;
				if(l[j] == l[k]) continue;
				int a = l[i] + l[j];
				int b = l[k];
				if(a > b){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys


def solve(K: int, A: int, B: int):
    for i in range(A,B+1):
        if i % K == 0:
            print("OK")
            exit()
    print("NG")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61764
#include <cstdio>
#include <cstring>
using namespace std;
char S[105][105];

int main()
{
	scanf("%s",&S[1]);
	int len = strlen (S[1]);
	if(len == 2){
		printf("%s",S[1]);
	}else if(len == 3){
		for(int m = len;m >= 1;m--){
				printf("%c",S[1][m - 1]);
		};
	};
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include<tr1::unordered_map>
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,a,n) for(int i=n;i>=a;--i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
const int  maxn=1e5+10;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll n)
{
    ll r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;
    return r;
}
int fa[maxn];
vector<int> ans[maxn];
int a[maxn];
int findfa(int x)
{

    if(fa[x]==x)
        return x;
    else
        return fa[x]=findfa(fa[x]);
}
int main()
{
  io;
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
  {cin>>a[i];
  fa[i]=i;
  ans[i].push_back(i);
  }
  while(m--)
  {

      int x,y;
      cin>>x>>y;
      int t=findfa(x);
      int tt=findfa(y);
      if(t==tt) continue;
      if(ans[t].size()>ans[tt].size())
      {
          ans[t].insert(ans[t].end(),ans[tt].begin(),ans[tt].end());
          fa[tt]=t;
          ans[tt].clear();
      }
      else
      {
          ans[tt].insert(ans[tt].end(),ans[t].begin(),ans[t].end());
          fa[t]=tt;
          ans[t].clear();
      }
  }
  int sum=0;
  for(int i=1;i<=n;i++) sort(ans[i].begin(),ans[i].end());
  for(int i=1;i<=n;i++)
  {

      if(a[i]==i)
      {  //cout<<a[i]<<' ';
          sum++; continue;

      }
      int f=findfa(i);
      int id=lower_bound(ans[f].begin(),ans[f].end(),a[i])-ans[f].begin();
      if(id<ans[f].size()&&ans[f][id]==a[i])
      {
          sum++;
          //cout<<ans[f][0]<<' '<<a[i]<<endl;
      }

  }
  //cout<<endl;
  cout<<sum<<endl;
}


Measured memory_bytes: 13304
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(3), b(3);
    rep(i, 3) {
        cin >> a[i];
    }
    rep(i, 3) {
        cin >> b[i];
    }

    vl dp1(n+1, -INF);  // dp1[i] : i個のドングリを持って取引所A⇒Bの順で行ったときに得られるドングリの個数の最大値
    dp1[0] = 0;
    rep(i, n+1) {
        if(dp1[i] == -INF) {
            continue;
        }
        rep(j, 3) {
            if(i + a[j] <= n) {
                chmax(dp1[i + a[j]], dp1[i] + b[j]);
            }
        }
    }

    ll m = -INF;
    rep(i, n+1) {
        chmax(m, n + dp1[i] - i);
    }

    vl dp2(m+1, -INF);  // dp2[i] : i個のドングリを持って取引所B⇒Aの順で行ったときに得られるドングリの個数の最大値
    dp2[0] = 0;
    rep(i, m+1) {
        if(dp2[i] == -INF) {
            continue;
        }
        rep(j, 3) {
            if(i + b[j] <= m) {
                chmax(dp2[i + b[j]], dp2[i] + a[j]);
            }
        }
    }

    ll ans = -INF;
    rep(i, m+1) {
        chmax(ans, m + dp2[i] - i);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 195584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<fstream>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;


int N;
vector<int>a;
vector<int>ans;
vector<int>eve, odd;
void solveMinus() {
	int mx = -INF;
	int id = 0;
	REP(i, N) {
		if (a[i] > mx) {
			id = i;
			mx = a[i];
		}
	}
	print(a[id]);
	print(N - 1);
	REP(i, id) {
		print(1);
	}
	REP(i, N - id - 1) {
		print(N - id - i);
	}
}
signed main() {
	/*std::ifstream in("rand_0.txt");
	std::cin.rdbuf(in.rdbuf());*/

	cin >> N;
	a.resize(N);
	bool minus = true;
	REP(i, N) {
		cin >> a[i];
		if (a[i] >= 0)minus = false;
	}
	if (minus) {
		solveMinus();
		return 0;
	}
	int cnt = 0;
	int l = 0, r = N - 1;
	while (a[l] < 0) {
		cnt++;
		l++;
		ans.pb(1);
	}
	while (a[r] < 0) {
		cnt++;
		r--;
		ans.pb(r - l + 2);
	}
	int res1 = 0, res2 = 0;
	
	for (int i = l; i <= r; i += 2) {
		if (a[i] >= 0)res1 += a[i];
		else eve.pb(i);
	}
	for (int i = l + 1; i <= r; i += 2) {
		if (a[i] >= 0)res2 += a[i];
		else odd.pb(i);
	}
	int del = 0;
	print(max(res1, res2));
	if (res1 > res2) {
		REP(i, eve.size()) {
			ans.pb(eve[i] - l + 1 - del);
			cnt++;
			del += 2;
		}
		if ((r - l) % 2 == 1) {
			ans.pb(r - l + 1 - del);
			cnt++;
			r--;
		}
		REP(i, (r - l-del) / 2) {
			cnt++;
			ans.pb(2);
		}
		print(cnt);
		REP(i, cnt)print(ans[i]);
	}
	else if (res1 <= res2) {
		REP(i, odd.size()) {
			ans.pb(odd[i] - l + 1 - del);
			cnt++;
			del += 2;
		}
		ans.pb(1);
		cnt++;
		l++;
		if ((r - l) % 2 == 1) {
			ans.pb(r - l + 1 - del);
			cnt++;
			r--;
		}
		REP(i, (r - l-del) / 2) {
			cnt++;
			ans.pb(2);
		}
		print(cnt);
		REP(i, cnt)print(ans[i]);
	}
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = lc()
n = len(s)

if s[0] == "0" or s[-1] == "1" or s[-2] == "0":
    print(-1)
    
elif s[:(n-1)//2] != s[n-2:n//2-1:-1]:
    print(-1)
    
else:
    par = n
    cur = n-1
    print(n,n-1)
    
    if n > 2:
        for si in s[-3::-1]:
            cur -= 1
            print(par,cur)
            if si == "1":
                par = cur

Measured memory_bytes: 6164
import itertools
import math
N = int(input())
xy = []
for i in range(N):
    a, b = map(int, input().split())
    xy.append([a,b])

s = 0

waru = math.factorial(N)
for v in itertools.permutations(xy, N):
    for i in range(len(v)-1):
        s += math.sqrt(pow(v[i][0]-v[i+1][0],2) + pow(v[i][1]-v[i+1][1],2))
print(float(s)/waru)


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<vector<int>> t;
  vector<int> grundy;
  Solver(LL n) : n(n), t(n), grundy(n){};

  void solve() {
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      t[--a].push_back(--b);
      t[b].push_back(a);
    }
    dfs(0, -1);
    cout << (grundy[0] ? "Alice" : "Bob") << endl;
  }
  void dfs(int c, int p) {
    for (auto v : t[c]) {
      if (v != p) {
        dfs(v, c);
        grundy[c] ^= (grundy[v] + 1);
      }
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 10112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        int n = in.intNext();
        int[] arr = in.nextIntArray(n);

        int a = 0;
        int b = Math.abs(arr[1] - arr[0]);

        for (int i = 2; i < n; i++) {
            int tmp = b;
            int first = Math.abs(arr[i] - arr[i-1]) + b;
            int second = Math.abs(arr[i] - arr[i-2]) + a;
            b = Math.min(first, second);
            a = tmp;
        }
        out.println(b);

        out.close();
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}




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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<nl;

    return 0;
}


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

//#define DEBUG

using namespace std;

constexpr uint64_t MAXIMUM_VALUE = 1000000000000000000;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void func_to_create(){
    uint32_t N ;
    cin >> N;
    std::vector<uint64_t> A;
    A.reserve(N);
    uint64_t product = 1;
    bool zero_term = false;
    while(N--){
        uint64_t a;
        cin >> a;
        if(a == 0){
            zero_term = true;
        }
        A.push_back(a);
    }
    if( zero_term){
        cout << 0 << endl;
    }else{
        for(uint32_t i = 0 ; i < A.size() ; i++){
            // cout << " A " << A[i] << endl;
            uint64_t upper_limit = MAXIMUM_VALUE / product;
            if(A[i] > upper_limit){
                cout << -1 << endl;
                return;
            }else{
                product *= A[i];
            }

        }
        cout << product << endl;
    }
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 3;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3972
N = int(input())
x = 0
for i in range(1, N + 1):
    y = 0
    over = False
    m = False
    if i % 2 != 0:


        for j in range(1, i + 1):
            if i % j == 0:
                y = y + 1


                if (y == 8) & (over == False):
                    x = x + 1
                    over = True

                elif (y < 8) & (over == True) & (m == False):
                    x = x -1

print(x)


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace abc075_c
{
    class Program
    {
        public static int[] x;
        public static bool[,] edge = new bool[100,100];
        public static bool[] visited = new bool[100];
        public static void dfs(int v)
        {
            visited[v] = true;
            for (int i = 0; i < x[0]; i++)
            {
                if (!edge[v,i]) continue;
                if (visited[i]) continue;
                dfs(i);
            }
        }
        static void Main()
        {
            x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[x[1]]; int[] b = new int[x[1]];
            for (int i = 0; i < x[1]; i++)
            {
                int[] xx = Console.ReadLine().Split().Select(int.Parse).ToArray();
                xx[0]--; xx[1]--;
                edge[xx[0],xx[1]] = true; edge[xx[1],xx[0]] = true;
                a[i] = xx[0]; b[i] = xx[1];
            }
            int ret = 0;
            for (int i = 0; i < x[1]; i++)
            {
                edge[a[i],b[i]] = false; edge[b[i],a[i]] = false;
                for (int j = 0; j < 100; j++) visited[j] = false;
                dfs(0);
                bool flag = false;
                for (int j = 0; j < x[0]; j++)
                {
                    if (!visited[j]) flag = true;
                }
                if (flag) ret++;
                edge[a[i],b[i]] = true; edge[b[i],a[i]] = true;
            }
            Console.WriteLine(ret);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 1e5 + 5;

ll n, a[N], b[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n;

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

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        ans += min(a[i] + a[i + 1], b[i]);
        b[i] -= min(a[i], b[i]);
        a[i + 1] = max(0ll, a[i + 1] - b[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

//
// solution 
//
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
    }

    if N < 10 {
        println!("0");
        return;
    }

    let mut num_primes = vec![0_usize; N+1];
    for n in 2..N+1 {
        let mut num = n;
        while num > 1 {
            if num % 2 == 0 {
                num_primes[2] += 1;
                num /= 2;
            } else if num % 3 == 0 {
                num_primes[3] += 1;
                num /= 3;
            } else if num % 5 == 0 {
                num_primes[5] += 1;
                num /= 5;
            } else if num % 7 == 0 {
                num_primes[7] += 1;
                num /= 7;
            } else {
                num_primes[num] += 1;
                num /= num;
            }
        }
    }

    // (2, 4, 4) or (4, 14) or (2, 24) or 74 を探す
    let num4 = num_primes.iter().filter(|a| **a >= 4).count();
    let num2 = num_primes.iter().filter(|a| **a >= 2).count();
    let num14 = num_primes.iter().filter(|a| **a >= 14).count();
    let num24 = num_primes.iter().filter(|a| **a >= 24).count();
    let num74 = num_primes.iter().filter(|a| **a >= 74).count();

    let num_4_4_1 = 
        if num4 >= 2 {
            num4 * (num4 - 1) / 2 * (num2 - 2) 
        } else {
            0
        };
    let num_4_14 = 
        if num4 >= 2 {
            num14 * (num4 - 1)
        } else {
            0
        };
    let num_2_24 =
        if num2 >= 2 {
            num24 * (num2 - 1)
        } else {
            0
        };

    println!("{}", num_4_4_1 + num_4_14 + num_2_24 + num74);
}


Measured memory_bytes: 4352
N = int(input())
a = [int(i) for i in input().split()]
c = 1
i = 0
while i < len(a):
    try:
        i = a.index(c,i)
        c += 1
    except:
        break
if c == 1:
    print(-1)
else:
    print(len(a)-c+1)

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

using ll = long long;

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

  ll ans{};
  for (int i{}; i <= K; ++i) {
    if (i == S) {
      ++ans;
      break;
    }
    for (int j{}; j <= K; ++j) {
      int r = S - (i + j);
      if (!r) {
        ++ans;
        break;
      }
      if (r <= K)
        ++ans;
    }
  }

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


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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {

    int n;
    cin >> n;

    int i = 1;
    while(1) {
        int x = i * 1000;
        if (x-n>=0) {
            printf("%d\n", x-n);
            return 0;
        }
        i++;
    }


  
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3760
N, M = map(int, input().split())
ERR = COR = 0
AC = [0]*N
WA = [0]*N

for i in range(M):
    s, t = input().split()
    s = int(s)-1

    if (t == 'AC' and AC[s] == -1):
        continue

    elif (t =='AC'):
        COR += 1
        AC[s] = -1
        ERR += WA[s]
    
    elif (t == 'WA'):
        WA[s] += 1

print(COR, ERR)

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a1(n), a2(n);
	for(int i = 0; i < n; ++i){ cin >> a1[i]; }
	for(int i = 0; i < n; ++i){ cin >> a2[i]; }
	for(int i = 1; i < n; ++i){ a1[i] += a1[i - 1]; }
	for(int i = n - 2; i >= 0; --i){ a2[i] += a2[i + 1]; }
	int answer = 0;
	for(int i = 0; i < n; ++i){
		answer = max(answer, a1[i] + a2[i]);
	}
	cout << answer << endl;
	return 0;
}



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

int main(){
    //元値
    int price = 700;

    string order;
    cin >> order;

    for (int i = 0; i < 3; i++) {
        if (order.at(i) == 'o') {
            price += 100;
        }
    }

    cout << price << endl;
}

Measured memory_bytes: 256
#include<cstdio>

int mi(int t)
{
	int s=1;
	for(int i=1;i<=t;i++) s*=2;
	return s;
}

int main()
{
	int n,t=1;
	scanf("%d",&n);
	while(mi(t)<=n) t++;
	printf("%d\n",mi(t-1)); 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
int main() {
  int n; cin>>n;
  vector<int> d(n); rep(i,n) cin>>d[i];
  sort(d.begin(),d.end());
  d.erase(unique(d.begin(),d.end()),d.end());
  cout<<d.size();
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; ++i) {
        cin >> S[i];
    }

    int dw[] = {
        0, 1, 1, 1, 0, -1, -1, -1
    };
    int dh[] = {
        -1, -1, 0, 1, 1, 1, 0, -1
    };

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') {
                continue;
            }
            int sum = 0;
            for (int k = 0; k < 8; ++k) {
                int pos_h = i + dh[k], pos_w = j + dw[k];
                if (0 <= pos_w && pos_w < W && 0 <= pos_h && pos_h < H) {
                    if (S[pos_h][pos_w] == '#') {
                        sum++;
                    }
                }
            }
            S[i][j] = '0' + sum;
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << S[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
using System;

class main
{
    public static int n = 1000000;
    static void Main()
    {
        string s;
        int c, q;
        int[] p = new int[n];
        for (int i = 2; i < 1001; ++i)
            for (int j = i * 2; j < n; j += i)
                p[j] = 1;
        while ((s = Console.ReadLine()) != null)
        {
            c = int.Parse(s);
            q = 0;
            for (int i = 2; i <= c; ++i)
                if (p[i] != 1) ++q;
            Console.WriteLine("{0}", q);
        }
    }
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 2005;
const int mod = 1e9+7;
int f[maxn],n,k;
int main(){
	n = rd(),k = rd();
	mem(f,0);
	f[n+1] = 1;
	Dep(i,n,n-k+1){
		Dep(j,n,i+1)f[j]=0;
		Dep(j,i,1) f[j] = (f[j] + f[j+1]) % mod;
	}
	ll ans = f[1];
	Rep(i,1,n-k-1)ans=ans*2%mod;
	writeln(ans);
}
//看不懂题解233

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int main(){
	int n;scanf("%d",&n);
	printf("%lld\n",1ll*n*(n-1)>>1);
	return 0;
}

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

using namespace std;

int main() {
	int point = 0, hits = 0, out = 0;
	int n; cin >> n;
	
	int i = 0;
	while (i < n) {
		string s; cin >> s;
		if (s == "HIT") {
			hits++;
			if (hits == 4) {
				point++;
				hits--;
			}
		}
		if (s == "OUT") {
			out++;
			if (out == 3) {
				hits = 0;
				out = 0;
				cout << point << endl;
				point = 0;
				i++;
			}
		}
		if (s == "HOMERUN") {
			point += hits + 1;
			hits = 0;
		}
	}
	
	return 0;
}

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

using namespace std;

int main( void ) {
  string s;
  cin >> s;
  bool answer = true;
  for ( int i = 0; i < 4; i++){
    char target = s[i];
    int count = 0;
    for ( int j = 0; j < 4; j++){
      if(target == s[j]) count++;
    }
    if(count == 2){
      answer &= true;
    }else{
      answer &= false;
    }
  }
  if(answer){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            int sum = 10000*i + 5000*j+1000*(N-i-j);
            if(sum==Y){
                cout << i << " " << j << " " <<(N-i-j)<<endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1"<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    string S;cin>>S;
    vector<vector<int>> when(10);
    for(int i=0;i<N;i++) when[S[i]-'0'].push_back(i);
    
    for(int i=0;i<10;i++){
        for(int j=0;j<3;j++){
            when[i].push_back(INF);
        }
    }
    
    int cnt=0;
    
    for(int i=0;i<10;i++){
        int a=when[i][0];
        if(a==INF) continue;
        for(int j=0;j<10;j++){
            int b=*upper_bound(all(when[j]),a);
            if(b==INF) continue;
            for(int k=0;k<10;k++){
                int c=*upper_bound(all(when[k]),b);
                if(c!=INF) cnt++;
            }
        }
    }
    
    cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    print(n/3);

}


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

int main(){
  int num;

  while(cin >> num){
    if(num == 0)
      break;
    int c, sum = 0;
    int N = num*(num-1)/2;
    for(int i = 0; i < N; i++){
      cin >> c;
      sum += c;
    }
    cout << sum / (num-1) << endl;
  }
  


 return 0;

}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int H , W , h , w;

int main()
{
    _FastIO;
    cin >> H >> W;
    cin >> h >> w;
    int x = H - h;
    int y = w * x;
    int ans = y + h * W;
    cout << (H * W) - ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = n // 100
b = n % 100

if a ==0 or (13 <=a<=99):
    if 1<=b<=12:
        ans = 'YYMM'
    else:
        ans = 'NA'
else:
    if b==0 or (13 <=b<=99):
        ans = 'MMYY'
    else:
        ans = 'AMBIGUOUS'


print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<ll> X(n), Y(n);
    loop (n, i) cin >> X[i] >> Y[i];

    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    int ans = 1<<29;
    loop (n, i) loop (n, j) {
        if (i == j) continue;
        ll p = X[i] - X[j], q = Y[i] - Y[j];
        int cnt = 0;
        loop (n, s) loop (n, t) {
            if (X[s] - X[t] == p && Y[s] - Y[t] == q) cnt++;
        }
        ans = min(ans, n - cnt);
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    long long N,M;
    cin >> N >> M;
    if(N>1 && M>1) cout << ((N-2)*(M-2)) << endl;
    else if(N>1) cout << (N-2) << endl;
    else if(M>1) cout << (M-2) << endl;
    else cout << 1 << endl;

    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  int *H;
  cin>>N;
  H = new int[N];
  for(int i =0; i<N; i++)cin>>H[i];
  int view = 0;
  bool flag;
  for(int i =0; i<N; i++){
    flag=true;
    for(int j=0; j<i; j++){
      if(H[j]>H[i]){
        flag=false;
        break;
      }
    }
    if(flag) view+=1;
  }
  cout<<view;
  return 0;
}

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

int main(){
	int N,W,w[100],v[100];
	cin >> N >> W;
	for(int i = 0; i < N; i++){
		cin >> v[i] >> w[i];
	}
	int DP[101][10001];
    	for(int j = 0;j <= W; j++){
       	DP[0][j] = 0;
	}

    	for(int i = 1;i <= N; i++){
		for(int j = 0; j <= W; j++){
			if(j < w[i-1]){
				DP[i][j] = DP[i-1][j];
			}else{
				if(DP[i-1][j] > DP[i][j-w[i-1]] + v[i-1]){
					DP[i][j] = DP[i-1][j];
				}else{
					DP[i][j] = DP[i][j-w[i-1]] + v[i-1];
				}
			}
		}
	}

	cout << DP[N][W] << endl;

	return 0;
}


Measured memory_bytes: 5104
#include <iostream>

int main(){
    using namespace std;
    int n, h, minimum;
    bool yes = true;
    cin >> n;
    cin >> minimum;
    minimum--;
    for (int i=0; i<n-1;i++){
        cin >> h;
        if (minimum > h){
            yes = false;
            break;
        }
        minimum = max(h - 1, minimum);
    }
    if (yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    print(int(n**0.5)**2)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
map<int,string>mp;
int main()
  {
  mp[1199]="ABC";
  mp[2799]="ARC";
  mp[4399]="AGC";
  int n;
  cin>>n;
  for(int i=1199;;i+=1600)
    {
    if(n<=i)
      {
      cout<<mp[i]<<endl;
      break;
      }
    else continue;
    }
  return 0;
  }

Measured memory_bytes: 256
#c

n = int(input())
a = list(map(int,input().split()))

for i in range(1,n+1):
    a[i-1] -= i
a.sort()
num0 = 0
num1 = a[int(n/2)-1]
num2 = a[int(n/2)]
num3 = int((num1 + num2)/2)
num4 = num3 - 1
num5 = num3 + 1
num6 = num1 + 1
num7 = num1 - 1
num8 = num2 + 1
num9 = num2 - 1

ans0 = 0
for i in range(n):
    ans0 += abs(a[i]-num0)
ans1 = 0
for i in range(n):
    ans1 += abs(a[i]-num1)
ans2 = 0
for i in range(n):
    ans2 += abs(a[i]-num2)
ans3 = 0
for i in range(n):
    ans3 += abs(a[i]-num3)
ans4 = 0
for i in range(n):
    ans4 += abs(a[i]-num4)
ans5 = 0
for i in range(n):
    ans5 += abs(a[i]-num5)
ans6 = 0
for i in range(n):
    ans6 += abs(a[i]-num6)
ans7 = 0
for i in range(n):
    ans7 += abs(a[i]-num7)
ans8 = 0
for i in range(n):
    ans8 += abs(a[i]-num8)
ans9 = 0
for i in range(n):
    ans9 += abs(a[i]-num9)

ans = min(ans0,ans1)
ans = min(ans,ans2)
ans = min(ans,ans3)
ans = min(ans,ans4)
ans = min(ans,ans5)
ans = min(ans,ans6)
ans = min(ans,ans7)
ans = min(ans,ans8)
ans = min(ans,ans9)
print(ans)

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

typedef long long ll;

using namespace std;

int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	ll i,j,n,k,sum(0);
	ll val=1e9+7,temp(0),temp2(0);
	cin>>n;
	vector<ll> v(n),s(n+1,0);
	for(i=0;i<n;i++){
		cin>>v[i];
		temp+=v[i];
		s[i+1]=temp;
	}
	for(i=0;i<n-1;i++){
		temp2+=(v[i]*((s[n]-s[i+1])%val))%val;
	}
	cout<<temp2%val;
	







	return 0;
}

Measured memory_bytes: 6324
#include <iostream>
//#include <bits/stdc++.h>
using namespace std;
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
int main() {
	ll a, b;
	cin >> a >> b;
	if(a==1 or b==1)return cout<<1,0;
	cout << (a *b) / 2 + (a * b) % 2;
	
}

Measured memory_bytes: 256
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10 , MOD = 1e9 + 7;
const long double PI = 3.14159265359;

int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);
        cout << fixed << setprecision(15);
        long double aa , bb, a , b , h , m;
        cin >> a >> b >> h >> m;
        aa = fmod(((h + m / 60) * 30) , 360);
        bb = fmod(((h * 60 + m) * 6) , 360);
        long double ans , c = abs(aa - bb);
        c = c * (PI/180);
        ans = sqrt(a*a + b*b - 2 * a * b * cos(c));
        cout << ans << '\n';
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int w[2000];
int main(){
	int n;cin>>n;
	rep(i,n)cin>>w[i];
	int Min=INT_MAX;
	for(int i=1;i<n;i++){
		int s1=0;
		for(int j=0;j<i;j++){
			s1+=w[j];
		}
		int s2=0;
		for(int k=i;k<n;k++){
			s2+=w[k];
		}
		Min=min(Min,abs(s1-s2));
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
A = LIST()

n = max(A+[K]).bit_length()
cnt = [[0, 0] for _ in range(n)]

for a in A:
	b = "{:b}".format(a).zfill(n)[::-1]
	for i in range(n):
		cnt[i][int(b[i])] += 1

max_X = []
for cnt_0, cnt_1 in cnt:
	if cnt_0 <= cnt_1:
		max_X.append(0)
	else:
		max_X.append(1)
max_X = max_X[::-1]     #Aのリストのみから算出た最大Xの2進数表記

k = "{:b}".format(K).zfill(n)

if len(k) == n:
	for i in range(n):
		if int(k[i]) > max_X[i]:
			break
		elif int(k[i]) < max_X[i]:
			max_X[i] = 0

X = 0
for i, p in enumerate(max_X[::-1]):
	X += 2**i*p

#print(X)
ans = 0
for a in A:
	ans += a^X

print(ans)


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

int main()
{

    ll N;
    cin >> N;
    ll c0, c1, c2, c3;
    c0 = c1 = c2 = c3 = 0;
    while (N--)
    {
        string s;
        cin >> s;
        if (s == "AC")
        {
            c0++;
        }
        else if (s == "WA")
        {
            c1++;
        }
        else if (s == "TLE")
        {
            c2++;
        }
        else if (s == "RE")
        {
            c3++;
        }
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    ll A,B;
    cin >> N >> A >> B;
    
    vl h(N);
    in(N,h);
    sort(all(h));
    reverse(all(h));
    
    ll s = 0,t = 1000000000;
    ll AB = A-B;
    while (t-s > 1) {
        ll m = (s+t)/2;
        ll n = 0;
        ll dh;
        rep(i,N){
            dh = h[i];
            dh -= m*B;
            if(dh <= 0) continue;
            n += (dh+AB-1)/AB;
        }
        if(n <= m) t = m;
        else s = m;
        
        //cout << s csp t << endl;
    }
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 1024
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var L = parseInt(input[0].split(" ")[1]);
  var sum=0;
  var min=10000;
  for(var i=1;i<N+1;i++){
    sum+=(L+i-1);
    if(Math.abs(min)>Math.abs(L+i-1)){
      min=L+i-1
    }
  }
  var ans=sum-min;
 
  console.log('%s', ans);
  return ans;
}

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


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

int main() {
  int n, k; cin >> n >> k;
  vector<double> e(n);
  for(int i=0; i<n; i++){
    double p; cin >> p;
    e[i] = (p+1)/2;
  }
  
  double mx,sum_e;
  for(int i=0; i<k; i++){
    sum_e += e[i];
  }
  
  mx = sum_e;
  
  for(int i=0; i<n-k; i++){
    sum_e = sum_e - e[i] + e[i+k];
    if(sum_e > mx) mx = sum_e;
  }
  
  cout << fixed << setprecision(5) << mx << endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
     int W, H, x, y, r; 
     cin >> W >> H >> x >> y >> r; 
     if(r <= x && r <= y && x+r <= W && y+r <= H){ cout << "Yes" << endl; } 
     else cout << "No" << endl; 
     return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n), cnt(100010, 0);
    set<int> st;
    for(int i=0; i<n; i++){
        cin>>a[i];
        cnt[a[i]]++;
        st.insert(a[i]);
    }

    ll ans=0;
    for(int i=1; i<=100000; i++){
        if(cnt[i]>0) ans+=cnt[i]-1;
    }

    int m=st.size();
    if(ans%2==0) cout << m << endl;
    else cout << m-1 << endl;
}

Measured memory_bytes: 5760