akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
 
const ll INF = 2e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod){ll x=1;while(b){while(!(b&1)){(a*=a)%=mod;b>>=1;}(x*=a)%=mod;b--;}return x;}
void YES(bool cond){ if(cond){ p("YES");}else{ p("NO");} return;}
void Yes(bool cond){ if(cond){ p("Yes");}else{ p("No");} return;}


ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}


bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, ans;

ll x[500005], y[500005], z[500005];
ll dp[5005][5005];
string s;

ll mul(ll a, ll b){
    if(b == 0)return 0;
    if(a > INF / b){
        return INF;
    }else{
        return a * b;
    }
}

void solve(){
    ll a;
    cin >> a;
    string s;
    cin >> s;
    ll cnt = 0;
    for(ll i=0;i<s.size();i++){
        if(s[i] == '.')continue;
        cnt *= 10;
        cnt += (s[i] - '0');
    }
    ll c = cnt * a;
    c /= 100;
    p(c);
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
#include <stdio.h>
using namespace std;


#define ll                 long long
#define mod                1000000007
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define T(t)               cout << "Case " << t <<": ";
#define scan(v)            for(int i = 0; i<n; i++){ll x;cin>>x;v.pb(x);}
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fout               freopen("output.txt","w",stdout);


int main(){

    int x;
    cin >> x;
    if(x == 0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }





    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main(void){
    char s[200];

    scanf("%s",s);

    //printf("%s\n",s);

    int i,j;
    int n;
    n=strlen(s);
    //printf("%d\n",n);
    for(i=n-1;i>0;i--){
        if(i%2==0){
            for(j=0;j<i/2;j++){
                if(s[j]!=s[j+i/2]){
                    break;
                }
            }
        }
        if(j==i/2){
            break;
        }
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        if (s.contains("a") && s.contains("b") && s.contains("c")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b && a > c) {
		cout << (b * c) / 2 << endl;
	}
	else if (b > a && b > c) {
		cout << (a * c) / 2 << endl;
	}
	else if (c > a && c > b) {
		cout << (a * b) / 2 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 8

bool graph[MAXN][MAXN];
int dfs(int v,int N,bool visited[MAXN])
{
  int i;
  bool all_visited=true;
  for(i=0;i<N;i++)
    {
      if(visited[i]==false)
	{
	  all_visited=false;
	}
    }
  if(all_visited == true)
    {
      return 1;
    }
  int ret=0;
  for(i=0;i<N;i++)
    {
      if(graph[v][i] == false) continue;
      if(visited[i] == true) continue;
      visited[i]=true;
      ret+=dfs(i,N,visited);
      visited[i]=false;
    }
  return ret;
}

int main(int argc,char const* argv[])
{
  int n,m,i,ans,a,b;
  cin >> n >> m;
  for(i=0;i<m;i++)
    {
      cin >> a >> b;
      graph[a-1][b-1]=graph[b-1][a-1]=true;
    }

  bool visited[MAXN];
  for(i=0;i<n;i++)
    {
      visited[i]=false;
    }
  visited[0]=true;
  ans=dfs(0,n,visited);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

struct dsu {
    vector<int> v, szs;

    dsu(int n) : v(n), szs(n, 1) {
        iota(begin(v), end(v), 0);
    }

    int fs(int x) {
        while(v[x] != x) x = v[x];
        return x;
    }

    void ms(int x, int y) {
        int px = fs(x), py = fs(y);
        if(px == py) return;
        if(szs[px] < szs[py]) swap(px, py);
        v[py] = px;
        szs[px] += szs[py];
    }

    int sz(int x) {
        return szs[fs(x)];
    }
};

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> g(n);
    vector<int> cnt(n, 0);
    vector<unordered_set<int>> ss(n);

    dsu dd(n);
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        ss[a].insert(b);
        g[b].push_back(a);
        ss[b].insert(a);
        dd.ms(a, b);
    }

    for(int i = 0; i < k; i++) {
        int c, d; cin >> c >> d; c--; d--;
        int pc = dd.fs(c), pd = dd.fs(d);
        if(!ss[c].count(d) && pc == pd) cnt[c]++, cnt[d]++;
    }
    //for(int i = 0; i < n; i++) cout << d.sz(i) << endl;
    //for(int i = 0; i < n; i++) cout << cnt[i] << endl;

    for(int i = 0; i < n; i++) 
        cout << dd.sz(i) - cnt[i] - g[i].size() - 1 << " ";
    cout << '\n';
}

Measured memory_bytes: 23708
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
void solve()
{
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    int lo=0;
    int hi=b-a;
    while(hi-lo>=2)
    {
        int x=(lo+hi)>>1;
        int val=(a+(x/2))*(a+x-(x/2));
        if(val<(a*b))
        {
            lo=x;
        }
        else
        {
            hi=x;
        }
    }
    cout<<2*(a-1)+lo<<endl;

}
 main()

{
    fast
    int q;
    cin>>q;
    f(i,1,q)
    {
        solve();
    }
    return 0;

}





































Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u)
    {
        cout << a - 1 << " " << b << "\n";
    }
    else
    {
        cout << a << " " << b - 1 << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;
using ld = long double;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()


int main(){
  int r,d,x;
  cin >>r >>d >>x;

  vector<int> ans(11,0);
  ans[0] = x;
  REP(i,10){
    ans[i+1] = r*ans[i]-d;
  }

  for(int i=1;i < 11;i++){
    cout <<ans[i] << endl;
  }
}


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

using namespace std;

const int maxm = 11, maxn = 130;
int n, m,f[1 << maxm][1 << maxm], mask[maxn], s[1 << maxm];

int main()
{
    while (scanf("%d%d", &m, &n), m || n)
    {
        for (int i = 0; i < n; i++)
        {
            char str[12];
            scanf("%s", str);
            mask[i] = 0;
	    int len = strlen(str);
            for (int j = 0; j < len; j++)
                mask[i] |= (str[j] == '1') * (1 << j);
        }
        memset(f, 0, sizeof f);
        for (int opt = (1 << m) - 2; opt >= 0; opt--)
        {
            memset(s, 0, sizeof s);
            for (int j = 0; j < n; j++)
                s[mask[j] & opt]++;
            for (int opt0 = 0; opt0 <= opt; opt0++)
                if (s[opt0] > 1)
                {
                    f[opt][opt0] = n + 1;
                    for (int k = 0; k < m; k++)
                        if (!((1 << k) & opt))
                            f[opt][opt0] = min(f[opt][opt0], max(f[opt ^ (1 << k)][opt0], f[opt ^ (1 << k)][opt0 ^ (1 << k)]) + 1);
                }
        }
        printf("%d\n", f[0][0]);
    }
    
    return 0;
}

Measured memory_bytes: 17432
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        a: usize,
    }
    println!("{}", n*n-a);
}


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

#ifdef LOCAL
void err() { cerr << '\n'; }
template <class T, class ...A>
void err(T a, A ...b) {
    cerr << " " << a; err(b...);
}
#define dbg(a...) cerr << __LINE__ << " [" << #a << "]:", err(a)
#else
#define dbg(a...) 0
#endif

#define all(v) (v).begin(), (v).end()
#define long int64_t
using vll = vector<long>;
using vi = vector<int>;

int constexpr MOD = (int) 1e9 + 7;

inline void norm(long &a) {
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    vll a(n); for (auto &i : a) cin >> i;
    vll suff(n);
    suff[n - 1] = a[n - 1] % MOD;
    for (int i = n - 2; i >= 0; --i) {
        norm(suff[i] = suff[i + 1] + (a[i] % MOD));
    }
    long ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        norm(ans += (suff[i + 1] * a[i]) % MOD);
    }
    cout << ans;
    return 0;
}



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

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

   priority_queue<ll> pq;

   rep(i, 0, N) {
      ll tmp;
      cin >> tmp;
      pq.push(tmp);
   }

   rep(i, 0, M) {
     ll top;
     top = pq.top();
     pq.pop();
     pq.push(top / 2);
   }

   ll ans = 0;

   while(!pq.empty()) {
     ans += pq.top();
     pq.pop();
   }

   cout << ans << endl;
 }


Measured memory_bytes: 1400
n = int(input())
xs = list(map(int, input().split()))
 
ys = list(sorted(xs))
m1 = ys[n//2 - 1]
m2 = ys[n//2]
 
medians = [m2 if x < m2 else m1 for x in xs]
print('\n'.join(map(str, medians)))

Measured memory_bytes: 30376
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	
	cout << n*n - a << endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        sc.close();

        int cnt = 0;
        cnt = (int)Math.pow(N, 3);

        PrintWriter out = new PrintWriter(System.out);
        out.println(cnt);
        out.flush();
    }
}

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

int main(){
	ll n;
	cin >> n;
	ll ans = n * 2 / __gcd(n,ll(2));
	cout << ans << endl;
    return 0;
}



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

int dp[3001][3001]={0};

int main(){

    string a;cin>>a; 
    string b;cin>>b;     
    int n=a.length();
    int m=b.length();
    rep(i,1,n+1){
        rep(j,1,m+1){
            if(a[i-1]==b[j-1])dp[i][j]=dp[i-1][j-1]+1;
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    stack<char> st;
    int i=n,j=m;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            st.push(a[i-1]);
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else j--;
        }
    }
    while(!st.empty()){
        cout<<st.top();
        st.pop();
    }

    return 0;

}

Measured memory_bytes: 35456
import java.util.*;

    class Main {
        public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int X = sc.nextInt();
    	int min = 100000;
    	int ans = 0;
    	for(int i = 0; i < N; i++) {
    	    int a = sc.nextInt();
    	    X -= a;
    	    min = Math.min(a, min);
			ans++;
    	} while(X>=min){
    		X -= min;
    		ans++;
    		
    	}
    	System.out.println(ans);
        }
    }

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
#include <set>
using namespace std;

#define mod 1000000007

vector<vector<long long> > memory;

long long combination(long long n, long long k){
    if (!memory[n][k]) {
        if (n == k || k == 0) memory[n][k] = 1;
        else if (k == 1) memory[n][k] = n;
        else memory[n][k] = (combination(n - 1, k) + combination(n - 1, k - 1)) % mod;
    }
    return memory[n][k];
}

int main(){
    int n, k;
    cin >> n >> k;
    memory = vector<vector<long long> >(n + 1, vector<long long> (k + 1, 0));
    long long result;
    for (int i = 1; i <= k; i++){
        if (n - k + 1 >= i)
            result = (combination(k - 1, i - 1) * combination(n - k + 1, i)) % mod;
        else
            result = 0;
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	string S;
	cin>>S;
	if(S[0]==S[1]&&S[0]==S[2]&&S[0]==S[3]){
		cout<<"No"<<endl;
	}else if(S[0]==S[1]&&S[2]==S[3]){
		cout<<"Yes"<<endl;
	}else if(S[0]==S[2]&&S[1]==S[3]){
		cout<<"Yes"<<endl;
	}else if(S[0]==S[3]&&S[2]==S[1]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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


int main(){

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    
    int ans = 0;

    if( A > B ) ans += B;
    else ans += A;

    if( C > D ) ans += D;
    else ans += C;

    cout << ans << endl;    

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[233],s,mn=23333333;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=10000;i++)
	{
		s=0;
		for(int j=1;j<=n;j++) 
		  s+=(a[j]-i)*(a[j]-i);
		mn=min(mn,s);
	}
	cout<<mn;
	return 0;
} 

Measured memory_bytes: 256
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i;

        String s[]=br.readLine().trim().split(" ");
        long N=Long.parseLong(s[0]);
        long K=Long.parseLong(s[1]);

        long min=N;
        N=Math.abs(N-K);
        min=Math.min(min,N);
        N=Math.abs((N-K));
        min=Math.min(min,N);

        if(N>K) N%=K;

        N=Math.abs(N-K);
        min=Math.min(min,N);
        N=Math.abs((N-K));
        min=Math.min(min,N);

        System.out.println(min);
    }
}

Measured memory_bytes: 20308
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

class prime_factorizer:private vector<pair<ll,ll>>{
    public:
        prime_factorizer(ll n)
        {
            vector<bool>is_prime=sieve(static_cast<ll>(sqrt(n)));
            for(ll i=2;i<is_prime.size();++i){
                if(is_prime[i]){
                    ll e=0;
                    while(n%i==0){
                        ++e;
                        n/=i;
                    }
                    if(e!=0)emplace_back(i,e);
                }
            }
            if(n!=1)emplace_back(n,1);
        }
        static vector<bool>sieve(ll n)
        {
            vector<bool>is_prime(n+1,true);
            is_prime[0]=is_prime[1]=false;
            for(ll i=2;i*i<=n;++i){
                if(is_prime[i]){
                    for(ll j=i*2;j<n+1;j+=i){
                        is_prime[j]=false;
                    }
                }
            }
            return is_prime;
        }
        using vector<pair<ll,ll>>::begin;
        using vector<pair<ll,ll>>::end;
};
ll mypow(ll x,ll y)
{
    return
    y==0?1
    :y%2==0?mypow(x*x,y/2)
    :x*mypow(x,y-1);
}
int main()
{
    ll n=in(),p=in();
    ll ans=1;
    for(auto pf:prime_factorizer(p))ans*=mypow(pf.first,pf.second/n);
    cout<<ans<<endl;
}


Measured memory_bytes: 384
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(n):
    a.append(a[i]+A[i])

for i in range(m):
    b.append(b[i]+B[i])

ptr = m
ans = 0

for i in range(n + 1):
    if a[i] > k:
        break
    while a[i] + b[ptr] > k:
        ptr -= 1
    ans = max(ans, i + ptr)

print(ans)


Measured memory_bytes: 47536
import itertools
import math

N = int(input())

xy = []

for _ in  range(N):
    xy.append([int(i) for i in input().split()])

d = 0
e = 0
for i in itertools.permutations(list(range(N)), N):
    e += 1
    for j in range(N - 1):
        a = pow(xy[i[j]][0] - xy[i[j+1]][0], 2)
        b = pow(xy[i[j]][1] - xy[i[j+1]][1], 2)
        c = math.sqrt(a+b)
        d += c
print(d/e)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
        int a[31];
        int w,n,i,an,bn;
        scanf("%d",&w);
        for(i=1;i<=w;i++)a[i]=i;
        scanf("%d",&n);
        while(n--){
        scanf("%d,%d",&an,&bn);
        a[bn]^=a[an];a[an]^=a[bn];a[bn]^=a[an];
        }
        i=0;
        while(i++!=w)printf("%d\n",a[i]);
        return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
struct nod{
	int x,y;
}a[100];
nod b[100];
int n,m,num[100];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
	for(int i=1;i<=m;i++)cin>>b[i].x>>b[i].y;
	for(int i=1;i<=n;i++){
		int maxx=1<<30;
		for(int j=1;j<=m;j++){
			if((abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y))<maxx){
				maxx=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
				num[i]=j;	
			}
		}
		cout<<num[i]<<endl;
	}
cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s=='AC' and a[p-1]==0:
        a[p-1]+=1
    elif s=='WA' and a[p-1]==0:
        b[p-1] +=1
for j in range(n):
    if a[j]==0:
        b[j]=0
        
print(sum(a),sum(b))

Measured memory_bytes: 4596
#include <stdio.h>

void main(void){
  int X;
  scanf("%d",&X);
  if(400<=X&&X<=599)
    puts("8");
  else if(600<=X&&X<=799)
    puts("7");
  else if(800<=X&&X<=999)
    puts("6");
  else if(1000<=X&&X<=1199)
    puts("5");
  else if(1200<=X&&X<=1399)
    puts("4");
  else if(1400<=X&&X<=1599)
    puts("3");
  else if(1600<=X&&X<=1799)
    puts("2");
  else if(1800<=X&&X<=1999)
    puts("1");
}
    

Measured memory_bytes: 1660
# input
s = input()
K = int(input())

# check
case = []
append = case.append
for i in range(1, K + 1):
    for idx in range(0, len(s) - (i - 1)):
        if s[idx:idx + i] not in case:
            append(s[idx:idx + i])
case.sort(reverse=True)

print(case[-K])

Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


bool used[100000];

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

    cin >> n >> m;
    vector<int> h(n);
    int a, b;
    for (int i = 0; i < n; i++) {
        used[i] = false;
    }
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--;
        b--;

        if (h[a] > h[b]) {
            used[b] = true;

        } else if ((h[a] < h[b])) {
            used[a] = true;

        } else {
            used[a] = true;
            used[b] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (used[i] == true) {
            continue;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
const double PI = acos(-1);

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

int main() {
	int n, a, b;

	cin >> n >> a >> b;
	
	if (n * a < b) {
		cout << n*a << endl;
	} else {
		cout << b << endl;
	}	
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), M = input();
    range(i, 0, M) N -= input();
    
    cout << (N < 0 ? -1 : N) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>

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

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


/* unionfind begin*/
class unionfind
{
private:
    vector<long long> par;
    vector<long long> rank;
public:
    void init(long long n);
    long long find(long long x);
    void unite(long long x, long long y);
    bool same(long long x, long long y);
};

// 初期化
void unionfind::init(long long n) {
    for (long long i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
    }
}

// 木の根を求める
long long unionfind::find(long long x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unionfind::unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y)return;
    
    if (rank[x] < rank[y]) {
        par[x] = y;
    }
    else {
        par[y] = x;
        if (rank[x] == rank[y]) {
            rank[x]++;
        }
    }
}

// xとyが同じ集合に属していたらtrue
bool unionfind::same(long long x, long long y) {
    return find(x) == find(y);
}
/* unionfind end*/


int main() {
    ll n, k, l;
    unionfind uni1,uni2;
    
    scanf("%lld %lld %lld", &n, &k, &l);
    uni1.init(n);
    uni2.init(n);
    REP(i, k){
        ll p, q;
        scanf("%lld %lld", &p, &q);
        p--;q--;
        uni1.unite(p, q);
    }
    REP(i, l){
        ll r, s;
        scanf("%lld %lld", &r, &s);
        r--;s--;
        uni2.unite(r, s);
    }
    
    map<pair<ll, ll>, ll> m;
    REP(i, n){
        m[{uni1.find(i), uni2.find(i)}]++;
    }
    REP(i, n - 1){
        cout << m[{uni1.find(i), uni2.find(i)}] << ' ';
    }
    cout << m[{uni1.find(n - 1), uni2.find(n - 1)}] << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef set <int> st;
typedef set <char> stc;
typedef vector<int>::iterator itr;

#define df first
#define ds second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<(b);i++)
#define f22(a,b) for(int j=(a);j<(b);j++)
#define sq(a) a*a
#define cu(a) (sq(a)*a)


const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int inf = 1e9+9;
const ll INF = 1e18;


int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    
    string s;
    int a = 0;
    cin >> s;
    
    f0((s.length() - ((s.length()%2 == 1)))/2){
     
	 if(s[i] != s[s.length()-1-i]) a++;	
    	
	} 
    
    cout << a;
    
    return 0; 
    
}


Measured memory_bytes: 256
n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
v = v.sort
j = 0
while true
    i1 = v.shift
    i2 = v.shift
    heikin = (i1 + i2) / 2.to_f
    v.unshift(heikin)
    if v.size == 1
        break
    end
end
puts v.pop

Measured memory_bytes: 14332
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		int numx[];
		numx = new int[N];
		
		int numy[];
		numy = new int[M];
		
		int i = 0;
		int j = 0;
		for(i = 0;i < N;i++){
			numx[i] = sc.nextInt();
		}
		for(i = 0;i < M;i++){
			numy[i] = sc.nextInt();
		}
		
		Arrays.sort(numx);
		Arrays.sort(numy);
		
		N = N - 1;
		M = M - 1;
		
		if(X < Y && numx[N] < numy[0] &&X != numx[N] && X < numy[0] && numx[N] < Y){
			
			System.out.println("No War");
		}
		else{
			System.out.println("War");
		}
	}
}

Measured memory_bytes: 21844
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n = Console.ReadLine().ToInt32();
        var k = Console.ReadLine().ToInt32();
        var x = Console.ReadLine().ToInt32();
        var y = Console.ReadLine().ToInt32();
        Console.WriteLine(k >= n ? x * n : x * k + y * (n - k));

        Console.ReadLine();
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    public const int Mod1e9 = 1000000007;
    

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, i, j, k, a, b, aa, bb, cc, s;
	cin >> n >> a >> b;
	vector<long long> h(n);
	for (i = 0; i < n; i++) cin >> h[i];

	aa = 1; bb = 1LL << 48;
	while (aa < bb) {
		cc = (aa + bb) / 2;

		s = 0;
		for (auto p : h) {
			if ((p + b - 1) / b > cc) s += max(0LL, (p - cc * b + (a - b - 1)) / (a - b));
		}

		if (s <= cc) bb = cc;
		else aa = cc + 1;			
	}

	cout << aa << "\n";


	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int x[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = n -1; i >= 0; i--) {
    cout << x[i];
    if (i != 0) {
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 3096
N,C,K = map(int,input().split())

T = []

for i in range(N):    
    T.append(int(input()))
    
T = sorted(T)
    
start = T[0]
ans = 1
now_C = 1
for t in T[1:]:
    if t<=start+K and now_C < C:
        now_C += 1
    else:
        start = t
        ans += 1
        now_C = 1

print(ans)

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    vector<LL> l{2,1};
    for (int i = 1; i < n; i++) {
        l.push_back(l[i-1]+l[i]);
    }

    cout << l.back() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007LL
//#define MOD 998244353LL
//#define MOD 1000000009LL
const long long INF = 1LL << 60;
typedef long long ll;

int main(){
    ll A,B,N,temp;
    ll ans = 0;
    scanf("%lld %lld %lld",&A,&B,&N);
    temp = N-N%B-1;
    ans = temp*A/B-A*(temp/B);
    ans = (ans<N*A/B-A*(N/B)) ? N*A/B-A*(N/B) : ans;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#-*-coding:utf-8-*-

def main():
    n = int(input())
    input_bulding_datas=[]
    input_bulding_datas=[[int(i) for i in input().split()] for _ in range(n)]

    all_buldings=[]
    for i in range(4):
        floors=[]
        buldings=[]
        for j in range(3):
            floors+=[[0]*10]
        buldings+=floors
        all_buldings+=[buldings]

    for input_floor_datas in input_bulding_datas:
            b,f,r,v=input_floor_datas
            all_buldings[b-1][f-1][r-1]+=v

    print_string=""
    for idx,bulding_data in enumerate(all_buldings):
        for floor_data in bulding_data:
            for data in floor_data:
                print_string+=" "+str(data)
            print(print_string)
            print_string=""
        if idx!=3:
            print("####################")



if __name__=="__main__":
    main()


Measured memory_bytes: 5608
#include <stdio.h>
long long a(long long x){
	return x*x*x*x*x;
}
int main()
{
	long long i,j;
	long long x;
	scanf("%lld",&x);
	for(i=-100;i<1000;i++){
		for(j=-100;j<1000;j++){
			if(a(i)-a(j)==x){
			printf("%lld %lld",i,j);
		    return 0;
		 }
		}
	}
} 

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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var s = arr[0] < arr[1] ? arr[1] < arr[2] ? "Yes" : "No" : "No";

            Console.WriteLine(s);
        }
    }
}



Measured memory_bytes: 16336
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInts(3)
	sort.Sort(sort.IntSlice(n))
	if n[0] == 5 && n[1] == 5 && n[2] == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    cin >> A >> B ;
    if (A+B == 3){
        cout << 3 << endl;
    }
    else if (A+B == 4){
        cout << 2 << endl;
    }
    else cout << 1 << endl;
}

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

using namespace std;

int main(){

  int n,m,p;

  while(cin>>n>>m>>p,n||m||p){

	vector<int> x(n+1);
	int total=0;
	
	for(int i=1;i<=n;++i){
	  cin>>x[i];
	  total+=x[i];
	}

	total=total*100;

	total=total*(100-p)/100;

	
	if(x[m]==0)
	  cout<<0<<endl;
	else
	  cout<<total/x[m]<<endl;
	
  }

}



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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c)cout<<a<<" "<<b<<" "<<c<<endl;
	else if(c<=b&&b<=a)cout<<c<<" "<<b<<" "<<a<<endl;
	else if(c<=a&&a<=b)cout<<c<<" "<<a<<" "<<b<<endl;
	else if(a<=c&&c<=b)cout<<a<<" "<<c<<" "<<b<<endl;
	else if(b<=a&&a<=c)cout<<b<<" "<<a<<" "<<c<<endl;
	else if(b<=c&&c<=a)cout<<b<<" "<<c<<" "<<a<<endl; 
    return 0;
}




Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

int main() {
	//入力;
	int N;
	cin >> N;
	if (N % 2 == 0) cout << N;
	else cout << N * 2;
	cout << endl;
	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 

ll gcd(ll a, ll b) 
{
	if (b > a) swap(a,b); 
	if (b == 0) return a;
	return gcd(b, a%b);
}

int main()
{
	while (1) {
		string s;
		cin >> s;
		if (s == "#") break;
		reverse(all(s));
		int deg = 0, per = 1;
		for (int i = 0; len(s); i++) {
			if (s[0]=='h') {
				s = s.substr(5);
				if (i == 0) deg = 0;
				else {
					deg *= 2;
					per *= 2;
					deg -= 90;
				}
			}
			else {
				s = s.substr(4);
				if (i == 0) deg = 90;
				else {
					deg *= 2;
					per *= 2;
					deg += 90;
				}
			}
		}
		ll g = gcd(deg, per);
		deg /= g;
		per /= g;
		deg % per == 0 ? cout << deg/per << endl : cout << deg << "/" << per << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3608
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
int N;
vector<pair<ll, ll>> TA;






//サブ関数
//入力
void input()
{
	cin >> N;
	ll a, b;
	REP(i, N) {
		cin >> a >> b;
		TA.push_back({ a,b });
	}
}

//計算
void calc()
{
	ll t = TA[0].first;
	ll a = TA[0].second;
	for (auto p : TA) {
		ll timesT = t / p.first + (t%p.first == 0 ? 0 : 1);
		ll timesA = a / p.second + (a%p.second == 0 ? 0 : 1);
		ll times = max(timesT, timesA);
		t = p.first*times;
		a = p.second*times;
	}
	cout << t + a << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


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

const int mod = 1e9 + 7;
int n, a[MAXN];
int spfract[MAXN];

int pwlog(int x, int pw) {
    if (!pw)
        return 1;
    int a = pwlog(x, pw >> 1);
    return 1LL * a * a % mod * ((pw & 1) ? x : 1) % mod;
}

int fmod(int x) {
    x %= mod;
    return (x < 0) ? (x + mod) : x;
}

int main() {
    ios::sync_with_stdio(0);

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

    spfract[1] = 1;
    for (int i = 2; i <= n; ++i)
        spfract[i] = (spfract[i - 1] + pwlog(i, mod - 2)) % mod; 

    long long sol = 0;
    for (int i = 1; i <= n; ++i)
        sol = (sol + 1LL * a[i] * fmod(spfract[i] + spfract[n - i + 1] - 1)) % mod;
    for (int i = 1; i <= n; ++i)
        sol = sol * i % mod;

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
p = list(map(int,input().split()))

def init_max(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=max(seg[2*i+1],seg[2*i+2]) 
    
def update_max(k,x):
    k += num-1
    seg[k] = x
    while k+1:
        k = (k-1)//2
        seg[k] = max(seg[k*2+1],seg[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg[p])
        if q&1 == 1:
            res = max(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg[p])
    else:
        res = max(max(res,seg[p]),seg[q])
    return res

def init_min(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=min(seg[2*i+1],seg[2*i+2]) 
    
def update_min(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = min(seg[k*2+1],seg[k*2+2])
    
def query_min(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = min(res,seg[p])
        if q&1 == 1:
            res = min(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = min(res,seg[p])
    else:
        res = min(min(res,seg[p]),seg[q])
    return res


#####単位元######
ide_ele = -1

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init_max(p)

a = [-1]*(n-k+1)
for i in range(n-k+1):
    a[i] = query_max(i,i+k)

#####単位元######
ide_ele = n

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init_min(p)

b = [-1]*(n-k+1)
for i in range(n-k+1):
    b[i] = query_min(i,i+k)

c = [1]*n
d = [True]*n
for i in range(n-2,-1,-1):
    if p[i] < p[i+1]:
        c[i] = c[i+1]+1
        if c[i] >= k:
            d[i] = False



res = 0
res2 = 0


for i in range(n-k):
    if not d[i]:
        res2 = 1
        continue
    if b[i] == p[i] and a[i+1] == p[i+k]:
        continue
    res += 1
if d[n-k]:
    res += 1

if n==k:
    print(1)
else:
    print(res+res2)


Measured memory_bytes: 100684
#include<iostream>
#include<map>
#define int long long
const int mod=1e9+7;
std::map <int,int> d;
int solve(int x) {
	if(d[x])
		return d[x];
	else
		return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main() {
	d[0]=1;
	d[1]=2;
	int n;
	std::cin>>n;
	int ans=solve(n);
	std::cout<<ans;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b;
    cin >> a >> b;
    string anser;
    if (a < b) {
        anser = "a < b";
    } else if (a > b) {
        anser = "a > b";
    } else {
        anser = "a == b";
    }
   
    cout << anser << endl;
}



Measured memory_bytes: 3152