akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
class complex {
public:
	double r, i, abs;
};
int main() {
	int n;
	cout << setprecision(8);
	while (1) {
		cin >> n;
		if (n == -1)break;
		complex x;
		x.i = 0; x.r = 1; x.abs = 1;
		for (int k = 1; k < n; k++) {
			complex w;
			w.r = x.r - x.i / x.abs;
			w.i = x.i + x.r / x.abs;
			w.abs = pow(w.r*w.r + w.i*w.i, 0.5);
			x = w;
		}
		cout << x.r << endl << x.i << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,c,ans=2145141919;
	cin>>a>>b;
	for(int i=0;i<4;i++){
		c=1;if(i==0)c=0;if(i==3)c=2;
		if(b>=a)ans=min(ans,b-a+c);
		a=-a;if(i==1)b=-b;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const double PI=3.14159265358979323846;


int main()
{
	double A,B,H,M;
	cin>>A>>B>>H>>M;
	double sitaA,sitaB;
	sitaA = (30*H) + (M/60)*30; //degree
	sitaB = (M/60)*360;
	sitaA = (PI/180)*sitaA;
	sitaB = (PI/180)*sitaB;
	double xa,ya,xb,yb;
	xa = A*cos(sitaA);
	ya = A*sin(sitaA);
	xb = B*cos(sitaB);
	yb = B*sin(sitaB);
	//cout<<xa<<" "<<ya<<" "<<xb<<" "<<yb<<endl;
	double length = abs(xa - xb)*abs(xa - xb) + abs(ya - yb)*abs(ya - yb);
	length = sqrt(length);
	printf("%.15lf\n",length);
	return 0;
}



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

int main() {
  int N ; cin >> N ;
  vector<int> d(N);
  for (int i = 0; i < N; i++){
    cin >> d[i];
  }
  sort(d.begin() , d.end());
  N = N / 2 ;
  if (d[N] == d[N-1]){
    cout << 0 << endl;
  }
  else{
    cout << d[N] -  d[N-1] << endl;
  }
  }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,L,Q;
vector<int> A;
using P = pair<int,int>;
vector<P> ais;

int main(){
	cin>>N>>L>>Q;
	A.resize(N);
	rep(i,N) cin>>A[i];
	rep(i,N){
		ais.pb(P(A[i],i));
	}
	sort(all(ais));

	int ans = 2e9;

	rep(i,N){
		int mn = A[i];
		vector<int> xs;
		xs.pb(-1);
		rep(j,N){
			if(A[j]<mn){
				xs.pb(j);
			}
		}
		xs.pb(N);

		int K = xs.size() - 1;
		vector<int> num(K);
		rep(i,K) num[i] = xs[i+1]-xs[i]-1;

		int taken = 0;

		for(P p: ais){
			int j = p.sc;
			if(A[j]<mn) continue;
			int lid = lower_bound(all(xs),j) - xs.begin() - 1;
			if(num[lid]>=L){
				num[lid]--;
				taken++;
				if(taken==Q){
					chmin(ans,A[j]-A[i]);
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vector<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}
map<int, int> primeFactors(int  n)
{
	mii factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors[2]++;

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		int count = 0;
		while (n % i == 0)
		{
			factors[i]++;
			n /= i;
		}
	}
	if (n > 2)
		factors[n]++;
	return factors;
}


// Graph------------------------------------------------------------------------

int32_t main()
{
	FIO;
	// c_p_c();
// --------------------------------------------------
// Never GIVE UP !!!!
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
}



Measured memory_bytes: 3632
func readInt() -> Int {
    return Int(readLine()!)!
}

func mainD() {
    let N = readInt()
    let stones = readLine()!

    let redCount = stones.reduce(0) { $0 + (String($1) == "R" ? 1 : 0) }

    print(stones.prefix(redCount).reduce(0) { $0 + (String($1) == "W" ? 1 : 0) })
}
mainD()

Measured memory_bytes: 8000
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String[] up = sc.next().split("");
        String[] down = sc.next().split("");
      
        String ans = "YES";
        for(int i = 0; i < 3; i++) {
          if (!up[i].equals(down[2 - i])) {
            ans = "NO";
            break;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main(){
    char S[6];

    scanf("%s", S);

    if(strlen(S)>6 || strlen(S)<1){
        return 0;
    }

    if(S[2]==S[3] && S[4]==S[5]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int a,b;
  cin >> a >> b;
  int maxi = max(a+b,a-b);
  cout << max(maxi,a*b) << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int n; cin >> n;
	bool f = true;
	rep(i, n){
		int a; cin >> a;
		if(a % 2 == 0 && (a % 3 && a % 5)) f = false;
	}
	puts(f ? "APPROVED" : "DENIED");
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
t = list(input())

ans = []
for i in range(n):
	if s[-(i + 1):] == t[:i + 1]:
		ans.append(i + 1)

if ans == []:
	print(2 * n)
else:
	print(2 * n - max(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

const int INF = 1e9;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

using namespace std;

int main(){
    int n, MAX = 0, sum = 0;
    string s;
    cin >> n >> s;
    
    REP(i, n){
        if(s[i] == 'I'){
            sum++;
            MAX = max(MAX, sum);
        }
        else sum --;
    }

    cout << MAX << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

   // cout << s.find('B') << endl;
   if((s.find('A') <= s.length()) & (s.find('B') <= s.length())){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }

   return 0;
}


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 200001
#define INF 1000000000

int n;
lli v[MAXN];
lli dp[MAXN][3];

lli solve(int i, int limit)
{
  if (dp[i][limit] != -1)
    return dp[i][limit];
  if (i >= n)
    return dp[i][limit] = 0;
  lli coloca = v[i] + solve(i + 2, limit);
  if (limit > 0)
  {
    lli nao_coloca = solve(i + 1, limit - 1);
    dp[i][limit] = max(coloca, nao_coloca);
  }
  else
    dp[i][limit] = coloca;
  return dp[i][limit];
}
signed main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> v[i];
  memset(dp, -1, sizeof(dp));
  lli m;
  (n % 2 == 0) ? m = 1 : m = 2;
  cout << solve(0, m) << endl;
  return 0;
}

Measured memory_bytes: 14508
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>mountain(n);
  
  for(int i=0;i<n;i++){
    cin >> mountain[i];
  }
  
  int ans = 0;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      if(mountain[j] > mountain[i])
        break;
      if(i == j){
        ans++;
      break;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  // ここでストリームに obj を書き込みます。
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  // ここでストリームに obj を書き込みます。
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

int main(){
  int x,y,a,b,c; cin >>x >>y >>a >>b >>c;
  map<pair<li,int>,int> mp;
  rep(i,a){
    int k; cin >>k;
    mp[{-k,2}]++;
  }
  rep(i,b){
    int k; cin >>k;
    mp[{-k,1}]++;
  }
  rep(i,c){
    int k; cin >>k;
    mp[{-k,0}]++;
  }
  if(df) print(mp);
  li ans=0; int ca=0,cb=0,cnt=0;
  if(df) print(x,y,cnt);
  while(cnt<x+y){
    auto p=*mp.begin(); mp.erase(p.first);
    if(df)print(p);
    if(p.first.second==2){
      if(ca>=x)continue;
      ans+=p.first.first*p.second;
      if(df)print("+",p.first.first*p.second);
      ca+=p.second;
      ans-=p.first.first*max(ca-x,0);
      if(df)print("-",p.first.first*max(ca-x,0));
    }
    if(p.first.second==1){
      if(cb>=y)continue;
      ans+=p.first.first*p.second;
      if(df)print("+",p.first.first*p.second);
      cb+=p.second;
      ans-=p.first.first*max(cb-y,0);
      if(df)print("-",p.first.first*max(cb-y,0));
    }
    if(p.first.second==0){
      ans+=p.first.first*p.second;
      if(df)print("+",p.first.first*p.second);
    }
    cnt+=p.second;
    ans-=p.first.first*max(cnt-x-y,0);
    if(df)print("-",p.first.first*max(cnt-x-y,0));
    if(df) print(ans,":",mp);
  }

  print(-ans);
}


Measured memory_bytes: 18944
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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; }


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}


ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}





// substr(start, len)

int main(){

  int N;
  

  int ai;

  cin >> N;
  vector<int> a(N, 0);

  rep(i, 1, N){

    cin >> ai;

    a[ai-1]++;
  }

  rep(i, 0, N){
    cout << a[i] << endl;;
  }




  
  // cout << setprecision(8) << ans << endl;  // For double
  // CHECK if it's possible to overflow!!
}

Measured memory_bytes: 4056
import itertools

n=int(input())
l=[int(x) for x in input().split()]

if n<3:
    print(0)
    exit()

ans=0
for x in itertools.combinations(l,3):
    x=list(x)
    x.sort(reverse=True)
    if x[0]<x[1]+x[2]:
        if x[0]!=x[1] and x[1]!=x[2] and x[2]!=x[0]:
            ans+=1
print(ans)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define int long long int

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;


#define mod 1000000007
#define INF 1e9+100
#define ff first
#define ss second
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fi(i,n)                for(urs(n) i=0;i<n;i++)
#define rep(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
#define endl '\n'
#define mex 300000
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>*/
main()
{
	int i,j,n,m,t;
	double r;
	cin>>r;
	cout<<2*(3.1416)*r<<endl;
}


Measured memory_bytes: 3784
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		
		var input = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
		long A = input[0];
		long B = input[1];
		long C = input[2];
		long D = input[3];

		long ans = B - A + 1;
		var calc = new Calculation();
		long gcd = calc.GetGcd(C, D);
		long l = C * D / gcd;
		ans -= (B / C) - ((A - 1) / C);
		ans -= (B / D) - ((A - 1) / D);
		ans += (B / l) - ((A - 1) / l);
		Console.WriteLine(ans);

	}
}

//var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
//入力用

public class Calculation //各種値の計算メソッド
{
    public long GetGcd(long a, long b) //最大公約数(２数)
	{
		if (a * b == 0)
		{
			return 0;
		}
		if (a < b)
		{
			long c = a;
			a = b;
			b = c;
		}

		long r = a % b;
		while (r > 0)
		{
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}
	public int GetGcdOfSortedArray(int[] array) //最大公約数(ソート済み数列)
	{
		if (array.Length == 0) { return 1; }
		else if (array.Length == 1) { return array[0]; }
		else
		{
			int n = 0;
			int g = -1;
			while (n <= array.Length - 2)
			{
                
				int a = array[n + 1];
				int b = array[n];
				int r = a % b;
				while (r > 0)
				{
					a = b;
					b = r;
					r = a % b;
				}
				g = b;
				array[n + 1] = g;
				n++;
			}

			return g;

		}
	}
	public long GetGcdOfSortedArrayL(long[] array) //最大公約数(ソート済み配列[long型])
	{
		if (array.Length == 0) { return 1; }
		else if (array.Length == 1) { return array[0]; }
		else
		{
			int n = 0;
			long g = -1;
			while (n <= array.Length - 2)
			{

				long a = array[n + 1];
				long b = array[n];
				long r = a % b;
				while (r > 0)
				{
					a = b;
					b = r;
					r = a % b;
				}
				g = b;
				array[n + 1] = g;
				n++;
			}

			return g;

		}
	}

	public long GetNCR(int n, int r) //二項係数(生の値)
	{
		if (n == 1) { return 1; }
		long[] nC = new long[n + 1];
		nC[0] = 1;
		for (var i = 0; i <= r - 1; i++)
		{
			nC[i + 1] = nC[i] * (n - i) / (i + 1);
		}
		return nC[r];
	}


}

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

int main() {
	bool cards[4][14];
	int n, rank;
	char suit;
	for (int s = 0; s < 4; s++)
		for (int r = 1; r <= 13; r++)
			cards[s][r] = 0;
	cin >> n;

	for (int i = 0; i < n;i++) {
		cin >> suit >> rank;
		if (suit == 'S')cards[0][rank]= 1;
		if (suit == 'H')cards[1][rank] = 1;
		if (suit == 'C')cards[2][rank] = 1;
		if (suit == 'D')cards[3][rank] = 1;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 1; j <= 13; j++) {
				if (cards[i][j])continue;
				if (i == 0)suit = 'S';
				if (i == 1)suit = 'H';
				if (i == 2)suit = 'C';
				if (i == 3)suit = 'D';
				cout << suit << " " << j << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n;
int h, w;
bool ans[80][80][6400];
int d[80][80];
deque<pair<int,int>> p;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

void bfs() {
	while(!p.empty()){
		pair<int, int> now = p.front();
		p.pop_front();
		int nh = now.first;
		int nw = now.second;
		if (nh != h - 1) {
			//printf("h nh+1=%d,nw=%d\n", nh+1, nw);
			REP(i, 6400) {
				if (ans[nh][nw][i]) {
					if (i + d[nh + 1][nw] < 6400) {
						ans[nh + 1][nw][i + d[nh + 1][nw]] = true;
						//printf("%d\n", i + d[nh + 1][nw]);
					}
					ans[nh + 1][nw][abs(i - d[nh + 1][nw])] = true;
					//printf("%d\n", abs(i - d[nh + 1][nw]));
				}
			}
			if (!p.empty()) {
				if (nw==0) {
					p.push_back(make_pair(nh + 1, nw));
				}
			}
			else {
				p.push_back(make_pair(nh + 1, nw));
			}
		}
		if (nw != w - 1) {
			//printf("w nh=%d,nw+1=%d\n", nh, nw+1);
			REP(i, 6400) {
				if (ans[nh][nw][i]) {
					if (i + d[nh][nw + 1] < 6400) {
						ans[nh][nw + 1][i + d[nh][nw + 1]] = true;
						//printf("%d\n", i + d[nh][nw + 1]);
					}
					ans[nh][nw + 1][abs(i - d[nh][nw + 1])] = true;
					//printf("%d\n", abs(i - d[nh][nw + 1]));
				}
			}
			p.push_back(make_pair(nh, nw + 1));
		}
	}

}

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

	REP(i, 80) {
		REP(j, 80) {
			REP(k, 6400) {
				//ans[i][j][k] = false;
			}
		}
	}

	cin >> h>> w;
	int a[80][80], b[80][80];
	REP(i, h) {
		REP(j, w) {
			cin >> a[i][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			cin >> b[i][j];
			d[i][j] = abs(a[i][j] - b[i][j]);
		}
	}
	ans[0][0][d[0][0]] = true;
	p.push_back(make_pair(0, 0));
	bfs();

	REP(i, 6400) {
		if (ans[h - 1][w - 1][i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 40192
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}


struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

bool sortbysec(const pair <ll,ll> &a, const pair <ll,ll> &b){
    return a.first-a.second<b.first-b.second;
}


int main(){
    IOS;
    make(ll,a);
    cout<<a+a*a+a*a*a<<endl;




    return 0;
}


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

int n, ma, mb, a[50], b[50], c[50], inf = 1e9 + 7, dp[50][444][444];

int main(){
    cin >> n >> ma >> mb;
    for (int i = 0; i < n; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                dp[i][j][k] = inf;
            }
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                if (dp[i][j][k] == inf) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    int ans = inf;
    for (int i = 1; i <= 400; i++){
        for (int j = 1; j <= 400; j++){
            if (i * mb == j * ma) ans = min(ans, dp[n][i][j]);
        }
    }
    if (ans == inf) ans = -1;
    printf("%d\n", ans);
}


Measured memory_bytes: 32896
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
a , b , c  = map(int, input().split())
k = int(input())


def f(a,b,c,k):
	if k < 0:
		return False
	if a < b < c:
		return True
	ll = False
	ll |= f(a*2,b,c,k-1)
	ll |= f(a,b*2,c,k-1)
	ll |= f(a,b,c*2,k-1)
	return ll
if f(a,b,c,k):
	print("Yes")
else:
	print("No")






Measured memory_bytes: 74404
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int r; cin >> r;
  cout << r*r << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s,t; cin >> s >> t;
    int si = SIZE(s);
    rng(i,1,si+1){
        if(s.substr(i)+ s.substr(0,i) == t){
            yes();
            return 0;
        }
    }
    no();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

  vector<long long> a(1001, 0);
  long long int mod = 1000000000L + 7L;
  for (int i = 2; i <= n; i++) {
    int tmp = i;
    for (int j = 2; j <= tmp; j++) {
      while(tmp % j == 0) {
        a[j]++;
        tmp /= j;
      }
    }
  }

  long long ans = 1;
  for (int i = 0; i <= n; i++) {
    //cout << i << " : " << a[i] << endl;
    ans = (ans * (a[i] + 1)) % mod;
  }
  cout << ans << endl;
}

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

import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
  if r == 0 or r == n: return 1
  if r == 1: return n
  if (n,r) in nCr: return nCr[(n,r)]
  nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
  return nCr[(n,r)]


for i in range(B):
  if i+1>A-B+1:
    print(0)
  else:
    x=cmb((A-B+1),(i+1))*cmb((B-1),i)
    print(x%(10**9+7))

Measured memory_bytes: 166108
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++){
            if(j==i){
                ans++;
                break;
            }
            if(H[i]<H[j]){
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  string A;
  cin >> A;
  vector<ll> alfa(26, 0);
  for (ll i = 0; i < A.size(); ++i) {
    alfa.at(A[i] - 'a') += 1;
  }
  // for (ll i = 0; i < 26; ++i) {
  //   cout << alfa.at(i) << " ";
  // }
  // cout << "\n";
  ll ans = (A.size() * (A.size() - 1)) / 2;
  for (ll i = 0; i < 26; ++i) {
    ans -= (alfa.at(i) * (alfa.at(i) - 1)) / 2;
  }
  ans += 1;
  cout << ans << "\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;


int main()
{
int n,m;
scanf("%d %d",&n,&m);
if(n<=9&&n>=1&&m<=9&&m>0)
printf("%d\n",n*m);
else
printf("-1\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

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

  std::vector<int> w(n);
  for (auto&& wi : w) std::cin >> wi;

  std::vector<int> cum(n);
  cum[0] = w[0];
  for (int i = 1; i < n; ++i) cum[i] = w[i] + cum[i-1];

  int min = cum[n-1];
  for (int i = 0; i < n; ++i) {
    const auto s1 = cum[i];
    const auto s2 = cum[n-1] - cum[i];
    const auto diff = std::abs(s2 - s1);
    if (min > diff) min = diff;
  }
  std::cout << min << std::endl;
}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    K, S = mi()
    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S-x-y
            if 0 <= z <= K:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73368
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}
 
 
int nextInt() { int x; scanf("%d", &x); return x;}
 
ll C(int n, int r) {
  ll res = 1;
  for (int i = 1; i <= r; i++) {
    res *= n + 1 - i;
    res /= i;
  }
  return res;
}
 
int main2() {
  int N = nextInt();
  int P = nextInt();
  int even = 0, odd = 0;
  REP(i, N) {
    int a = nextInt() % 2;
    if (a == 0) even++; else odd++;
  }
  ll ans = 0;
  for (int i = P; i <= odd; i += 2) {
    ans += C(odd, i);
  }
  ans *= (1LL << even);
  cout << ans << endl;
  return 0;
}
 
int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 384
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

def cross_foo(turn):
  posA1 = (T1 * A1 + T2 * A2) * (turn - 1)
  posB1 = (T1 * B1 + T2 * B2) * (turn - 1)
  posA2 = posA1 + T1 * A1
  posB2 = posB1 + T1 * B1
  if (posA1 - posB1 == 0): return False
  return ((posA1 - posB1) * (posA2 - posB2) <= 0)

def cross_bar(turn):
  posA1 = (T1 * A1 + T2 * A2) * (turn - 1) + T1 * A1;
  posB1 = (T1 * B1 + T2 * B2) * (turn - 1) + T1 * B1;
  posA2 = posA1 + T2 * A2;
  posB2 = posB1 + T2 * B2;
  if (posA1 - posB1 == 0): return False
  return ((posA1 - posB1) * (posA2 - posB2) <= 0)

def main():
  if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2):
    print("infinity")
    return

  if (not cross_bar(1)):
    print(0)
    return

  if (not cross_foo(2)):
    print(1)
    return

  ans = 0

  foo_ok = 2
  foo_ng = 1
  for i in range(110):
    foo_ng *= 10
  while (foo_ok < foo_ng - 1):
    mid = int((foo_ok + foo_ng) / 2)
    if (cross_foo(mid)): foo_ok = mid
    else: foo_ng = mid
  ans += foo_ok - 1

  bar_ok = 1
  bar_ng = 1
  for i in range(110):
    bar_ng *= 10
  while (bar_ok < bar_ng - 1):
    mid = int((bar_ok + bar_ng) / 2)
    if (cross_bar(mid)): bar_ok = mid
    else: bar_ng = mid;
  ans += bar_ok

  print(ans)

main()


Measured memory_bytes: 3064
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    return arr

N = int(input())
ans = 0
for _, cnt in factorization(N):
    i = 1
    while i<=cnt:
        ans += 1
        cnt -= i
        i += 1

print(ans)

Measured memory_bytes: 80940
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    p = list(map(int, readline().split()))
    a = [0] * n
    b = [0] * n

    for i, x in enumerate(p):
        y = p[i] - 1
        a[y] = (y + 1) * (4 * 10 ** 4) + i
        b[y] = (n - y) * (4 * 10 ** 4)

    print(*a)
    print(*b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75972
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a;
    cin>>a;
    cout<<3*a*a;
}

Measured memory_bytes: 3636
import java.util.*;

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

        int x = sc.nextInt();

        if (x == 0) {
            System.out.println(1);
        }else{
            System.out.println(0);
        }
        sc.close();
    }
}


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

int main()
{
    ll x;
    cin >> x;

    ll yen = 100;
    int i = 0;
    while (yen < x) {
        yen = yen*1.01;
        ++i;
    }

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N, M; cin >> N >> M;
    int k[10];
    vector<vector<int> > s;
    rep(i, M) {
        cin >> k[i];
        s.push_back(vector<int>{});
        rep(j, k[i]) {
            int temp; cin >> temp;
            s[i].push_back(temp);
        }
    }
    vector<int> p;
    rep(i, M) {
        int temp; cin >> temp;
        p.push_back(temp);
    }
    // view(s);
    // view(p);
    bool switch_on;
    int count = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        // cout << bitset<10>(bit) << endl;
        switch_on = true;
        for (int i = 0; i < M; i++) {
            // cout << bitset<10>(bit) << endl;
            // cout << bitset<10>(accumulate(s[i].begin(), s[i].end(), 0)) << endl;
            // cout << bitset<10>(bit & accumulate(s[i].begin(), s[i].end(), 0)) << endl;
            // int on_num = __builtin_popcount(bit & accumulate(s[i].begin(), s[i].end(), 0));
            int bit_num = 0;
            for (int j: s[i]) {
                if (bit & (1<<(j - 1))) {
                // if ((i >> j) & 1) {
                    bit_num++;
                }
            }
            if (bit_num % 2 != p[i]) {
                switch_on = false;
                // break;
            }
        }
        if (switch_on) count++;
        // switch_on = true;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL MOD = 998244353;
const int INF = (int)2e9 + 1;

int main() {
    int N;
    scanf("%d", &N);
    vector<pii> robots;
    for (int i = 0; i < N; i++) {
        int X, D;
        scanf("%d %d", &X, &D);
        robots.push_back(make_pair(X, D));
    }
    map<int, int> dp;
    set<pii> st;
    dp[INF] = 1;
    sort(robots.rbegin(), robots.rend());
    for (int i = 0; i < (int)robots.size(); i++) {
        int X = robots[i].first, D = robots[i].second;
        if (!i) {
            dp[X] = 2;
            st.insert(make_pair(X, X + D));
        } else {
            int dis = X + D;
            while (!st.empty() && st.begin()->first < dis) {
                dis = max(st.begin()->second, dis);
                st.erase(st.begin());
            }
            st.insert(make_pair(X, dis));
            //printf("X = %d dis = %d\n", X, dis);
            int touch = dp.lower_bound(dis)->first;
            dp[X] = (dp[touch] + dp[robots[i - 1].first]) % MOD;
        }
        //printf("X = %d dp = %d\n", X, dp[X]);
    }
    printf("%d\n", dp.begin()->second);
    return 0;
}


Measured memory_bytes: 15856
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    int n;
    cin>>n;
    string c;
    cin>>c;
    int ans=0;
    int left = 0;
    int right = n-1;
    while(left<right){
        while(c[left]=='R') left++;
        while(c[right]=='W') right--;
        if(left<right){
            char tmp = c[left];
            c[left] = c[right];
            c[right] = tmp;
            ans++;
        }
    }
    // cout<<c<<endl;
    rep(i,n-1){
        if(c[i]=='W' && c[i+1]=='R') ans++;
    }
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 3736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;


int main(){
	string L;
	int N,P,A,B,C,D,E,F,S,M;
	while(cin>>N){
		if(N==0)break;
		vector<pair<long double,string> >mp;
		REP(i,N){
			cin>>L>>P>>A>>B>>C>>D>>E>>F>>S>>M;
			int tm=A+B+C;
			REP(j,M)tm+=(D+E);
			int sum=F*M*S-P;
			mp.PB(MP(-(long double)sum/tm,L));
		}
		SORT(mp);
		REP(i,SZ(mp))cout<<mp[i].second<<endl;
		cout<<"#"<<endl;
	}
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<int,int> mode;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mode[x-1] += 1;
    mode[x] += 1;
    mode[x+1] += 1;
  }
  
  int pos = 0;
  for (auto m : mode) {
    pos = max(pos, m.second);
  }
  
  cout << pos << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
int main(){
  long long H, W;
  cin >> H >> W;
  long long ans = INF;
  for (int i = 1; i < H; i++){
    long long S1 = i * W;
    if (i <= H - 2){
      long long S2 = (H - i) / 2 * W;
      long long S3 = (H - i + 1) / 2 * W;
      ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    long long S2 = W / 2 * (H - i);
    long long S3 = (W + 1) / 2 * (H - i);
    ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
  }
  for (int i = 1; i < W; i++){
    long long S1 = i * H;
    if (i <= W - 2){
      long long S2 = (W - i) / 2 * H;
      long long S3 = (W - i + 1) / 2 * H;
      ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    long long S2 = H / 2 * (W - i);
    long long S3 = (H + 1) / 2 * (W - i);
    ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const ll oo = 0x3f3f3f3f3f3f3f3f;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<ll> v(n+1);
  for(int i = 0, x; i < n; ++i)
  {
    cin >> x;
    v[i+1] = v[i] + x;
  }
  
  
  vector<vector<ll>> dp(n, vector<ll>(n, oo));
  
  for(int i = 0; i < n; ++i)
  {
  	dp[i][i] = 0.0;
  }
  
  for(int l = 1; l < n; ++l)
  {
  	for(int i = 0; i+l < n; ++i)
    {
      for(int j = i; j < i+l; ++j)
      {
        //cout << i << " " << i+l << " " << j << endl;
      	dp[i][i+l] = min(dp[i][i+l], dp[i][j] + dp[j+1][i+l] + v[i+l+1] - v[i]);
      }
    }
  }
  
  for(int i = 0; i < n; ++i)
  {
  	for(int j = i; j < n; ++j)
    {
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }
  
  cout << dp[0][n-1] << endl;

  
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;

int main(){

    double a, b, h, m;
    cin >> a >> b >> h >> m;

    if (h>11){
        h -= 12;
    }

    double theta, theta_alt, theta_min;
    theta = abs((360.0/12.0)*h +(360.0/12.0)*(m/60.0)  - (360.0/60.0)*m);
    theta_alt = 360.0 - theta;
    theta_min = min(theta, theta_alt);

//    theta = atan(b/a);

    double ans;
    ans = a*a + b*b - 2*a*b*cos(theta_min*3.14159265359/180.0);
//    ans = a*a + b*b - 2*a*b*cos(theta);
    ans = sqrt(ans);

    cout << fixed << setprecision(15);
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 4204
#include <cstdio>
typedef long long ll;
int N;
int a[10001];
int b[10001];
ll p, q;
int main(){
	scanf("%d", &N);
	for (int n = 0; n < N; n++) scanf("%d", &a[n]), p += a[n];
	for (int n = 0; n < N; n++) scanf("%d", &b[n]), q += b[n];

	if (q - p < 0) return !printf("No\n");
	ll sa = 0, sb = 0;
	for (int n = 0; n < N; n++){
		if (a[n] > b[n]){
			sb += a[n] - b[n];
		}
		else if (a[n] < b[n]){
			int t = (b[n] - a[n] + 1) >> 1;
			sa += t;
			sb += a[n] + 2 * t - b[n];
		}
	}
	if (sa >= sb) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
for i in range(n):
    a,b=map(int,input().split())
    #n店舗、a値段、b本数
    s.append([a,b])
s.sort()
ans=0
i=0
while m-s[i][1]>0:
    m-=s[i][1]
    ans+=s[i][0]*s[i][1] #値段
    i+=1
print(ans+s[i][0]*m)

Measured memory_bytes: 20056
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 1100;

int n, k;
int cc[2][MAXN][MAXN];
int dd[2][MAXN][MAXN];

int get(int c, int x1, int y1, int x2, int y2) {
	return dd[c][x2][y2] - dd[c][x2][y1] - dd[c][x1][y2] + dd[c][x1][y1];
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		int x, y;
		char tmp;
		cin >> x >> y >> tmp;
		int c;
		if (tmp == 'B')
			c = 1;
		else
			c = 0;
		int d = x / k + y / k;
		if (d % 2 == 1)
			c ^= 1;
		x %= k, y %= k;
		++cc[c][x][y];
	}
	for (int c = 0; c < 2; ++c)
		for (int i = 1; i <= k; ++i)
			for (int j = 1; j <= k; ++j) {
				dd[c][i][j] = dd[c][i - 1][j] + dd[c][i][j - 1] - dd[c][i - 1][j - 1] + cc[c][i - 1][j - 1];
			}
	int ans = 0;
	for (int i = 0; i < k; ++i)
		for (int j = 0; j < k; ++j) {
			for (int c = 0; c < 2; ++c) {
				int now = get(c, 0, 0, i + 1, j + 1) + get(c, i + 1, j + 1, k, k) + get(1 - c, i + 1, 0, k, j + 1) + get(1 - c, 0, j + 1, i + 1, k);
				ans = max(ans, now);
			}
		}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 18688
import std.stdio, std.array, std.conv, std.container;

void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    int[][] job = new int[][](100000);
    foreach (i; 0 .. n) {
        tmp = readln.split.to!(int[]);
        int a = tmp[0] - 1, b = tmp[1];
        job[a] ~= b;
    }
    BinaryHeap!(int[]) h = BinaryHeap!(int[])(new int[n], 0);
    int ans;
    foreach (i; 0 .. m) {
        foreach (x; job[i]) {
            h.insert(x);
        }
        if (!h.empty) {
            ans += h.front;
            h.removeFront;
        }
    }
    ans.writeln;
}

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
    if(debug_flag){
        cout<<str;
    }
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(10);

    string s, t;
    cin>>s>>t;
    int idx = -1;
    bool flag = false;
    for(int i=s.length() - t.length(); i>=0; --i){
        flag = true;
        for(int j=0; j<t.length(); ++j){
            if(s[i+j]=='?' || s[i+j] == t[j]){
            }else{
                flag = false;
                break;
            }
        }
        if(flag){
            idx = i;
            break;
        }
    }

    if(idx == -1){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    string ans = s;
    for(int i=0; i<t.length(); ++i){
        ans[idx+i] = t[i];
    }
    for(int i=0; i<s.length(); ++i){
        if(ans[i] == '?'){
            ans[i] = 'a';
        } 
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256