akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
   string s;
   cin>>s;
    int n=s.size();
    string odd="RUD",even="LUD";
    bool ans=true;
   rep(i,n){
       if(i%2==0){
           //odd
           bool ok=false;
           rep(j,3){
               if(s[i]==odd[j]){
                   ok=true;
               }
           }
           if(!ok)ans=false;
       }else{
           bool ok=false;
           rep(j,3){
               if(s[i]==even[j]){
                   ok=true;
               }
           }
           if(!ok)ans=false;
       }
   }
   if(ans){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
function main(input)
    arr = [parse.(Int, a) for a in split.(input)]
    N = arr[1]
    prob = arr[2]
    M = arr[3]
    PT = arr[4:end]
    for p in PT
        println(sum([n==p[1] ? p[2] : prob[n] for n in 1:length(prob)]))
    end
end
main(readlines())

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

int main(){
  int k, n;
  int i;
  unsigned long long j = 0;

  cin >> n >> k;
  vector<int> a(n);

  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  
  for(i = 0; i < n-k; i++){
    j += a.at(i);
  }

 cout << j << endl;

}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=400010;
int n,a[N];
bool b[30],c[30];
ll ans;

bool jud(int x){
	rep(i,0,20) c[i]=b[i];
	rep(i,0,20) if (x&(1<<i)){
		if (c[i]) return 0;
		c[i]=1;
	}
	rep(i,0,20) b[i]=c[i];
	return 1; 
}

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	int l=1,r=1;
	rep(i,0,20) if (a[1]&(1<<i)) b[i]=1;
	for (; l<=n; l++){
		while (r<n && jud(a[r+1])) r++;
		ans+=r-l+1;
		rep(i,0,20) if (a[l]&(1<<i)) b[i]=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end

K = gets_i
S = gets_s

if S.size <= K
  puts S
else
  puts S[0,K] + "..."
end

Measured memory_bytes: 14684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vi p(n, 0);
    for (int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        a--;
        p[a]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (k - (q - p[i]) > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    int ans=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
    ans=fmin(ans*2,ans+k);
    }
    printf("%d",ans);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    map<string, int> m;
    rep(i,N) {
        string s;
        cin >> s;
        m[s]++;
    }
    printf("AC x %d\n", m["AC"]);
    printf("WA x %d\n", m["WA"]);
    printf("TLE x %d\n", m["TLE"]);
    printf("RE x %d\n", m["RE"]);
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
    using namespace std;
  #define int long long int
    #define endl "\n"
    #define MOD 1000000007
    #define mod 1000000007
    #define M 1000000007

    #define pb push_back
    #define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
  //  #define mp make_pair
  #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  #define mx 400005
  #define fiint(a,b) memset(a,b,sizeof(a))
  #define bitcount __builtin_popcount
  #define fori(i,a,b) for(int i=a;i<b;i++)
  #define ford(i,a,b) for(int i=a;i>=b;i--)
  #define debug(x) cout<<x<<endl;
  #define cases(t) int t; cin>>t; while(t--)
  #define inf1 INT_MAX
  #define all(a) a.begin(),a.end()
  #define vec vector<int>
  #define pii pair<int,int>
  #define plii pair<int,int>
  #define pint pair<int,int>
  #define ff first
  #define ss second
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define sz(x) (int)x.size()
#define PI                    3.14159265359

bool prime[10000001];

void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
vec v(mx);
vec tree(mx,-1);

signed  main()
{
  //  cout<<"df"<<endl;
    int n ;cin>>n;
    int xo = 0 ;
    vec v(n);
    for(int i = 0 ; i < n ;i++){ cin>>v[i]; xo^=v[i]; }
    for(int i = 0 ; i < n ; i++)
        cout<<(v[i]^xo)<<endl;
}


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

int main(){
    long long N;
    stack<char> ans;
    cin >> N;
    while(N){
        --N;
        ans.push('a'+(N%26));
        N /= 26;
    }
    while(!ans.empty()){
        cout << ans.top();
        ans.pop();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3608
def floor_sum(n, m, a, b):
    ans = 0
    if (a >= m):
        ans += (n - 1) * n * (a // m) // 2
        a %= m
    if (b >= m):
        ans += n * (b // m)
        b %= m

    y_max = (a * n + b) // m
    x_max = (y_max * m - b)
    if (y_max == 0):
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans
t=int(input())
for i in range(t):
    n,m,a,b=map(int,input().split())
    print(floor_sum(n,m,a,b))

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

int main() {
	int N, L;
	cin>> N >> L;
	string arr[N];
	for (int i=0; i<N; i++){
		cin >> arr[i];
	}
	sort(arr, arr+N);
	string ss="";
	for (int i=0; i<N; i++){
		ss += arr[i];
	}
	cout << ss << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  cin >> n;
  cout << (1 + n) * n / 2 << endl;
  return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

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 T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	ll N;
	cin >> N;
	cout << N * (N-1) / 2 << endl;
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  // int n;
  // int m;
  // cin >> n;
  // cin >> m;
  string s, t;
  int a, b;
  string u;
  cin >> s >> t >> a >> b >> u;
  if(u == s) --a;
  else --b;
  cout << a << " " << b;
  


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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const long long MOD = 1e9+7;

int fact[150000], revfact[150000];
queue<int> prime_count;

int powmod(int a, int p){
	int res = 1, tmp = a;
	while(p != 0){
		if(p % 2)
			res = (res*tmp) % MOD;
		tmp = (tmp*tmp) % MOD;
		p /= 2;
	}
	return res;
}

void factmod(){
	fact[0] = revfact[0] = 1;
	for(int i = 1; i < 150000; i++){
		fact[i] = (fact[i-1] * i) % MOD;
		revfact[i] = (revfact[i-1] * powmod(i, MOD-2)) % MOD;
	}
}

int nCrmod(int n, int r){ // nCr % MOD
	return (((fact[n] * revfact[r]) % MOD) * revfact[n-r]) % MOD;
}

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

	int n, m; cin >> n >> m;

	for(int i = 2; i <= sqrt(m); i++){ // 素因数分解して指数を queue に突っ込む
		if(m % i == 0){
			int cnt = 0;
			while(m % i == 0){
				m /= i;
				cnt++;
			}
			prime_count.push(cnt);
		}
		if(m == 1) break;
	}
	if(m != 1) prime_count.push(1);

	factmod();

	int ans = 1;
	while(!prime_count.empty()){
		int bi = prime_count.front();
		ans *= nCrmod(n+bi-1, bi); ans %= MOD;
		prime_count.pop();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    ll ab = a+b;
    ll times = n / ab;
    ans += times * a;
    ll last = n - ab*times;
    ans += min(a,last);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main{public static void main(String[] args) {java.util.Scanner s=new java.util.Scanner(System.in);int n=s.nextInt();long k=s.nextLong();long[] a=new long[n];for(int i=0;i<n;i++)a[i]=s.nextLong();int c=0;while((long)1<<(c+1)<= k)c++;long x=0;for(;c>=0;c--){long m=x+((long)1<<c);if(m<=k){long t=0,u=0;for(long l:a){t+=m^l;u+=x^l;}if(t>=u)x=m;}}long r=0;for(long i:a)r+=x^i;System.out.println(r);}}

Measured memory_bytes: 62876
#include <stdio.h>

int col[1000], row[1000];

int main() {

    int i, j, s, t, w, h, sumC = 0, sumR = 0;
    scanf("%d %d", &w, &h);
    
    for ( i=0; i<w; ++i ) {
	scanf("%d", &col[i]);
	sumC += col[i];
    }
    for ( int i=0; i<h; ++i ) {
	scanf("%d", &row[i]);
	sumR += row[i];
    }

    if ( sumR != sumC ) {
	printf("0\n");
	return 0;
    }
    
    for ( i=0; i<w; ++i ) {

	for ( s=0; s<h; ++s ) {
	    for ( t=s+1; t<h; ++t ) {
		if ( row[s] < row[t] ) {
		    int tmp = row[s];
		    row[s] = row[t];
		    row[t] = tmp;
		}
	    }
	}

	for ( j=0; j<h; ++j ) {
	    if ( !col[i] || !row[j] ) break;
	    --row[j];
	    --col[i];
	}

	if ( col[i] > 0 ) {
	    printf("0\n");
	    return 0;
	}
    }
    printf("1\n");
    
    return 0;
}



Measured memory_bytes: 2112
#81 コラッツの予想

while 1:
    n = int(input())
    if n == 0:
        break
    
    ans = 0
    while n != 1:
        if n%2 == 0:
            n = n//2
            ans += 1
        else:
            n = n*3+1
            ans += 1
    print(ans)


Measured memory_bytes: 5584
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
int t, n;
string s;
int main(){
	cin >>s;
	int ok = 0;
	for(int i = 0; i < s.length() &&!ok; i++){
		if(s[i] == '7')
			ok = 1;
	}
	if(ok)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=200005;

int n,m,cnt,last[N],a[N];
bool vis[N][2],ins[N][2];
struct edge{int to,next,w;}e[N*2];
char s[N];

void addedge(int u,int v,int w)
{
	e[++cnt].to=v;e[cnt].w=w;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].w=w;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x,int y)
{
	vis[x][y]=ins[x][y]=1;
	for (int i=last[x];i;i=e[i].next)
		if (e[i].w!=y)
		{
			if (!vis[e[i].to][y^1]) dfs(e[i].to,y^1);
			else if (ins[e[i].to][y^1]) {puts("Yes");exit(0);}
		}
	ins[x][y]=0;
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
		if (s[i]=='A') a[i]=0;
		else a[i]=1;
	for (int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		addedge(x,y,a[x]^a[y]);
	}
	for (int i=1;i<=n;i++)
	{
		if (!vis[i][0]) dfs(i,0);
		if (!vis[i][1]) dfs(i,1);
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 18048
// 2020 3/25 ABC158 A Station and Bus
#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;

    if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int a[n];
	for(int i=1;i<=n;i++)
		cin >> a[i-1];

	bool light[n];
	for(int i=1;i<=n;i++)
		light[i-1] = false;
	light[0] = true;

	int now = 1;
	int count=0;

	while(true)
	{
		now = a[now-1];
		count++;

		if(now==2)
			break;

		if(light[now-1]==true)
		{
			count=-1;
			break;
		}
		light[now-1] = true;
	}

	cout << count << endl;
}

Measured memory_bytes: 768
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    int minV = X - K + 1;
    int maxV = X + K - 1;

    for (int i = minV; i <= maxV; i++) {
        cout << i << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3592
#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);
	int n, m;
	cin >>n >>m;
	
	vector<VI> r(n);
	rep(i, m){
		int a,b; cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	const int INF= 1<<28;
	VI dd(n, INF);
	auto bfs = [&](int s){
		queue< int> que;
		que.emplace(s); dd[s]=0;
		while(!que.empty()){
			int cr = que.front();
			que.pop();
			for(auto v: r[cr]){
				if(dd[v] == INF ){
					que.emplace(v);
					dd[v] = dd[cr] + 1;
				}
			}
		}
	};
	bfs(0);
	puts((dd[n-1] <=2)? "POSSIBLE": "IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 13168
N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

opt = 0
opt_less = -10**30

40.downto(0) do |d|
    num1 = as.count{|a| a[d] == 1}
    num0 = N - num1

    opt_less += (1<<d) * [num0, num1].max

    if K[d] == 1
        opt_less = [opt_less, opt + (1<<d) * num1].max
        opt += (1<<d) * [num0, num1].max
    else
        opt += (1<<d) * num1
    end
end

puts [opt, opt_less].max

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int, int>> t;
    rep (i, m) {
        int p, y;
        cin >> p >> y;
        t.emplace_back(make_tuple(p, y, i, 0));
    }
    sort(all(t));
    int prep = get<0>(t[0]);
    int ctr = 0;
    rep (i, m) {
        if (get<0>(t[i]) == prep) {
            get<3>(t[i]) = ++ctr;
        } else {
            get<3>(t[i]) = 1;
            ctr = 1;
            prep = get<0>(t[i]);
        }
    }
    rep (i, m) {
        swap(get<0>(t[i]), get<2>(t[i]));
    }
    sort(all(t));

    rep (i, m) {
        int p = get<2>(t[i]);
        int y = get<3>(t[i]);
        printf("%06d%06d\n", p, y);
    }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

const ll N = 2e5+7;
const ll MOD = 1e9+7;


int main(){
	fast;
	int n;
	cin>>n;
	multiset<int> pos, neg;
	int x;
	for(int i = 0; i < n; i++){
		cin>>x;
		if(x < 0) neg.insert(x);
		else pos.insert(x);
		
		//st.insert(x);
	}
	
	vector<pair<int, int> > moves;
	
	if(neg.empty()){
		int a = *pos.begin();
		int b = *pos.rbegin();
		int p = a - b;
		moves.pb({a, b});
		neg.insert(p);
		pos.erase(pos.begin());
		pos.erase(pos.find(b));
		
		if(pos.empty()){
			cout<<abs(p)<<'\n';
			cout<<b<<' '<<a<<'\n';
			return 0;
		}
	}
	
	
	
	if(pos.empty()){
		int a = *neg.begin();
		int b = *neg.rbegin();
		int p = b - a;
		moves.pb({b, a});
		pos.insert(p);
		neg.erase(neg.begin());
		neg.erase(neg.find(b));
		
		if(neg.empty()){
			cout<<abs(p)<<'\n';
			cout<<b<<' '<<a<<'\n';
			return 0;
		}
	}
	
	
	
	int mx = *pos.rbegin();
	pos.erase(pos.find(mx));
	
	int mn = *neg.begin();
	neg.erase(neg.find(mn));
	
	while(!neg.empty()){
		int p = *neg.begin();
		moves.pb({mx, p});
		neg.erase(neg.begin());
		mx = mx - p;
	}
	
	while(!pos.empty()){
		int p = *pos.begin();
		moves.pb({mn, p});
		pos.erase(pos.begin());
		mn = mn - p;
	}
	
	
	moves.pb({mx, mn});
	mx = mx - mn;
	cout<<mx<<'\n';
	for(auto x: moves){
		cout<<x.fi<<' '<<x.se<<'\n';
	}
	
	return 0;
}


Measured memory_bytes: 7416
#include <iostream>
using namespace std;
int main(){
int n,c=0,max=0;
string s;
cin>>n>>s;
for(int i=0;i<n;i++){
if(s[i]=='I'){
c++;}
else{
c--;}
if(max<c){
max=c;
}
}
cout<<max;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxN 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
int32_t main()
{
fastio;
int t=1;
//in t;
while(t--){
string s;in s;
int a=0,b=0;
rep(i,s.size()){
    if(s[i]=='A') a++;
    else b++;
}
if(a!=0 && b!=0) cout<<"Yes";
else cout<<"No";
}
#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = []
    for i, x in enumerate(a):
        res.append([x, i])
    res.sort()
    ans = []
    for x, i in res:
        ans.append(i+1)
    print(" ".join(map(str,ans)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 31652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

int main(){
      int n,k;
      cin>>n>>k;
      string s;
      cin>>s;
      ll r=1;
      ll cnt=-1;
      if(s[0]=='0') cnt++;
      rep1(i,n-1){
            if(s[i-1]=='1'&&s[i]=='0'){
                  cnt++;
            }
            if(cnt==k){
                  break;
            }
            r++;
      }
      ll l=0;
      ll ans=r-l;
      while(r<n){
            while(r<n){
                  r++;
                  if(s[r-1]=='1'&&s[r]=='0'){
                        break;
                  }
            }
            while(l<n){
                  l++;
                  if(s[l-1]=='0'&&s[l]=='1'){
                        break;
                  }
            }
            ans=max(ans,r-l);
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 512
s_list = list()
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(float,input().split()))
    s_list.append(s)

for s in s_list:
    m = sum(s) / len(s)
    dispersion = 0
    for s_num in s:
        dispersion += (s_num - m)**2
    dispersion /= len(s)
    std = dispersion**0.5
    print(std)



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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)

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

  ll n;cin >> n;
  string s;cin >> s;

  ll ans = 0;

  ll cnt = 0;
  REP(i,n)cnt += (s[i] == 'R');

  REP(i,n){
  	ans += (i >= cnt && s[i] == 'R');
  }

  cout << ans << '\n';
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll x;
  cin >> x;
  rep(a, -1000, 1000) rep(b , -1000, 1000){
    if((a * a * a * a * a) - (b * b * b * b * b) == x) {
      cout << a << " " << b << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	ll num = 0;
	ll yen = 1000;


    // vector<int> maxs, mins;
	// for(int i=0; i<N-1; i++){
	// 	if(A[i] < A[i+1]) mins.push_back(i);
	// 	else if(A[i] > A[i+1]) maxs.push_back(i);
	// }
	// if(A[N-2]<A[N-1]) maxs.push_back(N-1);
	// if(A[N-2]>A[N-1]) mins.push_back(N-1);

	// reverse(mins.begin(), mins.end());
	// reverse(maxs.begin(), maxs.end());
	// while(true){
	// 	if(mins.back() < maxs.back()){
	// 		num += yen / A[mins.back()];
	// 		yen -= yen / A[mins.back()] * A[mins.back()];
	// 		yen += A[maxs.back()] * num;
	// 		num = 0;
	// 		mins.pop_back();
	// 		maxs.pop_back();			
	// 	}
	// 	else maxs.pop_back();
	// 	if((int)maxs.size() == 0) break;
	// }
	// cout << yen << endl;
	// return 0;
	
	// vector<int> is_up(N, 0);//0: 無視, 1:前日より上がった、 -1: 前日より下がった
	// for(int i=0; i<N; i++){
	// 	if(A)
	// }
	if(A[0] <= A[1]){// 明日上がるのでとりあえず買う
		num = yen/A[0];
		yen -= yen/A[0] *A[0];
	}
	for(int i=1; i<N-1; i++){
		if(A[i] >= A[i-1]){//前日より上がった　ので売る
			yen += num * A[i];
			num = 0;
		}
		if(A[i] < A[i-1]){//前日より下がった ので買う
			num += yen /A[i];
			yen -= yen/A[i] * A[i];
		}
		if(A[i] >= A[i+1]){//明日下がる ので　売る
			yen += num*A[i];
			num = 0;
		}
		if(A[i] < A[i+1]){//明日上がる ので買う
			num += yen /A[i];
			yen -= yen/A[i] * A[i];
		}


	    // cout << " i : "<< i << " yen: " << yen << " num : " << num << endl;
	}
	yen += num * A.back();
	cout << yen << endl;

	return 0;
}



Measured memory_bytes: 3640
S = raw_input()
T = raw_input()

s_array = list(S)
t_array = list(T)

#print s_array, t_array

s_array.sort()
t_array.sort()
t_array.reverse()
#print s_array
#print t_array

result = 'both'

while len(s_array) > 0:
    item_s = s_array.pop(0)
    tmp_array = t_array[:]
    while len(tmp_array) > 0:
        item_t = tmp_array.pop(0)
#        print item_s, item_t
        if item_s < item_t:
            result = 'Yes'
            break
        elif item_s > item_t:
            result = 'No'
            break
        else:
            pass
    
    if result == 'Yes' or result == 'No':
        break

if result == 'Yes' or result == 'No':
    print result
else:
#    print len(S) , len(T)
    if len(S) < len(T):
        print 'Yes'
    else:
        print 'No'


Measured memory_bytes: 2692
#include<iostream>
#include<vector>
#include<limits>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin >> arr[i];
    vector<int> dp(n, INT32_MAX);
    dp[0] = 0;
    for(int i=0;i<n-1;i++){
        dp[i+1] = min(abs(arr[i] - arr[i+1]) + dp[i], dp[i+1]);
        if(i+2 < n) dp[i+2] = min(abs(arr[i] - arr[i+2]) + dp[i], dp[i+2]);
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << 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; }
template<class T>void prarr(vector<vector<T>>& a){
rep(i, a.size()){
rep(j, a[i].size()){
cout << a[i][j]; printf(" ");}
printf("\n");} printf("\n");}

vector<ll> row, col;
arr<ll> dp;
ll ans = INFL;
int n; 

ll dfs(int l, int r){
    // printf("%lld %lld\n", l, r);
    if(dp[l][r]!=INFL) return dp[l][r];
    if(l==r) return dp[l][r] = 0;
    if(r==l+1) return dp[l][r] = row[l] * col[l] * col[r];

    ll tmp = INFL;
    FOR(k, l, r){
        chmin(tmp, dfs(l, k) + dfs(k+1, r) + row[l] * col[k] * col[r]);
    }

    return dp[l][r] = tmp;
}

int main()
{
    cin >> n;
    row.resize(n); col.resize(n);
    rep(i, n){
        cin >> row[i] >> col[i];
    }
    dp.assign(n, vector<ll>(n, INFL));

    ans = dfs(0, n-1);
    
    // prarr(dp);
    pr(ans);
    return 0;}


Measured memory_bytes: 3228
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		cout << a - 1 << " " << b << endl;
	}
	else {
		cout << a << " " << b - 1 << endl;
	}

	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b > c) swap(b,c);
    if(a > b) swap(a,b);
    if(b > c) swap(b,c);
    cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3092
/*input
86
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[105],n;
long long solve(int n){
	if(a[n]!=-1) return a[n];
	return a[n]=solve(n-1)+solve(n-2);
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n;
	memset(a,-1,sizeof(a));
	a[0]=2,a[1]=1;
	cout<<solve(n);
}

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

namespace cover_2d {
    double eps = 1e-9;
    using Point = complex<double>;
    struct Circle {
        Point p; double r;
    };
    double dist(Point p, Point q) {
        return abs(p - q);
    }
    double area2(Point p, Point q) {
        return (conj(p)*q).imag();
    }
    bool in(const Circle& c, Point p) {
        return dist(c.p, p) < c.r + eps;
    }
    Circle INVAL = Circle{ Point(0, 0), -1 };
    Circle mCC(Point a, Point b, Point c) {
        b -= a; c -= a;
        double d = 2 * (conj(b)*c).imag(); if(abs(d) < eps) return INVAL;
        Point ans = (c*norm(b) - b * norm(c)) * Point(0, -1) / d;
        return Circle{ a + ans, abs(ans) };
    }
    Circle solve(vector<Point> p) {
        mt19937 gen(0x94949); shuffle(p.begin(), p.end(), gen);
        Circle c = INVAL;
        for(int i = 0; i < p.size(); ++i) if(c.r < 0 || !in(c, p[i])) {
            c = Circle{ p[i], 0 };
            for(int j = 0; j <= i; ++j) if(!in(c, p[j])) {
                Circle ans{ (p[i] + p[j])*0.5, dist(p[i], p[j])*0.5 };
                if(c.r == 0) {
                    c = ans; continue;
                }
                Circle l, r; l = r = INVAL;
                Point pq = p[j] - p[i];
                for(int k = 0; k <= j; ++k) if(!in(ans, p[k])) {
                    double a2 = area2(pq, p[k] - p[i]);
                    Circle c = mCC(p[i], p[j], p[k]);
                    if(c.r < 0) continue;
                    else if(a2 > 0 && (l.r<0 || area2(pq, c.p - p[i]) > area2(pq, l.p - p[i]))) l = c;
                    else if(a2 < 0 && (r.r < 0 || area2(pq, c.p - p[i]) < area2(pq, r.p - p[i]))) r = c;
                }
                if(l.r < 0 && r.r < 0) c = ans;
                else if(l.r < 0) c = r;
                else if(r.r < 0) c = l;
                else c = l.r <= r.r ? l : r;
            }
        }
        return c;
    }
};

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

    vector<complex<double>> v;
    for(int i = 0; i < n; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v.push_back({ (double)x, (double)y });
    }

    auto c = cover_2d::solve(v);
    printf("%.10lf\n", c.r);
    return 0;
}


Measured memory_bytes: 256
//ATCODER:CARD
#include <bits/stdc++.h>
using namespace std;
map<string,int> m;
map<string,int>::iterator it;
int main()
{
	string str1;
	char sz[11];
	int n,mm,ma=0;

	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",sz);
		str1=sz;
		if(m.count(str1)==0)
		{
			m[str1]=1;
		}
		else
			m[str1]++;
	}

	scanf("%d",&mm);
	for(int i=0;i<mm;i++)
	{
		scanf("%s",sz);
		str1=sz;
		if(m.count(str1)==0)
		{
			m[str1]=-1;
		}
		else
			m[str1]--;
	}
	
	for(it=m.begin();it!=m.end();it++)
		ma=max(ma,it->second);
	printf("%d",ma);
	return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int64_t min, max;
    cin >> min >> max;
    
    int i=0;
    for(int64_t buf=min; buf<=max; ++i){
        buf *= 2;
    }
    
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string S;
	cin >> S;

	int N = S.size();
	string s;
	for( int i = 0; i < N; i++ ) {
		if( i + 1 < N && S[i] == 'B' && S[i + 1] == 'C' ) {
			s += 'D';
			i++;
		}
		else s += S[i];
	}
	int n = s.size();
	int a = 0;
	long long ans = 0;
	for( int i = 0; i < n; i++ ) {
		if( s[i] == 'A' ) a++;
		else if( s[i] == 'D' ) ans += a;
		else a = 0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

int a(int N){
	int cnt =N;
	if(cnt==1){
		int k;
		cin>>k;
		int k_cnt=0;
		int kk=2;
		while(true){
			if(k%kk==0){
				k_cnt++;
				kk*=2;
			}
			else{
				break;
			}
		}
		//cout<<k_cnt<<" ";
		return k_cnt;
	}
	int num,num_cnt;
	cin>>num;
	num_cnt=0;
	int Num=2;
	while(true){
		if(num%Num==0){
			num_cnt++;
			Num*=2;
		}
		else{
			break;
		}
    }
	//cout<<num_cnt<<" ";
	int d=a(N-1);
	return min(d,num_cnt);
}



signed main() {
	int N; cin>>N;
	int ans= a(N);
	cout<<ans<<endl;

}


Measured memory_bytes: 256
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    tmp = tmp.map(Number);
    
    N = tmp[0];
    m = Math.min(tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]);
    answer = 4 + Math.ceil(N/m);
    console.log(answer);
    
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));




Measured memory_bytes: 7372
from collections import Counter

input()
s = input()
try:
  x, y, z = Counter(s).values()
  print(x * y * z - sum(s[i] != s[(i + j) // 2] != s[j] != s[i]
                        for i in range(len(s)) for j in range(i % 2, i, 2)))
except ValueError:
  print(0)


Measured memory_bytes: 9396
x,y = [int(i) for i in input().split(" ")]

if x%y == 0:
    print(-1)
    quit()

if x==1:
    print(y*2+1)
    quit()

for i in range(x*2,10**18+1,x):
    if (i < y*2):
        continue
    elif (i%y != 0):
        print(i)
        quit()
print(-1)



Measured memory_bytes: 3060
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------
from math import *
 
def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi
 
 
def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans
 
def lcm(a, b): return a * b // gcd(a, b)
 
 
def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

a, b, h, m = map(int, input().split())
radians = pi * 2 * (h / 12 + (m / 60) / 12 - m / 60)
dist = a * a + b * b - (2 * a * b) * cos(radians);
print(sqrt(dist))


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

int p;
vector<string> s;

int dfs(int d) {
  if (s[p][d] == '+') {
    int res = 0;
    p++;
    while (p < s.size() && s[p].size() - 1 > d) res += dfs(d + 1);
    return res;
  } else if (s[p][d] == '*') {
    int res = 1;
    p++;
    while (p < s.size() && s[p].size() - 1 > d) res *= dfs(d + 1);
    return res;
  } else {
    int res = s[p][d] - '0';
    p++;
    return res;
  }
}

int main() {
  int n;
  while (cin >> n, n) {
    s = vector<string>(n);
    REP(i, n) cin >> s[i];
    p = 0;
    cout << dfs(0) << endl;;
  }
}



Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

typedef complex<double> P;

namespace std {
  bool operator < (const P& a, const P& b) {
    return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a)*b);
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > 0) return +1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

void convexHull(vector<P> &G, vector<P> &ch){
    sort(G.begin(), G.end());
    int k=0;
    int n = G.size();
    for(int i=0;i<n;i++){
        while(k > 1 && cross((ch[k-1]-ch[k-2]), G[i] - ch[k-1])<0){
            k--;
        }
        ch[k] = G[i];
        k++;
    }
    int t = k;
    for(int i=n-2;i>=0;i--){
        while(k>t && cross((ch[k-1]-ch[k-2]), G[i] - ch[k-1])<0){
            k--;
        }
        ch[k] = G[i];
        k++;
    }

    ch.resize(k-1);
    cout <<k-1<< endl;
    for(int i=0;i<k-1;i++){
        cout << real(ch[i]) << " " << imag(ch[i]) << endl;
    }
}

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

    vector<P> G;
    P p;
    for (int i=0;i<n;i++){
        cin >> p.real() >> p.imag();
        G.push_back(p);
    }

    vector<P> ch(2*n);
    convexHull(G, ch);

    return 0;
}

Measured memory_bytes: 7624
def operate(op_str, a, b):
    if op_str == '+':
        return a + b
    elif op_str == '-':
        return a - b
    elif op_str == '*':
        return int(a * b)
    elif op_str == '/':
        return int(a / b)

while True:
    i = input()
    a, op, b = i.split()
    if (op == '?'):
        break
    else:
        print(operate(op, int(a), int(b)))


Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int list[] = new int[Y];
		for (int i = 0; i < Y; i++) {
			list[i] = sc.nextInt();
		}

		int sum = 0;
		for (int i = 0; i < Y; i++) {
			sum += list[i];
		}

		int ans = X - sum;

		if(ans<0) {
			System.out.println(-1);
		}else {
			System.out.println(ans);
		}

	}
}


Measured memory_bytes: 46428
N=int(input())
s=[0]*N
for _ in[0]*(N*~-N//2):
 a,b,c,d=map(int,input().split())
 s[a-1]+=3*(c>d)+(c==d)
 s[b-1]+=3*(d>c)+(d==c)
b=[[]for _ in[0]*N*3]
for i in range(N):
 b[s[i]]+=[i]
r=1
for x in b[::-1]:
 for y in x:
  s[y]=r
 if x:r+=len(x)
print(*s,sep='\n')


Measured memory_bytes: 5664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc161_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var M = CIn.ReadInt();
      var A = CIn.ReadIntArray(N);
      var sum = A.Sum();

      var ans = A.Count(e => e * 4 * M >= sum) >= M;

      Console.WriteLine(ans ? "Yes" : "No");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
      static bool[,] map;
      static void Main(string[] args)
      {
        int[] line = Console.ReadLine().Split().Select(int.Parse).ToArray();
        map = new bool[line[0], line[1]];

        for (int i = 0; i < line[0]; i++)
        {
            var a = Console.ReadLine();
            for (int j = 0; j < a.Length; j++)
            {
                if (a[j] == '.') map[i, j] = false;
                else map[i, j] = true;
            }
        }

        for (int i = 0; i < line[0]; i++)
        {
            for (int j = 0; j < line[1]; j++)
            {
                if (j == line[1] - 1)
                {
                    var a = check(i, j);
                   
                    if (map[i, j] == false) Console.WriteLine("{0}", a);
                    else Console.WriteLine("#");


                }
                else {
                    var a = check(i, j);
                  
                    if (map[i, j] == false) Console.Write("{0}", a);
                    else Console.Write("#");
                }
            }
        }

    }

    private static string check(int y , int x) {
        int count = 0;
        for (int i = -1; i < 2; i++)
        {
            for (int j = 1; j > -2; j--)
            {
                if (i == 0 && j==0) continue;
                try
                {
                    if (map[y + j, x + i] == true) count++;
                }
                catch { }
            }
        }
        return count.ToString();
    }

    }



Measured memory_bytes: 13396