akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MAXN	524288
#define P	924844033
#define G	5
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct number {long long x; };
number operator + (number a, number b) {return (number) {(a.x + b.x) % P}; }
number operator - (number a, number b) {return (number) {(a.x - b.x + P) % P}; }
number operator * (number a, number b) {return (number) {(a.x * b.x) % P}; }
number power(number x, long long y) {
	if (y == 0) return (number) {1};
	number tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp;
	else return tmp * tmp * x;
}
int home[MAXN], N, Log;
long long fac[MAXN], inv[MAXN];
number a[MAXN], b[MAXN], res[MAXN];
void NTT(number *a, int type) {
	for (int i = 0; i < N; i++)
		if (home[i] > i) swap(a[i], a[home[i]]);
	for (int len = 2; len <= N; len <<= 1) {
		number delta = power((number) {G}, (P - 1) / len);
		if (type == -1) delta = power(delta, P - 2);
		for (int i = 0; i < N; i += len) {
			number now = (number) {1};
			for (int j = i, k = i + len / 2; k < i + len; j++, k++) {
				number tmp = a[j];
				number tnp = a[k] * now;
				a[j] = tmp + tnp;
				a[k] = tmp - tnp;
				now = now * delta;
			}
		}
	}
	if (type == -1) {
		number INV = power((number) {N}, P - 2);
		for (int i = 0; i < N; i++)
			a[i] = a[i] * INV;
	}
}
void PREBRC() {
	for (int i = 0; i < N; i++) {
		int res = 0, tmp = i;
		for (int j = 1; j <= Log; j++) {
			res = (res << 1) + (tmp & 1);
			tmp >>= 1;
		}
		home[i] = res;
	}
}
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
long long getc(int x, int y) {
	if (y > x) return 0;
	else return fac[x] * inv[y] % P * inv[x - y] % P;
}
int main() {
	int n, k;
	read(n), read(k);
	int val = 0, vbl = 0;
	int cnt = 0, cmt = 0;
	for (int i = 1; i <= k; i++) {
		int tmp = (n - i) / k + 1;
		if (val == 0 || val == tmp) {
			val = tmp;
			cnt += 2;
		} else {
			vbl = tmp;
			cmt += 2;
		}
	}
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
	for (int i = 0; i <= val; i++)
		a[i] = (number) {getc(val - i, i)};
	for (int i = 0; i <= vbl; i++)
		b[i] = (number) {getc(vbl - i, i)};
	N = 1, Log = 0;
	while (N <= 2 * n) {
		N <<= 1;
		Log++;
	}
	PREBRC();
	NTT(a, 1);
	NTT(b, 1);
	for (int i = 0; i < N; i++)
		res[i] = power(a[i], cnt) * power(b[i], cmt);
	NTT(res, -1);
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		long long tmp;
		if (i & 1) tmp = P - 1;
		else tmp = 1;
		ans += tmp * fac[n - i] % P * res[i].x;
		ans %= P;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> list(n);
  
  for(int i=0;i<n;i++){
    cin>>list[i];
  }
  sort(list.begin(),list.end());
  ll sum=0;
  for(int i=0;i<n-k;i++){
    sum+=list[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    vector<pair<double, pair<double,double>>> v;
    rep(i,n){
        double x, y;
        cin >> x >> y;
        pair<double, pair<double,double>> p;
        p.first = atan2(y, x);
        p.second.first = x;
        p.second.second = y;
        v.push_back(p);
    }

    sort(v.begin(), v.end());

    rep(i,n){
        v.push_back(v[i]);
    }

    double ans = 0;

    rep(i,n){
        srep(j, 1, n+1){
            ll tmpx = 0;
            ll tmpy = 0;
            rep(k,j){
                tmpx += v[i+k].second.first;
                tmpy += v[i+k].second.second;
            }
            ans = max(ans, sqrt(tmpx*tmpx + tmpy*tmpy));
        }
    }

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


Measured memory_bytes: 512
def main():
	a,b,m = map(int,input().split())
	a = list(map(int,input().split()))
	b = list(map(int,input().split()))
	min_cost = min(a)+min(b)
	for _ in range(m):
		x,y,c = map(int,input().split())
		min_cost = min(min_cost, a[x-1]+b[y-1]-c)
	print(min_cost)

main()

Measured memory_bytes: 18612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];
        for (int i = 0 ; i < m ;i++) {
            l[i] = sc.nextInt() ;
            r[i] = sc.nextInt() + 1;
        }
        int [] t = new int[n + 2];

        for (int i = 0 ; i < m ; i++) {
            t[l[i]]++;
            t[r[i]]--;
        }

        for (int i = 0 ; i <= n ; i++) {
            if (i > 0) t[i] += t[i - 1];
        }

        int count = 0;
        for (int i = 0 ; i < n+ 1 ; i++) {
            if (t[i] == m) count++;
        }

        System.out.println(count);


    }

}

Measured memory_bytes: 71368
def gi; gets.split.map(&:to_i); end
H,W,K=gi
field = H.times.map do
    gets.chomp
end

# puts field

ret = 0
0.upto(2**H) do |y|
    0.upto(2**W) do |x|
        count = 0
        H.times do |yi|
            W.times do |xi|
                a = y[yi] == 1
                b = x[xi] == 1
                c = field[yi][xi] == '#'
                if a && b && c
                    count += 1
                end
            end
        end
        ret += 1 if count == K
    end
end

puts ret

Measured memory_bytes: 14264
# coding: utf-8
s=list(input())
t=list(input())

s.sort(reverse=True)
t.sort(reverse=True)

if s[-1]<t[0]:
    print('Yes')
else:
    if set(s)==set(t) and len(t)>len(s):
        print('Yes')
    else:
        print('No')

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

inline void process(int& a, int& b)
{
	a = (a%2==1)?(a-1)/2:a/2;
	b += a;
}

int main() {
	int A,B,K;
	cin >> A >> B >> K;

	int flag = K % 2;
	while(K>0)
	{
		if(K % 2 == flag)
		{
			process(A, B);
		}
		else
		{
			process(B, A);
		}
		K--;
	}
	cout << A << " " << B << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
            #define ll long long
            #define f   first
            #define s   second
            #define pb          push_back
            #define mod        1000000007
            #define mod1       1000000009
            #define hell        998244353
            #define inf         1000000000000000000LL
            #define pi          3.14159265358979323
            #define N           5000005
            using namespace std;
            ll n,k,sum,q,res,m,val;
            ll x,y;
            
            void solve()    
            {   

                   
                    cin>>n;
                    /*ll id=lower_bound(v.begin(), v.end(),n)-v.begin()-1;
                    x=id+1;
                    n-=v[id];*/
                    ll len=x;
                    string ans="";
                    //cout<<n<<" ";
                    while(n>=26)
                    {
                        y=n%26;
                        if(y!=0)ans+=char('a'+y-1);
                        else ans+='z';
                        if(y==0) y=26;
                        n-=y;
                        //cout<<n<<" ";
                        n/=26;
                    }

                    if(n!=0) {ans+=char('a'+n-1);}
                    reverse(ans.begin(),ans.end());
                    cout<<ans;
                    




            }
            int main()
            {   
                ios_base::sync_with_stdio(false);
                cin.tie(0);cout.tie(0);
                ll t=1;
                //cin>>t;
                
                for(int i=1;i<=t;i++)
                    solve();
            
            }            

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll A, B, T;
  std::cin >> A >> B >> T;

  ll ans = (T / A) * B;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<pair<int, int> > P(N);
    REP(i, N) cin >> P[i].first >> P[i].second;
    vector<int> nums(N);
    REP(i, N) nums[i] = i;
    double ans = 0;
    double denom = 1;
    FOR(i, 1, N) denom *= i;
    do {
        double tmp = 0;
        FOR(i, 1, N-1) {
            int x = nums[i-1];
            int y = nums[i];
            tmp += sqrt(double(pow(P[x].first - P[y].first, 2) + pow(P[x].second - P[y].second, 2)));
        }
        ans += tmp / denom;
    } while (next_permutation(nums.begin(), nums.end()));
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	vector<int> v;
	vector<int> ans;
	int tmp;

	for (int i = 0; i < 5; i++)
	{
		scanf("%d", &tmp);
		v.push_back(tmp);
	}

	// for (int i = 0; i < (int)v.size(); ++i)
	// 	cout << v[i] << " ";
	// cout << endl;

	do
	{
		// for (int i = 0; i < (int)v.size(); ++i)
		// 	cout << v[i] << " ";
		// cout << endl;

		tmp = 0;
		for (int i = 0; i < (int)v.size(); ++i)
		{
			tmp += v[i];
			if(0<tmp % 10 && i<v.size()-1)
				tmp += 10-(tmp % 10);
			// cout << tmp << " ";
		}
		// cout << endl;
		ans.push_back(tmp);
	} while (next_permutation(v.begin(), v.end()));

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

	sort(ans.begin(), ans.end());

	cout << ans.front() << endl;

	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, k; cin >> a >> b >> k;
  int g = gcd(a, b);
  if(k == 1) {
    cout << g << endl;
    return 0;
  }
  
  set<int> st;
  int cnt = 2;
  st.insert(1);
  st.insert(g);
  for(int i=2;i*i<=g;++i) {
    if(g % i == 0) {
      cnt += 2 - (i * i == g);
      st.insert(i);
      st.insert(g / i);
    }
  }
  
  for(auto &e: st) {
    
    if(cnt == k) {
      cout << e << endl;
      break;
    }
    cnt--;
    
  }
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int d[5];
    rep(i, 5) cin >> d[i];
    int k;
    cin >> k;

    bool ok = true;
    rep(i, 5) {
        FOR(j, i + 1, 5) {
            if (d[j] - d[i] > k) ok = false;
        }
    }

    if (ok)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n');
  const char1 = s[0][0];
  const char2 = s[1][1];
  const char3 = s[2][2];

  const ans = char1 + char2 + char3;
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k=-1,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  string S="";
  cin >> a >> b >> c;
  if((a==b&&b!=c)||(a==c&&b!=c)||(c==b&&a!=c)) cout << "Yes" << endl;
  else cout << "No" << endl;

  //cout << ans << endl;
}

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

Measured memory_bytes: 3840
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))

mod = 10**9+7
ans = 1
mi = []
pl = []
for a in A:
    if a < 0:
        mi.append(a)
    else:
        pl.append(a)

if N == K:
    for a in A:
        ans *= a
        ans %= mod
    print(ans)
    exit()
if pl == []:
    if K%2:
        for k in range(K):
            ans *= mi[-1-k]
            ans %= mod
    else:
        for k in range(K):
            ans *= mi[k]
            ans %= mod
    print(ans)
    exit()

pl = pl[::-1]

ip = 0
im = 0
if K % 2:
    ans = pl[0]
    ip += 1
    K -= 1

while K > 0:
    check = True
    if ip + 2 <= len(pl):
        x = pl[ip]*pl[ip+1]
    else:
        x = 1
    if im + 2 <= len(mi):
        y = mi[im]*mi[im+1]
    else:
        check = False
        y = 1

    if x >= y or check == False:
        ans *= x
        ans %= mod
        ip += 2
    else:
        ans *= y
        ans %= mod
        im += 2
    K -= 2
print(ans)
    


Measured memory_bytes: 31792
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
const char newline = '\n';

int main()
{
	int a = 0, b = 0, k = 0;
	ll l = 0;
	char oper;
	cin >> a >> oper >> b;
  	switch(oper)
    {
      case '+':
        l= a+b;
        break;
      case '-':
        l = a-b;
        break;
    }
	cout << l << newline;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
 
using namespace std;
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007
 
int main()
{
    boost
    ll n;
    cin >> n;

    ll ans = 1e15;
    for(ll i = 1; i <= ceil(sqrt(n)); i++)
    {
        if(n%i == 0) ans = min(ans, i + n / i - 2);
    }

    cout << ans << nl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define take freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define speed ios_base::sync_with_stdio(false);
#define int long long
#define endl "\n"
#define maxi 10000007
#define rof(i,a,b) for(int i=a;i<b;i++)
int com(string s1,string s2,int i)
{
    int k=0;
    int cost=0;
    while(k<s2.size())
    {
        if(s1[i]!=s2[k])
        {
            cost++;
        }
        k++;
        i++;
    }
    return cost;
}
int32_t main()
{
    speed
    //take
    string s1;
    string s2;
    cin>>s1>>s2;
    int n=s1.size();
    int m=s2.size();
    int res=INT_MAX;
    for(int i=0;i<n-m+1;i++)
    {
        res=min(res,com(s1,s2,i));
    }
    cout<<res;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;

int main(){
	int H, W;
	char area[1001][1001];
	llong mod = 1e9+7;
	vector< vector<llong> > dp(1001, vector<llong>(1001, 0));
	cin >> H >> W;
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++)
			cin >> area[i][j];

	dp[0][0] = 1;
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++){
			if(area[i][j] == '#') continue;
			if(area[i+1][j] == '.') dp[i+1][j] += dp[i][j], dp[i+1][j] %= mod;
			if(area[i][j+1] == '.') dp[i][j+1] += dp[i][j], dp[i][j+1] %= mod;
		}

	cout << dp[H-1][W-1] << endl;

	return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0 and c>0){
       c -= b;
       if(c<=0){
           cout << "Yes" << endl;
           break;
       }
       a -= d;
       if(a<=0){
           cout << "No" << endl;
           break;
        }
    }
}

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

int main(void) {
    string S;cin>>S;
    int result = 0;
    if (S[0] == '+') result++;
    else result--;
    if (S[1] == '+') result++;
    else result--;
    if (S[2] == '+') result++;
    else result--;
    if (S[3] == '+') result++;
    else result--;
    cout << result << endl;
    return 0;
}

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

int abs(int x){

  if (x < 0){
    return -x;
  }else{
    return x;
  }
}

int main(){

  string S,remx = "";
  int nlis[100001],nind = 0;

  cin >> S;

  for (int i = 0 ; i < 100001 ; i++){
    nlis[i] = 0;
  }

  for (int i = 0 ; i < S.size() ; i++){

    if (S[i] != 'x'){
      remx += S[i];
      nind += 1;
    }else{
      nlis[nind] += 1;
    }

  }

  for (int i = 0 ; i < (remx.size()/2) ; i++){

    if (remx[i] != remx[remx.size()-1-i]){
      cout << -1 << endl;
      return 0;
    }

  }

  int ans = 0;

  for (int i = 0 ; i < ((remx.size()+1)/2) ; i++){

    ans += abs(nlis[i]-nlis[remx.size() - i]);

  }

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

  


Measured memory_bytes: 1024
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
int main()
{
    IO
    ll n,w;
    cin>>n>>w;
    ll wt[n+1],v[n+1];
    ll dp[n+1][w+1];
    for(ll i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
    }
    ll i,z; 
    memset(dp,0,sizeof(dp));
    for (i = 0; i <= n; i++) 
    { 
        for (z = 0; z <= w; z++) 
        { 
            if(i == 0 || z == 0) 
            {
                dp[i][z] = 0; 
            }
            else if (wt[i - 1] <= z) 
            {
                dp[i][z] = max(v[i - 1] + dp[i - 1][z - wt[i - 1]],dp[i - 1][z]); 
            }
            else
            {
                dp[i][z] = dp[i - 1][z]; 
            }
        } 
    } 
    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 82428
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    REP(i, 0, (tx - sx))cout << "R";
    REP(i, 0, (ty - sy)) cout << "U";
    REP(i, 0, (tx - sx))cout << "L";
    REP(i, 0, (ty - sy)) cout << "D";
    cout << "D";
    REP(i, 0, (tx - sx + 1))cout << "R";
    REP(i, 0, (ty - sy + 1)) cout << "U";
    cout << "L";
    cout << "U";
    REP(i, 0, (tx - sx + 1))cout << "L";
    REP(i, 0, (ty - sy + 1)) cout << "D";
    cout << "R" << endl;
    return 0;

}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> c(N);
    for(unsigned long i{1}, A; i < N; ++i){
        cin >> A;
        ++c[A - 1];
    }
    for(const auto& i : c)cout << i << endl;
    return 0;
}

Measured memory_bytes: 4844
//https://atcoder.jp/contests/dp/tasks/dp_b
#include<bits/stdc++.h>
using namespace std;


int main(){
    int n,k;
    cin>>n>>k;
    std::vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    std::vector<int> dp(n+1,INT_MAX/2);
    dp[0] = 0;

    // for(int i=1;i<k;i++){
    //     for(int j=i-1;j>=0;j--){
    //         dp[i] = min(dp[i],abs(a[i]-a[j])+dp[j]);
    //     }
    // }
    //dp[1] = abs(a[1] - a[0]);
    for(int i=1;i<n;i++){
        for(int j=i-1;j>=i-k;j--){
            if(j>=0)
                dp[i] = min(dp[i],abs(a[i]-a[j])+dp[j]);   
        }
    }
    cout<<dp[n-1]<<endl;
    //cin.get();
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<tuple<string, int, int>> A(N);
    rep(i,N) {
        string S; int P; cin >> S >> P;
        A[i] = make_tuple(S,-P,i);
    }

    sort(all(A));
    rep(i,N) cout << get<2>(A[i])+1 << endl;
}

Measured memory_bytes: 256
<?php
$n = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$map = [];
foreach($A as $a){
  if(!isset($map[$a]))$map[$a] = 0;
  $map[$a]++;
}
$sum = 0;
foreach($map as $num => $count){
  $sum += $count * ($count - 1) / 2;
}
foreach($A as $a){
  $result[]= $sum + 1 - $map[$a];
}
echo implode("\n", $result),"\n";


Measured memory_bytes: 36712
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(ll)(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })


#define MOD 1000000007
vector<vector<char>> grid;
vvl dp;

ll f(ll x, ll y){
  if(x < 0 || y < 0) return 0;
  if(grid[x][y] == '#') return 0;
  if(dp[x][y] != -1) return dp[x][y];
  dp[x][y] = (f(x-1,y) + f(x,y-1)) % MOD;
  return dp[x][y];
}

int main(){
  ll H,W;
  cin >> H >> W;
  grid.resize(H,vector<char>(W));
  dp.resize(H,vl(W,-1));
  dp[0][0] = 1;
  FOR(i,0,H)FOR(j,0,W){
    char in;
    cin >> in;
    grid[i][j] = in;
  }
  cout << f(H-1,W-1) << endl;
}


Measured memory_bytes: 9216
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = defaultdict(int)
for _ in range(n):
    s = input() 
    d[s[0]] += 1
res = 0
li = ['M','A','R','C','H']
for i in range(3):
    a = li[i]
    for j in range(i+1,4):
        b = li[j]
        for k in range(j+1,5):
            c = li[k]
            res += d[a] * d[b] * d[c]
print(res)

Measured memory_bytes: 10268
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (b > c) {
                System.out.printf("%d %d %d\n", c, b, a);
            } else if (a > c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", b, a, c);
            }
        }
    }
}


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

using namespace std;

typedef long long ll;

int main(void) {
	
	int H[2], ans = 100000;
	
	cin >> H[0] >> H[1];
	
	for (int i = 0; i < 2; i++) {
		if (H[i] % 3 == 0) {
			cout << 0 << endl;
			return 0;
		}
		ans = min(ans, H[1 - i]);
		int H1 = H[i] / 3;
		int S_max = (H1 + 1) * H[1 - i];
		int S_min = (H[i] - H1 - 1) * (H[1 - i] / 2);
		ans = min(ans, S_max - S_min);
		S_min = H1 * H[1 - i];
		S_max = (H[i] - H1) * ((H[1 - i] + 1) / 2);
		ans = min(ans, S_max - S_min);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps=1e-9;

 //< "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.answer"

enum R_Way {
	R_Left,
	R_Front,
	R_Right,
	R_Back,

	R_Dummy,
};
struct Dice {
	int tp;
	int bo;
	int no;
	int so;
	int ea;
	int we;
	Dice(int tp_, int bo_, int no_, int so_, int ea_, int we_) :
		tp(tp_), bo(bo_), no(no_), so(so_), ea(ea_), we(we_) {

	}
	Dice(vector<int>pips_) {

	}

	Dice() {
		tp = 1;
		/*bo = 6;
		no = 2;
		so = 5;
		ea = 3;
		we = 4;*/
	}
	
	int rotate(const R_Way way) {
		switch (way) {
		case R_Right: {
			int c = tp;
			tp = we;
			we = bo;
			bo = ea;
			ea = c;
		}
					  break;
		case R_Back: {
			int c = tp;
			tp = so;
			so = bo;
			bo = no;
			no = c;
		}
					 break;
		case R_Left: {
			int c = tp;
			tp = ea;
			ea = bo;
			bo = we;
			we = c;
		}
					 break;
		case R_Front: {
			int c = tp;
			tp = no;
			no = bo;
			bo = so;
			so = c;
		}
					  break;
		default:
			assert(false);
		}
		return tp;
	}
	int rotate(const int way) {
		return rotate(static_cast<R_Way>(way));
	}
	void spin(const int left) {
		if (left) {

			rotate(R_Way::R_Left);
			rotate(R_Way::R_Back);
			rotate(R_Way::R_Right);
		}
		else {

			rotate(R_Way::R_Left);
			rotate(R_Way::R_Front);
			rotate(R_Way::R_Right);
		}
	}
	int hash()const {
		return tp + we * 6 + no * 36;
	}
};

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<string, int>mp;
		mp["West"] = 0;
		mp["South"] = 1;
		mp["East"] = 2;
		mp["North"] = 3;
		mp["Right"] = 4;
		mp["Left"] = 5;
		Dice di(1, 6, 5, 2, 3, 4);
		int ans = 0;
		while (N--) {
			string st; cin >> st;
			int type = mp[st];
			if (type < 4) {
				di.rotate(type);
			}
			else {
				di.spin((type - 4));
			}
			ans += di.tp;


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

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

using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
 
int m, temp;
string str;
 
int main(){
    while(cin>>m, m){
        int t=1,n=2,w=3,e=4,s=5,b=6;
        for(int i=0; i<m; i++) {
            cin>>str;
            if(str=="north"){temp=n;n=t;t=s;s=b;b=temp;}
            if(str=="east"){temp=e;e=t;t=w;w=b;b=temp;}
            if(str=="south"){temp=s;s=t;t=n;n=b;b=temp;}
            if(str=="west"){temp=w;w=t;t=e;e=b;b=temp;}
        }
        cout<<t<<endl;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

typedef pair<int, int> pii;

int main()
{
  int N, M, ans;
  while(1){
    cin >> N >> M;
    if(N == 0 && M == 0){
      break;
    }else{
      ans = 0;
      pii DP[N];
      for(int i = 0; i < N; i++)
	cin >> DP[i].second >> DP[i].first;
      sort(DP, DP + N, greater<pii>());
      for(int i = 0; i < N; i++){
	while(DP[i].second > 0){
	  if(M)
	    DP[i].second--;
	  else
	    break;
	  M--;
	}
      }
      for(int i = 0; i < N; i++)
	ans += DP[i].first * DP[i].second; 
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  int n, m; cin >> n >> m;
  vector<int> a(n); int sum=0;
  FOR(i,0,n) {cin >> a[i]; sum += a[i];}
  sort(ALL(a));
  reverse(ALL(a));
  FOR(i,0,m) {if(a[i]< (double)sum/(4*(m))  ){cout << "No"; return;}}
  cout << "Yes";
}

int main(){
  solve();
  return 0;
}

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

// --------------------------------------------------------------------------------

void solve()
{
    int a, b;
    cin >> a >> b;
    if (a + b >= 10)
        cout << "error" << endl;
    else
        cout << a + b << endl;
}

// --------------------------------------------------------------------------------

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3624
num = int(input())
res = num % (6 + 5)
#print("res",res)
itr = num // (6 + 5) * 2
#print("itr",itr)
if res > 6:
    print(itr + 1 + 1)
elif res != 0 and res <= 6:
    print(itr + 1)
else:
    print(itr)


Measured memory_bytes: 3192
from sys import stdin
input = lambda: stdin.readline().rstrip()
s = input()
if len(s) % 2 == 1:
    print("No")
    exit()
ans = "Yes"
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "h":
            ans = "No"
            break
    else:
        if s[i] != 'i':
            ans = "No"
            break
print(ans)


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> A(H,vector<char>(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<W+2;i++){
    cout << "#";
  }
  cout << endl;
   for(int i=0;i<H;i++){
     cout << "#";
    for(int j=0;j<W;j++){
      cout << A.at(i).at(j);
    }
     cout << "#" << endl;
   }
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		int ans = a + b;
		if(ans > b + c)
			ans = b + c;
		if(ans > c + a)
			ans = c + a;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
fn main() {
    let n: i32 = read();
    let m: i32 = read();
    let mut r: Vec<(i32, i32)> = Vec::new();
    for _i in 0..m {
        let a: i32 = read();
        let b: i32 = read();
        r.push((a, b));
    }
    for i in 0..n {
        let mut count = 0;
        for &(a, b) in &r {
            if a == (i + 1) || b == (i + 1) {
                count += 1;
            }
        }
        println!("{}", count);
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}


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

ll solve(ll ai, ll aj, ll bi, ll bj) {
  if (aj > bj) {
    swap(ai,bi);
    swap(aj,bj);
  }
  ll s = 1;
  rep(i,30) s *= 3;
  ll dist = abs(ai-bi) + abs(aj-bj);
  ll res = dist;
  while (1) {
    s /= 3;
    if (s <= 0) break;
    ll nai = ai/s, nbi = bi/s;
    if (nai != nbi) break;
    ll naj = aj/s, nbj = bj/s;
    if (nai%3 == 1 && abs(naj-nbj) > 1) {
      ll up = s*nai-1;
      ll bot = s*(nai+1);
      ll loss = min(ai,bi) - up;
      loss = min(loss, bot - max(ai,bi));
      res = dist + loss*2;
      break;
    }
  }
  return res;
}

int main() {
  int q;
  cin >> q;
  rep(qi,q) {
    ll ai,aj,bi,bj;
    cin >> ai >> aj >> bi >> bj;
    ai--; aj--;
    bi--; bj--;
    ll ans = 0;
    ans = max(ans, solve(ai,aj,bi,bj));
    ans = max(ans, solve(aj,ai,bj,bi));
    cout << ans << endl;
  }
  return 0;
}

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

int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	//freopen("input.txt", "rt", stdin);
	int n, k; cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a+n);
	
	int first = INT_MAX;
	for (int i = 0; i <= n - k; i++) {
		first = min(first, abs(a[i] - a[i+k-1]));
	}
	cout << first << "\n";

	return 0;   
}  


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	ll n, j, pi = 1, p;
	cin >> n;
	j = n;

	for (ll i = 2; i*i <= n; ++i)
		if (n % i == 0) {
			if (pi == n / i)
				break;
			j = n / i;
			pi = i;
		}

	cout << pi - 1 + j - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MAXN 1000
#define INF 1000000000000000000LL
using namespace std;
typedef long long LL;
LL A[MAXN+5],B[MAXN+5];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld %lld",&A[i],&B[i]);
	LL k;
	for(int i=2;i<=n;i++)
	{
		k=-1LL;
		if(A[i]>=A[i-1]&&B[i]>=B[i-1])
			continue;
		LL L=1LL,R=INF,mid;
		while(L+1<R)
		{
			mid=(L-R)/2LL+R;
			if((A[i]*mid>=A[i-1]&&B[i]*mid>=B[i-1])||(A[i]*mid<=0||B[i]*mid<=0))
				R=mid;
			else
				L=mid;
		}
		k=R;
		A[i]*=k;
		B[i]*=k;
	}
	printf("%lld\n",A[n]+B[n]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



string str[11] = {
    "light fly", 
    "fly", 
    "bantam",
    "feather",
    "light",
    "light welter",
    "welter",
    "light middle",
    "middle",
    "light heavy",
    "heavy"
};

double seg[11] = {0.0, 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00};
double d;

int main() {
    while (cin >> d) {
        int it = lower_bound(seg, seg+11, d) - seg;
        cout << str[it-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1228
while True:
    ins = input().split()
    h = int(ins[0])
    w = int(ins[1])
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h - 1:
            print("#" * w)
        else:
            print("#" + "." * (w - 2) + "#")
    print("")

Measured memory_bytes: 7660
s=input()
#数値はスライスできないので一旦文字列で受け取って、int型にシフトする
fro=int(s[:2])
ba=int(s[2:])

#s==前半01~12
if 1<=fro<=12:
    #s==前半01~12かつ後半01~12
    if 1<=ba<=12:
        print("AMBIGUOUS")
    #s==前半00または13以上
    else:
        print("MMYY")
#s==前半00または13以上
else:
    #s==前半00または13以上かつ後半01~12
    if 1<=ba<=12:
        print("YYMM")
    #s==前半00または13以上かつ後半00もしくは13以上
    else:
        print("NA")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
const int INF = 1e9+7;
int h,w,k,freq_total[12],freq_local[12],mat[12][1007],ans=INF;
int main(){
	fastio; cin>>h>>w>>k;
	for(int i=0; i<h; i++){
		string s; cin>>s;
		for(int j=0; j<w; j++){
			mat[i][j] = s[j]-'0';
		}
	}
	
	for(int mask = 0; mask<(1<<h); mask+=2){//cortes horizontais (corte 0 nao faz sentido)
	
		for(int i=0; i<12; i++)freq_total[i] = 0;
		bool poss = true;//sera que eh possivel obter <=k em todas as faixas ?
		int anslc = __builtin_popcount(mask);//resposta local
		
		for(int j=0; j<w; j++){
		
			int regiao = 0;
			int max_f = 0;
			for(int i=0; i<12; i++)freq_local[i]=0;
			
			for(int i=0; i<h; i++){
				if(mask&(1<<i))regiao++;
				if(mat[i][j] == 1)freq_local[regiao]++;
			}
			
			bool precisa_cortar = false;
			for(int i=0; i<=regiao; i++){
				if(freq_local[i] > k){
					poss = false;
				}else if(freq_local[i] + freq_total[i] > k){
					precisa_cortar = true;				
				}else{
					freq_total[i] += freq_local[i];
				}
			}
			if(precisa_cortar){
				anslc++;
				for(int i=0; i<=regiao; i++)freq_total[i] = freq_local[i];
			}
		}

		if(poss)ans = min(ans, anslc);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    ll ans=0;
    vector<vector<int> > v(n);
    int r=0,g=0,b=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
        v[i]={r,g,b};
    }
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        char a=s[i],aa=s[j];
        if(a==aa)continue;
        if((a=='R'&&aa=='B')||(a=='B'&&aa=='R')){
            if(j!=n-1){
                ans+=v[j+1][1]*1ll;
                if(2*j-i<n&&s[2*j-i]=='G')ans--;
            }
        }
        if((a=='R'&&aa=='G')||(a=='G'&&aa=='R')){
            if(j!=n-1){
                ans+=v[j+1][2]*1ll;
                if(2*j-i<n&&s[2*j-i]=='B')ans--;
            }
        }
        if((a=='G'&&aa=='B')||(a=='B'&&aa=='G')){
            if(j!=n-1){
                ans+=v[j+1][0]*1ll;
                if(2*j-i<n&&s[2*j-i]=='R')ans--;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3852
#include <stdio.h>

int main(void)

{

int a,b;

scanf("%d %d",&a,&b);

if(a<b)

{

printf("a < b\n");

}

if(a>b)

{

printf("a > b\n");

}

if(a==b)

{

printf("a == b\n");

}

return 0;

}

Measured memory_bytes: 580
use std::io;
use std::cmp;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let mut num = read::<usize>();
    num.sort();
    let k = read_one::<usize>();

    println!("{}", usize::pow(2, k as u32) * num[2] + num[1] + num[0]);
}

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

typedef long long ll;

int main(){
    ll X, Y;
    cin >> X >> Y;
    
    int cnt=0;
    while(1){
        X *= 2;
        cnt++;
        if(X>Y){
            break;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
d,g = map(int, input().split())

pc = [list(map(int, input().split())) for _ in range(d)]

ans=float('inf')
for bit in range(2**d):
    b = 0
    score = 0
    num = 0
    # ボーナスを貰えるまで問題を解く場合を計算
    # bit探索し、ボーナスを貰うパターンを網羅する
    for i in range(d):
        if (bit >> i) & 1:
            # 問題を解いた点 + ボーナス
            score += pc[i][0] * (i+1) * 100 + pc[i][1]
            # 解いた問題数
            num += pc[i][0]
        else:
            # ボーナスを貰えるまで解かない問題の場合
            # この値には最終的にはボーナスを貰えるまでは解かない、最大点がもらえる問題の番号が入る
            b = i

    # ボーナスを貰えるまでは解かない問題による加点と回答の更新を行う
    for j in range(pc[b][0]):
        if score>=g and num<ans:
            ans=num
        score+=(b+1)*100
        num+=1

print(ans)

Measured memory_bytes: 3064