akhauriyash/Code-Regression huggingface dataset:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    x = ni()
    print(8 - (x - 400) // 200)
    return

solve()


Measured memory_bytes: 9172
function Main(input) {
  const line2Array = input.split("\n")[0].split(" ");
  if(line2Array[0][line2Array[0].length-1] == line2Array[1][0] && line2Array[1][line2Array[1].length-1] == line2Array[2][0]){
    console.log("YES");
  }else{
    console.log("NO");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()

//グローバル変数宣言
 ll p=0,q=0,r=0;

int main(){
  ll x=0,n;
  cin>>n;
  string s;
  cin>>s;
  p=0;
  rep(i,n)
  {
    if(s[i]=='I')x++;
    if(s[i]=='D')x--;
    p=max(x,p);
  }
  print(p);
}

Measured memory_bytes: 3592
function main(input: string) {
  const N = parseInt(input);
  const genka = Math.floor(N / 1.08);
  const genka2 = genka + 1;
  console.log(Math.floor(genka * 1.08) === N ? genka : Math.floor((genka2) * 1.08) === N ? genka2 : ":(");
}

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


Measured memory_bytes: 7372
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
	int n;
	int t[100000];
	int x[100000];
	int y[100000];
	cin >> n;
	int k;
	for(int i = 0;i < n;i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	for(int i = 0;i < n;i++){
		if(i){
			k = (t[i] - t[i - 1]) - (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]));
		}else{
			k = t[0] - (abs(x[0]) + abs(y[0]));
		}
		if(k < 0 || k % 2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,ans=0;
    string s;
    cin >> n >> s;
    vector<long> c(n+1),d(n+1),e(n+1);
    for(int i=0;i<n;i++){
        if(s[i]=='R') c[i+1] = c[i] + 1;
        else c[i+1] = c[i];
        if(s[i]=='B') d[i+1] = d[i] + 1;
        else d[i+1] = d[i];
        if(s[i]=='G') e[i+1] = e[i] + 1;
        else e[i+1] = e[i];
    }
    for(int i=0;i<n;i++){
        for(int k=n-1;i+1<k;k--){
            if(s[i]==s[k]) continue;
            char a;
            if(s[i]=='R'){
                if(s[k]=='G') a = 'B';
                else a = 'G';
            }
            else if(s[i]=='G'){
                if(s[k]=='R') a = 'B';
                else a = 'R';
            }
            else{
                if(s[k]=='R') a = 'G';
                else  a = 'R';
            }
            if(a=='R') ans += c[k+1]-c[i];
            if(a=='B') ans += d[k+1]-d[i];
            if(a=='G') ans += e[k+1]-e[i];
            if((k+i)%2==0&&s[(k+i)/2]==a) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
string=list(input())
num=int(input())
orders=[]
for n in range(num):
	orders.append(input().split(' '))

for order in orders:
	if order[0] == 'print':
		a=int(order[1])
		b=int(order[2])
		target_l=string[a:b+1]
		for i in target_l:
			print(i,end="")
		print()
		
	elif order[0] == 'reverse':
		a=int(order[1])
		b=int(order[2])
		target_l=string[a:b+1]
		for i in range(len(target_l)//2):
			tmp=target_l[i]
			target_l[i]=target_l[-(i+1)]
			target_l[-(i+1)]=tmp

		new_l=string[:a]+target_l+string[b+1:]
		string=new_l

	elif order[0] == 'replace':
		a=int(order[1])
		b=int(order[2])
		rep=list(order[3])
		for i,x in enumerate(string[a:b+1]):
			ii=i+a
			string[ii]=rep[i]







Measured memory_bytes: 6876
#include<stdio.h>

#define mod 1000000007

int ru2(int n){
	int i,r=1;
	for(i=0;i<n;i++)r=r*2;
	return r;
}

int main(){
	int h,w,i,k,j;
	scanf("%d%d%d",&h,&w,&k);
	long long dp[101][9]={0};
	dp[0][0]=1;
	for(i=0;i<h;i++){
		for(j=0;j<ru2(w-1);j++){
			int tmp[8]={0},k=0,f=0;
			while(j>=(1<<k)){
				tmp[k]=j&(1<<k);
				k++;
			}
			/*printf("%d:",j);
			for(k=0;k<w-1;k++){
				printf("%d",tmp[k]);
			}*/
			for(k=1;k<w-1;k++){
				if(tmp[k-1]!=0&&tmp[k]!=0)f=1;
			}
			//printf(":%d\n",f);
			if(f==0){
				for(k=0;k<w;k++){
					if(k!=w-1){
						if(tmp[k]!=0)dp[i+1][k+1]=(dp[i][k]+dp[i+1][k+1])%mod;
					}
					if(k!=w-1){
						if(tmp[k]!=0)dp[i+1][k]=(dp[i][k+1]+dp[i+1][k])%mod;
					}
					if(k==0&&tmp[k]==0)dp[i+1][0]=(dp[i+1][0]+dp[i][0])%mod;
					else if(k==w-1&&tmp[w-2]==0)dp[i+1][w-1]=(dp[i+1][w-1]+dp[i][w-1])%mod;
					else if(1<=k&&k<=w-2&&tmp[k-1]==0&&tmp[k]==0)dp[i+1][k]=(dp[i+1][k]+dp[i][k])%mod;
				}
			}
		}
	}
	/*for(i=0;i<h+1;i++){
		for(j=0;j<w;j++)printf("%d,",dp[i][j]);
		puts("");
	}*/
	printf("%lld\n",dp[h][k-1]);
	return 0;
}

Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
foods = {}
n.times do
  a = gets.split.map(&:to_i)
  k = a.shift
  k.times do |i|
    if foods.include?(a[i])
      foods[a[i]] += 1
    else
      foods[a[i]] = 1
    end
  end
end
count = 0
foods.each_value do |v|
  count += 1 if v == n
end
puts count


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const int mod = 998244353;
const int INF = 1e9;

signed main() {
	int x, k;
	cin >> x >> k;

	vector<int> r(k + 1, 0);
	for (int i = 1; i < k + 1; i++) {
		cin >> r[i];
	}
	k++;

	vector<int> dr(k);
	vector<int> dm(k);
	vector<int> df(k);
	dm[0] = 0;
	dr[0] = 0;
	df[0] = 0;

	REP(i, 1, k) {
		dr[i] = min(x, r[i] - r[i - 1]);
		dm[i] = dr[i] - dm[i - 1];
		df[i] = df[i - 1] + (i % 2 ? -1 : +1) * dr[i];
	}

	vector<P> ud(k);
	vector<P> dd(k);
	ud[0].first = x;
	ud[0].second = 0;
	dd[0].first = 0;
	dd[0].second = x;

	REP(i, 1, k) {
		ud[i] = ud[i - 1];
		dd[i] = dd[i - 1];
		if (i % 2 == 0) {
			{
				int df = min(dr[i], ud[i].second);
				ud[i].first += df;
				ud[i].second -= df;
			}
			{
				int df = min(dr[i], dd[i].second);
				dd[i].first += df;
				dd[i].second -= df;
			}
		} else {
			{
				int df = min(dr[i], ud[i].first);
				ud[i].first -= df;
				ud[i].second += df;
			}
			{
				int df = min(dr[i], dd[i].first);
				dd[i].first -= df;
				dd[i].second += df;
			}
		}
	}

	map<int, int> tmp;
	rep(i, k) {
		tmp[r[i]] = i;
	}

	map<int, int> mpA, mpB;
	rep(i, k) {
		int p = dm[i];
		if (i % 2 == 1 && (mpA.size() == 0 || prev(mpA.end())->first < p)) {
			mpA[p] = i;
		}
		if (i % 2 == 0 && (mpB.size() == 0 || prev(mpB.end())->first < p)) {
			mpB[p] = i;
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int t, a;
		cin >> t >> a;
		int b = x - a;

		int rt = prev(tmp.upper_bound(t))->first;
		int ti = prev(tmp.upper_bound(t))->second;
		int dt = (t - rt) * (ti % 2 ? +1 : -1);

		int left = INF;
		int la, lb;
		if (mpA.lower_bound(a) != mpA.end()) {
			if (left > mpA.lower_bound(a)->second) {
				left = mpA.lower_bound(a)->second;
				la = 0;
				lb = x;
			}
		}
		if (mpB.lower_bound(b) != mpB.end()) {
			if (left > mpB.lower_bound(b)->second) {
				left = mpB.lower_bound(b)->second;
				la = x;
				lb = 0;
			}
		}

		// dump(ti);
		// dump(dt);
		// dum(t);
		// dum(a);
		// dump(b);
		// dump(left);
		// dum(la);
		// dump(lb);
		// dum(ud[left].first);
		// dump(ud[left].second);
		// dum(dd[left].first);
		// dump(dd[left].second);

		int ans;
		if (ti < left) {
			ans = a + df[ti] + dt;
		} else if (la == ud[left].first && lb == ud[left].second) {
			ans = ud[ti].first + dt;
		} else if (la == dd[left].first && lb == dd[left].second) {
			ans = dd[ti].first + dt;
		} else {
			assert(0);
		}
		cout << max(0ll, min(x, ans)) << endl;
	}

	return 0;
}


Measured memory_bytes: 13696
n = int(input())
a = [int(x) for x in input().split()]

ans = 0
for num in a:
    ans += num ** 2

for i in range(-100, 101):
    cnt = 0
    for num in a:
        cnt += (i - num)**2
    
    ans = min(ans, cnt)

print(ans)

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

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

  vector<int> a(n);

  for (auto &i : a) cin >> i;

  int64_t sum = 0;
  vector<int64_t> b(2 * m + 3);

  for (int i = 1; i < n; ++i) {
    int l = a[i - 1], r = a[i] + (a[i - 1] < a[i] ? 0 : m);

    sum += r - l;
    b[l + 2]--;
    b[r + 1] += (r - l);
    b[r + 2] -= (r - l - 1);
  }

  for (int i = 1; i < b.size(); ++i) b[i] += b[i - 1];
  for (int i = 1; i < b.size(); ++i) b[i] += b[i - 1];

  int64_t ans = sum;
  for (int i = 1; i <= m; ++i) {
    ans = min(ans, sum + b[i] + b[i + m]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n-1];
  int c[n];
  for(int i=0;i<n;i++)
  {
    c[i]=0;
  }
  for(int i=0;i<n-1;i++)
  {
    cin>>a[i];
    c[a[i]-1]+=1;
  }
  for(int i=0;i<n;i++)
  {
    cout<<c[i]<<endl;
  }
  return 0;
}

  
    

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N,X,M;
int main(){
  cin>>N>>X>>M;
  if(N<=M){
  ll ans=0;ll a=X;
    for(ll i=0;i<N;i++){
    ans+=a;
      a=(a*a)%M;
    }cout<<ans<<endl;
      
  }else{
  set<ll>S;ll a=X;ll I,r;
    for(ll i=0;i<N;i++){
    if(S.count(a)){I=i-1;r=a;break;}
      S.insert(a);
      a=(a*a)%M;
    }a=X;
    ll ans=0;ll J;
    for(ll i=0;i<N;i++){
    if(a!=r){ans+=a;a=(a*a)%M;}else{J=i;break;}
     }
  ll A=(I-J+1);ll B=(N-J)%A;ll C=(N-J)/A;
    ll sum=0;ll R=r;
    for(ll i=J;i<=I;i++){
    sum+=R;R=(R*R)%M;
    }ll y=0;ll R1=r;
    for(ll i=J;i<J+B;i++){
    y+=R1;R1=(R1*R1)%M;
    }ans+=(sum*C+y);
      
      cout<<ans<<endl;
   }
  return 0;
}
  

Measured memory_bytes: 5896
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  vector<ll> v(3);
  rep(i,3) cin>>v[i];
  ll k;
  cin>>k;
  sort(ALL(v));
  cout<<v[0]+v[1]+v[2]*(ll)pow(2,k)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
pair<vector<int>, vector<int> > solve(int n, const string &T) {
	if (!n) {
		return make_pair(vector<int>(1, 0), vector<int>(T.size(), 0));
	}
	vector<int> P, W;
	tie(P, W) = solve(n - 1, T);
	int sz = P.size();
	vector<int> nP(3 * sz), nW(T.size()), D(3 * sz), lt(3 * sz, 0);
	for (int i = 0; i < 3; i++) for (int j = 0; j < sz; j++) D[i * sz + j] = i;
	int ct = 0;
	function<void(int)> upd = [&](int i) {
		if (D[i] && (ct - lt[i]) % 2 == 1) D[i] = 3 - D[i];
		lt[i] = ct;
	};
	for (int i = 0; i < (int)T.size(); i++) {
		for (int j = W[i]; j < 3 * sz; j += sz) {
			upd(j);
			if (D[j] == 2) nW[i] = j;
		}
		if (T[i] == 'S') ct++;
		else {
			for (int j = W[i]; j < 3 * sz; j += sz) {
				D[j] = (D[j] + 1) % 3;
			}
		}
	}
	for (int i = 0; i < 3 * sz; i++) {
		upd(i);
		nP[i] = P[i % sz] + D[i] * sz;
	}
	return make_pair(nP, nW);
}
int main() {
	int n;
	string T;
	cin >> n >> T;
	vector<int> ans = solve(n, T).first;
	for (int x : ans) cout << x << ' ';
	return 0;
}

Measured memory_bytes: 15704
class Tree
    def initialize(val, parent)
        @val, @parent = val, parent
        @depth = (parent ? parent.depth + 1 : 1)
        @children = []
        @parent.children << self if @parent
    end

    def eval
        return @val.to_i if @val =~ /\d/
        return @children.map {|c| c.eval}.inject(@val.to_sym)
    end

    attr_reader :parent, :children, :depth
end

loop do
    n = gets.to_i
    break if n == 0

    parent = {}
    root = nil
    v = nil
    n.times do
        gets.chomp =~ /(\.*)(.+)/
        indent = $1.size
        v = v.parent until !v || indent == v.depth
        x = $2
        v = Tree.new(x, v)
        root ||= v
    end
    p root.eval
end

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

int main()
{
  int n, k, q;
  std::cin >> n >> k >> q;
  std::vector<int> scores(n);
  for(int i = 0; i < n; i++)scores[i] = k - q;
  std::vector<int> a(q);
  for(int i = 0; i < q; i++)
  {
    int score;
    std::cin >> score;
    scores[score-1] ++;
  } 
  for(int i = 0; i < n; i++ )
  {
    if(scores[i]>0)
    {
      std::cout << "Yes" << std::endl;
    }
    else
    {
      std::cout << "No" << std::endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;
ll fun(ll l,ll r){
    if(l>r)return 0;
    ll num;
    num=(r-l)/3+1;
    return num;
}
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       
        ll x,y,a,b;cin>>x>>y;
        if(y%2){
            cout<<"No";
        }
        else{
            b=y/2-x;
            a=x-b;
            if(a<0||b<0)
            cout<<"No";
            else{
            if(a+b==x&&a*2+4*b==y)
            cout<<"Yes";
            else
            cout<<"No";}
        }
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
ll wf[305][305];
vector<ll> once[305];
ll ans[305][305];
bool isUsed[305];

int main(){
    ll n, m, l;
    cin >> n >> m >> l;

    REP(i, n) REP(j, n) {
        if(i == j) wf[i][j] = 0;
        else wf[i][j] = INF;
    }

    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        wf[a][b] = c;
        wf[b][a] = c;
    }

    REP(i, n) REP(j, n) REP(k, n) wf[j][k] = min(wf[j][k], wf[j][i] + wf[i][k]);
    REP(i, n) REP(j, n) if(0 < wf[i][j] && wf[i][j] <= l) once[i].push_back(j);
    REP(i, n) REP(j, n) ans[i][j] = -1;

    int q;
    cin >> q;

    REP(query, q) {
        int s, t;
        cin >> s >> t;
        s--, t--;

        if(ans[s][t] != -1) {
            cout << ans[s][t] - 1 << endl;
            continue;
        }

        queue<int> que;
        que.push(s);
        ans[s][s] = 0;
        REP(i, n) isUsed[i] = false;

        while(que.size()) {
            REP(i, que.size()) {
                int k = que.front();
                que.pop();
                REP(j, once[k].size()) {
                    int dst = once[k][j];
                    if(!isUsed[dst]) {
                        isUsed[dst] = true;
                        ans[s][dst] = ans[s][k] + 1;
                        que.push(dst);
                    }
                }
            }
        }

        if(ans[s][t] == -1) cout << "-1" << endl;
        else cout << ans[s][t] - 1 << endl;
    } 

    return 0;
}


Measured memory_bytes: 3072
def t(a,b,x):return b*(100+x)//100+(a-b)*(100+x)//100

while 1:
    x,y,s=map(int,input().split())
    if x==0:break
    a=0
    for i in range(s*100//(100+x),s+1):
        for j in range(1,i//2+1):
            if t(i,j,x)!=s:pass
            else:a=max(a,t(i,j,y))
    print(a)   

Measured memory_bytes: 7764
#include<stdio.h>
int main(){
  int c[5],i,a,b;
  for(i=1;i<=3;i++){
    c[i]=0;
  }
  scanf("%d\n%d\n",&a,&b);
  c[a]=1,c[b]=1;
  for(i=1;i<=3;i++){
    if(c[i]==0){
      printf("%d\n",i);
    }
  }
  return 0;
}

Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.shift();
var a = arr.shift().split(" ").map(Number);
a.sort(function(a,b){
   return b-a;
});
var s = [];
a.reduce(function(a,b){
   s.push([a-b,a,b]); 
   return b;
});
var max = 0;
a.reduce(function(a,b){
   s.forEach(function(v){
      if(v[1] != a && v[2] != b && v[1] != b && v[2] != a){
         max = Math.max(max, (a+b)/v[0]).toFixed(6);
      }
   });
   return b;
});
console.log(max);

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

def main():

    A, B, C, X, Y = map(int, input().split())

    if A + B <= 2 * C:
        ans = (A * X + B * Y)

    else:
        if X <= Y:
            ans = min(2 * C * X + B * (Y - X), 2 * C * Y)

        else:
            ans = min(2 * C * Y + A * (X - Y), 2 * C * X)
    

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
import java.io.*;
import java.util.*;

public class  Main{
	static int mod=(int)1e9+7;
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        pair[]in=new pair[n];
        for(int i=0;i<n;i++)in[i]=new pair(sc.next(),sc.nextInt(),i+1);
        Arrays.sort(in);
        for(int i=0;i<n;i++) pw.println(in[i].idx);
        pw.flush();
    }
    static class pair implements Comparable<pair>{
    	String t;int d;int idx;
    	pair(String x,int y,int i){
    		t=x;d=y;idx=i;
    	}
    	@Override
    	public int compareTo(pair o) {
    		if(t.compareTo(o.t)!=0) {
    			return t.compareTo(o.t);
    		}
    		return o.d-d;
    	}
    	 
    	public boolean equals(pair o) {
    		if(this.compareTo(o)==0)return true;
    		return false;
    	}
    	public String toString() {
    		return "("+t+" "+d+")";
    	}
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int a = max(h, w);
    cout << (n + a - 1) / a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 105
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(void);
void visit(int);
  
int m[MAX][MAX];
int d[MAX];
int f[MAX];
int color[MAX];
int n;
int time;
  
int main(){
  
    int i,j,u,k,ne;
  
    scanf("%d",&n);
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            m[i][j] = 0;
        }
    }
    for(i = 1; i <= n;i++){
        scanf("%d",&u);
	scanf("%d",&k);
        for(j = 1; j <= k; j++){
	  scanf("%d",&ne);
	  m[i][ne] = 1;
        }
    }
    dfs();
    for(i = 1; i <= n; i++){
        printf("%d %d %d\n",i,d[i],f[i]);    }
  
    return 0;
}
void dfs(void){
  
    int u;
  
    for(u = 1; u <= n; u++){
        color[u] = WHITE;
    }
    time = 0;
    for(u = 1; u <= n; u++){
        if(color[u] == WHITE) visit(u);
    }
}
void visit(int u){
  
    int v;
  
    color[u] = GRAY;
    d[u] = ++time;
    for(v = 1; v <= n; v++){
        if(m[u][v] == 1 && color[v] == WHITE)
            visit(v);
    }
    color[u] = BLACK;
    f[u] = ++time;
}

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

using namespace std;

const int N=2005;
int n,m,q,s[3][N][N];
char mp[N][N];

inline int query(int a[N][N],int lx,int rx,int ly,int ry){return a[rx][ry]-a[lx-1][ry]-a[rx][ly-1]+a[lx-1][ly-1];}

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		scanf("%s",mp[i]+1);
		for(int j=1;j<=m;j++){
			for(int k=0;k<3;k++)s[k][i][j]=s[k][i-1][j]+s[k][i][j-1]-s[k][i-1][j-1];
			if(mp[i][j]=='1'){
				s[0][i][j]+=mp[i][j-1]=='1';
				s[1][i][j]+=mp[i-1][j]=='1';
				s[2][i][j]++;
			}
		}
	}
	for(int i=1,lx,ly,rx,ry;i<=q;i++){
		scanf("%d%d%d%d",&lx,&ly,&rx,&ry);
		printf("%d\n",query(s[2],lx,rx,ly,ry)-query(s[1],lx+1,rx,ly,ry)-query(s[0],lx,rx,ly+1,ry));
	}
	return 0;
}

Measured memory_bytes: 52864
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int j,k;
int memo[3050][3050];

string s1,s2;

void lcs(int t,int y){

    for(int i=0;i<t;i++){
        for(int z=0;z<y;z++){

            if(s1[i] == s2[z]){
                memo[i+1][z+1] = 1 + memo[i][z];
            }
            else{
                memo[i+1][z+1] = max(memo[i][z+1],memo[i+1][z]);
            }        
        }
    }
    int index = memo[t][y];
    char lc[index+1];
    lc[index]= '\0';

    int i= t ,z = y;
    while(i>=0 && z>=0){
        if(s1[i]==s2[z]){
            lc[index] = s1[i];
            i--,z--,index--;
        }
        else{
            if(memo[i][z+1] > memo[i+1][z]){
                i--;
            }
            else{z--;}
        }
    }
    cout << lc << endl;
}

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

    cin >> s1 >> s2;
    int l1= s1.size();
    int l2 = s2.size();

    lcs(l1,l2);

}

Measured memory_bytes: 35968
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int d = sc.nextInt();
    	int n = sc.nextInt();
    	int reg=1;
    	switch(d){
    	case 0:
    		reg=1;
    		break;
    	case 1:
    		reg=100;
    		break;
    	case 2:
    		reg=10000;
    		break;
    	}
    	if(n==100){
    		n=101;
    	}
    	System.out.println(reg*n);
    }
}

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

int S(int a,int b){
	return a*b;
}

int L(int a,int b){
	return a*2+b*2;
}


int main() {
	int a,b;
	cin>>a>>b;
	
	cout<<S(a,b)<<" "<<L(a,b)<<endl;
	
	return 0;
}

Measured memory_bytes: 3004
S = gets.chomp

cnt = 0
if S.size == 1 then
  puts "0"
  exit
elsif S.size % 2 == 0 then
  s = S[0..S.size/2-1]
  t = S[S.size/2..-1]
  cnt = 0
  s.chars.zip(t.chars.reverse).each do |v|
    cnt += 1 if v[0] != v[1]
  end
else
  s = S[0..S.size/2-1]
  t = S[S.size/2+1..-1]
  s.chars.zip(t.chars.reverse).each do |v|
    cnt += 1 if v[0] != v[1]
  end
end

puts cnt


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

string base26 (long long n)
{
    string t = "zabcdefghijklmnopqrstuvwxy" ,res;
    while(n > 0)
    {
        long long x = n%26;
        res = t[x]+res;
        n = ceil((double)n/26)-1;
    }
    return res;
}

int main()
{
    long long n;
    cin >> n;
    cout << base26(n)<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
 int main() {
    int N,i;
  
   scanf("%d",&N);
   
   double x[N],sum;
   
   char u[N][4];
   
   for(i=0;i<N;i++){
   scanf("%lf %s",&x[i],u[i]);
   }
   
    for(i=0;i<N;i++){
    //  printf("%s",u[i]);
  if(u[i][0]=='J')
    sum=sum+x[i];
     
     if(u[i][0]=='B')
    sum=sum+x[i]*380000.0;
   }
   
   printf("%lf",sum);
   return 0;
 }

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i] >> ys[i];
    }
    double ans1 = 0, ans2 = 0;
    vector<int> v(n);
    iota(v.begin(),v.end(), 0);
    do {
        ans2 += 1;
        for (int i = 0; i < n - 1; ++i) {
            ans1 += hypot(xs[v[i]]-xs[v[i+1]], ys[v[i]]-ys[v[i+1]]);
        }
    }while(next_permutation(v.begin(),v.end()));
    printf("%.10lf\n", ans1/ans2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	ll N, x;
	cin >> N >> x;
	vector<ll> a(N);
	rep(i, N) {
		cin >> a[i];
	}
	ll ans = 0;
	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}
	for (int i = 1; i < N; i++) {
		if (a[i] + a[i - 1] > x) {
			ans += a[i] - (x - a[i - 1]);
			a[i] = x - a[i - 1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 510000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int n, k, c;
string s;
int f[200005], b[200005];
VI ans;

int main() {

	cin >> n >> k >> c >> s;

	int j = 0;
	rep(i, n) {
		if (s[i] == 'o') {
			f[j] = i + 1;
			j++;
			i += c;
		}
		if (j == k) break;
	}

	j--;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'o') {
			b[j] = i + 1;
			j--;
			i -= c;
		}
		if (j < 0)break;
	}

	rep(i, k) {
		if (f[i] == b[i])ans.pb(f[i]);
	}

	if (!ans.empty()) {
		rep(i, ans.size()) {
			cout << ans[i] << endl;
		}
	}
	else cout << endl;

	return 0;
}


Measured memory_bytes: 4216
#include <cstring>
#include <cstring>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <set>

#include <cstring>
#include <unordered_set>
#include <algorithm>
using namespace std;


int main()
{
	string s;
	cin >> s;
	string cmp = "keyence";
	int n = s.length();
	for (int i = 0; i < n; i++)
	{
		
		for (int j = 0; j < n - i; j++)
		{
			string q = s;
			q.erase(i, j);
			if (q == cmp) {
				cout << "YES";
				return 0;
			}
		}
	}
	cout << "NO";
	return 0;
			
}
	

		
	

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

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n, m; cin >> n >> m;

	VV mods(m);
	rep(i, n) {
		int x; cin >> x;
		mods[x % m].push_back(x);
	}
	rep(i, m) sort(all(mods[i]));

	int ans = mods[0].size() / 2;
	if (m != 1 && m % 2 == 0) ans += mods[m / 2].size() / 2;
	rep(i, 1, (m + 1) / 2) {
		auto& a = mods[i];
		auto& b = mods[m - i];
		if (a.size() > b.size()) swap(a, b);
		int rem = b.size() - a.size();
		ans += a.size();
		rep(j, (signed)b.size() - 1) breakif(rem <= 1) if(b[j] == b[j + 1]) {
			ans++;
			rem -= 2;
			j++;
		}
	}
	cout << ans << endl;

	system("pause");
}

Measured memory_bytes: 5888
import itertools
N = int(input())
L = list(map(int, input().split()))
L_c = sorted(list(L))
cnt = 0
for i in range(len(L)):
    for j in range(i+1,len(L_c)):
        for l in range(j+1,len(L_c)):
            if L_c[i]!=L_c[j] and L_c[j] !=L_c[l] and L_c[l]<L_c[i] +L_c[j]:
                cnt+=1

print(cnt)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);
map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    FOR(i,1,n+1) {
        if(n/i==0) break;
        ans += (n/i)*(n/i+1)*i/2;
        //cout << (n/i)*(n/i+1)*i/2 << endl;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    string s;
    int k;
    cin >> s;
    cin >> k;
    vector<int> initial;
    vector<int> initial_list;
    vector<string> word_list;
    int tmp_initial;
    for(int i=0; i<s.size(); i++){
        tmp_initial = s[i]-'a';
        initial.push_back(tmp_initial);
    }

    sort(initial.begin(),initial.end());
    initial_list.push_back(initial[0]);

    for(int i=1; i<initial.size(); i++){
        if(initial[i-1]!=initial[i]){
            initial_list.push_back(initial[i]);
        }
    }

    for(int i=0; i<5; i++){
        char c=initial_list[i]+'a';
        for(int j=0; j<s.size(); j++){
            if(s[j]==c){
                string w;
                w+=s[j];
                word_list.push_back(w);
                for(int k=1; k<5; k++){
                    if(j+k<s.size()){
                        w+=s[j+k];
                        word_list.push_back(w);
                    }
                }
            }
        }
    }

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

    int num_k=1;
    if(num_k==k){
        cout << word_list[0] << endl;
    }else{
        for(int i=1; i<word_list.size(); i++){
            if(word_list[i-1]!=word_list[i]){
                num_k++;
                if(num_k==k){
                    cout << word_list[i] << endl;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const int INF = 100000; 

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

    int n = s.size();
    if(n % 2 == 0){
        n -= 2;
    }else{
        n--;
    }

    string t, t1, t2;
    for(int i = n; i >= 2; i -= 2){
        t = s.substr(0, i);
        t1 = t.substr(0, i / 2);
        t2 = t.substr(i / 2, i / 2);
        if(t1 == t2){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner
object Main{
    def main(args:Array[String]):Unit = {
        val scan = new Scanner(System.in)
        var res_gcd = List[Long]()
        var res_lcm = List[Long]()
        var count = 0
        while(scan.hasNextLong()){
            val a = scan.nextLong()
            val b = scan.nextLong()
            res_gcd :+= gcd(a,b)
            res_lcm :+= lcm(a,b)
            count+=1
        }

        for(i <- 0 to count-1) println(s"${res_gcd(i)} ${res_lcm(i)}")

    }

    def gcd(a:Long,b:Long):Long = if(b == 0) a else gcd(b,a%b)
    def lcm(a:Long,b:Long):Long = a*b/gcd(a,b)
}

Measured memory_bytes: 44908
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
	int n,cnt=0;
  cin>>n;
  int p[n];
  for(int i=0;i<n;i++){
  	cin>>p[i];
  }
  for(int i=1;i<n-1;i++){
  	if(min(p[i-1],p[i])==p[i-1]&&max(p[i],p[i+1])==p[i+1]) cnt++;
    else if(min(p[i+1],p[i])==p[i+1]&&max(p[i],p[i-1])==p[i-1]) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();

    if (a.equals("H")) {
      if (b.equals("H")) {
        System.out.println("H");
      } else {
        System.out.println("D");
      }
    } else {
      if (b.equals("H")) {
        System.out.println("D");
      } else {
        System.out.println("H");
      }
    }

  }
}

Measured memory_bytes: 23124
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<bool> eratosthenes_sieve(size_t size) {
  vector<bool> is_prime(size + 1, true);
  for (size_t i = 0; i <= size; i++) {
    if (i < 2) {
      is_prime[i] = false;
    } else if (is_prime[i]) {
      for (size_t j = 2 * i; j <= size; j += i) {
        is_prime[j] = false;
      }
    }
  }
  return move(is_prime);
}
int main() {
  int64_t n;
  cin >> n;

  int64_t m = floor(sqrt(n)) + 1;

  vector<bool> p = eratosthenes_sieve(m);

  using P = pair<int64_t, int64_t>;
  vector<P> fact;
  for (int64_t i = 2; i <= m; i++) {
    if (p[i]) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      if (cnt != 0) {
        fact.push_back(P(i, cnt));
      }
    }
  }
  if (n != 1) {
    fact.push_back(P(n, 1));
  }

  int64_t result = 0;
  for (auto f : fact) {
    int64_t e;
    tie(ignore, e) = f;
    int i = 1;
    for (i = 1; i <= e; i++) {
      e -= i;
    }
    result += i - 1;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3848
S = gets.chomp.chars
cnt1 = 0
cnt2 = 0

S.each_with_index do |e, idx|
  cnt1 += 1 if idx.even? && e == '1'
  cnt1 += 1 if idx.odd? && e == '0'
end

S.each_with_index do |e, idx|
  cnt2 += 1 if idx.even? && e == '0'
  cnt2 += 1 if idx.odd? && e == '1'
end

puts [cnt1, cnt2].min

Measured memory_bytes: 22508
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,Z,W;cin>>N>>Z>>W;
    int a[2010];
    for(int i=0;i<N;i++)cin>>a[i];
    
    //カードがi枚、手番がjから最善を尽くした時のスコア
    int dp[2010][2];
    dp[1][0]=dp[1][1]=abs(a[N-1]-a[N-2]);
    for(int i=2;i<N;i++){
        dp[i][0]=abs(a[N-i-1]-a[N-1]);
        dp[i][1]=abs(a[N-i-1]-a[N-1]);
        for(int j=1;j<i;j++){
            dp[i][0]=max(dp[i][0],dp[j][1]);
            dp[i][1]=min(dp[i][1],dp[j][0]);
        }
    }
    dp[N][0]=abs(W-a[N-1]);
    for(int j=1;j<N;j++)
        dp[N][0]=max(dp[N][0],dp[j][1]);
    cout<<dp[N][0]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	for (int i = 1; i < S.size(); i++) {
		if (S.at(i - 1) == S.at(i)) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n);
    vector<int> y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];
    repk(i, X + 1, Y + 1) {
        bool flag = true;
        rep(j, n) {
            if (x[j] >= i)
                flag = false;
        }
        rep(j, m) {
            if (y[j] < i)
                flag = false;
        }
        if (flag) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 256
"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival"
from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register

if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream


if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip


def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    n=int(input())
    l1=[]
    for i in range(n):
        l1.append(list(map(int,input().split())))
    dp=[ [0]*3 for _ in range(n)]
    dp[0]=l1[0]
    for i in range(1,n):
        dp[i][0]=l1[i][0]+max(dp[i-1][1],dp[i-1][2])
        dp[i][1]=l1[i][1]+max(dp[i-1][0],dp[i-1][2])
        dp[i][2]=l1[i][2]+max(dp[i-1][0],dp[i-1][1])
    print(max(dp[-1]))
if __name__ == '__main__':
    sync_with_stdio(False)
    main()

Measured memory_bytes: 58328
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;
using LD = long double;

LL N, T;
LL dp[234567][55];

int main() {
	cin >> N >> T;
	vector<pair<LD, pair<LL, LL>>>vec;
	vector<LL>zero;
	for (int i = 0; i < N; ++i) {
		LL a, b;
		cin >> a >> b;
		if (a == 0) {
			zero.push_back(b);
		}
		else {
			vec.push_back({ (LD(b + 1) / LD(a)),{a,b} });
		}
	}
	sort(vec.begin(), vec.end());
	sort(zero.begin(), zero.end());
	vector<LL>imos;
	imos.push_back(0);
	for (auto z : zero)imos.push_back(imos.back() + z + 1);
	int M = vec.size();
	dp[0][0] = 1;
	for (int j = 1; j < 50; ++j) {
		dp[0][j] = INT_MAX;
	}
	for (int i = 1; i <= M; ++i) {
		dp[i][0] = 1;
		LL a = vec[i - 1].second.first;
		LL b = vec[i - 1].second.second;
		for (int j = 1; j < 50; ++j) {
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] * (a + 1) + (b + 1));
		}
	}
	LL ans = -1;
	for (int j = 0; j < 50; ++j) {
		if (dp[M][j] > T + 1)continue;
		int index = upper_bound(imos.begin(), imos.end(), T + 1 - dp[M][j]) - imos.begin() - 1;
		ans = max(ans, LL(j) + index);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 94056
import itertools

def hoge(lst):
    n = 0
    for x in list(lst[0:4]):
        n += x
        if n % 10 != 0:
            n = n + (10 - (n % 10))
    return n + lst[4]

lst = [int(input()) for _ in range(5)]
lst = list(itertools.permutations(lst))
ret = 100000000
for x in lst:
    ret = min(ret, hoge(x))

print(ret)    

Measured memory_bytes: 3064
import java.util.*;

public class Main {

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

		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == N) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
 int a,b,c,d,i;
  d=0;
  cin>>a>>b;
  if(b<10){
  c=a*10+b;
  }else if(b<100){
  c=a*100+b;
  } else{
  c=a*1000+b;
  }
  for(i=0;i<320;i++){
  if(c==i*i){
  d++;
  }
  }
  if(d==1){
  cout<<"Yes"<<endl;
  }else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a;
	for (int i = 1; i <= 100000; i++) a.pb(i*(i + 1) / 2);
	cout << lower_bound(all(a), n) - a.begin() + 1 << endl;
}

Measured memory_bytes: 1400