akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());

        var ret = 0;
        for (var i = 1; i <= input; i++)
        {
            if (i.ToString().Length % 2 == 0) continue;
            ret++;
        }

        Console.Write(ret);
    }
}



Measured memory_bytes: 13140
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
    int x,a,b,d1,d2;
    cin>>x>>a>>b;
   d1=abs(x-a);
   d2=abs(x-b);
   if(d1>d2){
    cout<<"B"<<endl;
   }
   else
    cout<<"A"<<endl;

return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  for(int i = 0; i < gy - sy; i++) cout << 'U';
  for(int i = 0; i < gx - sx; i++) cout << 'R';
  cout << 'U';
  for(int i = 0; i <= gx - sx; i++) cout << 'L';
  for(int i = 0; i <= gy - sy; i++) cout << 'D';
  cout << 'R';
  for(int i = 0; i < gx - sx; i++) cout << 'R';
  for(int i = 0; i < gy - sy; i++) cout << 'U';
  cout << 'R';
  for(int i = 0; i <= gy - sy; i++) cout << 'D';
  for(int i = 0; i <= gx - sx; i++) cout << 'L';
  cout << 'U';
}

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

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

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

const long double EPS = 1e-12;
const int INF = 10000;


long num[100001];
int main(){
	vector<long>prime;
	FOR(i,2,200000){
		bool flag=true;
		for(int j=2;j*j<=i;j++)if(i%j==0)flag=false;
		if(flag)prime.PB(i);
	}
	
	int N,P;
	while(cin>>N>>P){
		if(N==-1&&P==-1)break;
		long pos=distance(prime.begin(),upper_bound(ALL(prime),N));
		vector<long>rnk;
		FOR(i,pos,pos+100)FOR(j,i,pos+100)rnk.PB(prime[i]+prime[j]);
		SORT(rnk);
		cout<<rnk[P-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll x;
	ll ans=0LL;
	cin >>x;
	ans+=(x/11)*2;
	x%=11LL;
	if(x >0){
		ans++;
		if(x>6){
			ans++;
		}
	}

	cout<<ans<<endl;
}

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

int n;
vector<int> s;
int sum, ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		s.push_back(t);
	}
	for(int i=0; i<n; ++i)
		sum += s[i];
	if(sum % 10 != 0) ans = sum;
	for(int i=0; i<n; ++i)
		if((sum - s[i]) % 10 != 0)
			ans = max(ans, sum - s[i]);
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int w,h,n,i;
    cin>>w>>h>>n;
    int lx=0,ux=w,ly=0,uy=h;
    int x,y,a;
    for (i=0;i<n;i++)
    {
        cin>>x>>y>>a;
        if (a==1)
            lx=max(lx,x);
        else if (a==2)
            ux=min(ux,x);
        else if (a==3)
            ly=max(ly,y);
        else
            uy=min(uy,y);
    }
    if (lx<=ux && ly<=uy)
        cout<<(ux-lx)*(uy-ly)<<endl;
    else
        cout<<"0\n";
}

Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	ll n,a,b; scanf("%lld%lld%lld",&n,&a,&b);
	printf("%lld",n/(a+b)*a+min(n%(a+b),a));
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	int n; cin >> n;
	rep(i, 70000) {
		if (floor(i*1.08) == n) {
			cout << i << endl; return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i += 2){
        Alice += a[i];
    }
    for (int i = 1; i < N; i +=2){
        Bob += a[i];
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long 
using namespace std; 
int FindLCM(int a, int b) 
{ 
    return (a * b) / __gcd(a, b); 
} 

int rangeDivisor(int m, int n, int a, int b) 
{ 
    int lcm = FindLCM(a, b); 

    int a_divisor = n / a - (m - 1) / a; 
    int b_divisor = n / b - (m - 1) / b; 

    int common_divisor = n / lcm - (m - 1) / lcm; 

    int ans = a_divisor + b_divisor - common_divisor; 
    return ans; 
} 

int32_t main() 
{ 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=(b-a+1)-(rangeDivisor(a,b,c,d));
    cout<<ans;
    return 0; 
} 


Measured memory_bytes: 256
lst = list(map(int, input().split()))

lst.sort()

mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av
ans1 = 0
mini += d
d2 = max - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans1 += 1

else:
    d2 = d2 // 2

ans1 += d + d2

ans2 = 0
mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av

mini += d

d2 = max + 1 - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans2 += 1
else:
    d2 = d2 // 2

ans2 += d + d2 + 1

print(min(ans1, ans2))





Measured memory_bytes: 3064
dica=[]
dicb=[]

S=raw_input()
T=raw_input()

N=len(S)

a=''
b=''
countA=0
countB=0
flag=0
for i in range(N):
	if S[i] in dica:
		a+=str(dica.index(S[i]))
	else:
		dica.append(S[i])
		a+=str(dica.index(S[i]))
		
	if T[i] in dicb:
		b+=str(dicb.index(T[i]))
	else:
		dicb.append(T[i])
		b+=str(dicb.index(T[i]))
		
	if a!=b:
		print 'No'
		flag=1
		break
				

if flag==0:
	if a==b:
		print 'Yes'
	else:
		print 'No'

Measured memory_bytes: 9792
import sys
input = sys.stdin.readline

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

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

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [ai//2 for ai in a]
    
L = 1

for bi in b:
    L = lcm(L, bi)

flag = True

for i in range(N):
    if (L-b[i])%a[i]!=0:
        flag = False
    
if not flag:
    print(0)
    exit()
    
L2 = 1

for ai in a:
    L2 = lcm(L2, ai)

if L>M:
    print(0)
else:
    print((M-L)//L2+1)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A.at(i)=a;
  }
  for(int i=0;i<N;i++)
    for(int j=N-1;j>i;j--)
      if(A.at(j)>A.at(j-1)){
        int k=A.at(j);
        A.at(j)=A.at(j-1);
        A.at(j-1)=k;
      }
  int j=0;
  for(int i=0;i<N;i++){
    if(i%2==0)
      j+=A.at(i);
    else
      j-=A.at(i);
  }
  cout << j << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		p[i] = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
		if (i - 1 >= 0) p[i] = max(p[i], p[i - 1] + 1);
	}
	for (int i = n - 2; i >= 0; i--) {
		p[i] = max(p[i], p[i + 1] - 1);
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == b[p[i] % n]) {
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << "\n";
	for (int i = 0; i < n; i++) {
		cout << b[p[i] % n] << " \n"[i == n - 1];
	}
	return 0;
}


Measured memory_bytes: 5560
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >>a;
    cin >>b;
    if (a<=5) {
        cout << "0" << endl;
    }
    else if (a>=6&&a<=12) {
        cout << b / 2 << endl;
    }
    else {
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100][2][5];

int main(){
  string N;
  int K;
  vector<int> n;
  cin >> N >> K;
  int l = N.size();
  for(auto a : N) n.push_back(a-'0');
  
  dp[0][0][0]=1;
  dp[0][1][0]=0;
  dp[0][0][1]=0;
  dp[0][1][1]=0;
  for(int i=0; i<l; i++){
    for(int smaller=0; smaller<2; smaller++){
      for(int j=0; j<5; j++){
        for(int x=0; x <= (smaller ? 9 : n[i]); x++){
          dp[i+1][smaller || x<n[i]][x!=0 ? min(4, j+1) : j]+=dp[i][smaller][j];
        }
      }
    }
  }
  cout << dp[l][0][K]+dp[l][1][K] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	int H, W, N;
    cin >> H >> W >> N;

    int a = max(H,W);

    int ans = N/a;
    if (N%a>0){
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val k = sc.nextInt()

    val sq = Array.fill(h)(sc.next().split("").filter(_ != "").map(_ == "#")).flatten

    val wps = powerSet((0 until w).toList)
    val hps = powerSet((0 until h).toList)

    var ans = 0

    wps.foreach { wl =>
      val wp = wl.flatMap(wi => (0 until h).map(i => w * i + wi))
      hps.foreach { hl =>
        val hp = hl.flatMap(hi => (0 until w).map(i => i + hi * w))
        val po = (wp ++ hp).toSet

        var cnt = 0
        (0 until h * w).foreach(i => if (sq(i) && !po.contains(i)) cnt += 1)

        if (cnt == k) ans += 1
      }
    }

    println(ans)
  }


  def powerSet[A](xs: List[A]): List[List[A]] =
    xs.foldLeft(List(Nil: List[A]))((accum, elem) => accum.flatMap(l => Seq(l, elem :: l)))

}


Measured memory_bytes: 60928
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<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
#endif



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
  

    int n;
    cin>>n;
    set<int> st;
    rep(i,0,n){
        int a;
        cin>>a;
        st.insert(a);
    }
    // int val = ;
    cout<<st.size() - (st.size()%2==0) ;
 
 
    
 
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, n + 1)
    {
        cin >> a[i];
    }
    vector<int> b(n);
    rep(i, n)
    {
        cin >> b[i];
    }
    ll ans = 0;
    rep(i, n)
    {
        if (a[i] <= b[i])
        {
            ans += a[i];
            b[i] -= a[i];
            if (a[i + 1] <= b[i])
            {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
            else
            {
                ans += b[i];
                a[i + 1] -= b[i];
            }
        }
        else
        {
            ans += b[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void)
{
	int n,x,y,a,b;
	int g,min;

	scanf("%d",&n);
	
	while(n!=0){
		scanf("%d %d %d %d",&x,&y,&a,&b);
		g=x*a+y*b;
		if(a>4 && b>1)	min=g*0.8;

		else if(a<5){
			if(b<2) min=(x*5+y*2)*0.8;
			else min=(x*5+y*b)*0.8;
		}
		else {
			if(b<2) min=(x*a+y*2)*0.8;
			else min=(x*b+y*b)*0.8;
		}

		if(g>min) g=min;
		printf("%d\n",g);
		n--;
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009
#define MOD MOD7

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int tatekeisu[100010];
int yokokeisu[100010];

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

	vector<int> tx, ty;
	inputVector(tx, n);
	inputVector(ty, m);

	vector<int> x(n - 1), y(m - 1);

	rep(i, n - 1) {
		x[i] = tx[i + 1] - tx[i];
	}
	rep(i, m - 1) {
		y[i] = ty[i + 1] - ty[i];
	}
	n--; m--;

	REP(i, 1, n) {
		if (i <= (n + 1) / 2) {
			tatekeisu[i] = i * (n - i + 1);
			tatekeisu[i] %= MOD;
		} else {
			tatekeisu[i] = tatekeisu[n - i + 1];
		}
	}
	REP(i, 1, m) {
		if (i <= (m + 1) / 2) {
			yokokeisu[i] = i * (m - i + 1);
			yokokeisu[i] %= MOD;
		} else {
			yokokeisu[i] = yokokeisu[m - i + 1];
		}
	}

	int tate = 0;
	rep(i, n) {
		tate += tatekeisu[i + 1] * x[i];
		tate %= MOD;
	}

	int yoko = 0;
	rep(i, m) {
		yoko += yokokeisu[i + 1] * y[i];
		yoko %= MOD;
	}

	int ret = (tate * yoko) % MOD;

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define P pair<ll, ll>
#define VI vector<ll>
#define int long long
using namespace std;

signed main() {
  int n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
typedef long long ll;
int main(void){
    string s;
    cin >> s;
    vector<bool> a;
    a.resize(26);
    for(int i = 0;i < s.size();i++) a[s[i]-'a'] = true;
    
    for(int i = 0;i < 26;i++){
        if(!a[i]){
            cout << (char)(i+'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
# rerootingは後で
from collections import deque
n=int(input())
e = [[] for _ in range(n)]

for i in range(n-1):
    ai,bi=map(int,input().split( ))
    ai-=1;bi-=1
    e[ai].append(bi)
    e[bi].append(ai)

deg = [len(e[i]) for i in range(n)]
dep0 = [-1]*n
dep0[0]=0

Q=deque();Q.append(0)

while Q:
    v=Q.popleft()
    for u in e[v]:
        if dep0[u]<0:
            dep0[u]=dep0[v]+1
            Q.append(u)
size = [1]*n
for i in range(n):
    flag=True
    for j in e[i]:
        if dep0[i]<dep0[j]:
            flag=False
            break
    if flag:
        Q.append(i)
while Q:
    v=Q.popleft()
    for u in e[v]:
        if dep0[u]<dep0[v]:
            size[u]+=size[v]
            deg[u]-=1
            if deg[u]==1 and u:
                Q.append(u)
ans=0
mod=10**9+7
x=pow(2,mod-2,mod)
#pw=[1]*(n+1)
pw_rev=[1]*(n+1)
for i in range(1,n+1):
    #pw[i] = pw[i-1] * 2 % mod
    pw_rev[i] = pw_rev[i-1] * x % mod
for u in range(n):
    for v in e[u]:
        if dep0[u]<dep0[v]:#dep
            ans += (1 - pw_rev[size[v]]) * (1 - pw_rev[n-size[v]])
    ans%=mod
## 空集合の場合
print((ans-n*x+1-pw_rev[n]) % mod)


Measured memory_bytes: 97400
#include<bits/stdc++.h>
using namespace std;
const int tot=26+26+10;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} 
char enc(int t){
	if(t<10)return '0'+t;
	t-=10;
	if(t<26)return 'a'+t;
	t-=26;
	return 'A'+t;
}
 
string s[tot];
int sum=tot;
int ttm=0;
inline int query (string str){
	if (str.size() > 128) return 1e9;
	cout << '?' << ' ' << str << '\n';
	fflush(stdout); int ans = 0; read (ans); return ans;
}
 
 
int len=0x3f3f3f3f;
int q[tot];
 
string merge(string a,string b){
	int i=0,j=0;
	int la=a.length(),lb=b.length();
	string fir=string();
	while(i<la&&j<lb){
		string qr=fir;
		qr+=a[i];
		for(int k=j;k<lb;k++){
			qr+=b[k];
		}
		if(query(qr)+qr.length()==len){
			fir+=a[i++];
		}else {
			fir+=b[j++];
		}
	}
	while(i<la)fir+=a[i++];
	while(j<lb)fir+=b[j++];
	return fir;
}
 
int main()
{
	for(int i=0;i<tot;i++){
		s[i]+=enc(i);
		q[i]=query(s[i])+1;
		len=min(len,q[i]);
	}
	for(int i=0;i<tot;i++){
		if(q[i]==len){
			while(query(s[i]+enc(i))+s[i].length()+1==len)s[i]+=enc(i);
		}else s[i]=string();
	}
	while(1){
    	for(int i=0;i<tot;i++)for(int j=i+1;j<tot;j++)if(s[i].length()>s[j].length())swap(s[i],s[j]);
		int t=0;
		while(!s[t].length())++t;
		if(t+1==tot)break ;
		s[t+1]=merge(s[t],s[t+1]); s[t]=string();
	}
	assert(query(s[tot-1])==0);
	cout << "! "<< s[tot-1] << endl;
	fflush(stdout);
}


Measured memory_bytes: 3796
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int max = 1130;
        boolean[] p = new boolean[max];
        for(int i=2; i<max; i++) p[i] = true;
        for(int i=2; i<Math.sqrt(max); i++){
            for(int j=i*i; j<max; j+=i) p[j] = false;
        }

        int[][] dp = new int[max][15];
        dp[0][0] = 1;
        for(int s=0; s<max; s++){
            if(!p[s]) continue;
            for(int i=max-1; i>=s; i--){
                for(int j=1; j<15; j++){
                    dp[i][j] += dp[i-s][j-1];
                }
            }
        }


        while(true){
            int n = sc.nextInt(), k = sc.nextInt();
            if(n==0 && k==0) break;
            System.out.println(dp[n][k]);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 21092
#include <iostream>
int main( void )
{
    int a, b, c;
    int ans = 0;
    std::cin >> a >> b >> c;
    
    for ( int i = a; i <= b; i++ )
    {
        if ( ( c % i ) == 0 )
        {
            ans++;
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

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

n = inp()
a = sorted(inpl())
print(max(0, a[n//2]-a[n//2-1]))

Measured memory_bytes: 79596
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
void input()
{
    cin>>N;
    A.resize(N);
    rep(i,0,N-1){
        cin>>A[i];
    }
}
int dp[512322];
void solve()
{
    rep(i,1,N+3)dp[i]=INF;
    dp[0] = 0;
    rep(i,0,N-1){
        if (i+1<N)
        dp[i+1] = min(dp[i+1], dp[i]+abs(A[i]-A[i+1]));
        if (i+2<N)
        dp[i+2] = min(dp[i+2], dp[i]+abs(A[i]-A[i+2]));
    }
    cout<<dp[N-1]<<endl;



}
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1920
import math
a,b  = map(int,input().split())



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

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
  
print(lcm(a, b))

Measured memory_bytes: 3064
import sys
n = int(input())
# a = tuple(input().split())
a = tuple(map(int,sys.stdin.readline().split()))
q = int(input())
# for _ in range(q):
#     if input() in a:print('1')
#     else:print('0')
for k in sys.stdin:
    k = int(k.strip())
    if k < a[0] or a[-1] < k:
        print('0')
    else:
        j1 = 0
        j2 = len(a)
        for _ in range(len(a)):
            j = (j1 + j2) // 2
            if k == a[j]:
                print('1')
                break
            else:
                if a[j] < k:j1 = j
                else:j2 = j
                if j1 + 1 == j2:
                    if k == a[j1] or k == a[j2]:
                        print('1')
                        break
                    else:
                        print('0')
                        break
            if _ == len(a)-1:print('0')


Measured memory_bytes: 16844
# import sys
# input = sys.stdin.readline
import collections

def main():
    n = int(input())
    s = input()
    a_list = []
    for i in range(n):
        if s[i] == "W":
            a_list.append(0)
        else:
            a_list.append(1)
    r_count = sum(a_list)
    print(r_count - sum(a_list[0:r_count]))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12568
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
void vout(vl V) {
	for (ll i = 0; i < (ll)V.size(); i++) cout << V[i] << " ";
	cout << endl;
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color; vll path; vl A; vl dp; vl Ans;
//***********//
int main() {
	cin >> N;
	vl C(26,INF); 
	for (i = 0; i < N; i++) {
		string S;
		cin >> S;
		vl pre(26, 0);
		for (j = 0; j < S.length(); j++) {
			pre[S[j] - 'a']++;
		}
		for (j = 0; j < 26; j++) {
			C[j] = min(C[j], pre[j]);
		}
	}
	for (i = 0; i < 26; i++) {
		for (j = 0; j < C[i];j++) {
			char key = 'a' + i;
			cout << key;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Next Mayor
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int p = sc.nextInt();
			if((n|p)==0)break;
			int w = p;
			int[] s = new int[n];
			int k=0;
			int ans = -1;
			while(true){
				if(w > 0){
					s[k]++;
					w--;
				}
				else{
					w += s[k];
					s[k] = 0;
				}
				if(s[k]==p){
					ans = k;
					break;
				}
				k = (k+1)%n;
			}
			System.out.println(ans);
		}
	}
}

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

using namespace std;

int c[1005][1005];
int n, m, a, b;
int main(){
	scanf("%d%d%d%d", &n, &m, &a, &b);
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			if(i <= b && j <= a) c[i][j] = 0;
			else if(i > b && j > a) c[i][j] = 0;
			else c[i][j] = 1; 	
		}
	}
	int flag = 1;
	for(int i = 1; i <= n; i ++){
		int cnt = 0;
		for(int j = 1; j <= m; j ++){
			cnt += c[i][j];
		}
		cnt = min(cnt, m - cnt);
		if(cnt != a){
			flag = -1;
		}
	}
	
	for(int i = 1; i <= m; i ++){
		int cnt = 0;
		for(int j = 1; j <= n; j ++){
			cnt += c[j][i];
		}
		cnt = min(cnt, n - cnt);
		if(cnt != b){
			flag = -1;
		}
	}
	if(flag == 1){
			
		for(int i = 1; i <= n; i ++){
			for(int j = 1; j <= m; j ++){
				printf("%d", c[i][j]);
			}
		printf("\n");
		}
	}else puts("-1");
	return 0;
}

Measured memory_bytes: 5248
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
a, b = map(int, input().split())

if a+b == 15 :
  print ("+")
elif a*b == 15 :
  print ("*")
else :
  print ("x")
  
  
  

Measured memory_bytes: 3436
#include<stdio.h>

int main(void)
{
  int a, b, c;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);

  if(a < b && b < c)
    printf("Yes\n");
  else 
    printf("No\n");

  return 0;
}

Measured memory_bytes: 1816
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

bool check(ll n){
	bool a,b,c ;
	a = b = c = false ;
	while(n>0){
		if(n%10==3) a = true ;
		else if(n%10==5) b = true ;
		else if(n%10==7) c = true ;
		n /= 10 ;
	}
	return (a&&b&&c) ;
}

int main(){
	ll n ; cin >> n ;
	queue<ll> q ;
	q.push(3) ;
	q.push(5) ;
	q.push(7) ;
	ll ans = 0 ;
	while(q.front()<=n){
		ll sub = q.front() ;
		ans += check(sub) ;
		q.pop() ;
		sub *= 10 ;
		q.push(sub+3) ;
		q.push(sub+5) ;
		q.push(sub+7) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int h[100010];
int main()
{
    int n, m, a, b, i;
    scanf("%d%d", &n, &m);
    while(m--)
    {
        scanf("%d%d", &a, &b);
        if(a == 1)
        {
            h[b]++;
        }else
        if(b == 1)
        {
            h[a]++;
        }else
        {
            h[a]++;
            h[b]++;
        }
    }
    int mark = 0;
    for(i = 2; i <= n; ++i)
    {
        if(h[i] % 2 == 1)
        {
            mark = 1;
            puts("NO");
            break;
        }
    }
    if(!mark)
        puts("YES");
    return 0;
}


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

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

int main() {
    string s;
    cin >> s;
    string ans = "";

    rep(i, s.size()) {
        if (s[i] == '0')
            ans += '0';
        else if (s[i] == '1')
            ans += '1';
        else if (s[i] == 'B' && ans.size() != 0) {
            ans.erase(ans.size() - 1, 1);
        }
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

int main(void)
{
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> div;
    for(int i = 1; i <= min(A,B); i++)
    {
        if(A % i == 0 && B % i == 0)
        {
            div.push_back(i);
        }
    }

    sort(div.begin(), div.end(), greater<int>());
    cout << div[K - 1] << endl;

    return 0;
}

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

using namespace std;

int main(void) {
	string s;
	int count[4] = {};
	bool flag = true;

	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		switch (s[i]) {
		case 'N':
			count[0]++;
			break;
		case 'E':
			count[1]++;
			break;
		case 'W':
			count[2]++;
			break;
		case 'S':
			count[3]++;
			break;
		}
	}

	if (count[0] == 0 && count[3] > 0) {
		flag = false;
	}
	if (count[3] == 0 && count[0] > 0) {
		flag = false;
	}
	if (count[1] == 0 && count[2] > 0) {
		flag = false;
	}
	if (count[2] == 0 && count[1] > 0) {
		flag = false;
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int kaijou(int i, int j){
    int m = 0;
    while(i < j){
        i *= 2;
        m++;
    }
    return m;
}   
int main(){
    int n, k; cin >> n >> k;
    double p;
    _rep(i, 1, n + 1){
        int l = kaijou(i, k);
        p += (double)(1.0 / n) * pow(0.5, l);
    }
    cout << setprecision(15) << p << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 2000000

int n, heap[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l = i*2;
    r = i*2+1;
    
    if(l<=n && heap[l]>heap[i]) largest = l;
    else largest = i;
    if(r<=n && heap[r]>heap[largest]) largest = r;

    if(largest!=i){
        swap(heap[i], heap[largest]);
        maxHeapify(largest);
    }
}


int main(){
    cin >> n;
    for(int i=1;i<=n;i++) cin >> heap[i];
    for(int i=n/2;i>0;i--) maxHeapify(i);
    for(int i=1;i<=n;i++) cout << " " << heap[i];
    cout << endl;

    return 0;
}



Measured memory_bytes: 4956
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            string s,x;
            cin>>s>>x;
            int ans=x.length();
            for (int i = 0; i <=s.length()-x.length(); ++i)
            {
                int k=0;
                for(int j=0;j<x.length();j++)
                {
                    if(x[j]!=s[i+j])
                        k++;
                }
                if(k<ans)
                    ans=k;
            }
            cout<<ans<<endl;
        }
        return 0;
    }

Measured memory_bytes: 3588
import Data.List

main :: IO ()
main = do
  [_,k] <- reads2List
  input <- reads2List :: IO [Int]
  print . sum . take k $ sortBy (flip compare) input


s2List :: Read a => String -> [a]
s2List = fmap read . words

reads2List :: Read a => IO [a]
reads2List = do
  s <- getLine
  return (s2List s)


Measured memory_bytes: 764
#C
#入力
N=int(input())
S=[input() for i in range(N)]

#処理
result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())

Z=[]
for i in result.items():
    if i[1]==x:
        Z.append(i[0])
Z.sort()
for i in Z:
    print(i)

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

int main(){
    char S[4];int a=0;
    for(int j=0; j<4;j++)
    cin>>S[j];
    for(int i=0;i<3;i++){
        if(S[i]==S[i+1]){
        a++;
        }
    }
    if(a==0)
    cout<<"Good"<<endl;
    if(a!=0)
    cout<<"Bad"<<endl;
    return 0;
}

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

#define max_n 100000

using namespace std;

typedef long long ll;

const ll B=1000;

ll a[max_n],m[max_n/B];

void update(ll i,ll x){
  a[i]=x;
  m[i/B]=INT_MAX;
  for(int j=i-i%B;j<i-i%B+B;j++)
    m[i/B]=min(m[i/B],a[j]);
}

ll find(ll s,ll t){
  ll res=INT_MAX;

  for(int i=s/B+1;i<t/B;i++){
    res=min(res,m[i]);
  }
  
  for(int i=s;i<min(s-s%B+B,t+1);i++)res=min(res,a[i]);
  for(int i=max(s,t-t%B);i<=t;i++)res=min(res,a[i]);

  return res;
}

int main(void){
  int n,q;

  cin >> n >> q;

  fill(m,m+max_n/B,INT_MAX);
  fill(a,a+max_n,INT_MAX);

  ll com,x,y;
  for(int i=0;i<q;i++){
    cin >> com >> x >> y;
    
    if(com==0)update(x,y);
    else cout << find(x,y) << endl;
  }
  
  return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int32 n = s.size();
    vector<vector<int32>> dp(n+1,vector<int32>(2,INF));

    reverse(ALL(s));
    dp[0][0] = 0;
    REP(i,n){
        dp[i+1][0] = min(dp[i][0] + s[i] - '0', dp[i][1] + s[i] - '0' + 1);
        dp[i+1][1] = min(dp[i][0] + 10 - (s[i] - '0'), dp[i][1] + 10 - (s[i] - '0') - 1);
    }
    // REP(i,n+1){
    //     REP(j,2){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ANS(min(dp[n][0], dp[n][1]+1));

    // dp[0][1] = 1;
    // FOR(i,1,n){
    //     dp[i+1][0] = min(dp[i][0] + s[i] - '0', dp[i][1] + 10 - (s[i] - '0'));
    //     dp[i+1][1] = min(dp[i][0] + s[i] - '0' + 1, dp[i][1] + 10 - (s[i] - '0'));
    // }
    // ANS(dp[n][0]);
    return 0;
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	ll ret = 0;

	for (int i = 1; i < n; i++) {
		ll tmp = a[i]+a[i-1];
		if (tmp>x) {
			ll minus = tmp-x;
			ret += minus;
			a[i] -= minus;
			if (a[i]<0) {
				a[i]=0;
			}
		}
	}
	cout << ret << endl;

}


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

int n, q;
int a[200010];
int ans[200010];

int main() {
    cin >> n >> q;
    for (int i = 0; i < n-1; ++i) {
        int a_, b_;
        cin >> a_ >> b_;
        a[b_] = a_;
    }
    for (int i = 0; i < q; ++i) {
        int p, x;
        cin >> p >> x;
        ans[p] += x;
    }
    for (int i = 2; i < n+1; ++i) ans[i] += ans[a[i]];
    for (int i = 1; i < n+1; ++i) cout << ans[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define PI 3.14159265358979323846

int main() {
	ld r;
	cin >> r;
	printf("%.10Lf\n", 2 * PI * r);

	return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
int a[1000000];
long long int ans;
void mergesort(int l,int r){
	if(l==r)return;
	if(l==r-1){
		ans+=2;
		if(a[r]<a[l]){
			int temp;
			temp=a[l];
			a[l]=a[r];
			a[r]=temp;
		}
		return;
	}
	int mid=(l+r)/2,now=0,b[r-l+1];
	mergesort(l,mid);
	mergesort(mid+1,r);
	for(int i=0;i<=r-l;i++){
	if(a[l+i-now]<a[mid+1+now]){
		b[i]=a[i+l-now];
		if(i+l-now==mid){
			for(i++;i<=r-l;i++)b[i]=a[i+l];
		}
	}
	else{
		b[i]=a[mid+1+now];
		now++;
		if(mid+now==r){
			for(i++;i<=r-l;i++){
				b[i]=a[i+l-now];
			}
		}
	}
	}
	for(int i=0;i<=r-l;i++){
		a[i+l]=b[i];
	}
	ans+=r-l+1;
}
int main(){
	int n;	
scanf("%d",&n);
ans=0;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	mergesort(0,n-1);
	printf("%d",a[0]);
	for(int i=1;i<n;i++)printf("% d",a[i]);
	printf("\n%lld\n",ans);
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    if(a1 + a2 + a3 >= 22)
        cout << "bust\n";
    else
        cout << "win\n";

    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    vector<vector<int>> sub;
    for(int i = 1; i < 1<<10; i++){
        vector<int> x;
        for(int j = 0; j < 10; j++) if((i>>j)&1)    x.push_back(j);
        sub.push_back(x);
    }

    int n, m;
    while(cin >> n >> m, n){
        vector<string> a(m);
        vector<int> b(m), c(m);
        for(int i = 0; i < m; i++)  cin >> a[i] >> b[i] >> c[i];
        vector<vector<bool>> origin(m, vector<bool>(10,0));
        for(int i = 0; i < m; i++){
            for(char c : a[i])  origin[i][c-'0'] = true;
        }
        bool no = false;
        vector<string> ans;
        for(vector<int> x : sub){
            if(x.size() != n) continue;
            do{
                bool valid = true;
                for(int j = 0; valid && j < m; j++){
                    int blow = 0, hit = 0;
                    for(int k = 0; k < n; k++){
                        hit += a[j][k]-'0'==x[k];
                        blow += origin[j][x[k]];
                    }
                    blow -= hit;
                    valid &= b[j]==hit && c[j]==blow;
                }
                if(valid){
                    if(ans.size()){
                        no = true;
                        break;
                    }
                    string tmp = "";
                    for(int j = 0; j < n; j++)  tmp += (char)('0'+x[j]);
                    ans.push_back(tmp);
                }
            }while(next_permutation(x.begin(),x.end()));
            sort(x.begin(), x.end());
            if(no)  break;
        }
        if(ans.size() == 0 || no)  cout << "NO" << endl;
        else    cout << ans[0] << endl;

    }
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define INF (ll)(1e18)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible\n";
	else cout<<"Impossible\n";
	return 0;
}











Measured memory_bytes: 256
using System;

namespace _059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            for(int i = 0; i < str.Length; i++)
            {
                str[i] = str[i].Substring(0,1).ToUpper();
                Console.Write(str[i]);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140