akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){

    long double a;
    long double b;
    long double x;
    cin >> a >> b >> x;
    if(2*x>=a*a*b){
        cout << setprecision(12) << atan(2*(a*a*b-x)/(a*a*a))/M_PI*180 << endl;
    }
    else{
        cout << setprecision(12) << atan((a*b*b)/(2*x))/M_PI*180 << endl;
    }

}

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


Measured memory_bytes: 384
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

map<P, int> M;

int32_t main(){_
   
   cin>>n;

   for (int i = 1; i <= n; ++i)
   {
      string s = to_string(i);
      int f = s[0] - '0';
      int l = s.back() - '0';
      M[{f, l}]++;
   }

   int ans = 0;
   for (int f = 1; f <=9; ++f)
   {
      for (int l = 0; l <= 9; ++l)
      {
         ans += M[{f, l}] * M[{l, f}];
      }
   }

   cout<<ans;

   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct T{char n[30];int p;}T;
T L[15];
int N,w,e,l,i,j,f;

int main()
{
	for(f=0;scanf("%d\n",&N),N;f++)
	{
		if(f)puts("");
		for(i=0;i<N;i++)
		{
			scanf("%s%d%d%d\n",L[i].n,&w,&l,&e);
			L[i].p=w*3+e;
			for(j=i;j>0&&L[j-1].p<L[j].p;j--)
			{
				T s=L[j];
				L[j]=L[j-1];
				L[j-1]=s;
			}
		}
		for(i=0;i<N;i++)
			printf("%s,%d\n",L[i].n,L[i].p);
	}
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  vector<int> hcount(H);
  vector<int> wcount(W);
  
  for(int i=0;i < H;i++){
    for(int j=0;j < W;j++){
      cin >> a.at(i).at(j);
    }
  }
  
  for(int i=0;i < H;i++){
    for(int j=0;j < W;j++){
      if (a.at(i).at(j) == '.'){
        hcount.at(i)++;
        wcount.at(j)++;
      }
    }
  }
  
  for(int i=0;i < H;i++){
    
    if (hcount.at(i) == W){
      continue;
    }
    for(int j=0;j < W;j++){
      if (wcount.at(j) == H){
        continue;
      }
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <list>
#include <stack>
#define lar(a, b) ((a>b) ? (a):(b))
#define sml(a, b) ((a<b) ? (a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> p;

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

int main(void) {
    ll n, i;
    cin >> n;
    ull t[n];
    for(i=0; i<n; i++)
        cin >> t[i];
    sort(t, t+n);
    
    ll ans=t[0];
    for(i=0; i<n; i++)
        ans = ans/gcd(ans, t[i])*t[i];
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#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 vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}



int main()
{


ll n;cin>>n;


ll ans=0;

vector<pair<ll,ll>>a[n];

for(int i=0;i<n;i++)
{
  ll temp;cin>>temp;

  for(int j=0;j<temp;j++)
  {
    ll x,y;cin>>x>>y;
    a[i].pb({x,y});
  }
}

/*for(int i=0;i<n;i++)
{
  for(int j=0;j<a[i].size();j++)
  {
    cout<<a[i][j].ff<<" "<<a[i][j].ss<<"\n";
  }
  cout<<endl;
}*/

for(int mask=0;mask<1<<n;mask++)
{
  vector<ll>honest(n,0);
 // honest.clear();
  fill(all(honest),0);
  ll cnt=0;
  for(int i=0;i<n;i++)
  {
    if(mask&(1<<i))
    {
      honest[i]=1;
      cnt++;
    }
  }
  /*if(mask==3)
  {
    cout<<honest[0]<<honest[1]<<honest[2]<<"\n";
  }*/
  //cout<<cnt<<"\n";
ll flag=0;
  for(int i=0;i<n;i++)
  {
    if(honest[i]==1)
    {
       for(int j=0;j<a[i].size();j++)
        {
          if(honest[a[i][j].ff-1]!=a[i][j].ss)
          {
            flag=1;
            break;
          }

          }

        }
        if(flag)break;
    }
   // else continue;

    
  

 // if(mask==3)cout<<flag<<" "<<cnt<<"\n";

  if(!flag)ans=max(ans,cnt);
}

cout<<ans<<"\n";

return 0;

}

Measured memory_bytes: 256
N = int(input())
dp = [[0 for i in range(4)] for j in range(N)]
mod = 10**9 + 7

for i in range(N):
    if(i == 0):
        for j in range(4):
            dp[0][j] = 1
    elif(i == 1):
        for j in range(4):
            dp[1][j] = 4
    elif(i == 2):
        base = dp[i-1][0] + dp[i-1][1] + dp[i-1][2] + dp[i-1][3]
        dp[i][0] += base
        dp[i][1] += base - dp[i-2][2] - dp[i-2][0]
        dp[i][2] += base - dp[i-2][0]
        dp[i][3] += base
        for j in range(4):
            dp[i][j] %= mod
    else:
        base = dp[i-1][0] + dp[i-1][1] + dp[i-1][2] + dp[i-1][3]
        dp[i][0] += base
        dp[i][1] += base - dp[i-3][0]*3 - dp[i-2][2] - dp[i-2][0]
        dp[i][2] += base - (dp[i-2][0] - dp[i-3][2])
        dp[i][3] += base
        for j in range(4):
            dp[i][j] %= mod
    
print((dp[N-1][0] + dp[N-1][1] + dp[N-1][2] + dp[N-1][3])%mod)




Measured memory_bytes: 38256
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    while True:
        B = read_int()
        if B == 0:
            break
        print(*solve(B))


def solve(B):
    bb = 2 * B

    lb = 1
    ub = B + 1
    while ub - lb > 1:
        m = (lb + ub) // 2
        if m * m <= bb:
            lb = m
        else:
            ub = m

    n = lb
    while True:
        if bb % n == 0:
            k = bb // n
            if (k - n) % 2 == 1:
                return (k - n + 1) // 2, n
        n -= 1


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7316
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

  map<string, long> ss;
  string tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    stable_sort(tmp.begin(), tmp.end());
    ss[tmp]++;
  }

  long ans = 0;

  for(auto itr = ss.begin(); itr != ss.end(); ++itr){
    if((itr->second) > 1) ans += (itr->second)*((itr->second)-1) / 2;
  }

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


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
	cin >> s.at(i);
  }
  set<string> S;
  rep(i,n){
   S.insert(s.at(i));
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 25004
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

int main()
{
#ifdef _MSC_VER
	freopen("d.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;
	--l;
	vector<int> p(n);
	vector<int> inv_p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		--p[i];
		inv_p[p[i]] = i;
	}
	vector<long long> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	long long ret = -(1LL << 62);
	for (int start = 0; start < n; ++start) {
		long long s = 0;
		vector<long long> a;
		a.push_back(s);
		for (int i = start; ; i = p[i]) {
			s += c[i];
			a.push_back(s);
			if (p[i] == start) {
				break;
			}
		}
		int m = a.size() - 1;
		vector<long long> b = a;
		for (int i = 1; i <= m; i++) {
			b[i] = max(b[i], b[i - 1]);
		}
		for (int d : {0, 1, 2, l / m, l / m - 1, l / m - 2}) {
			if (d < 0 || d * m > l) {
				continue;
			}
			ret = max(ret, c[inv_p[start]] + s * d + b[min(m, l - d * m)]);
		}
	}
	cout << ret << endl;
	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

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

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll N; scanf("%lld", &N);
  Vi A(N), B(N);
  REP(i, N) scanf("%lld%lld", &A[i], &B[i]);
  ll ans = 0;
  for(ll i = N - 1; i >= 0; i--){
    ans += residue(-(A[i] + ans),B[i]);
  }
  printf("%lld\n", ans);
}


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

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    vector<long long> S(n + 1, 0);
    unordered_map<long long, long long> mp;
    
    mp[0]++;
    for(int i = 1; i < n + 1; i++){
        S[i] += S[i - 1] + A[i - 1];
        mp[S[i]]++;
    }

    long long ans = 0;
    for(auto x : mp){
        ans += x.second * (x.second - 1) / 2; 
    }

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

Measured memory_bytes: 11592
#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 rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N,K;cin >> N >> K;
    cout << min(N % K,abs(N % K - K)) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
        void solve(IO io, PrintWriter out)
        {
            int t = 1;
            while(t-->0)
            {
                int n = io.nextInt();
              	int k = io.nextInt();
              	int[] ar = new int[n];
              	for(int i=0 ; i<n ; i++)
                  ar[i] = io.nextInt();
              	int dp[] = new int[n];
              	Arrays.fill(dp,Integer.MAX_VALUE);
              	dp[0]=0;
              	int end=0;
              	for( ; end<n-1; end++)
                {
                  for(int i=end+1 ; i<=Math.min(end+k,n-1) ; i++)
                  {
                    dp[i] = Math.min(dp[i],dp[end]+Math.abs(ar[end]-ar[i]));
                  }
                  //out.println(dp[end]);
                }
              	out.print(dp[n-1]);
            }
	    }
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	private static final int BUF_SIZE = 2048;
        BufferedReader br;
        private IO() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        private boolean isSpace(char c) {
            return c == '\n' || c == '\r' || c == ' ';
        }
        String next() {
            try {
                StringBuilder sb = new StringBuilder();
                int r;
                while ((r = br.read()) != -1 && isSpace((char) r));
                if (r == -1) {
                    return null;
                }
                sb.append((char) r);
                while ((r = br.read()) != -1 && !isSpace((char) r)) {
                    sb.append((char) r);
                }
                return sb.toString();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
	}
}

Measured memory_bytes: 36668
a, b, c = sorted([int(n) for n in input().split()])

resa = c - a
resb = c - b

if resa % 2 == resb % 2:
    ans = (b - a) // 2 + (c - b)
else:
    ans = 1 + (b + 1 - a) // 2 + (c - b)

print(ans)


Measured memory_bytes: 2940
// 2009ツアツジツアツ地ツ凝ヲツ予ツ選 J : Infected Land
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <queue>

using namespace std;

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

class Node{
public:
	int land, x, y;
	Node(int land, int x, int y) : land(land), x(x), y(y) {}
	bool operator < (const Node &n) const { 
		return make_pair(land,make_pair(x,y)) < make_pair(n.land,make_pair(n.x,n.y));
	}
};

int main(){
	int n;
	string s[5];
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> s[i];
		int sx, sy;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(s[i][j]=='@') sx = i, sy = j;
		int land = 0;
		for(int i=n-1;i>=0;i--)
			for(int j=n-1;j>=0;j--)
				land = 2*land + (s[i][j]=='#');
		int ans = -1;
		set<Node> mem; mem.insert(Node(land, sx, sy));
		queue< pair<Node,int> > qu; qu.push(make_pair(Node(land,sx,sy),0));
		while(!qu.empty()){
			pair<Node,int> p = qu.front(); qu.pop();
			int L = p.first.land, x = p.first.x, y = p.first.y, cost = p.second;
			if(L==0){ ans = cost; break; }
			for(int dir=0;dir<8;dir++){
				int nx = x+dx[dir], ny = y+dy[dir];
				if(nx<0||n<=nx||ny<0||n<=ny||(L>>(nx*n+ny))&1) continue;
				int nL = 0;
				for(int i=n-1;i>=0;i--){
					for(int j=n-1;j>=0;j--){
						if(i==nx&&j==ny) continue;
						int cnt = 0;
						for(int k=0;k<8;k++){
							int ni = i+dx[k], nj = j+dy[k];
							if(ni<0||n<=ni||nj<0||n<=nj) continue;
							if(ni==nx&&nj==ny) cnt++;
							else cnt += (L>>(ni*n+nj))&1;
						}
						if((L>>(i*n+j))&1){
							if(cnt==2||cnt==3) nL |= 1<<(i*n+j);
						} else {
							if(cnt==3) nL |= 1<<(i*n+j);
						}
					}
				}
				if(mem.find(Node(nL,nx,ny))==mem.end()){
					mem.insert(Node(nL,nx,ny));
					qu.push(make_pair(Node(nL,nx,ny),cost+1));
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1728
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left
from math import floor, ceil


class Solution:
    def gcd(self, a, b):
        while b:
            a, b = b, a % b
        return a

    def lcm(self, a, b):
        return a * b // self.gcd(a, b)

    def floor(self, a, b):
        return (a + (b - 1)) // b

    def main(self):
        A, B, C, D = map(int, input().split())
        v = self.lcm(C, D)
        c_and_d = B//v - self.floor(A, v) + 1
        only_c = B//C - self.floor(A, C) + 1
        only_d = B//D - self.floor(A, D) + 1
        res = (B - A + 1) - (only_c + only_d - c_and_d)
        print(res)

if __name__ == '__main__':
    Solution().main()

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

int main() {
  int64_t x;
  cin >> x;
  for(int a=0;a<200;a++){
    for(int b=-200;b<200;b++){
      int64_t A=a;
      A*=a*a;
      A*=a*a;
      int64_t B=b;
      B*=b*b;
      B*=b*b;
      if(A-B==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int c[22],u[22];
int a[22][22];
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	int ans=1e9;
	for(int state=0;state<(1<<n);state++){
		int cost=0;
		for(int i=0;i<m;i++)
			u[i]=0;
		for(int i=0;i<n;i++)
			if((1<<i)&state){
				cost+=c[i];
				for(int j=0;j<m;j++)
					u[j]+=a[i][j];
			}
		if(*min_element(u,u+m)>=x)
			ans=min(cost,ans);
	}
	if(ans==1e9)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	return 0;
}

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

l = len(S)

anss = []
for i in range(1<<l-1):
	ans = []
	i = list("{:b}".format(i).zfill(l-1))
	#print(i)
	S_ = S.copy()
	ans.append(S_.pop(0))
	while S_ != []:
		if i.pop(0) == "1":
			ans.append("+")
		ans.append(S_.pop(0))
		#print(ans)
	anss.append(eval("".join(ans)))
#print(anss)
print(sum(anss))

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
    long long i,j,k,count=0,ans=0,x,y,l,n,sum=0,m,r;
    cin>>x>>y>>l>>r>>k;
    count=l*60+r-x*60-y-k;
    cout<<count;
    
	return 0;
}

Measured memory_bytes: 3652
import bisect

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]

a.sort()
f.sort(reverse=True)

af = [[0 for i in range(3)] for j in range(n)]

for i in range(n):
    af[i][0] = a[i]*f[i]
    af[i][1] = a[i]
    af[i][2] = f[i]
    
af.sort(reverse=True)

if k == 0:
    print(af[0][0])
    exit()

low = -1
high = af[0][0]+1
tmp = 0

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    for i in range(n):
        tmp += max(0,af[i][1] - mid // af[i][2])
    #print(tmp)
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)


Measured memory_bytes: 123468
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b,c;
    vi v;
    cin>>a>>b>>c;
    v.push_back(a+b);
    v.push_back(b+c);
    v.push_back(a+c);
    int ans = min(v[0],v[1]);
    ans =min(ans,v[2]); 
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void) {
	int n, k, h[100000];
	int i;
	int ans=0;

	scanf("%d %d", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	for (i = 0; i < n; i++) {
		if (h[i] >= k)ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>


typedef long long ll;


#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;



// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }



ll mypow(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}

mint ans[3010][3010];


int main()
{
    ll n, s; cin >> n >> s;
    vector<int> a;

    rep(i, n) {
        int temp; cin >> temp; a.pb(temp);
    }



    rep(i, n+1) {
        if (i == 0) {
            ans[0][0] = 1;
        }
        else {
            rep(j, s + 1) {
                    if (j >= a[i - 1])
                        ans[i][j] += ans[i-1][j - a[i - 1]] + ans[i-1][j] * 2;  
                    else
                        ans[i][j] += ans[i-1][j] * 2;
                
            }
        }
    }

    mint res = 0;
  


   cout << ans[n][s] << endl;
}

Measured memory_bytes: 74436
P = 100
alph = (?A..?Z).to_a + (?a..?z).to_a
code = Hash[*alph.zip((0..alph.size-1).to_a.reverse).flatten]

n = gets.to_i
a = $<.map {|l| l.chomp.split("")}
edges = {}
(1..n).each do |i|
    edges[[0, i]] = 0
    (1..n).each do |j|
        edges[[i, n+j]] = P ** 52 - P ** code[a[i-1][j-1]]
    end
    edges[[n+i, 2*n+1]] = 0
end

n.times do
    dist = [Float::INFINITY] * (2*n+2)
    dist[0] = 0
    prev_node = [nil] * (2*n+2)
    (2*n+2).times do
        edges.each do |(i, j), len|
            d = dist[i] + len
            if d < dist[j]
                dist[j] = d
                prev_node[j] = i
            end
        end
    end
    path = [2*n+1]
    path << prev_node[path[-1]] while prev_node[path[-1]]
    path.each_cons(2) do |i, j|
        c = edges[[j, i]]
        edges.delete([j, i])
        edges[[i, j]] = -c
    end
end

puts edges.keys.select {|i, j| i > j && j != 0 && i != 2*n+1}.map {|j, i| a[i-1][j-n-1]}.sort.join

Measured memory_bytes: 10072
//itp1_3-d
#include <iostream>
using namespace std;

int main(){
 int a,b,c;
 int cnt=0;

 cin>>a>>b>>c;
 for(int i=a;i<=b;i++)
  if(c%i==0) cnt++;
 cout<<cnt<<endl;
 return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int A[1000000], n;

int main(){

	cin >> n;
	for( int i= 0; i< n; i++) {

		scanf( "%d", &A[i ]);

	}

	int q, k, sum = 0;
	cin >> q;
	for( int i= 0; i < q; i++ ){
		scanf( "%d", &k);
	if ( *lower_bound( A, A + n, k) == k) sum ++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3516
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())

    def rec(m,j):
        if m==0:
            return 0
        else:
            return 2**j + rec(m//2,j+1)
            
        
    print(rec(n,0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 63468
import heapq

n=int(input())
ve=[0 for _ in range(100010)]
vo=[0 for _ in range(100010)]
v = list(map(int,input().split()))

for nn in range(n):
        vv = v[nn]
        if(nn%2==0):
                ve[vv]+=1
        else:
                vo[vv]+=1
hve = heapq.nlargest(2,range(len(ve)),key=ve.__getitem__)
hvo = heapq.nlargest(2,range(len(vo)),key=vo.__getitem__)

if hve[0]==hvo[0]:
        ans = min((n-ve[hve[0]]-vo[hvo[1]]),(n-ve[hve[1]]-vo[hvo[0]]))
else:
        ans = n-ve[hve[0]]-vo[hvo[0]]

print(ans)


Measured memory_bytes: 16160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var sum = 1L;
        for(long i = 1; i <= n; i++)
        {
            sum = (sum * i) % 1000000007;
        }

        WriteLine(sum);
    }
}


Measured memory_bytes: 17596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> par_size;

    UnionFind(int N) : par(N){ //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
        }
        par_size.resize(N);
        for(int i = 0; i < N; i++){
            par_size[i] = 1;
        }

    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x){
            return x;
        }
        else{
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        par_size[ry] += par_size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int get_size(int x){
        int rx = root(x);
        return par_size[rx];
    }
};



int main(){

    ll N_island, N_bridge;
    cin >> N_island >> N_bridge;

    vector< pair<ll, ll> > connect(N_bridge);
    for(int i = 0; i < N_bridge; i++){
        cin >> connect[i].first >> connect[i].second;
    }

    UnionFind tree(N_island);
    vector<ll> ans(N_bridge);
    ans[N_bridge - 1] = N_island * (N_island - 1) / 2;
    for(int i = N_bridge - 1; i >= 1; i-- ){
        int a = connect[i].first - 1;
        int b = connect[i].second - 1;
        if(tree.same(a, b) == false ){
            ans[i-1] = ans[i] - tree.get_size(a) * tree.get_size(b);
            tree.unite(a, b);
        }
        else{
            ans[i-1] = ans[i];
        }
    }

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

}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x,y;
	cin>>n>>x>>y;
	vector<int>v[n+1];
	
	for(int i =1; i<n ;i++)
	{
		v[i].push_back(i+1);
		v[i+1].push_back(i);
	}
	
	v[x].push_back(y);
	v[y].push_back(x);
	int a[n+1]={0};
	for(int i =1;i<=n; i++)
	{
		queue<int>q;
		q.push(i);
		int dist[n+1];
		memset(dist,0x3f,sizeof(dist));
		bool vis[n+1]={false};
		vis[i]=1;
		dist[i]=0;
		while(!q.empty())
		{
			int e = q.front();
			for(auto it:v[e])
				if(!vis[it])
				{
					dist[it]=1+dist[e];
					vis[it]=1;
					q.push(it);
				}
			q.pop();
		}
		for(int i =1; i<=n; i++)
			if(dist[i]<n)
				a[dist[i]]++;
	}
	for(int i = 1; i<n; i++)
		cout<<a[i]/2<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    vector<int> nums;
    int sum = 0;
    for(int i = 0; i < n; ++i){
    	int x; cin >> x;
    	sum += x;
    	nums.pb(x);
    }
    int ans = 0;
    while(sum != 0){
    	bool flag = false;
    	for(int i = 0; i < n; ++i){
    		if(nums[i] == 0 && flag == false) continue;
    		if(nums[i] == 0 && flag == true) break;
    		if(nums[i] != 0){
    			flag = true;
    			nums[i]--;
    			sum--;
    		}
    	}
    	ans++;
    }
    cout << ans << endl;
	return 0;
} 			

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine($"{Math.PI * GetDouble() * 2.0:F6}");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 27632
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b){

        cout<<a+a-1<<endl;

    }else if(b>a){
        cout<<b+b-1<<endl;


    }else if(a==b){
        cout<<a+b<<endl;

    }
    return 0;




}


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



int main() {

	int a,b;
    cin>>a>>b;

    string s;
    cin>>s;

    bool flg=true;

    for(int i=0;i<s.size();i++){
        if(i==a){
            if(s.at(i)!='-')
                flg=false;
        }
        else if(s.at(i)<'0'||s.at(i)>'9')
            flg=false;
    }

    if(flg)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNext()) {
                int n = sc.nextInt();
                int x = sc.nextInt();
                int[] ms = new int[n];
                for(int i = 0; i < n; i++){
                    ms[i] = sc.nextInt();
                }
                int sum = 0;
                int min = Integer.MAX_VALUE;
                int mini = 0;
                for(int i=0; i<n; i++){
                    sum += ms[i];
                    if(min > ms[i]){
                        min = ms[i];
                        mini = i;
                    }
                }
                int rest = x - sum;
                int restX = rest / min;
                System.out.println(n + restX);
            }
        }
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
  int a,b,c;
  char op;
  while(op!='?'){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+')printf("%d\n",a+b);
    else if(op=='-')printf("%d\n",a-b);
    else if(op=='*')printf("%d\n",a*b);
    else if(op=='/')printf("%d\n",a/b);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

int h, w;

ll calc(int h, int w){
    ll x = h % 3 ? w : 0;
    rep(i, h + 1){
        ll a = ll(i) * w;
        ll b = ll(h - i) * (w / 2);
        ll c = ll(h - i) * (w - w / 2);
        x = min(max(a, c) - min(a, b), x);
    }
    return x;
}

int main(){
    cin >> h >> w;

    cout << min(calc(h, w), calc(w, h)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

string S;

void solve(){
    vector<int> nw;
    
    int s = 0;
    while(true){
        if(S.find("north", s) == s){
            nw.push_back(-1);
            s += 5;
        }else if((S.find("west", s) == s)){
            nw.push_back(1);
            s += 4;
        }else{
            break;
        }
    }
    
    int n = nw.size();
    int ansu = nw[n-1]==1? 90: 0;
    int ansb = 1;
    
    for(int i=n-2; i>=0; i--){
        ansu *= 2;
        ansb *= 2;
        ansu += 90 * nw[i];
    }
    int gcd = __gcd(ansu, ansb);
    if(ansb/gcd == 1)
        cout << ansu/gcd << endl;
    else
        cout << ansu/gcd << "/" << ansb/gcd << endl;
}
    
//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    while(cin>>S, S!="#")
        solve();
    
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int c = s.size();
    for (int i = 0; i-1 < c; i++){
        for (int j = i+1; j < c; j++){
            if (s[i] == s[j]){
                cout<<"no";return 0;
            }
        }
    }

cout<<"yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+100;
int n,a[N],b[N],fac[N];
char ch[N];
bool bl;
int C(int n,int m)
{
	return (n&m)==m;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",ch+1);
	for (int i=1;i<=n;i++) a[i]=ch[i]-'0';
	for (int i=1;i<n;i++) b[i]=abs(a[i]-a[i+1]);
	bl=1;
	for (int i=1;i<n;i++)
	{
		if (b[i]==1)
		{
			bl=0;
			break;
		}
	}
	if (bl)
	{
		for (int i=1;i<n;i++)
		  b[i]/=2;
	}
	for (int i=1;i<n;i++) b[i]%=2;
	int ans=0;
	for (int i=1;i<n;i++) ans=(ans+C(n-2,i-1)*b[i])%2;
	if (bl) ans*=2;
	printf("%d\n",ans);
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
int main(){
    int N,M,X,Y;
    int x[101];int y[101];
    cin >> N >> M >> X >> Y;
    rep(i,N)cin >> x[i];
    rep(i,M)cin >> y[i];
    bool ok = false;
    int tmp = X+1;
    for(int i=tmp;i<=Y;i++){
        bool ok_n = true;
        rep(j,N){
            if(x[j] >= i){
                ok_n = false;
            }
        }
        bool ok_m = true;
        if(ok_n){
            rep(j,M){
                if(y[j] < i) {
                    ok_m = false;
                }
            }
        }
        if(ok_n && ok_m){
            // cout << i << endl; 
            ok = true;
            break;
        }
    }

    if(ok)cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,K;
    cin>>N>>K;
    vector<ll> h(N);
    rep(i,N)cin>>h.at(i);
    sort(h.begin(),h.end());
    ll ans=h.at(N-1);
    rep(i,N-K+1){
        chmin(ans,h.at(i+K-1)-h.at(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4060
#include<iostream>
#include<string>
int main() {
	std::string s, t;
	std::cin >> s;
	std::cin >> t;
	// s最小t最大
	char tmp;
	for (int i = 0; i < s.size() - 1; i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] > s[j]) {
				tmp = s[i];
				s[i] = s[j];
				s[j] = tmp;
			}
		}
	}
	for (int i = 0; i < t.size() - 1; i++) {
		for (int j = i + 1; j < t.size(); j++) {
			if (t[i] < t[j]) {
				tmp = t[i];
				t[i] = t[j];
				t[j] = tmp;
			}
		}
	}
	std::string ans;
	if (s < t) ans = "Yes";
	else ans = "No";
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
switch = []
for i in range(m):
    switch.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    i = format(i, "0{}b".format(n))
    flag = 1
    for j in range(m):
        count = 0
        for k in range(switch[j][0]):
            if i[switch[j][k+1]-1] == "1":
                count += 1
        if count % 2 == p[j]:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans += 1
print(ans)


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

using namespace std;

int main(){
    int n, g= INT_MIN; 
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++) cin >> array[i];
    int m = array[n-1];
    for(int i=n-2; i>= 0; i--){
        if(g<m-array[i]) g = m-array[i];
        m = max(m, array[i]);
    }
    
    cout << g << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
    int w,h,x,y,r = 0;

    scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);

    if( ((r<=x)&&(x<=(w-r))) && ((r<=y)&&(y<=(h-r))) ){
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2612
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int K = Integer.parseInt(s[0]);
    int S = Integer.parseInt(s[1]);
    
    int count = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S - i - j;
        if(k <= K && k >= 0){
          count++;
        }
      }
    }
   System.out.println(count);
  }
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
stores = [list(map(int, input().split())) for _ in range(N)]
stores.sort()
ans = 0

for i in range(N):
    if stores[i][1] < M:
        ans += stores[i][1] * stores[i][0]
        M -= stores[i][1]
    else:
        ans += M * stores[i][0]
        break
print(ans)

Measured memory_bytes: 27756
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  if(n==1){
    cout<<"Hello World"<<"\n";
  }
  else{
    int a,b;cin>>a>>b;
    cout<<a+b<<"\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int t[1003],a[1003];    
int main(){
	fastIO;  
	long long n,aa,bv;
	cin>>n;
	cin>>t[0]>>a[0];
	aa=t[0];
	bv=a[0];
	for(int i=1;i<n;i++){
		cin>>t[i]>>a[i];
		long long tmpa=aa/t[i]+(aa%t[i] ? 1 : 0);
		long long tmpb=bv/a[i]+(bv%a[i] ? 1 : 0);
		long long aux=max(tmpa,tmpb);
		aa=aux*t[i];
		bv=aux*a[i];
	}
	cout<<aa+bv<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n,k;cin>>n>>k;int ans = 0;
  vector<int> v(50);rep(i,n)cin>>v[i];
  rep(i,k+2){
    repd(j,i+1,k+2){
      int sum = 0;priority_queue<int, vector<int>, greater<int>> q;//greater?
      if(i + j-i-1 > n)continue;
      int minusLim = min(k+1-j,i + j-i-1); 
      rep(left, i){
        sum += v[left];q.push(v[left]);
      }
      rep(right, j-i-1){
        sum += v[n-right-1];q.push(v[n-right-1]);
      }
      rep(ind, minusLim){
        if(q.top()>0)break;
        sum -= q.top();q.pop();
      }
      ans = max(ans, sum);
    }
  }
  cout << max(ans,0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n;
    cin>>n;
    string a;
    ve<pair<ll,pair<ll,ll>>> v;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        ll p=a.length(),c=0,num=0;
        for(int j=p-1,k=0;j>=0;j--,k++)
            if(a[j]=='.')
                c=k;
        for(int j=0;j<p;j++)
            if(a[j]!='.')
                num=(10ll*num)+(a[j]-'0');
        ll x=0,y=0;
        while(num%2==0)
        {
            num=num/2;
            x++;
        }
        while(num%5==0)
        {
            num=num/5;
            y++;
        }
        v.pb({x-c,{1,y-c}});
        v.pb({c-x,{0,c-y}});
    }
    sort(v.begin(),v.end());
    oset s;
    ll p=(ll)v.size(),ans=0;
    for(int i=p-1;i>=0;i--)
    {
        ll co=0;
        pair<ll,pair<ll,ll>> x=v[i];
        if(x.second.first==0)
        {
            co=((ll)s.size())-s.order_of_key(x.second.second);
            if(x.first<=0 && x.second.second<=0)
                co--;
        }
        else
            s.insert(x.second.second);
        ans+=co;
    }
    cout<<ans/2;
    subt;
    return 0;
}

Measured memory_bytes: 25212
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  long p = 1;
  long C = 1000000007;
  for(int i = 0; i < N; i++){
    p = p * (i + 1);
    if (p > C) p = p % C;
  }

  cout << p;

  return 0;
}


Measured memory_bytes: 256