akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		Stack<Integer> stack = new Stack<Integer>();
		
		for (; sc.hasNext(); ) {
			if (sc.hasNextInt()) {
				stack.push(sc.nextInt());
			} else {
				char op = sc.next().charAt(0);
				int b = stack.pop();
				int a = stack.pop();
				int result;
				switch (op) {
				case '+':
					result = a + b;
					break;
				case '-':
					result = a - b;
					break;
				case '*':
					result = a * b;
					break;
				default:
					result = -1;
				}
				stack.push(result);
			}
		}
		
    	System.out.println(stack.pop());
    	
        sc.close();
	}
}

Measured memory_bytes: 20420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  cin >> N >> K;
  K--;
  
  string unchi;
  
  cin >> unchi;
  
  if (unchi.at(K) == 'A') {
    unchi.at(K) = 'a';
  }
  
  else if(unchi.at(K) == 'B') {
    unchi.at(K) ='b';
  }
  
  else {
    unchi.at(K) = 'c';
  }
  
  cout << unchi << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> arr(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr.begin(),arr.end());
	int ans=0;
	for(int i=n-1;i>=0;i--)
	{
		if(arr[i]<k)
		{
			break;
		}
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
from collections import Counter
S=input()[::-1]

X=[0]
md=2019

for i,s in enumerate(S):
    X.append((X[-1]+int(s)*pow(10,i,md))%md)

C=Counter(X)
ans=0
for v in C.values():
    ans+=v*(v-1)//2

print(ans)

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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define Int long long 
int i,j,k;
int dx,dy;
int a,b,c;
string s,t;

int main(){ 
  int n;
  cin>>n;
  int p[n];
  rep(i,n)cin>>p[i];
  int max=100;
  rep(i,n)if(p[i]>max)max=p[i];
  int ttl=0;
  rep(i,n)ttl+=p[i];
  ttl-=max;
  ttl+=max/2;
  cout<<ttl;


  return 0;
}


Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#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 endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here
    setprec(2)

    ld b; int a; cin >> a >> b;
    b *= 100.0; int c = (floor)(b + 0.5);

    int x = a*c; 

    cout << x /100 ;

    return 0;
}


Measured memory_bytes: 3748
n, m = map(int, input().split())
h = list(map(int, input().split()))

se = set()
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] <= h[b]:
        se.add(a)
    if h[a] >= h[b]:
        se.add(b)

ans = n - len(se)
print(ans)


Measured memory_bytes: 85272
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	LL n;
	cin>>n;
	VLL a(n);
	rep(i,n){
		cin>>a[i];
	}
	VLL wa(n),sa(n);
	map<int, int> m;
	LL ans=0;
	rep(i,n){
		wa[i]=i+a[i];
		sa[i]=i-a[i];
		ans+=m[sa[i]];
		m[wa[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char c[1000010];
int sm[1000010], mn[1000010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        multiset<pair<int, int>> st, s;
        int tmp=0;
        for(int i=0; i<n; ++i){
            scanf("%s",c);
            int m=strlen(c);
            sm[i]=mn[i]=0;
            for(int j=0; j<m; ++j){
            	if(c[j]=='('){
            		++sm[i];
            	}
            	else{
            		--sm[i];
            	}
            	mn[i]=min(mn[i], sm[i]);
            }
            tmp+=sm[i];
            st.insert(mk(-mn[i], sm[i]));
        }
        if(tmp!=0){
            cout<<"No"<<endl;
            continue;
        }
        bool l=1;
        int smm=0, cnt=0;
        while(cnt<n){
        	while(st.size()>0 && (st.begin()->fs)<=smm){
        		s.insert(mk(-(st.begin()->sc), st.begin()->fs));
        		st.erase(st.begin());
        	}
            if(s.size()==0){
                l=0;
                break;
            }
            if(-(s.begin()->fs) < 0){
                if(st.size()>0){
                    l=0;
                }
                else{
                    smm=0;
                    for(auto it:s){
                        st.insert(mk(-it.fs+it.sc, -it.fs));
                    }
                    for(auto it:st){
                        // cout<<smm<<" "<<it.fs<<" "<<it.sc<<endl;
                        if(it.fs>smm){
                            l=0;break;
                        }
                        smm-=it.sc;
                    }
                }
                break;
            }
        	smm+=(-(s.begin()->fs));
            assert(smm>=0);
        	s.erase(s.begin());
        	++cnt;
        }
        if((cnt==n && smm==0)||l){
        	cout<<"Yes"<<endl;
        }
        else{
        	cout<<"No"<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 58352
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll a;
  cin >> a;
  printf("%lld",a%9);
}

Measured memory_bytes: 512
n,k = list(map(int,input().split()))
s = str(input())
ans = 0
for i in range(1,len(s)):
  if s[i] == s[i-1]:
    ans += 1

if (n-1) >= (ans + 2*k):
  ans += 2*k
else:
  ans = n - 1

print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    while(true){

    int n,m;
    cin>>n>>m;
        if(n==0&&m==0)break;
    
    vector<pair<int,int>> sum(m);
    REP(i,m){
        sum[i].first=0;
        sum[i].second=1000-(i+1);
    }
    REP(i,n)REP(j,m){
        int t;
        cin>>t;
        sum[j].first+=t;
    }
    
    sort(sum.begin(),sum.end());
    reverse(sum.begin(),sum.end());
    
    REP(i,m-1)cout<<1000-sum[i].second<<" ";
    cout<<1000-sum[sum.size()-1].second<<endl;
    }
    
    return 0;
    
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	if (n>=30) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3636
//============================================================================
// Name        : Test.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b;
	cin>>a;
	cin>>b;
	cout<<a*b<<" "<<a*2+b*2<<endl;
}



Measured memory_bytes: 3072
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, P[222222], C[222222] = {0};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> P[i];

  for (int i = 0; i < N; i ++)
    C[P[i]] = C[P[i] - 1] + 1;

  std::cout << N - *std::max_element(C + 1, C + N + 1) << std::endl;

  return 0;
}


Measured memory_bytes: 1792
import sys
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
  print(0)
  sys.exit()
K = 1
for i in range(N):
  K = A[i]*K
  if K > 10**18:
    print(-1)
    sys.exit()
print(K)

Measured memory_bytes: 21664
def is_distance_int(X, Y):
    _sum = 0
    for x, y in zip(X, Y):
        _sum += (x - y) ** 2
    distance = _sum ** 0.5
    return distance.is_integer()


def main():
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for _ in range(n)]
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            if is_distance_int(x[i], x[j]):
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int min = 0;
        for (int i = 1; i < n; i++) {
            String[] a = String.valueOf(i).split("");
            String[] b = String.valueOf(n - i).split("");
            int sum = 0;
            for (int j = 0; j < a.length; j++) {
                sum += Integer.parseInt(a[j]);
            }
            for (int j = 0; j < b.length; j++) {
                sum += Integer.parseInt(b[j]);
            }
            if (i == 1 || min > sum) {
                min = sum;
            }
        }
        System.out.println(min);
    }

}


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

using namespace std;

int main(){
	int n, m;
	while(cin >> n >> m, n){
		int now = 1;
		int turn = 0;
		int area[1001];
		int goes[1001];
		for(int i = 1; i <= n; i++) cin >> area[i];
		for(int i = 1; i <= m; i++) cin >> goes[i];
		while(now < n){
			turn++;
			now += goes[turn];
			now += area[now];
		}
		cout << turn << endl;
	}

	return 0;
}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

int main() {
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	vi l(n), r(n);
	int prev = -c - 1;
	int t = 1;
	for(int i = 0; i < n; i++) {
		if(i - prev > c && s[i] == 'o') {
			prev = i;
			l[i] = t++;
			continue;
		}
	}
	prev = n + c;
	t--;
	for(int i = n - 1; i >= 0; i--) {
		if(prev - i > c && s[i] == 'o') {
			prev = i;
			r[i] = t--;
		}
	}
	if(l[n - 1] > k)
		return 0;
	for(int i = 0; i < n; i++) {
		if(l[i] == r[i] && l[i] > 0)
			cout << i + 1 << '\n';
	}
	// for(int i = 0; i < n; i++)
	// 	cout << l[i] << ' ';
	// cout << '\n';
	// for(int i = 0; i < n; i++)
	// 	cout << r[i] << ' ';
}

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

def BFS(i,E,V):
    if all(V):
        return True
    if V[i]:
        return False
    V[i]=True
    if any([BFS(v,E,V) for v in E[i]]):
        return True
    return False

n,m=map(int,input().split())
Edges=[list(map(int,input().split())) for _ in range(m)]
ans=0
for i in range(m):
    E_i=[[] for _ in range(n)]
    for j in range(m):
        if i!=j:
            E_i[Edges[j][0]-1].append(Edges[j][1]-1)
            E_i[Edges[j][1]-1].append(Edges[j][0]-1)
    Visited=[False]*n
    if not BFS(0,E_i,Visited):
        ans+=1
print(ans)

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

bool ok(vector<string> &v, int m, int goal) {
    int pos = m;
    for (int i=0; i<(int)v.size(); ++i) {
        if (pos < (int)v[i].size() && v[i][pos] == '1') {
            pos ++;
        } else if (0 <= pos - 1 && v[i][pos-1] == '1') {
            pos --;
        }
    }
    return (pos == goal);
}

int main() {
    int n, m, goal, d;
    while (cin >> n, n) {
        cin >> m >> goal >> d;
        -- m; -- goal;
        vector<string> amida(d);
        for (int i=0; i<d; ++i) {
            cin >> amida[i];
        }
        if (ok(amida, m, goal)) {
            cout << 0 << endl;
            continue;
        }
        int y = -1, x;
        for (int i=0; i<d; ++i) {
            for (int j=0; j<n-1; ++j) {
                if (amida[i][j] == '1') continue;
                if (j+1 < n-1 && amida[i][j+1] == '1') continue;
                if (0 <= j-1 && amida[i][j-1] == '1') continue;
                amida[i][j] = '1';
                if (ok(amida, m, goal)) {
                    y = i;
                    x = j;
                    goto end;
                }
                amida[i][j] = '0';
            }
        }end:;
        if (y < 0) {
            cout << 1 << endl;
        } else {
            cout << y+1 << " " << x+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1212
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {
	int N;
	int[] a,b;
	TreeSet<Integer> set;
	public void solve() {
		N = nextInt();
		a = new int[N];
		b = new int[N + 1];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
			b[a[i]] = i;
		}

		set = new TreeSet<Integer>();

		long ans = 0;

		for(int i = 1;i <= N;i++){
			set.add(b[i]);
			int index = b[i];

			//indexより大きく、最小のインデックスを持つiより小さい要素のインデックス
			Integer right = set.higher(index);
			//indexより小さく、最大のインデックスを持つiより小さい要素のインデックス
			Integer left = set.lower(index);


			if(right == null){
				right = N;
			}
			right = right - index;

			if(left == null){
				left = -1;
			}
			left = index - left;

			ans += (long)right * left * i;
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];

    int ans = 1001001001;
    rep(i, n-k+1){
        int tmp = abs(x[i]) + abs(x[i] - x[i+k-1]);
        tmp = min(tmp, abs(x[i+k-1]) + abs(x[i] - x[i+k-1]));
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int y1 = sc.nextInt();
			int m1 = sc.nextInt();
			int d1 = sc.nextInt();
			int y2 = sc.nextInt();
			int m2 = sc.nextInt();
			int d2 = sc.nextInt();
			if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0){
				break;
			}
			int res = getdays(y2, m2, d2) - getdays(y1, m1, d1);
			System.out.println(res);
		}
	}
	
	int getdays(int y, int m, int d) {
		if (m <= 2) {
			y--;
			m += 12;
		}
		int dy = 365 * (y - 1);
		int c = y / 100;
		int dl = (y >> 2) - c + (c >> 2);
		int dm = (m * 979 - 1033) >> 5;
		return dy + dl + dm + d - 1;
	}
	
	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin >> n;
  int l[n];
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l,l+n);
  for(int i=0;i<n-1;i++){
    sum+=l[i];
  }
  cout << ((l[n-1]<sum)?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n; cin >> n;
  while(n --> 0){
    string str;
    stack<int> q;
    int cnt = 0;
    cin >> str;

    FOR(it, str) q.push(*it - '0');

    while(q.size() > 1){
      int a = q.top(); q.pop();
      int b = q.top(); q.pop();

      int c = a + b;

      cnt++;

      if(c >= 10){
	q.push(c % 10);
	q.push(c / 10);
      }else{
	q.push(c);
      }
    }

    printf("%s wins.\n", cnt % 2 == 0 ? "Audrey" : "Fabre");
  }
  return 0;
}

Measured memory_bytes: 0
import java.math.BigDecimal
import kotlin.math.log10

fun main() {
    var n = readLine()!!.trim().toLong()
    var p = 2L
    var count = 0
    while (p * p <= n) {
        if (n % p == 0L) {
            var c = 0
            var i = 1
            while (n % p == 0L) {
                ++c
                n /= p
                if (c >= i) {
                    ++count
                    c -= i
                    ++i
                }
            }
        }
        ++p
    }
    if (n != 1L) ++count
    println(count)
}


Measured memory_bytes: 35720
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define IN(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); for(auto &i : name)cin>>i;
#define VIn(T,name,n) vector<T> name(n); for(auto &i : name)cin>>i;
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	IN(string, s);
	out(700 + Count(s, 'o') * 100);
}

Measured memory_bytes: 768
N, A, B = map(int, input().split())


distance =(B - A - 1 )//2
if( (A % 2 == 0 and B % 2 ==0) or (A%2==1 and B%2==1)):
    ans=(B - A)//2
else:
    ans = min(A-1,N - B) + 1 + distance

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int main(){
	string a,b;
	cin >> a >> b;
	int c = stoi(a+b);
	printf("%s\n",(floor(sqrt(c))*floor(sqrt(c))==c)?"Yes":"No");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 vector<long long> v(3);
 cin >> v[0] >> v[1] >> v[2];

 sort(v.begin(), v.end());
 cout << v[0] << " " << v[1] << " " << v[2] << endl;
}


Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };

string s[3000]; 
int R[2005][2005] ;
int C[2005][2005];

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

  int H , W;
  cin >> H >> W;

  for(int i = 0; i < H; i++) {
    cin >> s[i];
  }
  for(int i = 0; i < H; i++) {
    int cnt = 0;
    for(int j = 0; j < W;j++) {
      if(s[i][j] == '.') cnt++;
      else cnt = 0;
      R[i][j] = cnt;
    }
    cnt = 0;
    for(int j = W - 1; j >= 0; j--) {
      if(s[i][j] == '.') cnt++;
      else cnt = 0;
      R[i][j] += cnt;
    }
  }

  for(int j = 0; j < W; j++) {
    int cnt = 0;
    for(int i = 0;i < H; i++) {
      if(s[i][j] == '.') cnt++;
      else cnt = 0;
      C[i][j] = cnt;
    }
    cnt = 0;
    for(int i = H - 1; i >= 0;i--) {
      if(s[i][j] == '.') cnt++;
      else cnt = 0;
      C[i][j] += cnt;
    }
  }

  int ans = 0;
  for(int i = 0;i < H;i++) {
    for(int j = 0; j < W;j++) {
      if(s[i][j] == '.'){
        ans = max(ans , R[i][j] + C[i][j] - 3);
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 70392
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
    int a, p;
    cin >> a >> p;
    cout << (3*a+p)/2 << endl;

    return 0;
}


Measured memory_bytes: 888
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toDouble() }.toDoubleArray()
    v.sort()

    v[0] /= 2.0
    v[1] /= 2.0

    (2 until N).forEach { i ->
        (0 .. i).forEach { j ->
            v[j] /= 2.0
        }
    }
    println(v.sum())
}

Measured memory_bytes: 36016
#include <stdio.h>

int main() {
    int N;
    char s[128];
    scanf("%d%s", &N, s);
    int r = 0;
    int b = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') {
            r++;
        }
        else {
            b++;
        }
    }
    puts(r > b ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
//file_name:ABC60_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,c;
    cin >> a >> b >> c;


    a = a%b;
    int x = 0;

    rep(i,1000){
        x = (x+a)%b;
        if(x==c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}



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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 200000;

int main() {
  int N, a[MAX_N + 1], s[MAX_N + 1] = {}, M = 0;
  std::vector<int> b = {};
  std::cin >> N;
  rep(i, N) std::cin >> a[i + 1];

  for(int i = N; i > 0; --i) {
    int cnt = 0;
    for(int j = i + i; j <= N; j += i) cnt += s[j];
    if(cnt % 2 != a[i]) {
      s[i] = 1;
      ++M;
      b.push_back(i);
    }
  }

  std::cout << M << '\n';
  for(auto i : b) {
    std::cout << i << ' ';
  } std::cout << std::endl;
}


Measured memory_bytes: 3192
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int n;
  cin >> n;
  int l[2*n];
  REP(i,2*n){
    cin >> l[i];
  }
  sort(l,l+2*n);
  int ans = 0;
  REP(i,n){
    ans += l[2*i];
  }
  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 A = sc.nextInt();
    int B = sc.nextInt();

    if ((A * B) % 2 != 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 21588
// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}


// 優先度付きキュー（最大値）
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)
#define QSIZE 300010
int que[QSIZE + 5];
int qsize;

void max_heapify(int i)
{
	int l, r, max;
	int qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l] > que[i]) max = l; else max = i;
	if (r < qsize && que[r] > que[max]) max = r;
	if (max != i) {
		qt = que[i], que[i] = que[max], que[max] = qt;
		max_heapify(max);
	}
}

void deq()
{
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(int c)
{
	int i, max;
	int qt;

	i = qsize++;
	que[i] = c;
	while (i > 0 && que[max = PARENT(i)] < que[i]) {
		qt = que[i]; que[i] = que[max], que[max] = qt;
		i = max;
	}
}


// 本問題関連
int c[300010];
int top[300010], sz[300010]; int N;

int main()
{
	int i, k, M;
	unsigned ans;

	N = in(), k = 0;
	for (i = 0; i < N; i++) {
		sz[i] = M = in();
		top[i] = k;
		while (M--) c[k++] = in();
	}
	
	// 各列のデータを逆順に優先度付きキューに追加
	ans = 0, qsize = 0;
	for (i = N - 1; i >= 0; i--) {
		M = sz[i], k = top[i];
		while (M--) enq(c[k++]);
		ans += (unsigned)que[0];
		deq();
	}
	printf("%u\n", ans);
	return (0);
}



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

int cnt, h, w, xy[110][110]={-1};
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
pair<int,int> p;
char c[110][110];

int bfs(int x, int y){
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			xy[i][j] = -1;
	
	xy[x][y]=0;
	queue<pair<int,int>> q;
	q.push(pair<int,int>(x, y));
	while(q.size()){
		p=q.front();
		q.pop();
		for(int i = 0; i < 4; i ++){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(0 <= nx && nx <h  && 0 <= ny && ny < w && c[nx][ny] != '#' && xy[nx][ny]==-1){
				q.push(pair<int, int>(nx, ny));
				xy[nx][ny] = xy[p.first][p.second]+1;
			}
		}
	}
	return xy[p.first][p.second];
}
int32_t main()
{
	cin>>h>>w;
	for(int i =0; i<h; i++)
		for(int j =0; j<w; j++)
			cin>>c[i][j];
	for(int i =0; i < h; i++)
		for(int j =0; j < w; j++)
			if(c[i][j] == '.')
				cnt = max(cnt, bfs(i,j));
	cout<<cnt;
	return 0;
}

// 3 3
// ...
// ...
// ...


Measured memory_bytes: 256
n=int(input())
*a,=map(int, input().split())
c=0

flag=1
while flag:
    flag=0
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            c+=1
            flag=1
print(*a)
print(c)
    



Measured memory_bytes: 5612
#include<iostream>
#include<cmath>
using namespace std;
int n,m,T,U;
int t[1000],u[1000];
double at,au;
double EPS=0.000000001;
double calc_area(double);

bool eq(double x,double y){return (-EPS<x-y&&x-y<EPS);}
int main(){
  while(cin>>n&&n!=0){
    at=au=0.0;
    T=U=360;
    for(int i=0;i<n-1;i++){
      cin>>t[i];
      T-=t[i];
      at+=calc_area((double)t[i]*M_PI/180.0);
    }
    at+=calc_area((double)T*M_PI/180.0);

    cin>>m;
    for(int i=0;i<m-1;i++){
      cin>>u[i];
      U-=u[i];
      au+=calc_area((double)u[i]*M_PI/180.0);
    }
    au+=calc_area((double)U*M_PI/180.0);

    if(eq(au,at))cout<<"0"<<endl;
    else if(au<at)cout<<"1"<<endl;
    else cout<<"2"<<endl;
    
  }
  return 0;
}

double calc_area(double x){
  return sin(x);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  int res = 1001001000;
  
  rep(i, 100001){
    int cost = c * 2 * i;
    int a_left = max(0, x - i);
    int b_left = max(0, y - i);
    
    cost += a_left * a + b_left * b;
    
   	res = min(res, cost);
  }
 
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]

dp[0][3][3][3] = 1

MOD = 10 ** 9 + 7
for l in range(N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                if dp[l][i][j][k] == 0:
                    continue
                
                for n in range(4):
                    if j == 0 and k == 2 and n == 1: continue
                    if j == 0 and k == 1 and n == 2: continue
                    if j == 1 and k == 0 and n == 2: continue

                    if i == 0 and j == 1 and n == 2: continue
                    if i == 0 and k == 1 and n == 2: continue 

                    dp[l+1][j][k][n] += dp[l][i][j][k]
                    dp[l+1][j][k][n] %= MOD
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
            ans %= MOD
print(ans%MOD)

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

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

using namespace std;

int main(){
	int a,b,k; cin>>a>>b>>k;
	for(int c=min(a,b);;c--) if(a%c==0 && b%c==0) {
		k--;
		if(k==0){ cout<<c<<endl; break; }
	}

	return 0;
}


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

const int M = 200005;

int main()
{
    char S[M] = "";
    char T[M] = "";
    cin >> S;
    cin >> T;

    int ans = 0;
    rep(i, strlen(S))
    {
        if (S[i] != T[i]) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
     
using namespace std;
     
#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'
     
typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;
     
const int MX = 310;

double dp[MX+5][MX+5][MX+5];

int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	int n,a;
	cin >> n;
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	FOR(i,0,n) {
		cin >> a;
		if (a == 1) cnt1++;
		else if (a == 2) cnt2++;
		else cnt3++;
	}
	FOR(k,0,MX) FOR(j,0,MX) FOR(i,0,MX) {
		int t = i+j+k;
		if (t == 0 || t > MX) continue;
		dp[i][j][k] = 1.0*n/t;
		if (i) dp[i][j][k] += dp[i-1][j][k]*1.0*i/t;
		if (j) dp[i][j][k] += dp[i+1][j-1][k]*1.0*j/t;
		if (k) dp[i][j][k] += dp[i][j+1][k-1]*1.0*k/t;
	}
	cout << std::fixed;
	cout << std::setprecision(10) << dp[cnt1][cnt2][cnt3] << endl;
    return 0;
}


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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int MAXINT = 2147483647;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];
int head[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

struct edge {
	int to, next;
}e[MAXN << 1];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

int h1, h2, m1, m2;

int main(){
	int T;
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	printf("%d\n", max(0, (h2 - h1) * 60 + m2 - m1 - k));
	return 0;
}

/*

*/

//Flakire
//Lord Wang
//yxm9
//akdxl
//WYXak
//MifafaOvO
//AKarry5037
//deakX
//xyx
//Fraggay



Measured memory_bytes: 3840
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 300005;
const int MOD = 998244353;

int n, a, b; ll k, ans;
ll inv[MAXN], fac[MAXN], ifac[MAXN];

inline ll C( int a, int b ){
	if( a == b || b == 0 ) return 1;
	return fac[a] * ifac[b] % MOD * ifac[a-b] % MOD;
}

int main(){
	scanf( "%d%d%d%lld", &n, &a, &b, &k );
	inv[1] = 1;
	for( int i = 2; i <= n; ++i )
		inv[i] = (ll)( MOD-MOD/i ) * inv[ MOD%i ] % MOD;
	fac[0] = ifac[0] = 1;
	for( int i = 1; i <= n; ++i ){
		fac[i] = fac[i-1] * i % MOD;
		ifac[i] = ifac[i-1] * inv[i] % MOD;
	}
	for( int i = 0; i <= n; ++i ){
		if( (ll)i * a > k ) break;
		if( ( k - (ll)i * a ) % b ) continue;
		ll j = ( k - (ll)i * a ) / b;
		if( j > n ) continue;
		ans = ( ans + C(n,i) * C(n,(int)j) % MOD ) % MOD;
	}
	printf( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 7168
N , M = map(int,input().split())
L = []
for _ in range(N):
    L.append(list(map(int,input().split())))
L = sorted(L)
quantity = 0
cost = 0
for x in L:
    if quantity + x[1] < M:
        cost += x[1] * x[0]
        quantity += x[1]
    else:
        cost += max(M - quantity,0) * x[0]
        break
print(cost)


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


int main() {
	int n, k; cin >> n >> k;
	vector<pii>G;
	int key = (n - 1)*(n - 2) / 2;
	for (int i = 1; i < n; ++i) {
		G.push_back({ i,n });
	}
	if (key < k) {
		cout << -1 << endl;
	}
	else {
		if (key == k) {
			cout << G.size() << endl;
			for (auto p : G) {
				cout << p.first << " " << p.second << endl;
			}
			return 0;
		}
		for (int i = 1; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				G.push_back({ i,j });
				key--;
				if (key == k) {
					cout << G.size() << endl;
					for (auto p : G) {
						cout << p.first << " " << p.second << endl;
					}
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define INF 1000000000
#define mod 1000000007
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

int main()
{
	fio
	ll n;
	cin >> n;
	ll h[n + 1];
	for(ll i = 1; i <= n; i++) {
		cin >> h[i];
	}
	ll dp[n + 1] = {0};
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for(ll i = 3; i <= n; i++) {
		dp[i] = min((abs(h[i] - h[i - 1]) + dp[i - 1]), (abs(h[i] - h[i - 2]) + dp[i - 2]));
	}
	cout << dp[n];
 	return 0;
}


Measured memory_bytes: 5188