akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// min
int main(void){
  double n, k;
  double ans = 0;

  double tmp = 1;
  long int s = 0;

  scanf("%lf%lf", &n, &k);

  for(long int i = 1; i <= n; i++){
    s = i;
    //    tmp++;
    while(s < k){
      s = 2 * s;
      //      tmp++;
      tmp *= 0.5;
    }
    //    ans += pow((1.0/2.0), tmp);
    
    //    fprintf(stderr, "i:%ld, ans:%f 1.0/n = %f  tmp = %f\n", i, ans, 1.0 / n, pow((1.0/2.0), tmp));
    ans += tmp;
    tmp = 1;
  }
  
  
  printf("%.12lf\n", ans * 1.0/n);

  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



int main(){
  ll X;
  cin>>X;
  ll sum=0,i;

  for(i=1;sum<X;i++){
    sum+=i;
  }
  cout<<i-1<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  vector<int> prime(1000001, 0);
  vector<int> prime1000(0);
  vector<bool> isprime(1001,true);
  for(int i=2; i<1001; ++i){
    if(!isprime[i]) continue;
    prime1000.push_back(i);
    for(int j=i*i; j<1001; j += i){
      isprime[j] = false;
    }
  }
  bool pc = true, sc = true;
  for(int i=0; i<n; ++i){
    for(int j:prime1000){
      if(an[i]%j == 0){
        while(an[i]%j == 0) an[i] /= j;
        ++prime[j];
      }
    }
    if(an[i] > 1) ++prime[an[i]];
  }
  for(int i=0; i<1000001; ++i){
    if(prime[i] > 1) pc = false;
    if(prime[i] == n) sc = false;
  }
  if(pc) cout << "pairwise coprime" << endl;
  else if(sc) cout << "setwise coprime" << endl;
  else cout <<"not coprime" << endl;
}

Measured memory_bytes: 11116
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, q;
	cin >> n;
	VI s(n);
	rep(i, n)cin >> s[i];
	cin >> q;
	VI t(q);
	rep(i, q)cin >> t[i];

	int cnt = 0;
	rep(i, q) {
		if (binary_search(all(s), t[i]))cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define INF 1e10
using namespace std;
struct edge{
  int to,limit;
  double dist;
};
struct Point{
  int speed,prev,v;
  double cost;
  Point(){}
  Point(int speed_,int prev_,int v_,double cost_)
    :speed(speed_),prev(prev_),v(v_),cost(cost_){}
  bool operator>(const Point &a)const{
    return cost > a.cost;
  }
};
vector<edge> G[100];
double d[40][40][40];//speed,pos,prev
bool used[40][40][40];
typedef pair<int,int> pii; //speed,prev
typedef pair<int,pii> PII;//to,speed,prev
typedef pair<double,PII> P;//cost,to,speed

double dikstra(int s,int g){
  int ds[3]={-1,0,1};
  priority_queue<Point,vector<Point>,greater<Point> > que;
  
  for(int i=0;i<40;i++)
    for(int j=0;j<40;j++)
      for(int k=0;k<40;k++)
	d[i][j][k]=INF;
  
  memset(used,0,sizeof(used));
  d[0][s][0]=0;
  Point tmp(0,0,s,0);
  que.push(tmp);
  
  while(!que.empty()){
    Point p=que.top();que.pop();
    if(d[p.speed][p.v][p.prev]<p.cost)continue;
    if(p.speed==1 && p.v==g)return p.cost;

    for(int i=0;i<G[p.v].size();i++){
	edge e=G[p.v][i];
      for(int j=0;j<3;j++){
	int ns=p.speed+ds[j];
	if(1<=ns && ns<= e.limit &&
	   used[ns][e.to][p.v]==false &&
	   e.to!=p.prev && 
	   d[ns][e.to][p.v]>p.cost+e.dist/ns){

	  used[ns][e.to][p.v]=true;
	  Point tmp(ns,p.v,e.to,p.cost+e.dist/ns);
	  que.push(tmp);
	  d[ns][e.to][p.v]=p.cost+e.dist/ns;
	  //cout << "d[" << ns << "][" << e.to << "][" << p.v << "]:" << d[ns][e.to][p.v] << endl;
	}
      }
    }
  }
  return -1;
}

int main(){
  int n,m,s,g;
  while(cin>>n>>m,n){
    for(int i=0;i<100;i++)G[i].clear();
    cin>>s>>g;
    for(int i=0;i<m;i++){
      int x,y,d,c;
      cin>>x>>y>>d>>c;
      G[x].push_back((edge){y,c,d});
      G[y].push_back((edge){x,c,d});
    }
    double ans=dikstra(s,g);
    if(ans==-1)cout << "unreachable" << endl;
    else printf("%.5lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N;cin>>N;
  string s;cin>>s;
  ll left=0,right=N-1;
  ll cnt=0;
  while(left<right){
    if(s[left]=='R') left++;
    else {
      while(s[right]=='W'){
        right--;
      }
      if(right<=left) break;
      left++;
      right--;
      cnt++;
    }
    //cout<<"l r c"<<left << right << cnt << endl;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3748
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

template <typename T>
std::map<T, size_t> group_count(std::vector<T>& v) {
	std::map<T, size_t> c;
	for(T& e : v) {
		c[e]++;
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	VI a(n);
	REP(i, n) { cin >> a[i]; }
	map<int, size_t> g = group_count(a);
	int d = 0;
	EACH(e, g) {
		if(e.second > 1) {
			d += e.second - 1;
		}
	}
	cout << g.size() - (d % 2) << endl;
	return 0;
}


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

using namespace std;

int main() {
  // input
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (abs(a-c)<=d){
    cout << "Yes" << endl;
  }else if(abs(a-b)<=d && abs(b-c)<=d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
  public:
  vector<int> rank, prt;
  disjoint_set (int size) {
    rank.resize(size);
    prt.resize(size);
    for (int i = 0; i < size; i++) {
      prt[i] = i;
      rank[i] = 0;
    }
  }
  int find (int x) {
    if (x == prt[x]){
      return x;
    } else {
      return prt[x] = find(prt[x]);
    }
  }
  bool is_equiv (int x, int y) {
    return find(x) == find(y);
  }
  bool unite (int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }
    if (rank[x] > rank[y]) {
      swap(x, y);
    }
    prt[x] = y;
    if (rank[x] == rank[y]) {
      rank[y]++;
    }
    return true;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  disjoint_set djs(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    djs.unite(--a, --b);
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    if (djs.is_equiv(i, p[i])) ret++;
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 1408
N, M = map(int,input().split())
good = [0]*N

H = list(map(int,input().split()))

for j in range(M):
  a, b = map(int,input().split())
  if(H[a-1] == H[b-1]):
    good[a-1] += 1
    good[b-1] += 1
  elif(H[a-1] < H[b-1]):
    good[a-1] += 1
  else:
    good[b-1] += 1
count = 0
for i in range(N):
  if(good[i] == 0):
    count += 1
print(count)

Measured memory_bytes: 20908
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair <int,int> P;

int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i = 0;i<N;i++){
        cin >> H[i];
    }

    int MAX = 0;
    int cnt = 0;
    for(int i = 0;i<N;i++){
        if(H[i] >= MAX){
            cnt = cnt + 1;
            MAX = H[i];
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long L = sc.nextInt();
        long R = sc.nextInt();

        if ((R - L) >= 2019) {
            System.out.println(0);
        }
        else {
            long res = 2019;
            for(long i = L; i <= R; i++) {
                for(long j = i + 1; j <= R; j++ ) {
                    long temp = (i * j) % 2019;
                    res = Math.min(res , temp);

                }
            }
            System.out.println(res);
        }

    }
}


Measured memory_bytes: 23252
N,W = gets.split.map(&:to_i)
Items = (0...N).map{ gets.split.map(&:to_i) }

INF = 1000000000000

$memo = {}
def V(i, w)
  return 0 if i < 0
  return 0 if w <= 0
  key = [i,w]
  if !$memo[key]
    wi,vi = *Items[i]
    $memo[key] = [w >= wi ? V(i-1, w - wi) + vi : 0, V(i-1, w)].max
  end
  $memo[key]
end

puts V(N-1,W)
#p $memo

Measured memory_bytes: 14972
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Beginner_Contest_134
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static  void Solve()
        {
            var r = Sarray()[0];
            WriteLine(3 * r * r);
        }
    }
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static class Task {
        public void solve(InputReader in, PrintWriter out) {
        	int a = in.nextInt();
        	int b = in.nextInt();
        	out.println((double)a/(double)b);
        }
    }
	
    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
    }	
}

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

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << char(s1[0] - 32) << char(s2[0] - 32) << char(s3[0] - 32) << endl;
  return 0;
}

Measured memory_bytes: 3544
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

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

int matrixChainMultiplication(int **m,int *p,int n);

const int Sentinel = 2000000;

int main(){
	int n,row,column,*p,**m; cin>>n;
	p = new int[n+1];
	for(int i=1;i<=n;i++){
		cin>>row>>column;
		p[i-1] = row; p[i] = column;
	}

	m = new int*[n+1]; for(int i=0;i<=n;i++) m[i] = new int[n+1];

	cout<<matrixChainMultiplication(m,p,n)<<endl;

	delete [] p;
	for(int i=0;i<=n;i++) delete [] m[i]; delete [] m;
}

int matrixChainMultiplication(int **m,int *p,int n){
	for(int i=1;i<=n;i++) m[i][i] = 0;

	int minimum = 0;
	for(int l=2;l<=n;l++){
		for(int i=1;i<=n-l+1;i++){
			int j = i+l-1;
			m[i][j] = Sentinel;
			for(int k=i;k<j;k++){
				m[i][j] = min(m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j],m[i][j]);
				minimum = (minimum,m[i][j]);
			}
		}
	}
	return minimum;
}

Measured memory_bytes: 3132
io = STDIN
n=io.gets.to_i
$testimony = Array.new(n){[]}
n.times do |i|
  io.gets.to_i.times do
    x, y = io.gets.split.map(&:to_i)
    $testimony[i] << [x.pred, y == 1]
  end
end
def unkind?(bits)  #bits:bit pattern,  true(y==1)の人に対する証言のみ不一致を確認
  bits.flat_map.with_index do |bit, i|
    bit ? $testimony[i] : []
  end.any?{|x, y| bits[x] != y}
end
cnt=[true, false].repeated_permutation(n).map do |bits|
  unkind?(bits) ? 0 : bits.count(true)
end
puts cnt.max

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

int main() {
ios_base::sync_with_stdio(0);int n; cin >> n; vector <int> tab(2*n); for(int i = 0; i < 2*n; i++) cin >> tab[i]; sort(tab.begin(), tab.end()); int ans = 0; for(int i = 0; i < n; i++) ans+=tab[2*i];cout<<ans;
}

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

int main()
{
    char s[101];

    while(scanf("%s", s) != EOF)
    {
        int len = strlen(s);

        map<char, int> charMap;

        for(int i=0; i<len; i++) charMap[s[i]]++;

        bool beautiful = true;

        for(int i=97; i<=122; i++)
        {
            if(charMap[(char) i] % 2!=0)
            {
                beautiful = false;
                break;
            }
        }

        if(beautiful) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  char s;int al[26] = {};bool ok = true;
  while(cin >> s){
    if(al[s-'a']){
      ok = false;break;
    } else al[s-'a']++;
  }
  cout << ((ok) ? "yes":"no") << endl;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

signed main (){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(n);
    rep(i,0,n)cin>>v[i].fi>>v[i].se;
    Sort(v);
    int ans=0;
    for(int i=0;m>0;i++){
        int mi=min(m,v[i].se);
        ans+=v[i].fi*mi;
        m-=mi;
    } 
    cout<<ans<<endl;

    

    
}  
/*

*/


Measured memory_bytes: 1792
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;


int main(void){
    int n;

    cin >> n;

    int a[100000+5];
    int b[100000+5];

    for(int i=0;i<100000+5;i++){
        a[i] =0;
        b[i] = 0;
    }
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }

    int ans;

    ans = a[0]+a[1];

    for(int i=1;i<100000+5-1;i++){
        ans = max(ans, a[i-1]+a[i]+a[i+1]);
    }

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

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int N[4],i;
  bool a=false,b=false,c=false,d=false;
  for(i=0;i<4;i++){
    scanf("%d",&N[i]);
    if(N[i]==1) a=true;
    else if(N[i]==9) b=true;
    else if(N[i]==7) c=true;
    else if(N[i]==4) d=true;
  }
  if(a && b && c && d) printf("YES");
  else printf("NO");
  
  return 0;
}

Measured memory_bytes: 128
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

struct Edge {
    int from, to, cost;
    Edge(int t, int c) : to(t), cost(c) {}
    Edge(int f, int t, int c) : from(f), to(t), cost(c) {}
    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
};

const int MAXN = 4010;
struct UnionFind {
    int node[MAXN];
    UnionFind() {
        memset(node, -1, sizeof(node));
    }
    int find(int x) {
        return node[x] < 0 ? x : node[x] = find(node[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        node[x] += node[y];
        node[y] = x;
        return true;
    }
};

using Graph = vector< vector<Edge> >;
int max_edge[MAXN][MAXN];

void dfs(Graph &G, int cur, int par, int orig) {
    int prev_max = max_edge[orig][cur];
    for(auto e : G[cur]) {
        if(e.to == par) continue;
        chmax(max_edge[orig][e.to], max(prev_max, e.cost));
        dfs(G, e.to, cur, orig);
    }
}
 
UnionFind uf;
signed main() {
    int N, M; cin >> N >> M;
    
    vector<Edge> edges;
    for(int i=0; i<M; i++) {
        int u, v, cost; cin >> u >> v >> cost;
        u--; v--;
        edges.emplace_back(u, v, cost);
    }
    sort(edges.begin(), edges.end());

    int sum = 0;
    Graph MST(N);
    for(int i=0; i<M; i++) {
        Edge e = edges[i];
        if(uf.unite(e.from, e.to)) {
            MST[e.from].emplace_back(e.from, e.to  , e.cost);
            MST[e.to  ].emplace_back(e.to,   e.from, e.cost);
            sum += e.cost;
        }
    }

    for(int i=0; i<N; i++) dfs(MST, i, -1, i);

    /*
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            printf("max_edge[%lld][%lld] = %lld\n", i+1, j+1, max_edge[i][j]);
        }
    }
    */

    int Q; cin >> Q;
    for(int i=0; i<Q; i++) {
        int s, t; cin >> s >> t;
        s--; t--;
        // printf("max_edge = %lld\n", max_edge[s][t]);
        cout << sum - max_edge[s][t] << endl;
    }
    return 0;
}


Measured memory_bytes: 138088
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int zoro_count = 0;
    int a, b;
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        if (a == b)
        {
            ++zoro_count;
        }
        else
        {
            zoro_count = 0;
        }
        if (zoro_count == 3)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

int N, C;
vll V(N), W(N);
vvl dp;

ll helper(ll i, ll cur_C) {
    if (cur_C <= 0) {
        return 0;
    }
    if (i < 0) return 0;

    if (dp[i][cur_C]) {
        return dp[i][cur_C];
    }
    if (cur_C - W[i] < 0) {
        return dp[i][cur_C] = helper(i - 1, cur_C);
    }
    return dp[i][cur_C] = max(helper(i - 1, cur_C), helper(i - 1, cur_C - W[i]) + V[i]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, C;
    cin >> N >> C;
    V.resize(N);
    W.resize(N);
    dp = vvl(N+1, vll(C + 1));
    loop(i, 0, N) {
        cin >> W[i] >> V[i];
    }

    cout << helper(N, C) << endl;


    //cout << dp[C] << "\n";
    return 0;
}


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

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void ins(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

void del(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

Node* search(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void print() {
    Node *cur = nil->next;
    int i = 0;
    while (cur != nil) {
        printf("%s%d", (i++ ? " " : ""), cur->key);
        cur = cur->next;
    }
    puts("");
}

int main()
{
    int n;
    scanf("%d", &n);

    init();

    for (int i = 0; i < n; i++)  {
        char s[10];
        scanf("%s", s);

        int a;
        if (!strcmp(s,"insert")) {
            scanf("%d", &a);
            ins(a);
        }
        if (!strcmp(s,"delete")) {
            scanf("%d", &a);
            del(search(a));
        }
        if (!strcmp(s,"deleteFirst")) {
            del(nil->next);
        }
        if (!strcmp(s,"deleteLast")) {
            del(nil->prev);
        }
    }

    print();

    return 0;
}



Measured memory_bytes: 34440
def lcm(a, b):
    import fractions 
    return a // fractions.gcd(a, b) * b

def f(x, c, d):
    res = x
    res -= x//c
    res -= x//d
    res += x//lcm(c,d)
    return res

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

ans = f(B, C, D) - f(A-1, C, D)
print(ans)

Measured memory_bytes: 5044
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        s: chars,
    }
    let mut cnt = 0;
    let mut f: Vec<i32> = vec![];
    let mut skel = vec![];
    for c in s {
        if c == 'x' {
            cnt += 1;
        } else {
            f.push(cnt);
            cnt = 0;
            skel.push(c);
        }
    }
    f.push(cnt);
    let mut skel_rev = skel.clone();
    skel_rev.reverse();
    if skel != skel_rev {
        puts!("-1\n");
        return;
    }
    let mut tot = 0;
    for i in 0 .. f.len() / 2 {
        tot += (f[i] - f[f.len() - 1 - i]).abs();
    }
    //eprintln!("f = {:?}", f);
    //eprintln!("skel = {:?}", skel);
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    string s; cin >> s;
    int n = s.size();
    if(s[n-1] == 's') cout << s << "es";
    else cout << s << 's';
}

Measured memory_bytes: 3624
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

for i in range(40,-1,-1):
    power = 1 << i
    #<<...ビット演算子「左シフト」。(=値２倍)
    bit_count_of_1 = sum(1 for a in a if a & power != 0) #i番目のビットに1はいくつあるか?

    if power > k: # power > kなら、kの該当ビットは必ず0なので、寄与はその時点で決定
        ans += power * bit_count_of_1
    elif bit_count_of_1 > n - bit_count_of_1: #その桁で1の方が多いならxの最適解は0。
        ans += power * bit_count_of_1
    else:
        ans += power * (n - bit_count_of_1)
        k -= power

print(ans)

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

int main()
{
    int h,w,j,i,a=0,z;
    cin>>h>>w;
    string s;
    char c[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>c[i][j];
        }
    }
    for(i=0;i<h;i++){

            for(j=0;j<w;j++){
                s.push_back(c[i][j]);
                 a++;
        }
        if(a==w){
            cout<<s<<endl<<s<<endl;
            s.erase (s.begin(),s.end());
            a=0;
        }
    }}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
using namespace std;
const ll M = 1e9 + 7;
ll n,ans;
void solve()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int s=0;
    for(int i=0;i<n;i++)
    {
        s=s+arr[i];
        if(i+1==k)
        break;
    }
    cout<<s;
}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3624
/* title: tile
 * source: JOI2010-2011
 * hint:
 * x > N / 2 テ」ツ?ョテ」ツ?ィテ」ツ?催」ツ?ッテゥツ渉。テ・ツδ湘」ツつ津ィツ?ε」ツ?暗」ツつ?
 * y > N / 2 テ」ツ?ョテ」ツ?ィテ」ツ?催」ツつづ・ツ青古ヲツァツ佚」ツ?ァテ」ツ?づ」ツつ?
 * テ・ツョツ淌」ツ?ッテ・ツキツヲテ、ツクツ甘」ツ?凝」ツつ嘉・ツ渉ウテ、ツクツ凝」ツ?クテ」ツ?ョテ・ツッツセティツァツ津ァツキツ堙」ツつづゥツ渉。テゥツ敖「テ」ツ?ョテァツキツ堙」ツ?ォテ」ツ?ェテ」ツつ甘」ツ??」ツつ凝」ツ?ョテ」ツ?ァテ」ツ??
 * テァツオツ静・ツアツ?ヲツュツ」テヲツ鳴ケテ・ツスツ「テ」ツつ?テ」ツ?、テ」ツ?ォテヲツ環佚」ツつ甘」ツ?淌」ツ?淌」ツつ禿」ツ??」ツつづ」ツ?ョテ」ツつ津ィツ?ε」ツ?暗」ツつ古」ツ?ーテ」ツ??」ツ??
 */



#include <iostream>
using namespace std;


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

	for(int i = 0; i < K; i++) {
		int x, y;
		cin >> x >> y;

		if(N % 2 == 0) {
			if(x > N / 2) x = N + 1 - x;
			if(y > N / 2) y = N + 1 - y;
		} else {
			if(x > N / 2 + 1) x = N + 1 - x;
			if(y > N / 2 + 1) y = N + 1 - y;
		}

		cout << (min(x, y) - 1) % 3 + 1<< endl;
	}
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
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 inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        map<ll,ll> mp;
        rep(i,0,n)cin>>a[i],mp[a[i]]++;
        ll as=0;
        ll tmp=as;
        for(auto x:mp)
            as+=(x.Y)*(x.Y-1)/2;
        tmp=as;
        for(int i=0;i<n;i++){
            ll xx=mp[a[i]];
            as-=(xx)*(xx-1)/2;
            xx--;
            as+=(xx)*(xx-1)/2;
            cout<<as<<nl;
            as=tmp;
        }
    }
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main(void)
{
    int l[11];
    int v1,v2;
    double t;
    int i,j;
    int L,L2;
    double x;
    int count;

    while (scanf("%d", &l[0]) != EOF){
        for (i = 1; i < 10; i++){
            scanf(",%d", &l[i]);
        }
        scanf(",%d,%d", &v1, &v2);

        L = 0;
        for (i = 0; i < 10; i++){
            L += l[i];
        }

        t = (double)L / ((double)v1 + (double)v2);
        //printf("t:%lf\n", t);
        x = ((double)v1 * t);
        //printf("x:%lf\n", x);
        L2 = 0;
        count = 0;
        


        
        for (i = 0; i < L; i++){
            L2 += 1;
            //printf("<L2:%lf> ", (double)L2);
            if ((double)L2 == x){
                count = i + 1;
                //printf("<%d>\n", count);
                break;
            }else if (L2 < x && x < L2 + 1){
                count = i + 2;
                //printf("[%d]\n", count);
                break;
            }  
        }
        L = 0;
        for (i = 0; i < 10; i++){
            L += l[i];
            if (L - l[i] < count && count < L){
                printf("%d\n", i + 1);
            }else if (L == count){
                printf("%d\n", i + 1);
            }
        } 

    }
    return (0);
}


Measured memory_bytes: 1972
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, m;
    string s;
    while (cin >> n, n) {
        cin >> m >> s;
        int ans = 0;
        rep(i, m) {
            if (s[i] == 'I') {
                int j = i + 1;
                int cnt = 0;
                while (j + 1 < m && s.substr(j, 2) == "OI") {
                    j += 2;
                    cnt++;
                }
                ans += max(0ll, cnt - n + 1);
                i = j - 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;	cin >> n >> m;
  for(int i=0;i<m;i++){
    int x;	cin >> x;
    n-=x;
  }
  if(n<0)	cout << -1;
  else cout << n;
}

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

int main()
{
	string n;
	cin >> n;
	for(int i(0);i<n.size();++i){
		if(n[i] == '1') cout << '9';
		else cout << '1';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
kind=Hash.new(0)
ans=0
A.each do|a|
    kind[a]+=1
    ans+=a
end
Q=gets.to_i
Q.times do
    b,c=get_i
    v=kind[b]
    ans-=b*v
    kind[b]=0
    kind[c]+=v
    ans+=c*v
    puts ans
end

Measured memory_bytes: 26448
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define pb push_back
#define fi first
#define se second
#define int long long
#define mod 1000000007
#define rem 998244353
#define MAXN 200005
const int INF = 1e18;
typedef pair<int, int> pii;

int parent[MAXN], siz[MAXN];
void make_set(int v) {
    parent[v] = v;
    siz[v] = 1;
}
int find_set(int v) {
    if (v == parent[v]) return v;
    return parent[v] = find_set(parent[v]);
}
void union_set(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (siz[b] < siz[a])
            swap(a, b);
        parent[b] = a;
        siz[a] += siz[b];
    }
}
signed main() {
    boostIO;
    int n, m;
    cin >> n >> m;
    repn(i, n) make_set(i);
    while(m--){
        int a, b;
        cin >> a >> b;
        union_set(a, b);
    }
    map<int,int> cnt;
    repn(i, n) cnt[find_set(i)]++;
    int ans = 0;
    for(auto i : cnt){
        ans = max(ans, i.se);
    }
    cout << ans << endl;
    return 0;
}
// XD

Measured memory_bytes: 19264
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))

left = 0
right = 10**10


for _ in range(100):
    mid = left + (right - left) / 2
    count = 0
    for i in range(n):
        count += (a[i]-1)//mid

    if count > k:
        left = mid
    else:
        right = mid

print(ceil(right))


Measured memory_bytes: 93888
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		char[] cArray = S.toCharArray();

		String res = "No";
		for(int i=1;i<cArray.length;i++) {
			if(cArray[0] == cArray[i]) {
				int ti = 0,tj = 0;
				if(i == 1) {
					ti = 2;
					tj = 3;
				}
				if(i == 2) {
					ti = 1;
					tj = 3;
				}
				if(i == 3) {
					ti = 1;
					tj = 2;
				}
				if(cArray[ti] == cArray[tj]) {
					if(cArray[ti] != cArray[i]) {
						res = "Yes";
					}
				}
			}
		}

		out.println(res);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}
}

Measured memory_bytes: 21716
n,y=map(int,input().split())
for i in range(0,n+1):
    for j in range(0,n+1):
        if 10000*i+5000*j+1000*(n-i-j)==y and i+j<=n:
            print(i,j,(n-i-j))
            break
    else:
        continue
    break
if i==n and j==n:print('-1 -1 -1')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[][] line = new char[8][3];
		while (in.hasNext()) {
			char[] masu = in.nextLine().toCharArray();
			for (int i = 0; i < 3; i++) {
				line[i][0] = masu[i * 3];
				line[i][1] = masu[i * 3 + 1];
				line[i][2] = masu[i * 3 + 2];
				final int tate = i + 3;
				line[tate][0] = masu[i];
				line[tate][1] = masu[i + 3];
				line[tate][2] = masu[i + 6];
			}
			line[6][0] = masu[0];
			line[6][1] = masu[4];
			line[6][2] = masu[8];
			line[7][0] = masu[2];
			line[7][1] = masu[4];
			line[7][2] = masu[6];
			char winner = 'd';
			for (int i = 0; i < 8; i++) {
				if (line[i][0] != 's' && line[i][0] == line[i][1]
						&& line[i][1] == line[i][2]) {
					winner = line[i][0];
					break;
				}
			}
			System.out.println(winner);
		}

	}
}

Measured memory_bytes: 17144
#include "bits/stdc++.h"

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

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
P r[110], b[110];
bool used[110];
int cnt;

int main(void){
	cin>>n;
	for(int i=0;i<n;i++) cin>>r[i].first>>r[i].second;
	for(int i=0;i<n;i++) cin>>b[i].first>>b[i].second;

	sort(r, r + n, [&](P a, P b) { return a.second > b.second; });
	sort(b, b + n);

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(r[j].first < b[i].first && r[j].second < b[i].second && !(used[j])) {
				cnt++;
				used[j] = true;
				break;
			}
		}
	}

	cout<< cnt <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, M, A[1005], B[1005];
ll ans = 1;

int main(){
	getint(N), getint(M);
	for(register int i = 1; i <= N; i++) getint(A[i]);
	for(register int i = 1; i <= M; i++) getint(B[i]);
	sort(A + 1, A + N + 1), sort(B + 1, B + M + 1), A[N + 1] = B[M + 1] = inf;
	for(register int i = 1; i < N; i++) if(A[i] == A[i + 1]) return puts("0"), 0;
	for(register int i = 1; i < M; i++) if(B[i] == B[i + 1]) return puts("0"), 0;
	for(register int i = 1, j = 1, k = 1; i <= N * M; i++){
		while(j <= N && A[j] < i) j++;
		while(k <= M && B[k] < i) k++;
		if(A[j] == i && B[k] != i) ans = ans * (M - k + 1) % MOD;
		else if(A[j] != i && B[k] == i) ans = ans * (N - j + 1) % MOD;
		else if(A[j] != i && B[k] != i) ans = ans * ((M - k + 1) * (N - j + 1) - (N * M - i)) % MOD;
	}
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 256
n = int(input())
playlist = [[s for s in input().split()] for _ in range(n)]
x = input()

flag = False
ans = 0
for i in range(n):
    if flag:
        ans += int(playlist[i][1])
    else:
        if playlist[i][0] == x:
            flag = True

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << "a == b\n";
    else if (a > b)
        cout << "a > b\n";
    else
        cout << "a < b\n";
    return 0;
}


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

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

    cout << ans << endl;
}

Measured memory_bytes: 3624
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
lis = list(range(1,n+1))
count = 0
temp1 = 0
temp2 = 0
for v in itertools.permutations(lis):
    count += 1
    if list(v) == p:
        temp1 = count
    if list(v) == q:
        temp2 = count
print(abs(temp1-temp2))

Measured memory_bytes: 42352
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif
	int N,M,K;
	cin >> N >> M >> K;

	for(int m=0;m<=M;m++){
		for(int n=0;n<=N;n++){
			int k = m*N -m*n + (M-m)*n ;
			if (k==K){printf("Yes\n");return 0;}
		}
	}

	printf("No\n");
	return 0;
}


Measured memory_bytes: 256