akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> count(N, 0);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        count[a]++, count[b]++;
    }
    bool ok = true;
    for (int i = 0; i < N; i++) {
        if (count[i] % 2 == 1) { ok = false; }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 640
S = str(input())
N = len(S)

l_s = S[:int(N//2)]
rev_l_s = l_s[::-1]

r_s = S[int(N//2+1):]
rev_r_s = r_s[::-1]

if (l_s == rev_l_s) & (r_s == rev_r_s) & (r_s == rev_l_s) :
    print("Yes")
else:
    print("No")
    


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


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

    bool hasSnack[N];
    for (int i = 0; i < N; i++) hasSnack[i] = false;

    for (int k = 0; k < K; k++) {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++) {
            int a;
            cin >> a;
            hasSnack[a - 1] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) if (!hasSnack[i]) ans++;

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


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

int K, N;
deque<int> ans;

void solve(int k, int n) {
    if(n == 1) {
        ans.push_back((k + 1) / 2);
        return;
    }

    if(k % 2 == 0) {
        for(int i = 0; i < n - 1; i++) ans.push_front(K);
        ans.push_front(k / 2);
        return;
    }

    solve(k, n - 1);

    ans.push_front((k + 1) / 2);
    if(n % 2 == 0) {
        ans.back()--;
        if(ans.back() == 0) ans.pop_back();
        else {
            while(ans.size() < n) ans.push_back(k);
        }
    }

}

int main() {
    std::ios::sync_with_stdio(false);

    cin >> K >> N;

    solve(K, N);

    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << ' ';
    }
}


Measured memory_bytes: 22272
//in the name of god
#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    if(s[s.size() - 1] != 's')
    {
        s += 's';
    }

    else
    {
        s += "es";
    }

    cout << s << '\n';    
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N + 1];
		for(int i = 0; i < N; i++) {
			h[i + 1] = sc.nextInt();
		}
		sc.close();
		if(N == 2) {
			System.out.println(Math.abs(h[2] - h[1]));
			System.exit(0);
		}
		long[] dp = new long[N + 1];
		for(int i = 1; i < N; i++) {
			if(i == 1) {
				dp[2] = Math.abs(h[2] - h[1]);
				dp[3] = Math.abs(h[3] - h[1]);
			}else if(i == N - 1) {
				long t = dp[N - 1] + Math.abs(h[N] - h[N - 1]);
				dp[N] = Math.min(dp[N], t);
			}else {
				dp[i + 2] = dp[i] + Math.abs(h[i + 2] - h[i]);
				long t = dp[i] + Math.abs(h[i + 1] - h[i]);
				dp[i + 1] = Math.min(dp[i + 1], t);
			}
		}
		System.out.println(dp[N]);
	}
}

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

using namespace std;

int f(int a, int b) {
    int x = (a * 10 + b * 10) / 2;
    if (x % 10 > 0) {
        x += 10;
    }
    x /= 10;
    return x;
}

int main() {

    int a;
    cin >> a;

    int b;
    cin >> b;

    int result = f(a, b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
///1000000000000

#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl
long long n, in, ans = 1;
int main ()
{
  cin >> n;
  in = log2(n) + 1;
  for(int i = 1; i <= in; i++) ans *= 2;
  cout << ans-1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,ans=0;
	string s,t,u;
	in(n);
	in(s);

	repeq(i, 0, 9) {
		ll x = s.find((char)(i + '0'));
		if (x >= 0 && x < s.length() - 2) {
			t = s.substr(x + 1);
			repeq(j, 0, 9) {
				ll y=t.find((char)(j + '0'));
				if (y >= 0 && y < t.length() - 1) {
					u = t.substr(y + 1);
					repeq(k, 0, 9) {
						ll z = u.find((char)(k + '0'));
						if (z>=0) {
							ans++;
						}
					}
				}
			}
		}
		
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 436
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    double ans=0;
    double p=1;
    ll b=binary_power(2,m);
    double a=1.0/b;
    rep(i,1000000) {
        double tp=p*a;
        ans+=((n-m)*100+m*1900)*(i+1)*tp;
        p-=tp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [x, y] = input[0].map(Number);

  const groups = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]];

  for (const group of groups) {
    if (group.includes(x) && group.includes(y)) {
      return "Yes";
    }
  }

  return "No";
};

console.log(main(read()));


Measured memory_bytes: 29628
N,K=map(int,input().split())
S=list(map(int,input().split()))

L=[0]*(N-K+1)

target=0


for i in range(N-K+1):
    if i==0:
        for j in range(K):
            target+=S[j]
        L[0]=target
    else:    
        target+=S[K+i-1]-S[i-1]
        L[i]=target
best=max(L)    
print((best+K)/2)
    

Measured memory_bytes: 25060
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  string S;
  cin >> S;
  int N = S.length();
  // cout << N << endl;
  string S1 = S.substr(0, (N - 1) / 2);
  string S2 = S.substr(((N + 3) / 2)-1, N);
  // cout << S1 << endl;
  // cout << S2 << endl;
  if (S1 == S2)
  {
    cout << "Yes" << endl;
    return 0;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){ cin >> a[i]; }
  sort(a.begin(),a.end());
  
  cout << a[n-1]-a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ps = list(map(int, input().split()))
G = list(range(N))
def getparent(n):
  if G[n] == n:
    return n
  G[n] = getparent(G[n])
  return G[n]
for i in range(M):
  x, y = map(int, input().split())
  x, y = x-1, y-1
  x = getparent(x)
  y = getparent(y)
  G[x] = y
#print(G)
Ss = [set() for i in range(N)]
for i in range(N):
  j = getparent(i)
  Ss[j].add(ps[i])
#print(Ss)
r = 0
for i in range(N):
  if i+1 in Ss[G[i]]:
    r += 1
print(r)


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

#define MOD 1000000007
// #define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

#define INF 100000000000

int main(int argc, char const *argv[]) {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B), x(Q);
    for (int i = 0; i < A; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> t[i];
    }
    for (int i = 0; i < Q; ++i) {
        cin >> x[i];
    }

    for (int i = 0; i < Q; ++i) {
        auto s_it = lower_bound(s.begin(), s.end(), x[i]);
        auto t_it = lower_bound(t.begin(), t.end(), x[i]);
        ll s_left = (s_it != s.begin()) ? *prev(s_it) : -1;
        ll s_right = (s_it != s.end()) ? *s_it : -1;
        ll t_left = (t_it != t.begin()) ? *prev(t_it) : -1;
        ll t_right = (t_it != t.end()) ? *t_it : -1;

        // print(s_left, s_right, t_left, t_right);

        ll ans = INF;
        if (s_left >= 0 && t_left >= 0) {
            ll dist = x[i] - min(s_left, t_left);
            ans = min(dist, ans);
            // print("1:", dist);
        }
        if (s_left >= 0 && t_right >= 0) {
            ll dist = min(x[i] + t_right - s_left*2, t_right*2 - x[i] - s_left);
            ans = min(dist, ans);
            // print("2:", dist);
        }
        if (s_right >= 0 && t_left >= 0) {
            ll dist = min(x[i] + s_right - t_left*2, s_right*2 - x[i] - t_left);
            ans = min(dist, ans);
            // print("3:", dist);
        }
        if (s_right >= 0 && t_right >= 0) {
            ll dist = max(s_right, t_right) - x[i];
            ans = min(dist, ans);
            // print("4:", dist);
        }

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


Measured memory_bytes: 3712
// abc135b: 0 or 1 Swap
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define downto(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define in(x) cin>>(x)
#define out(x) cout<<(x)
#define oute(x) cout<<(x)<<endl

void p1(vi a){
  upto(i,0,a.size(),1) cout<<a[i]<<",";
}
void p2(vvi &x){
  for(auto v: x){
    cout<<"["; p1(v); cout<<"]\n";
  }
}

int main(){
  int n;in(n);
  // oute(n);//////

  int c=0;
  vi p(n+1);
  upto(i,1,n+1,1){
    int k;in(k);
    p[k] = i;
    if(i!=k)c++;
  }

  // out("[");p1(p);out("]\n");///
  // oute(c);//

  oute(c>2?"NO":"YES");

}

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

typedef long long ll;


int main()
{
    string s;
    cin>>s;
    int len=s.size();
    for(int i=0; i<len; i++)
        if(s[i]!=s[len-i-1])
        {

            cout<<"No"<<endl;
            return 0;
        }
    int len1=(len-1)/2;
    for(int i=0;i<len1;i++)
    {
          if(s[i]!=s[len1-i-1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    len1=(len+3)/2;
    for(int i=len1-1;i<len;i++)
    {
          if(s[i]!=s[len-i-2+len1])
        {
//            cout<<i<<" "<<len-i-2+len1<<" "<<endl;
//            cout<<"??"<<endl;
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n,a,b;cin>>n;
    if(n==1)cout<<"Hello World";
    if(n==2){cin>>a>>b;cout<<a+b;}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 100005
#define inf 100000000000000000LL
ll a[mx], b[mx], c[mx];
/// 0     1       2
int n;
ll dp[mx][3];
int main()
{
    while(scanf("%d",&n)){
        for(int i=1; i<=n; i++)
            scanf("%lld%lld%lld",&a[i], &b[i], &c[i]);
        dp[1][0] = a[1];
        dp[1][1] = b[1];
        dp[1][2] = c[1];
        for(int i=2; i<=n; i++){
            dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
            dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
            dp[i][2] = c[i] + max(dp[i-1][0] , dp[i-1][1]);
        }
        printf("%lld\n",max(dp[n][0], max(dp[n][1], dp[n][2])));
        return 0;
    }
}



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

int main(){
  string S;
  getline(cin,S);
  if (S == "abc" || S == "acb" || S == "bac" || S == "bca"||S == "cab"||S == "cba"){
    cout <<"Yes"<<endl;
  }else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>

using namespace std;

int main() {
    string s;
    cin>>s;
    int ans = 0, len = s.length();
    for (int i=0, j=len-1; i<j;) {
        if (s[i] == s[j]) i++, j--;
        else if (s[i] == 'x') i++, ans++;
        else if (s[j] == 'x') j--, ans++;
        else {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iostream>
#include <limits>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef stringstream ss;
const int mii = numeric_limits<int>::min();
const int mai = numeric_limits<int>::max();
const ll mil = numeric_limits<long long>::min();
const ll mal = numeric_limits<long long>::max();

#define REP(i, a, b) for(int i=a; i<=b; ++i)
#define RREP(i, a, b) for(int i=a; i>=b; --i)
#define PB(x) push_back(x)

int main(int argc, char **argv) {

    int n, k, c;
    string s;
    cin >> n >> k >> c;
    cin >> s;

    vi l(k);
    vi r(k);

    int cc = 0;

    int kc = 0;
    REP(i, 0, n-1 && kc < k) {
        if(cc > 0) {
            cc--;
            continue;
        }

        if(s[i] == 'o') {
            l[kc] = i;
            ++kc;
            cc = c;
        }

    }

    kc = k-1;
    cc=0;
    RREP(i, n-1, 0 && kc >= 0) {
        if(cc > 0) {
            cc--;
            continue;
        }

        if(s[i] == 'o') {
            r[kc] = i;
            kc--;
            cc = c;
        }
    }

    REP(i, 0, k-1) {
        if(l[i] == r[i])
            cout << l[i]+1 << endl;
    }
}

Measured memory_bytes: 3332
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int X;
	scan(X);
	ll now=0;
	rep1(i,INF){
		now=(now+X)%360;
		if(now==0){
			prin(i);
			return 0;
		}
	}
	return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    long long len=s.size();
    long long sum=0,c=-1;
    for(int i=0;i<len;i++){
        if(s[i]=='W') {sum+=i;c++;}
    }
    c=c*(c+1)/2;
    cout<<(sum-c);
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    ll H;
    cin >> N >> H;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    ll aMax = a[0];
    ll ans = 0;
    // max(a[i])より大きいb[j]の刀を投げまくり
    for (int i = 0; 0 < H && i < N; i++) {
        if (aMax < b[i]) {
            H -= b[i];
            ans++;
        }
    }
    // 残ったHPはmax(a[i])を何回も振る
    if (0 < H) {
        ans += (H + aMax-1) / aMax;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 4824
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> k;
    m = n/k;
    ans = pow(m,3);
    if(k%2==0){
        for(int i=1; i<=n;i++){
            if(i%k==k/2){
                sum++;
            }
        }
    }
    ans += pow(sum,3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i] = sc.nextInt();
      int g = gcd(a[0],a[1]);
      for(int i = 2;i < n;i++){
      	g = gcd(g,a[i]);
      }
      System.out.println(g);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
	string s;
	cin >> s;
	rep (i, s.size()-1) {
		if (s[i] == s[i+1]) {
			puts("Bad");
			return 0;
		}
	}
			puts("Good");

	return 0;
}

Measured memory_bytes: 764
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll>h(n);
    rep(i,n)cin>>h[i];
    int ans=0;
    int count=0;
    rep(i,n-1){
        if(h[i]>=h[i+1])count++;
        else{
            chmax(ans,count);
            count=0;
        }
    }
    chmax(ans, count);
    cout<<ans<<"\n";
}


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

int main(){
    string s;
    cin>>s;
    vector<int> cnt(26,0);

    for(int i=0; i<s.size(); i++){
        cnt[s[i] - 'a']++;
    }

    string ans;

    if(s.size() != 26){
        ans = s;
        for(int i=0; i<26; i++){
            if(cnt[i] == 0){
                ans += (char)('a'+i);
                break;
            }
        }
    }

    else{

        if(s == "zyxwvutsrqponmlkjihgfedcba") ans = "-1";

        else{
            string tmp = s;
            next_permutation(s.begin(),s.end());

            ans = "";

            for(int i=0; i<s.size(); i++){
                ans += s[i];
                if(s[i] > tmp[i]) break;
            }
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b)
{
	return a<=b ? a:b;
}

int main()
{
	int N, M, X;
	scanf("%d%d%d", &N, &M, &X);
	int A[M];
	for(int i=0;i<M;i++) scanf("%d", &A[i]);
	
	int sum_1 = 0;
	int sum_2 = 0;
	for(int i = 0;i < M;i++)
	{
		if (A[i] < X) ++sum_1;
		else ++sum_2;
	}
	
	printf("%d", min(sum_1, sum_2));
	
	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++)
#define all(x) x.begin(),x.end()

int main() {
   int x;
   cin >> x;
   int ans=1;
   for(int b=2;b<=x;b++){
      int p=b*b;
      while(p<=x){
         ans=max(ans,p);
         p*=b;
      }
   }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){
	long long s, ans = 0;
	map<long long, bool> m;

	cin >> s;

	while (1){
		if (!m[s]){
			m[s] = true;
			++ans;
			if (s % 2 == 0)
				s /= 2;
			else
				s = s * 3 + 1;
		}
		else{
			break;
		}
	}
	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
typedef long long LL;
using namespace std;
typedef std::pair<int, int> pii;
typedef std::pair<LL, LL> pll;
const int MAXN = 234567;
int a[MAXN], ans[MAXN];
vector<int> G[MAXN];
vector<int> LIS;

void dfs(int cur, int par) {
    auto it = lower_bound(LIS.begin(), LIS.end(), a[cur]);
    int idx = -1, val = -1;
    if (it == LIS.end()) {
        LIS.push_back(a[cur]);
    } else {
        idx = (it - LIS.begin());
        val = LIS[idx];
        LIS[idx] = a[cur];
    }
    ans[cur] = (int)LIS.size();
    for (int i : G[cur]) {
        if (i == par) continue;
        dfs(i, cur);
    }
    if (idx == -1) LIS.pop_back();
    else LIS[idx] = val;
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0);
    for (int i = 1; i <= N; i++)
        printf("%d\n", ans[i]);

    return 0;
}


Measured memory_bytes: 28408
#include <iostream>
using namespace std; typedef long long ll;
int main() {
  int a,b,m; cin>>a>>b>>m;
  int c[a],d[b];
  for(int i=0;i<a;i++) cin>>c[i];
  for(int i=0;i<b;i++) cin>>d[i];
  int mn=1e9; for(int i=0;i<b;i++) mn=min(mn,d[i]);
  int an[a];
  for(int i=0;i<a;i++) {
    an[i] = c[i] + mn;
  }
  for(int i=0;i<m;i++) {
    int x,y,z; cin>>x>>y>>z; x--; y--;
    an[x] = min(an[x], c[x]+d[y]-z);
  }
  int ans=1e9;
  for(int i=0;i<a;i++) {
    ans=min(ans,an[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdio>

using namespace std;

typedef long double ld;
typedef long long ll;
const int MAX = 100010;
bool cal[MAX];
ll N,K,T,U,V,L;

void input(){
  cin >> N >> K >> T >> U >> V >> L;
  for(int i = 0; i < N; i++){
    int pos;
    cin >> pos;
    cal[pos] = true;
  }
}

void solve(){
  ld ans = 0;
  ll boost = 0;

  for(int i = 0; i < L; i++){
    if(cal[i]) boost = min((K+1)*T*V,boost+T*V); 
    //cout << boost << endl;
    if(boost > 0){
      boost--;
      ans += 1.0/(ld)V;
    }else{
      ans += 1.0/(ld)U;
    }
 
  }
  printf("%.8Lf\n",ans);
}

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

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
	
	int m,f,b;
	cin>>m>>f>>b;
	if(b-m<=0){
		cout<<0<<endl;
	}
	if(b-m>0 && b-m<=f){
		cout<<b-m<<endl;
	}
	if(b-m>0 && b-m>f){
		cout<<"NA"<<endl;
	}
	/*int a,b;
	cin>>a>>b;
	cout<<(a+b)/2<<endl;*/
	
	/*random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rnd3(1, 3);
	
	string p1, p2, p3, p4;
	cin >> p1 >> p2 >> p3 >> p4;
	
	int t = rnd()%3;
	
	if(t == 0){
		cout << "1:" << p1 << ',' << p2 << endl;
		cout << "2:" << p3 << ',' << p4 << endl;
	}
	if(t == 1){
		cout << "1:" << p1 << ',' << p3 << endl;
		cout << "2:" << p2 << ',' << p4 << endl;
	}
	if(t == 2){
		cout << "1:" << p1 << ',' << p4 << endl;
		cout << "2:" << p2 << ',' << p3 << endl;
	}*/
	
	/*
	switch(type){
		case 0:
			cout << "1:" << p1 << ',' << p2 << endl;
			cout << "2:" << p3 << ',' << p4 << endl;
			break;
		case 1:
			cout << "1:" << p1 << ',' << p3 << endl;
			cout << "2:" << p2 << ',' << p4 << endl;
			break;
		case 2:
			cout << "1:" << p1 << ',' << p4 << endl;
			cout << "2:" << p2 << ',' << p3 << endl;
			break;
	}
	*/
	
	
	return 0;
}



Measured memory_bytes: 3108
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
	{
		int f,l;
		cin>>f>>l;
		ans+=(l-f+1);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

signed main(){
	string S,T;
	
	cin>>S>>T;
	
	for(int i = 0; i < S.size(); i++){
		if(S[i] == T[i]){
			
		}else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}



Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(10**6)
def rec(i,j):
    res=0
    if(dp[i][j]>=0):
        return dp[i][j]
    if(i==n):
        res=0
    elif(j<w[i]):
        res=rec(i+1,j)
    else:
        res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i])
    dp[i][j]=res
    return res
n,x=map(int,input().split())
dp=[[-1]*(x+10) for i in range(n+10)]
w,v=[],[]
for i in range(n):
    a,b=map(int,input().split())
    w.append(a);v.append(b)
print(rec(0,x))

Measured memory_bytes: 150664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  ll B[N - 1];
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i];
  }
  ll ans = B[0] + B[N - 1 - 1];
  for (int i = 1; i < N - 1; i++) {
    ans += min(B[i],B[i - 1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

struct edge {
	int a, b; ll y;
	bool operator<(const edge &o) const {
		return y < o.y;
	}
};

edge e[N];
ll x[N], wt[N];
int sz[N], parent[N];
priority_queue<ll, vector<ll>, greater<ll>> pq[N];

int get_root(int u);
void merge(int u, int v, ll w);
void clear_pq(int i);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i];
		wt[i] = x[i];
		sz[i] = 1;
		parent[i] = i;
	}
	for (int i = 1; i <= m; ++i) {
		cin >> e[i].a >> e[i].b >> e[i].y;
	}
	sort(e + 1, e + 1 + m);
	for (int i = 1; i <= m; ++i) {
		merge(e[i].a, e[i].b, e[i].y);
	}
	cout << pq[get_root(1)].size() << endl;
}

int get_root(int u) {
	if (parent[u] != u) {
		parent[u] = get_root(parent[u]);
	}
	return parent[u];
}

void merge(int u, int v, ll w) {
	u = get_root(u);
	v = get_root(v);
	if (u == v) {
		if (w > wt[u]) {
			pq[u].push(w);
		} else {
			clear_pq(u);
		}
		return;
	}
	if (sz[u] < sz[v]) {
		swap(u, v);
	}
	wt[u] += wt[v];
	sz[u] += sz[v];
	parent[v] = u;
	if (w > wt[u]) {
		while (!pq[v].empty()) {
			pq[u].push(pq[v].top());
			pq[v].pop();
		}
		pq[u].push(w);
	} else {
		clear_pq(u);
		clear_pq(v);
	}
}

void clear_pq(int i) {
	while (!pq[i].empty()) {
		pq[i].pop();
	}
}

Measured memory_bytes: 13172
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
int dp[100][100];

int main (){
	int top[3];
	for(int i=0 ;i<3; ++i){
		top[i]=0;
	}
	for(int i=0; i<10; ++i){
		int tmp;
		cin >> tmp;
		for(int j=0; j<3; ++j){
			if(top[j]<tmp){
				swap(top[j],tmp);
			}
		}
	}
	for(int i=0; i<3; ++i){
		cout << top[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const int MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    long long res = 0;
    long long two_factor = 1;
    for (int d = 0; d < 60; ++d) {
        long long even = 0, odd = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] & (1LL<<d)) ++odd;
            else ++even;
        }
        long long add = (odd * even) % MOD * two_factor % MOD;
        res = (res + add) % MOD;
        two_factor = (two_factor * 2) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)

S = sum(a)
cond = S / 4 / m
Buy = True

for i in range(m):
    if a[i] < cond:
        Buy = False
        break

if Buy:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const double EPS=1e-9;
const double PI=acos(-1.0);
//const long double PI=acos(-1.0L);

struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}

    Point operator +(const Point &b) const {return Point(x+b.x,y+b.y);}
    Point operator -(const Point &b) const {return Point(x-b.x,y-b.y);}
    Point operator *(const double b) const {return Point(x*b,y*b);}
    Point operator /(const double b) const {return Point(x/b,y/b);}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point a,Point b):a(a),b(b){}
};

int sgn(double a) {return (a>EPS)-(a<-EPS);}
int sgn(double a,double b) {return sgn(a-b);}

double dot(const Point &a,const Point &b) {return (a.x*b.x+a.y*b.y);}
double cross(const Point &a,const Point &b) {return (a.x*b.y-a.y*b.x);}
double norm(const Point &p) {return dot(p,p);}
double abs(const Point &p) {return sqrt(norm(p));}

vector<Point> ConvexHull(vector<Point> ps,bool linear){
    sort(ps.begin(),ps.end(),[](Point &a,Point &b){
        return (a.x!=b.x?a.x<b.x:a.y<b.y);
    });
    int n=ps.size();
    vector<Point> res(2*n);
    int lim=linear?0:1;

    int k=0;
    for(int i=0;i<n;i++){
        while(k>=2&&sgn(cross(res[k-1]-res[k-2],ps[i]-res[k-2]))<lim) --k;
        res[k++]=ps[i];
    }
    int t=k+1;
    for(int i=n-2;i>=0;i--){
        while(k>=t&&sgn(cross(res[k-1]-res[k-2],ps[i]-res[k-2]))<lim) --k;
        res[k++]=ps[i];
    }

    res.resize(k-1);
    return res;
}


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

  int N;
  cin>>N;
  vector<Point> ps(N);
  rep(i,N) cin>>ps[i].x>>ps[i].y;

  vector<Point> h=ConvexHull(ps,false);
  int m=h.size();
  vector<double> ans(m,0.0);
  if(m==2){
      ans[0]=0.5;
      ans[1]=0.5;
  }else{
    for(int i=0;i<m;i++){
        Point v1=h[(i-1+m)%m]-h[i];
        Point v2=h[(i+1)%m]-h[i];
        double val=dot(v1,v2);
        val/=abs(v1);
        val/=abs(v2);
        ans[i]=(PI-acos(val))/(2*PI);
    }
  }

  for(int i=0;i<N;i++){
      int tar=-1;
      for(int j=0;j<m;j++){
          if(sgn(ps[i].x-h[j].x)==0&&sgn(ps[i].y-h[j].y)==0) tar=j;
      }
      if(tar==-1) cout<<fixed<<setprecision(15)<<0.0<<endl;
      else cout<<fixed<<setprecision(15)<<ans[tar]<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    //dp[i][j] denotes the least weight to get a value of
   // j from the first i objects
   dp[0][0]=0;//It takes 0 weight here
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
      // Just set it arbitrarily large
       //because it's not possible 
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
                //Either don't choose this object(dp[i][j]) or choose this object
                //The value without it would be j-object[i].value
                //the minimum weight would be the minimum weight needed to
                //get a value of j- object[i].value and add the weight of this object.
           }
           else{
               //If I choose this object the value will go over j
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){//Is it possible to get value of j in less than w weight
               ans=max(ans,j);//Find maximum such j
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}

Measured memory_bytes: 82460
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    int n;
    cin>>n;
    map<int,int> mp;
    V<int> a(n);
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(all(a));
    int m=a[n-1]+1;
    bool ok=1;
    if(a[0]<m/2) ok=0;
    if(ok){
        if(m%2==0){
            if(a[0]!=m/2) ok=0;
            if(a[0]==m/2&&mp[a[0]]!=2) ok=0;
        }else{
            if(a[0]!=m/2) ok=0;
            if(a[0]==m/2&&mp[a[0]]!=1) ok=0;
        }
        set<int> st;
        for(auto pp:mp){
            int u=pp.ft,v=pp.sc;
            st.insert(u);
            if(u!=m/2){
                if(v<2) ok=0;
            }
        }
        int t=st.size();
        if(m%2==0){
            if(t<m/2) ok=0;
        }else{
            if(t<m/2+1) ok=0;
        }
    }
    if(ok) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	string s;
	cin >> s;
	int ans = stoi(s);
	int sum = 0;
	rep0(i, s.length() - 1) {
		sum += s[i] - '0';
	}
	if (ans % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main() {
	int N, K;
	int height[100000];

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

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (height[i] >= K) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


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

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int l=1,s=0;
	int ans=-1;
	while(l<n){
		if(a[l+1]<=a[l]){
			s++;
		}else{
			ans=max(ans,s);
			s=0;
		}
		l++;
	}
	ans=max(ans,s);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string S;
  cin >> S;
  int ans = 0;
  for (auto s : S) {
    if (s == '-')
      --ans;
    else
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
    print('Yes')
else:
    print('No')


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

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

  int sum = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i != j) {
        sum += d[i] * d[j];
      }
    }
  }

  cout << sum / 2 << endl;
}


Measured memory_bytes: 256
K, N = map(int, input().split())
Aj = list(map(int, input().split()))

ans = 0
max = 0 
for i in range(N-1):
	diff = Aj[i+1] - Aj[i]
	ans += diff
	if max < diff:
		max = diff
diff = K-Aj[N-1]+Aj[0] 
ans += diff
if max < diff:
	max = diff
ans -= max
print(ans)

Measured memory_bytes: 25836