akhauriyash/Code-Regression huggingface dataset:
N, K = gets.chomp.split(' ').map(&:to_i)
A = gets.chomp.split(' ').map(&:to_i)

count = Hash.new(0)
A.each do |ai|
  count[ai] += 1
end

ans = 0
count.values.sort.reverse.each.with_index do |c, i|
  next if i < K
  ans += c
end

print ans

Measured memory_bytes: 34160
def insertionSort(a,n):
    for i in range(n):
        v = a[i]
        j = i-1
        while j>=0 and a[j]>v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(" ".join(map(str,a)))
    return a

n = int(input())
a = [int(i) for i in input().split()]

insertionSort(a,n)

Measured memory_bytes: 7660
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    A, B = LI()
    print(max(max(A+B, A-B), A*B))

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int h,w;cin>>h>>w;
    char s[h+2][w+2];
    for(int i=1;i<h+1;i++) for(int j=1;j<w+1;j++) cin>>s[i][j];
    for(int i=0;i<h+2;i++) {s[i][0]='a';s[i][w+1]='a';}
    for(int i=0;i<w+2;i++) {s[0][i]='a';s[h+1][i]='a';}
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            if(s[i][j]=='.'){
                int cnt=0;
                for(int k=i-1;k<=i+1;k++)for(int l=j-1;l<=j+1;l++)if(s[k][l]=='#') cnt++;
                s[i][j]=cnt+'0';
            }

        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++)cout<<s[i][j];
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;

int main() {
    ll l;
    cin >> l;
    cout << (l + l * l + l * l * l) << endl;
}




Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
#define INF (1 << 30)


priority_queue<int> PQ;

int main() { 
    string com;
    int key;
    while( 1 ) {
        cin >> com;
        if (com == "insert") {
            cin >> key;
            PQ.push(key);
        }
        else if (com == "extract") {
            cout << PQ.top() << '\n';
            PQ.pop();
        }
        else if (com == "end")
            break;
    }
}



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

int main(){
  int n;
  cin >> n;
  while(n){
    if(n%10 == 7){
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
import sys
read = sys.stdin.readline


# 下の桁から貪欲に見ていくと解ける
# 1の位が4以下ならそのまま紙幣で支払うのが得→自身をそのまま答えに採用 (枚数として加算)
# 6以上ならばお釣り狙いのほうが得→自身は0にセットして、上位桁を+1する (枚数として10-自身を加算)
# 5ちょうどのときは、お釣りもそのまま払っても枚数は変わらない。だけど555みたいに、上位桁に+1すると得になる可能性がある。
# 555→15枚, 1000-445→15枚
# つまり5が出たときは更に上位の桁を見て、4以下ならそのまま払うほうが得,5以上なら桁上りのほうが得

# 5ちょうどのときは？ #お釣りもそのまま払っても同じ。だけど上位 お釣り狙いだと上の桁が多くなって支払う金額が増える可能性がある？
# 5ピッタリのときに上位桁に+1すると悪くなる場合が存在する 455 とは 15にってしまう
# 5ピッタリのときはどうするのがよいのか？

N = '00' + read()[:-1]

N = N[::-1]
ans = 0
i = 0

lo = int(N[i])
while i < len(N) - 1:
    hi = int(N[i + 1])
    if lo == 5:  # 5のときは上の桁の大きさによってお釣りが得になるかそのまま払うのが良くなるか変化する
        ans += lo
        if hi < 5:
            pass
        else:
            hi += 1
    elif lo < 5:
        # loが5以外のとき (お釣りが良いか、そのまま払うのが良いか考えるだけ)
        ans += lo
    else:
        ans += 10 - lo
        hi += 1  # 上の桁が繰り上がる
    lo = hi  # 桁を一つずらす
    i += 1


print(ans)


Measured memory_bytes: 5516
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int a[100000];

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

    int n = gi();
    for (int i = 0; i < n; i++)
        a[i] = gi();

    for (int i = 0; i < n; i++) {
        if (i == 0 || a[i] > a[i-1])
            a[i]--;
        if (i && a[i] < a[i-1]) {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdlib>
#include<istream>
#include <stdio.h>
#include<vector>
#include <fstream>
#include <string>
#include<stdio.h>
using namespace std;
int main() {
	int P, Q, R,M;
	cin >> P >> Q >> R;
	 if (P + Q > Q + R) {
		 M = Q+R;
	 }
	 else {
		 M = P + Q;
	 }
	 if (M < P + R) {}
	 else {
		 M = P + R;
		 }
	 cout << M <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  string ans = "";
  while (N != 0) {
    if (N % 2 != 0) {
      N--;
      ans = "1" + ans;
    } else ans = "0" + ans;
    N /= -2;
  }
  if (ans == "") ans = "0";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.chop.to_i

l = Hash.new(0)
n.times do |n|
  t = Hash.new(0)

  s = gets.chop.to_s
  l[s.chars.sort.join] += 1
end


a = 0
l.each_value do |c|
  a += c * (c-1) / 2
end

puts a

Measured memory_bytes: 17916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace workspace
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = Console.ReadLine().ToCharArray();
            char[] T = Console.ReadLine().ToCharArray();
            int top = 0;

            char[] tmp = new char[S.Length];

            for (int i = 0; i < S.Length; i++)
            {
                for(int index = 0; index < S.Length; index++)
                {
                    tmp[index] = S[(index + top) % S.Length];
                }
                if (tmp.SequenceEqual(T))
                {
                    Console.WriteLine("Yes");
                    Environment.Exit(0);
                }
                top++;
            }
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main() {
    long long N, K;
    cin >> N >> K;

    long long remain = 0;
    if (K != 0) {
        for (int b = K + 1; b <= N; b++) {
            remain += (N / b) * (b - K);

            if (N % b >= 1) remain += max(N % b - K + 1, 0LL);
            //        for (int a = (N / b) * b + 1; a <= N; a++) remain += a % b >= K ? 1 : 0;
        }
    } else {
        for (int b = K + 1; b <= N; b++) {
            remain += (N / b) * (b - K);

            if (N % b >= 1) remain += max(N % b - K, 0LL);
            //        for (int a = (N / b) * b + 1; a <= N; a++) remain += a % b >= K ? 1 : 0;
        }
    }

    cout << remain << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const double eps = 1e-12;
int a[40005],b[40005],c[40005];
struct Line{
    double k,b;
    double y;
};
Line xLine[40005];
Line yLine[40005];
double t[40005];
int bit[40005];

void initBit(int n){
    for(int i = 1; i <= n; i++) bit[i] = 0;
}

void change(int p,int v,int n){
    while(p<=n){
        bit[p] += v;
        p += p&-p;
    }
}

double abs(double u){ return u>0?u:-u; }

int ask(int p){
    int res = 0;
    while(p!=0){
        res += bit[p];
        p -= p&-p;
    }
    return res;
}

int preWork(int n){
    std::sort(t+1,t+1+n);
    int p = 1, size = 0;
    while(p<=n){
        int np = p;
        while(np+1<=n && abs(t[np+1]-t[p])<=eps) np++;
        t[++size] = t[p];
        p = np+1;
    }
    return size;
}

int getId(double u,int n){
    int L = 1, R = n;
    int res = -1;
    while(L<=R){
        int M = (L+R)/2;
        if(t[M]<=(u+eps)){
            res = M;
            L = M+1;
        }
        else R = M-1;
    }
    return res;
}

long long getCnt(double x,Line line[],int n){
    for(int i = 1; i <= n; i++){
        line[i].y = line[i].k*x+line[i].b;
        t[i] = line[i].y;
        //printf("y = %.6f ",t[i]);
    }
    //printf("\n");
    int upper = preWork(n);
    initBit(upper);
    long long cnt = 0;
    for(int i = 1; i <= n; i++){
        int u = getId(line[i].y,upper);
        cnt += (long long)ask(u);
        change(u,1,upper);
    }
    initBit(upper);
    for(int i = n; i >= 1; i--){
        int u = getId(line[i].y,upper);
        cnt += (long long)ask(upper)-(long long)ask(u-1);
        change(u,1,upper);
    }
    return cnt;
}

double getAnswer(Line line[],int n){
    long long all = n*(n-1);
    double L = -(1e10+7), R = 1e10+7;
    double res = -1;
    for(int i = 0; i < 100; i++){
        double M = (L+R)/2;
        long long cnt = getCnt(M,line,n);
        if(cnt*2ll>=all){
            res = M;
            R = M-eps;
        }
        else L = M+eps;
    }
    return res;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        xLine[i].k = (double)(-a[i])/(double)b[i];
        xLine[i].b = (double)c[i]/(double)b[i];
        //printf("k = %.3f, b = %.3f\n",xLine[i].k,xLine[i].b);
        yLine[i].k = (double)(-b[i])/(double)a[i];
        yLine[i].b = (double)c[i]/(double)a[i];
    }
    std::sort(xLine+1,xLine+1+n,[&](Line& u,Line& v){ return u.k<v.k; });
    std::sort(yLine+1,yLine+1+n,[&](Line& u,Line& v){ return u.k<v.k; });
    //yLine sort...
    printf("%.12f %.12f\n",getAnswer(xLine,n),getAnswer(yLine,n));
    return 0;
}


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

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class CRectangle {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ios_base::sync_with_stdio(false);
	    int H, W, h, w;
	    bool swapped = false;
	    in>>H>>W>>h>>w;
	    if(H%h==0 and W%w==0) {out<<"No\n"; return;}
	    if(H%h==0) swap(H, W), swap(h, w), swapped = true;
	    vector<vector<int>> ans(H+1, vector<int>(W+1, 500));
	    for(int i=h;i<H;i+=h){
	        RREP(j, W) ans[i][j] = 499 - 500 * h;
	    }
	    out<<"Yes\n";
	    if(swapped){
	        RREP(j, W){
	            RREP(i, H) out<<ans[i][j]<<' ';
	            out<<'\n';
	        }
	    } else {
	        RREP(i, H){
	            RREP(j, W) out<<ans[i][j]<<' ';
	            out<<'\n';
	        }
	    }
	}
};


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


Measured memory_bytes: 2304
N, L = map(int, input().split())

if L <= 0 <= L+N-1:
  a = L
  b = L+N-1
elif 0 < L:
  a = L+1
  b = L+N-1
else:
  a = L
  b = L+N-2

ans = 0
for i in range(a, b+1):
  ans += i
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e3;
const int inf=1e9;
int A[size][size];
int cnt=0;
vector<pair<int,int>> vf,vs;
void work(int a,int b,int c,int d){
	A[a][b]--; A[c][d]++;
	cnt++;
	vf.push_back({a,b});
	vs.push_back({c,d});
	return;
}
int main(){
	int H,W;cin>>H>>W;	
	rep(i,0,H)rep(j,0,W) cin>>A[i][j];
	rep(i,0,H){
		if(i%2==0)rep(j,0,W){
			if(A[i][j]%2){
				if(j<W-1) work(i,j,i,j+1);
				else if(i<H-1) work(i,j,i+1,j);
			}
		}if(i%2==1)for(int j=W-1;j>=0;j--){
			if(A[i][j]%2){
				if(j>0) work(i,j,i,j-1);
				else if(i<H-1) work(i,j,i+1,j);
			}
		}
	}
	cout<<cnt<<endl;
	if(vf.empty()) return 0;
	rep(i,0,vf.size()){
		cout<<vf[i].first+1<<" "<<vf[i].second+1<<" ";
		cout<<vs[i].first+1<<" "<<vs[i].second+1<<endl;
	}
}

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

using namespace std;
#define ll long long
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int inf = 1e9 + 7;
const ll linf  = 1ll * inf * inf;
const int N = 100000 + 7;
const int M = 150;
const int multipleTest = 0;
const double pi = acos(-1);


vector<int> prime;
bool isPrime[N];

void init() {
    fill_n(isPrime, N, true);
    isPrime[1] = false;
    for (int i = 2; i < N; ++i) {
        if (isPrime[i]) {
            for (int j = i + i; j < N; j += i)
                isPrime[j] = false;
            prime.push_back(i);
        }
    }
}


void solve() {
    init();
    int n;
    cin >> n;
    vector<int> res;
    for (int x : prime) if (x % 5 == 1 && res.size() < n) res.push_back(x);

    for (int x : res) cout << x << ' ';
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
//        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 512
using System;


public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var count = 0;
        for (int i = a; i < b + 1; i++)
            if (c % i == 0) count++;
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 9180
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = n/3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, a, b = sc.nextInt()
  val s = sc.next().toCharArray.toList
  @scala.annotation.tailrec
  def loop(chars: Seq[Char], a: Int, b: Int): Unit = chars match {
    case Seq() => Unit
    case x::xs => x match {
      case 'a' if 0 < a =>
        println("Yes")
        loop(xs, a - 1, b)
      case 'a' if 0 < b =>
        println("Yes")
        loop(xs, 0, b - 1)
      case 'b' if 0 < b =>
        println("Yes")
        loop(xs, a, b - 1)
      case _ =>
        println("No")
        loop(xs, a, b)
    }
  }
  loop(s, a, b)
}


Measured memory_bytes: 41448
import sys
li = list(input())
new_li = []
if len(li) == 1:
    print(1)
    sys.exit()
tmp = ''
for i,l in enumerate(li):
    if i == 0:
        new_li.append(li[0])
        continue
    if len(tmp)>0:
        new_li.append(tmp+l)
        tmp = ''
    elif new_li[-1] != l:
        new_li.append(l)
    else:
        tmp = l
print(len(new_li))

Measured memory_bytes: 61808
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{

    
    int x, n, tmp;
    int res, res_u;
    vector<int> p;
    
    cin >> x >> n;
    res = x;
    res_u = x;
    
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        p.push_back(tmp);
        
    }
    
    sort(p.begin(), p.end());
    
    for(int j = 0; j < n; j++)
    {
        for(int i = 0; i < n; i++)
        {
            if(p[i] == res)
            {
                res--;
            }
            if(p[n-i] == res_u)
            {
                res_u++;
            }
        }
    }
    
    if(n)
    {
        if(p[0] == res_u)
        {
            res_u++;
        }
    }
    
    if(abs(res - x) <= abs(res_u - x))
    {
        cout << res;
    }
    else
    {
        cout << res_u;
    }
    
    
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<ll,ll>>v(n);
    rep(i, 0, n){
        ll x, l;
        cin >> x >> l;
        v[i].first = x+l;
        v[i].second = x-l; 
    }
    sort(v.begin(), v.end());
    ll ans = 1;
    ll now = v[0].first;
    rep(i, 1, n){
        if(v[i].second < now)continue;
        ans++;
        now = v[i].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k,ans=0;
	cin >> n;
	for (int i = 0; i < n;++i) {
		cin >> k;
		ans += k;
	}
	cout << ans-n << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    cnt += min(a[i],b[i])
    if b[i] > a[i]:
        if a[i+1] >= b[i] - a[i]:
            cnt += b[i] - a[i]
            a[i+1] -= b[i] - a[i]
        else:
            cnt += a[i+1]
            a[i+1] = 0
print(cnt)

Measured memory_bytes: 90820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    map<P,vector<P>> gg;
    rep(i,m){
        ll p,q,c;
        cin>>p>>q>>c;
        p--,q--,c--;
        gg[P(p,c)].push_back(P(q,c));
        gg[P(q,c)].push_back(P(p,c));
    }
    map<P,vector<P>> g(gg);
    for(auto &[p,vec]:gg){
        auto [x,y]=p;
        g[p].push_back(P(x,-1));
        g[P(x,-1)].push_back(p);
    }
    map<P,ll> dp;
    dp[P(0,-1)]=0;
    deque<P> que;
    que.push_back(P(0,-1));
    while(!que.empty()){
        auto p=que.front();
        que.pop_front();
        auto [v,c]=p;
        for(auto np:g[p]){
            auto [nv,nc]=np;
            if(c==-1){
                if(dp.count(np) && dp[np]<=dp[p]+1)  continue;
                dp[np]=dp[p]+1;
                que.push_back(np);
            }else{
                if(dp.count(np) && dp[np]<=dp[p]) continue;
                dp[np]=dp[p];
                que.push_front(np);
            }
        }
    }
    ll ans=inf;
    for(auto [p,x]:dp){
        auto [v,c]=p;
        if(v!=n-1) continue;
        chmin(ans,x);
    }
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 158672
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using Dams = std::vector<long>;
using Mountains = std::vector<long>;

Mountains solve(int n, const Dams& dams)
{
  long s = 0;
  for (int i = 0; i < n; ++i) {
    s += dams[n - i - 1] * (i % 2 ? -1 : 1);
  }

  Mountains result(n);
  result[0] = s;
  for (int i = 1; i < n; ++i) {
    result[i] = 2 * dams[i - 1] - result[i - 1];
  }
  return result;
}

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

  Dams dams(n);
  for (auto& m : dams) {
    std::cin >> m;
  }

  const auto mountains = solve(n, dams);
  auto it = mountains.begin();
  std::cout << *it;
  for (++it; it != mountains.end(); ++it) {
    std::cout << " " << *it;
  }
  std::cout << std::endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    double A, B, P, Q, R;
    cin >> A >> B >> P >> Q >> R;
    fcout << (B * P - (B - A) * Q) / (Q + R) + B << endl;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    ll ans=0,c=0;
    rep(0,i,s.size()){
        string s0=s.substr(i,1);
        if(s0=="W"){
            ans+=i;
            ++c;
        }
    }
    ans-=c*(c-1)/2;
    cout<<ans;
}


Measured memory_bytes: 640
n = int(input())
pret, prea, preb = 0, 0, 0
flag = True
for i in range(n):
    t, a, b = map(int, input().split())
    if (t - pret) % 2 == abs((a + b) - (prea + preb)) % 2 and t - pret >= abs((a + b) - (prea + preb)):
        pass
    else:
        print("No")
        break

    if i == n - 1:
        print("Yes")


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

int main() {

    ll n; cin >> n;
    const ll p = 86;
    vector<ll> l(p + 1);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++) {
        l[i] = l[i - 1] + l[i - 2];
    }

    cout << l[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int n, sum = 0, ans = 1e9;
	cin >> n;
	vector<int> w(n);
	for (int i=0; i<n; i++) {
		cin >> w.at(i);
		sum += w.at(i);
	}
	for (int i=1; i<n; i++) {
		int s1 = 0;
		for (int j=0; j<i; j++) {
			s1 += w.at(j);
		}
		int s2 = sum - s1;
		ans = min(ans, abs(s2 - s1));
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		v[i]--;
	}
	int s = 0;
	for (int i = 0; i < N; i++) {
		if (v[v[i]] == i) {
			s++;
		}
	}
	cout << s/2 << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int[] intArray = new int[100];
        for (int i = 0; i < n1; i++) {
            intArray[i] = sc.nextInt();
        }

        int count = 0;
        for (int i= 0; i < intArray.length; i++) {
            for (int j = i + 1; j < intArray.length; j++) {
                if (intArray[j] == 0) {
                   break;
                }
                if (intArray[i] == intArray[j]) {
                   continue;
                }
                for (int k = j + 1; k <  intArray.length; k++) {
                    if (intArray[k] == 0) {
                        break;
                    }
                    if ((intArray[i] + intArray[j] > intArray[k]) && (intArray[j] + intArray[k] > intArray[i]) && (intArray[k] + intArray[i] > intArray[j])) {
                        if (intArray[i] != intArray[k] && intArray[j] != intArray[k]) {
                            count++;
                        }
                    }
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 36472
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N;
  invec<int> A(N-1);
  
  vector<int> r(N, 0);
  
  REP(i, N-1)
    r[A[i]-1]++;


  for(auto i : r)
    cout << i << endl;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int ans = 1900 * m + 100 * (n - m);
  rep(i, m) ans *= 2;
  cout << ans << endl;


  
  return 0;
}

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

using namespace std;

#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {

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

    int n;
    cin >> n;
    ll s = 0;
    for(int i = 1; i <= n; ++i) {
    	if(i % 3 == 0 || i % 5 == 0) {
    		continue;
    	}
    	s += i;
    }
    cout << s;
    cout << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    int d;
    cin >> d;
    vint c(26);
    cin >> c;
    vector<vint> s(d, vint(26));
    REP(i,d){
        REP(j, 26) { cin >> s[i][j]; }
    }
    vint t(d);
    cin>>t;
    REP(i, d) { t[i]--; }
    ll score = 0;
    vint last(26, -1);
    REP(i, d) {
        ll tmp = INT_MIN, nowans = -1;
        REP(k, 26) {
            ll score = 0;
            int nowcont = k;
            last[nowcont] = i;
            score += s[i][nowcont];
            REP(j, 26) { score -= c[j] * (i - last[j]); }
            if (score > tmp){
                nowans = nowcont + 1;
                tmp = score;
            }
        }
        cout << nowans << endl;
    }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;



int main()
{
    idfc;

    int n;
    cin>>n;
    string s;
    cin>>s;

    int i;
    int c=0;
    int a=0;
    int b=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='(')c++;
        else{
            if(c)c--;
            else{
                a++;
            }
        }
    }
    while(a--)cout<<"(";
    cout<<s;
    while(c--)cout<<")";


    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]<a[i-1])
		{
			printf("No");
			return 0;
		}
		if(a[i]>a[i-1])
			a[i]--;
	}
	printf("Yes");
}

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

int main(){
  ll n,sum=0,tempsum=0;
  cin>>n;
  vector<ll>v1(n);
  for(ll i=0;i<n;i++){
    cin>>v1[i];
    sum+=v1[i];
    if(i%2==1){
      tempsum+=v1[i]*2;
    }
  }
  ll x1=sum-tempsum;
  cout<<x1<<" ";
  for(ll j=0;j<n-1;j++){
    ll y=v1[j]*2-x1;
    x1=y;
    cout<<x1<<" ";
  }

  
}

Measured memory_bytes: 3980
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll a, v, b, w, t;

bool solve() {
    ll d = abs(a - b);
    ll dv = v - w;
    return dv * t >= d;
}

void input() {
    cin >> a >> v >> b >> w >> t;
}

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

    input();
    cout << (solve()?"YES":"NO") << endl;
}


Measured memory_bytes: 3040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int r[7][7];

void setr(void)
{
	r[1][2] = 3;
	r[1][3] = 5;
	r[1][5] = 4;
	r[1][4] = 2;

	r[2][1] = 4;
	r[2][3] = 1;
	r[2][4] = 6;
	r[2][6] = 3;

	r[3][1] = 2;
	r[3][2] = 6;
	r[3][5] = 1;
	r[3][6] = 5;

	r[4][1] = 5;
	r[4][2] = 1;
	r[4][5] = 6;
	r[4][6] = 2;

	r[5][1] = 3;
	r[5][3] = 6;
	r[5][4] = 1;
	r[5][6] = 4;

	r[6][2] = 4;
	r[6][3] = 2;
	r[6][4] = 5;
	r[6][5] = 3;
}

class dice {
public:
	int f, l, d;
	int v[7];

	dice(void) {
		f = 1;
		l = 4;
		d = 2;
	}
	void rot(char c)
	{
		int pf = f, pl = l, pd = d;

		if (c == 'W') set(7 - pl, pf, pd);
		else if (c == 'S') set(7 - pd, pl, pf);
		else if (c == 'E') set(pl, 7 - pf, pd);
		else set(pd, pl, 7 - pf);
	}
	int front(void)
	{
		return v[f];
	}
private:
	void set(int fv, int lv, int dv) {
		f = fv;
		l = lv;
		d = dv;
	}
};

int main()
{
	int q, a, b;
	dice d;

	setr();

	repc(i, 1, 6) cin >> d.v[i];
	cin >> q;
	rep(i, q) {
		cin >> a >> b;
		int ai, bi;
		repc(j, 1, 6) if (d.v[j] == a) ai = j;
		repc(j, 1, 6) if (d.v[j] == b) bi = j;

		cout << d.v[r[ai][bi]] << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
x, y = [int(i) for i in input().split()]
date = [[int(i) for i in input().split()]for i in range(1,x+1)]
date2 =[int(input())for i in range(1,y+1)]
date3 =[]
for a in range(0,x):
    for b in range(0,y,):
        date3 += [date2[b]*date[a][b]]
for d in range(0,len(date3),y):
    print(sum(date3[d:d+y]))

Measured memory_bytes: 8492
using System;

namespace ABC061_D___Score_Attack
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var N = read[0];
            var M = read[1];
            var edges = new Edge[M];

            for(int i = 0 ; i < M ; i++)
            {
                var read2 = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
                edges[i] = new Edge(read2[0],read2[1],-read2[2]);
            }

            var distance = new long[N+1];
            distance[1] = 0;
            for(int i = 2 ; i < N+1 ; i++) distance[i] = long.MaxValue;

            var update = new bool[N+1];
            bool isInfinite = false;
            
            for(int i = 0 ; i < N ; i++)
            {
                for(int j = 0 ; j < N+1 ; j++) update[j] = false;
                for(int k = 0 ; k < M ; k++)
                {
                    if(distance[edges[k].from] == long.MaxValue) continue;
                    if(distance[edges[k].to] > distance[edges[k].from] + edges[k].cost)
                    {
                        distance[edges[k].to] = distance[edges[k].from] + edges[k].cost;
                        update[edges[k].to] = true;
                        update[edges[k].from] = true;
                        if(i == N-1)
                        {
                            if(update[N]==true) isInfinite = true;
                        }
                    }
                }
            }
            if(isInfinite == true)
            {
                Console.WriteLine("inf");
            }else
            {
                Console.WriteLine(-distance[N]);
            }
        }
        struct Edge
        {
            public long from{get;set;}
            public long to{get;set;}
            public long cost{get;set;}
            public Edge(long _from,long _to,long _cost)
            {
                this.from = _from;
                this.to = _to;
                this.cost = _cost;
            }
        }
    }
}


Measured memory_bytes: 13224
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
const int X = 31;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%d %d %d\n",c,a,b );
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		//int d=scan.nextInt();
		//int e=scan.nextInt();
		boolean bool=false;
		int ans=0;
		System.out.println(c/a*b);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=(a); i<(b); i++)
typedef unsigned long long ll;
using namespace std;

int main(){
	map<string,int> a;
	string s;
	int n,m=0;
	cin>>n;
	For(i,0,n){
		cin>>s;
		a[s]++;
		m=max(m,a[s]);
	}
	map<string,int>::iterator it;
	for(it=a.begin(); it!=a.end(); it++){
		if (it->second==m)
			cout<<it->first<<endl;
	}
	return 0;
}

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

int main(){
  int k,s;
  auto ans = 0;
  cin >> k >> s;
  for(int x=0;x<=k;++x){
    for(int y=0;y<=k;++y){
    int z = s-x-y;
    if(0<= z and z<= k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __print__(os, ", ", "\n", __VA_ARGS__);           \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

template <typename T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

template <typename T>
bool umin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        deque<int> d;
        rep(i, n) {
            int x;
            cin >> x;
            int c = 0;
            while (x % 2 == 0 && c < 4) {
                x /= 2;
                ++c;
            }
            d.push_back(c);
        }
        sort(all(d));
        vector<int> v;
        rep(i, n) {
            if (i & 1) {
                v.push_back(d.back());
                d.pop_back();
            } else {
                v.push_back(d.front());
                d.pop_front();
            }
        }
        // print_(all(v));
        bool ok = true;
        rep(i, n - 1) {
            if (v[i] + v[i + 1] < 2) ok = false;
        }
        print(ok ? "Yes" : "No");
    }
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  int siz = s.length();
  int left = 0, right = siz-1, ans = 0;
  bool ok = true;
  while (right - left >= 1 && ok) {
    if (s[left] == s[right]) {
      left++; right--;
    }
    else {
      if (s[left] == 'x') {
        ans++; left++; //xを挿入
      }
      else if (s[right] == 'x') {
        ans++; right--; //xを挿入
      }
      else ok = false;
    }
  }
  debug(left, right, ans);
  cout << (ok ? ans : -1) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
int main(){
    ll n, a;
    string ans = "YES";
    cin >> n;
    map<ll, ll> check;
    RAP(i, n){
        cin >> a;
        if(check[a]!=0){
            ans = "NO";
            break;
        }
        check[a]++;
    }
    
    cout << ans << endl;
    return 0;
 
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  
  if(A >= 13) cout <<B <<endl;
  else if(A > 5) cout << B/ 2<< endl;
  else cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 256
from collections import deque
n,k = (int(i) for i in input().split())
b = [[int(i)-1 for i in input().split()] for i in range(n-1)]
x,d,ans,c = [[] for i in range(n)],[[] for i in range(n)],n,0
for i,j in b:
	x[i].append(j)
	x[j].append(i)
def f(s):
	for i in range(n):
		q,v = deque(),[1]*n
		v[i] = 0
		for j in x[i]:
			q.append((j,1,j))
			d[i].append(j)
			v[j] = 0
		while q:
			p = q.pop()
			if p[1]<s:
				for j in x[p[0]]:
					if v[j]:
						q.append((j,p[1]+1,p[2]))
						d[i].append(p[2])
						v[j] = 0
if k>n//2:
	for i in x: c = max(len(i),c)
if n-c+1<=k: ans = 0
elif k==1: ans = n-2
else:
	f(k//2)
	if k%2:
		for i,j in b: ans = min(ans,n-len(d[i])-len(d[j])+d[i].count(j)+d[j].count(i)-2)
	else:
		for i in range(n): ans = min(ans,n-len(d[i])-1)
print(ans)

Measured memory_bytes: 25580
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N;cin>>N;
    int count=0;
    long long res=0;
    while(N>1){
        N/=2;
        res+=pow(2,count);
        //cout<<res<<endl;
        count+=1;
    }
    res+=pow(2,count);
    cout<<res<<endl;
    //cout<<count<<endl;
}

Measured memory_bytes: 256
def dsum(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret
n = int(input())
ans = 10**7
for i in range(1, n//2+1):
    ans = min(ans, dsum(i) + dsum(n-i))
print(ans)

Measured memory_bytes: 3060