akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }

    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;

    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    int n;
    cin >> n;
    cout << factorial(n) % pow107 << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const mod = int(1e9 + 7)

var ifac, fac []int

func main() {
	const cmax = int(5e5 + 1)
	fac = make([]int, cmax)
	ifac = make([]int, cmax)
	inv := make([]int, cmax)
	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[0], inv[1] = 1, 1
	for i := 2; i < cmax; i++ {
		fac[i] = (fac[i-1] * i) % mod
		inv[i] = (mod - inv[mod%i]*(mod/i)) % mod
		if inv[i] < 0 {
			inv[i] += mod
		}
		ifac[i] = (ifac[i-1] * inv[i]) % mod
	}

	var n, m int
	fmt.Scan(&n, &m)

	var pt int
	for fx := 0; fx <= n; fx++ {
		b := comb(n, fx) * perm(m-fx, n-fx)
		if fx%2 == 1 {
			b = -b
		}
		pt += b
		pt %= mod
	}
	if pt < 0 {
		pt += mod
	}

	fmt.Println(perm(m, n) * pt % mod)
}

func comb(n, r int) int {
	if r > n {
		return 0
	} else if r == 0 || r == n {
		return 1
	}
	t := (ifac[n-r] * ifac[r]) % mod
	return (t * fac[n]) % mod
}

func perm(n, r int) int {
	if r > n {
		return 0
	} else if r == 0 {
		return 1
	}
	return (fac[n] * ifac[n-r]) % mod
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 14012
use strict;
use warnings;
package SuffixArray;
#sub sa_is(\@$);
sub sa_is{
	my$upper=shift;
	my@s=@_;
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	elsif($n==2){
		if($s[0]<$s[1]){
			return(0,1);
		}
		else{
			return(1,0);
		}
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	for(0..$n-1){
		if($ls[$_]){
			$sum_l[$s[$_]+1]++;
		}
		else{
			$sum_s[$s[$_]]++;
		}
	}
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@{$_[0]}){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(0..$n-1){
			my$v=$sa[$_];
			$sa[$buf[$s[$v-1]]++]=$v-1if$v>=1&&!$ls[$v-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms_map=(-1)x($n+1);
	my$m=0;
	my@lms=();
	for(1..$n-1){
		if(!$ls[$_-1]&&$ls[$_]){
			$lms_map[$_]=$m++;
			push@lms,$_;
		}
	}
	@sa=$induce->(\@lms);
	if($m>0){
		my@sorted_lms;
		for(@sa){
			push@sorted_lms,$_ if$lms_map[$_]!=-1;
		}
		my@rec_s=();
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<$m?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<$m?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$r==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is($rec_upper,@rec_s);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(\@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(255,@s);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


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

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    string a = S.substr(0, K-1);
    string b = string() + (char)(S[K-1] + 32);
    string c = S.substr(K, S.length()) ;
    cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;


int P[1001];
int twice[1002010];
vector<int> vi;


int main(void){
	int N,M;
	
	while(scanf("%d%d", &N, &M) && N != 0 && M != 0 ){
		int ans = 0;
		
		P[0] = 0;
		
		for(int i = 1; i <= N; i++){
			scanf("%d", &P[i]);
		}
		
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= N; j++){
				vi.push_back( P[i]+P[j] );
			}
		}
		
		sort(vi.begin(),vi.end());
		
		twice[0] = vi[0];
		int c = 1;
		
		for(int i = 1; i < vi.size(); i++){
			if(vi[i] != vi[i-1]){
				twice[c] = vi[i];
				c++;
			}
		}
		/*
		for(int i = 0; i < c; i++){
			printf("%d\n",twice[i]);
		}
		*/
		//cツ古つづ荊wice
		
		for(int i = 0; i < c; i++){
			int *p = upper_bound(twice,twice+c,M-twice[i]);
			int u = p - twice;
			int t = u-1;
			if(twice[i]+twice[u]<=M)ans = max(ans,twice[i]+twice[u]);
			if(t != -1 &&twice[i]+twice[t]<=M)ans = max(ans,twice[i]+twice[t]);
		}
		
		printf("%d\n",ans);
		vi.clear();
		
	}
	
	return 0;
}

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

int gcd(long x, long y){
  long tmp, r;
  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main(){
  long n;
  long long int ans = 0;
  cin >> n;
  vector<long long int> a(n), left(n), right(n);

  rep(i, n) cin >> a[i];
  ans = 0;
  
  rep(i, n-1){
    left[0] = a[0];
    left[i+1] = gcd(a[i+1], left[i]);
    right[n-1] = a[n-1];
    right[n-2-i] = gcd(right[n-1-i], a[n-i-2]);
  }
  
  ans = max(left[n-2], right[1]);
  for(int i = 1; i < n-1; i++){
    if(ans < gcd(left[i-1], right[i+1])) ans = gcd(left[i-1], right[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	int ans=0;
	rep(i,n){
		if(i%2==1)a[i]*=-1;
		ans+=a[i];
	}
	cout<<ans<<endl;
}





Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author CompuWare
 */

#include <bits/stdc++.h>

using namespace std;

class ALphabet {
public:
    void solve(istream &in, ostream &out) {
        char a;
        in >> a;
        if (isupper(a))
            out << 'A';
        else
            out << 'a';
    }
};


int main() {
    ALphabet solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);


int main() {
	ll n, h;
	cin >> n >> h;

	vector<ll> a(n);
	vector<ll> b(n);
	ll x = 0;

	rep(i, n) {
		cin >> a[i] >> b[i];
		if (a[i] > x) x = a[i];
	}

	sort(b.begin(), b.end(), greater<>());
	ll cnt = 0, i = 0;
	bool flag = true;;

	while (h > 0) {
		if (x < b[i] && flag) {
			h -= b[i];
			cnt++;
			i++;
			if (i == n) {
				flag = false;
				i = 0;
			}
		}
		else {
			cnt += (h - 1) / x + 1;
			break;
		}
	}
	
	cout << cnt;

	return 0;
}

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

Measured memory_bytes: 4844
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
int n;
vi in;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n;
	in=vi(n);
	rep(i,n)cin>>in[i];
		bool h=true;
		rep(k,n-1)if(in[k]>in[k+1])h=false;
		if(h){
			cout<<"YES"<<endl;
			return 0;
		}
	
	rep(i,n)loop(j,i+1,n){
		swap(in[i],in[j]);
		bool h=true;
		rep(k,n-1)if(in[k]>in[k+1])h=false;
		if(h){
			cout<<"YES"<<endl;
			return 0;
		}
		swap(in[i],in[j]);
	}
	cout<<"NO"<<endl;
}












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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> xs(n);
    vector<int> ys(n);
    for(int i=0; i<n; ++i){
        scanf("%d", &xs[i]);
    }
    copy(xs.begin(), xs.end(), ys.begin());
    sort(ys.begin(), ys.end());
    int yl=ys[n/2-1], yr=ys[n/2];
    for(int i=0; i<n; ++i){
        if(xs[i]<=yl){
            printf("%d\n", yr);
        } else{
            printf("%d\n", yl);
        }
    }
    return 0;
}

Measured memory_bytes: 3712
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1)
using namespace std;
int main() {
    int n,a[107];
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=n;i>=1;i--)
    {
        if(i==1)cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --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())

#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
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

struct edge
{
    int to, cost;
    edge(int to, int cost) : to(to), cost(cost) {}
};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void dfs(vector<vector<edge>> &es, VLL &d, int p, int par)
{
    for (auto &&e : es[p])
    {
        if (e.to == par)
            continue;
        d[e.to] = d[p] + e.cost;
        dfs(es, d, e.to, p);
    }
}

void solve()
{
    int n, q, k;
    cin >> n;
    vector<vector<edge>> es(n);
    LL a, b, c;
    REP(i, 0, n - 1)
    {
        cin >> a >> b >> c;
        --a;
        --b;
        es[a].pb(b, c);
        es[b].pb(a, c);
    }
    cin >> q >> k;
    VLL d(n);
    dfs(es, d, k - 1, -1);

    int x, y;
    REP(i, 0, q)
    {
        cin >> x >> y;
        --x;
        --y;
        cout << d[x] + d[y] << endl;
    }
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long
#define pb push_back


using namespace std;


int main() {
  //cout << "Hello world";
  int n;
  cin >> n;
  ll arr[n];

  for(int i = 0; i < n; i++)
    cin >>arr[i];
  ll all = 0;
  for(int i = 0; i < n; i+= 2) {
    all ^= (arr[i] ^ arr[i + 1]);
  }

  for(int i = 0; i < n; i++) {
    cout << (all ^ arr[i]) << " ";;
  }

}



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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main(){
	string s, t; cin >> s >> t;
	char one = t[s.size()];
	s = s + one;
	if(s == t) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3620
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		sc.nextLine();

		String ans = sc.nextLine();

		for(int i = 1; i<ans.length(); i++)
		{
			if(a == 1)
				break;
			if(ans.charAt(i) == ans.charAt(i-1))
				a--;
		}
		System.out.print(a);
	}
}

Measured memory_bytes: 27896
#include <iostream>

int main()
{
    int highest = 0;//height_of_highest_mountain;
    int second = 0;//height_of_second_highest_mountain;
    int third = 0;//height_of_third_highest_mountain;
    int height;
    for (int i = 0;i < 10; i++) {
        std::cin >> height;

        if (height >= highest) {
            third = second;
            second = highest;
            highest = height;
            height = 0;
        } else if (height >= second) {
            third = second;
            second = height;
            height = 0;
        } else if (height >= third) {
            third = height;
            height = 0;
        }
    }

    std::cout << highest << std::endl;
    std::cout << second << std::endl;
    std::cout << third << std::endl;

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		int answer = 0;
		for(int i = 1; i < n; ++i){
			int sum = 0;
			for(int j = i; sum < n; ++j){ sum += j; }
			if(sum == n){ ++answer; }
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <iomanip>

int main(){
  long a, b, x;
  std::cin >> a >> b >> x;
  long numA, numB;
  numA = a / x;
  if(a % x == 0) numA--;
  numB = b / x;
  std::cout << numB - numA << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll D;

int main(){
  ll G; cin >> D >> G;
  ll p[D];
  ll c[D];
  for(int i=0; i<D; i++) cin >> p[i] >> c[i];
  
  ll ans=0;
  int temp=0;
  int count=10000;
  for(int bit=0; bit<(1<<D); bit++){
    int frag=0;
    for(int i=D-1; i>=0; i--){
      if(bit & (1<<i)){
        for(int j=0; j<p[i]; j++){
          ans += (i+1)*100;
          temp++;
          if(ans >= G){
            frag=1;
            break;
          }
        }
        if(!frag) ans+=c[i];
      }
      if(ans>=G) break;
    }
    if(ans>=G) count = min(count, temp);
    ans=0;
    temp=0;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<int> count(N, 0);
    loop(i, M){
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        ++count[ai];
        ++count[bi];
    }
    for (auto& c : count){
        printf("%d\n", c);
    }
}


Measured memory_bytes: 256
import math

n, m = map(int, input().split())
n_f = math.factorial(n)
m_f = math.factorial(m)
mod = 1000000007

if abs(n-m) > 1:
    print(0)
    exit()
if n == m:
    print((n_f * m_f * 2) % mod)
else:
    print((n_f * m_f) % mod)

Measured memory_bytes: 11276
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = input().unwrap();
    let s: VecDeque<char> = input::<String>().unwrap().chars().collect();
    let mut ans = s.clone();
    let mut debt = 0;
    for c in s {
        if c == ')' {
            debt -= 1;
        } else {
            debt += 1;
        }
        if debt < 0 {
            ans.push_front('(');
            debt += 1;
        }
    }
    for _i in 0..debt {
        ans.push_back(')');
    }

    println!("{}", ans.into_iter().collect::<String>());
}

pub fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

pub fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define mp make_pair
#define pb push_back
#define ins insert
#define si size()
#define E exp(1.0)
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#pragma GCC optimize(2)
using namespace std;
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void put1(){ puts("YES") ;}void put2(){ puts("NO") ;}void put3(){ puts("-1"); }
ll qp(ll a,ll b, ll p){ll ans = 1;while(b){if(b&1){ans = (ans*a)%p;--b;}a =
(a*a)%p;b >>= 1;}return ans%p;}ll Inv(ll x,ll p){return qp(x,p-2,p);}
ll Cal(ll n,ll m,ll p){if (m>n) return 0;ll ans = 1;for(int i = 1; i <= m; ++i)
ans=ans*Inv(i,p)%p*(n-i+1)%p;return ans%p;}

const int manx=3e5+5;

ll a[33]{0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    ll n=read();
    cout<<a[n];
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include<queue>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
using ll = long long;
using IR = pair<int, int>;

int N;
string S[200000];

int main() {
	vector<string> ans;
	S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}

	sort(S, S + N);

	int max = -1;
	int num = 0;
	R(i, N) {
		if (i > 0) {
			if (S[i] == S[i - 1]) num++;
			else num = 0;
		}
		if (num == max) {
			ans.push_back(S[i]);
		}
		else if (num > max) {
			max = num;
			ans.clear();
			ans.push_back(S[i]);
		}
	}
	R(i, ans.size()) {
		printf("%s\n", ans[i].c_str());
	}
}



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


int main() {
	int n; cin >> n;
	int a[100001];
	for (int i = 0; i < n+1; i++) {
		cin >> a[i];
	}

	long long q = 0;
	for (int i = 0; i < n; i++) {
		int b; cin >> b;
		if (b < a[i]) {
			q += b;
		}
		else {
			q += a[i]; b -= a[i];
			if (a[i + 1] < b) {
				q += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				q += b;
				a[i + 1] -= b;
			}
		}
	}

	cout << q << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,in[M],c2;
map<int,int> cnt;
int main()
{
    while (~scanf("%d", &n)) {
        c2 = 0;
        cnt.clear();
        REP(i,1,n) {
            scanf("%d", &in[i]);
            cnt[in[i]]++;
            if (cnt[in[i]] == 1) c2++;
        }

        auto chk0 = [&]() {
            if (c2 != 2) return false;
            if (cnt[0] == 0) return false;
            int x = -1;
            for (auto i: cnt) if (i.second && i.first) {
                x = i.second;
                break;
            }

            if (x-cnt[0] == 1) return true;
            if (x==cnt[0]) return true;
            return false;
        };
        auto chk1 = [&]() {
            if (c2 != 3) return false;
            vector<int> tmp;

            for (auto i: cnt) if (i.second) {
                if (i.second != n/3) return false;
                tmp.push_back(i.first);
            }
            
            if ((tmp[0]^tmp[1])==tmp[2])  return true;
            return false;
        };
        auto chk2 = [&]() {
            if (c2 != 2) return false;
            if (cnt[0] != n/3) return false;
            for (auto i: cnt) if (i.second && i.first) {
                if (i.second != n/3*2) return false;
            }
            return true;
        };


        if (cnt[0]==n) puts("Yes");
//        else if (chk0()) puts("Yes");
        else if (n%3 != 0) puts("No");
        else if (chk1()) puts("Yes");
        else if (chk2()) puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 4224
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int64_t solve(const vector<int64_t> &a, int64_t init) {
    const int n = a.size();
    int64_t cnt = abs(init);
    int64_t acc = a[0] + init;

    rep(i, n - 1) {
        int64_t next = acc + a[i + 1];

        if (acc > 0 and next >= 0) {
            cnt += next + 1;
            next = -1;
        }
        if (acc < 0 and next <= 0) {
            cnt += -next + 1;
            next = 1;
        }
        acc = next;
    }
    return cnt;
}
int main() {
    int n; cin >> n;
    vector<int64_t> a(n);
    for (auto &e: a) { cin >> e; };

    int64_t ans = min({solve(a, 0),
                       solve(a, -a[0] - 1),
                       solve(a, -a[0] + 1)});
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807
#define NN 9
#define N 3

typedef struct Pazzle
{
    int frame[N][N];
    int space[2];
    int level;

    bool operator<(const Pazzle &p) const
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (frame[i][j] == p.frame[i][j])
                    continue;
                return frame[i][j] > p.frame[i][j];
            }
        }
        return false;
    };
} Pazzle;

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

bool equal(Pazzle a, Pazzle b)
{
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            if (a.frame[i][j] != b.frame[i][j])
                return false;
    return true;
}

int solve(Pazzle start)
{
    Pazzle goal;
    queue<Pazzle> q;
    map<Pazzle, bool> V;

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            goal.frame[i][j] = (j + i * 3 + 1) % 9;
    goal.space[0] = 2;
    goal.space[1] = 2;

    if (equal(start, goal))
        return 0;
    V[start] = true;
    q.push(start);

    while (1)
    {
        Pazzle u = q.front();
        q.pop();

        for (int i = 0; i < 4; i++)
        {
            Pazzle v = u;
            int x = v.space[0] + dx[i];
            int y = v.space[1] + dy[i];

            if (x >= 0 && x < N && y >= 0 && y < N)
            {
                swap(v.frame[v.space[1]][v.space[0]], v.frame[y][x]);
                v.space[1] = y;
                v.space[0] = x;
                v.level = u.level + 1;
                if (equal(v, goal))
                    return v.level;
                if (!V[v])
                {
                    V[v] = true;
                    q.push(v);
                }
            }
        }
    }
}

signed main()
{
    Pazzle start;
    start.level = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            int n;
            cin >> n;
            if (n == 0)
            {
                start.space[0] = j;
                start.space[1] = i;
            }
            start.frame[i][j] = n;
        }
    }

    cout << solve(start) << endl;
}


Measured memory_bytes: 30516
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll mod = 998244353;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	string S;
	cin >> N >> S;
	vector<ll>cnt(7);
	cnt[6] = N;
	ll ans = 1;
	for (int i = 0; i < 3*N; i++) {
		int c = S[i];
		if (c == 'R') {
			if (cnt[2]) {
				ans *= cnt[2];
				cnt[2]--;
			}
			else if (cnt[3]) {
				ans *= cnt[3];
				cnt[3]--;
				cnt[0]++;
			}
			else if (cnt[5]) {
				ans *= cnt[5];
				cnt[5]--;
				cnt[1]++;
			}
			else {
				ans *= cnt[6];
				cnt[6]--;
				cnt[4]++;
			}
		}
		else if (c == 'G') {
			if (cnt[1]) {
				ans *= cnt[1];
				cnt[1]--;
			}
			else if (cnt[4]) {
				ans *= cnt[4];
				cnt[4]--;
				cnt[0]++;
			}
			else if (cnt[5]) {
				ans *= cnt[5];
				cnt[5]--;
				cnt[2]++;
			}
			else {
				ans *= cnt[6];
				cnt[6]--;
				cnt[3]++;
			}
		}
		else {
			if (cnt[0]) {
				ans *= cnt[0];
				cnt[0]--;
			}
			else if (cnt[3]) {
				ans *= cnt[3];
				cnt[3]--;
				cnt[2]++;
			}
			else if (cnt[4]) {
				ans *= cnt[4];
				cnt[4]--;
				cnt[1]++;
			}
			else {
				ans *= cnt[6];
				cnt[6]--;
				cnt[5]++;
			}
		}
		ans %= mod;
	}
	puts(ans);

	return 0;
}



Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>
#include<unordered_set>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct node
{
	node():left(-1),right(-1),depth(1){}
	int left,right,depth;
};
node memo[100010];

unordered_set<ll> mp;

ll f(ll n)
{
	ll ret = 1;
	if(n == 0)return 0;
	while(n % (ret*2) == 0)
	{
		ret *= 2;
	}
	return ret;
}

int main()
{
	ll n,l;cin >> n >> l;l++;
	int po = 1;
	REP(i,n)
	{
		string tmp;cin >> tmp;
		ll str = 0;
		REP(i,tmp.size())
		{
			int tmtm = str;
			if(tmp[i] == '0')str = memo[str].left;
			else str = memo[str].right;
			if(str == -1)
			{
				if(tmp[i] == '0')memo[tmtm].left = po;
				else memo[tmtm].right = po;
				str = po;memo[str].depth = memo[tmtm].depth+1;
				po++;
			}
		}
	}
	
	
	ll ans = 0;
	REP(i,po)
	{
		ll cou = 0;
		if(memo[i].left == -1)cou++;
		if(memo[i].right == -1)cou++;
		
		if(cou == 1)
		{
			ll tmp = f(l - memo[i].depth);
			ans ^= tmp;
		}
	}
	
	
	if(ans == 0)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Alice" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
    int main(){
      char s[200010],t[200010];
      int i,c=0;
      scanf("%s %s",s,t);
      for(i=0;s[i];i++){
        if(s[i]-t[i])c++;
      }
      printf("%d\n",c);
      return 0;
    }

Measured memory_bytes: 2088
import math
while True:
    n = int(input())
    if n==0:
        break
    s = list(map(int, input().split()))
    sum = 0.0
    for i in range(n):
        sum += s[i]
    average = sum / n
    a2 = 0.0
    for i in range(n):
        a2 += (s[i]-average)**2 / n
    a = math.sqrt(a2)
    print('%.8f'%a)


Measured memory_bytes: 5704
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

a, b = input_a

puts a * b


Measured memory_bytes: 14316
S=input()
f=True
while len(S)>0:
    if S.endswith('dream') or S.endswith('erase'):
        S=S[:-5]
    elif S.endswith('eraser'):
        S=S[:-6]
    elif S.endswith('dreamer'):
        S=S[:-7]
    else:
        f=False
        break
print('YES' if f else 'NO')

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

using namespace std;

const int inf=30000;

int edge[30000],nxt[30000],flow[30000],first[300];
int g[300],h[300];
char c[300][300];
int i,j,m,n,s,head,tail,sum_edge;

inline void addedge(int x,int y,int f)
{
	sum_edge++,edge[sum_edge]=y,flow[sum_edge]=f,nxt[sum_edge]=first[x],first[x]=sum_edge;
	return;
}

inline int oppedge(int x)
{
	return ((x-1)^1)+1;
}

inline void buildgraph()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%s",c[i]+1);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			switch (c[i][j])
			{
				case 'S':
					addedge(0,i,inf),addedge(i,0,0);
					addedge(0,n+j,inf),addedge(n+j,0,0);
					break;
				case 'T':
					addedge(i,n+m+1,inf),addedge(n+m+1,i,0);
					addedge(n+j,n+m+1,inf),addedge(n+m+1,n+j,0);
					break;
				case 'o':
					addedge(i,n+j,1),addedge(n+j,i,1);
					break;
			}
	return;
}

inline int dinic_bfs()
{
	memset(h,0,sizeof(h));
	tail=1,g[tail]=0,h[g[tail]]=1;
	for (head=1;head<=tail;head++)
		for (i=first[g[head]];i!=0;i=nxt[i])
			if ((flow[i]) && (! h[edge[i]]))
				tail++,g[tail]=edge[i],h[g[tail]]=h[g[head]]+1;
	return h[n+m+1];
}

inline int dinic_dfs(int now,int cap)
{
	if (now==n+m+1)
		return cap;
	int s=0,t=0;
	for (int i=first[now];i!=0;i=nxt[i])
		if ((flow[i]) && (h[edge[i]]==h[now]+1))
		{
			t=dinic_dfs(edge[i],min(cap,flow[i]));
			s=s+t,cap=cap-t;
			flow[i]=flow[i]-t,flow[oppedge(i)]=flow[oppedge(i)]+t;
			if (! cap)
				break;
		}
	if (cap)
		h[now]=0;
	return s;
}

inline void maxflow()
{
	while (dinic_bfs())
		s=s+dinic_dfs(0,inf);
	if (s>n*m)
		printf("-1");
	else
		printf("%d",s);
	return;
}

int main()
{
	buildgraph();
	maxflow();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

int main() {
    ll N, D, X;
    cin >> N >> D >> X;
    vll A(N);
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        int j = 0;
        while (j * A[i] + 1 <= D) {
            ++ans;
            ++j;
        }
    }
    ans += X;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
x = list(map(int,input().split()))
min_space = 10**9
for i in range(N-K+1):
    min_space = min(x[i+K-1] - x[i]+min(abs(x[i]),abs(x[i+K-1])),min_space)
# for i in range(N-K):
#     if x[i+K-1] - x[i]==min_space:
#         min_x = x[i]

print(min_space)

Measured memory_bytes: 15020
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	int n,m;
	cin >> n >> m;
	char tab[n][n], stb[m][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin >> tab[i][j];
		}
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin >> stb[i][j];
		}
	}
	for(int i=0;i<n-m+1;i++)
	{
		for(int j=0;j<n-m+1;j++)
		{
			bool ok =1;
			for(int k=0;k<m;k++)
			{
				for(int l=0;l<m;l++)
				{
					if(tab[i+k][j+l] != stb[k][l])
					{
						ok = 0;
						break ;
					}
				}
			}
			if(ok==1)
			{
				cout << "Yes\n";
				return ;
			}
		}
	}
	cout << "No\n";
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;

int main()
{

    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int ret = 0x7FFFFFFF;

    ret = min(ret, abs(a1 - a2) + abs(a2 - a3));
    ret = min(ret, abs(a1 - a3) + abs(a3 - a2));
    ret = min(ret, abs(a2 - a1) + abs(a1 - a3));

    cout << ret << endl;

    return 0;
}

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

if A+B <= C*2:
    min_cost = A*X + B*Y
    
else:
    if X <= Y:
        if B >= C*2:
            min_cost = C*2*X+C*2*(Y-X)
        else:
            min_cost = C*2*X+B*(Y-X)
            
    else:
        if A >= C*2:
            min_cost = C*2*Y+C*2*(X-Y)
        else:
            min_cost = C*2*Y+A*(X-Y)

print(min_cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,m,k,i,j,a[100100],b[100100],f[100100];
bool was[100100];
vector<int> v;
int main() {
  scanf("%d%d%d",&n,&m,&k);
  for (i=0; i<k; i++) scanf("%d",&a[i]);
  for (i=1; i<=m; i++) b[i]=-1;
  for (i=k-1; i>=0; i--) if (!was[a[i]]) {
    was[a[i]]=true;
    b[a[i]]=v.size();
    v.push_back(a[i]);
  }
  for (i=1; i<=m; i++) if (!was[i]) break;
  for (m=v.size(); m>0 && v[m-1]<i; m--) i=v[m-1];
  for (i=k-1; i>=0; i--) {
    j=b[a[i]];
    f[j]=min(n,(j>0)?min(f[j]+1,f[j-1]):(f[j]+1));
  }
  puts((m==0 || f[m-1]>=n)?"Yes":"No");
  return 0;
}


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

int n, k;

// dp[i] = 整数iの状態から勝つ確率
double dp[200005]; 

double solve(int i) {
    if (dp[i] >= 0) return dp[i];
    return dp[i] = solve(2*i) / 2.0;
}

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

    rep(i,100005) dp[i] = -1.0;
    for (int i=k; i<200005; i++) dp[i] = 1.0;

    double ans = 0.0;
    for (int i=n; i >= 1; i--) {
        ans += solve(i);
    }
    ans /= n;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {// Main
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
      int n =(int) sc.nextLong();
     int m =(int) sc.nextLong();
      long x =sc.nextLong();
      
      
      long [][] arr =  new long[n][m+1];
      for(int i = 0 ; i < n ; i++) {
    	  for(int j = 0 ;  j <= m ; j++) {
    		  arr[i][j] = sc.nextLong();
    	  }
      }
     
      long min =Long.MAX_VALUE ;
      for(int i =  0 ;  i < Math.pow(2, n ) ; i++) {
    	  long[] temp = new long[m+1];
    	  int t = i ;
    	  for(int j = 0  ; j <n;j++) {
    		  if((t>>j &1) ==1) {
    			  for(int k = 0 ; k<temp.length ; k++ ) {
    				  temp[k]+=arr[j][k];
    			  }
    		  }
    	  }
    	  if(check(temp , x)) {
    		  min = Math.min(min, temp[0]);
    	  }
       }
      if(min==Long.MAX_VALUE) {
    	  System.out.println(-1);
      }else
       System.out.println(min);
	}

	private static boolean check(long[] temp, long x) {
		// TODO Auto-generated method stub
		 
		for(int i = 1 ;i< temp.length ; i++) {
			if(temp[i] < x) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 37624
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
using namespace fastIO;
const int MAXN = 100000+5;
int N,M;
std::map<int,int> S;
std::priority_queue<std::pair<int,int> > q[MAXN];
#define MP std::make_pair

struct ss{
	int P,Y;
	int pos,x;
	
	bool operator < (const ss &other) const {
		if(P == other.P) return Y < other.Y;
		return P < other.P;
	}
}p[MAXN];
int cnt;
int ans[MAXN];

inline int getlen(int x){
	int cnt=0;
	while(x){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int P[MAXN];

int main(){
	read(N);read(M);
	FOR(i,1,M) read(p[i].P),read(p[i].Y),p[i].pos = i,P[i] = p[i].P;
	std::sort(p+1,p+M+1);
	FOR(i,1,M){
		if((i == 1) || (i != 1 && p[i].P != p[i-1].P)){
			ans[p[i].pos] = cnt = 1;
			continue;
		}
		else ans[p[i].pos] = ++cnt;
	}
	FOR(i,1,M){
		int len = 6-getlen(P[i]);
		while(len--) putchar('0');
		printf("%d",P[i]);
		len = 6-getlen(ans[i]);
		while(len--) putchar('0');
		printf("%d\n",ans[i]);
	}
	return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;

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



int main() {

    ll N;
    cin >> N;
    vector<pair<ll, ll>> work(N);
    REP(i, N){
        cin >> work[i].second >> work[i].first;
    }
    sort(work.begin(), work.end());

    ll sum = 0;
    REP(i, N){
        sum += work[i].second;
        if(sum > work[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;



  
      
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3328
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	long N, i, j, k, max_num;
	cin >> N;
	max_num = 0;
	for (i = 1; i < N; i++) {
		max_num += i;
	}

	cout << max_num;
	return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int M = 3500;
int main(){
	int N;
	while(cin >> N) {
		int h, n, w;
		bool ok = 0;
		rep(i,1,M) {
			rep(j,1,M) {
				//4/N - (h+n)/hn
				long long a = (long long)N * i * j;
				long long b = (long long)i*j*4 - (long long)N*(i+j);
				if(b > 0 && a % b == 0 && a/b < M) {
					cout << i << " " << j << " " << a/b << endl;
					ok = 1;
					break;
				}
			}
			if(ok) break;
		}
	}
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define eb emplace_back

int in(){int x;cin>>x;return x;}
main(){
    while(1){
        int t=in();
        int p=in();
        int r=in();
        if(!t and !p and !r)exit(0);
        vector<vector<int>> pen(t,vector<int>(p));
        vector<int> T(t),cnt(t);
        rep(i,r){
            int id=in()-1;
            int pid=in()-1;
            int tim=in();
            string val;cin>>val;
            if(val[0]=='C'){
                T[id]+=tim;
                T[id]+=pen[id][pid]*1200;
                cnt[id]++;
            }
            else pen[id][pid]++;
        }
        vector<int> id(t);
        iota(id.begin(),id.end(),0);
        sort(id.begin(),id.end(),[&](int x,int y){
            if(cnt[x]!=cnt[y]) return cnt[x]>cnt[y];
            else if(T[x]!=T[y]) return T[x]<T[y];
            else return x<y;
        });
        rep(i,t){
            cout<<id[i]+1<<" "<<cnt[id[i]]<<" "<<T[id[i]]<<endl;
        }
    }
}


Measured memory_bytes: 3168
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    set_a = set(a)
    if len(set_a) == n:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 25172
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e2;
ll d[mm];
ll dd[mm];
int vis[mm];
vector<ll> v;
int main()
{
	ll i,j,ss;
	string s;
	cin>>s; ss=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='h'&&s[i+1]=='i')
		{
			i++;
			continue;
		}
		else
		ss=1;
	}
	if(ss)
	printf("No\n");
	else
	printf("Yes\n");
	
}

Measured memory_bytes: 256