akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

# 総和は一定なので高橋君が何点(?)とるかの問題に置き換えられる
# d=0かつx=0のときは1、x!=0ならn+1で確定
# d,xと-d,-xは同値なので、dを正にすることで増加数列で考える
# d,xを同じ数で割っても答えは変わらないので、互いに素にする
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def main():
    n, x, d = MI()
    if d == 0:
        if x == 0:
            print(1)
        else:
            print(n + 1)
        exit()
    if d < 0: d, x = -d, -x
    g = gcd(d, abs(x))
    d, x = d // g, x // g
    #print(x, d)
    # aをk個選ぶと和sはs=k*x+c*dで、cは最小で0からk-1の和
    # 最大でn-kからn-1の和
    # kを固定するとs//dは1ずつの単調増加なので、最小と最大で個数が分かる
    # sはs mod d = x*k mod dが同じなので、それで分類する
    kk = list(range(n + 1))
    kk.sort(key=lambda k: (k * x % d, k))
    #print(kk)
    ans = 0
    pmd = -1
    pl, pr = 1, 0
    for k in kk:
        l = (k * x + (k - 1) * k // 2 * d) // d
        r = (k * x + (2 * n - k - 1) * k // 2 * d) // d
        md = x * k % d
        if md == pmd and l <= pr and pl<=r:
            pl,pr=min(pl,l),max(pr,r)
        else:
            ans += pr - pl + 1
            pl, pr = l, r
        pmd = md
        #print(k, l, r, pl, pr, ans)
    ans += pr - pl + 1
    print(ans)

main()


Measured memory_bytes: 33432
#include <iostream>
using namespace std;
int main()
{
	int i;
	char str[30];
	cin >> str;
	for(i=0; str[i] != 0; i++);
	i--;
	for(;i>=0; i--){
		cout << str[i];
	}
	cout << endl;
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const int MOD=1000000007;//1e9+7
//const int MOD=998244353;
const int INTMAX=2147483647;//2e9
const ll LLMAX=9223372036854775807;//9e17


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A;
    double B;
    
    cin>>A>>B;
    
    ll b=100*(B+0.0001);
    
    cout<<A*b/100<<endl;
    
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main()
{
    long int ans;
    long double a,b;
    cin>>a>>b;
    ans=floor(a*b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int high = s[0];
            int ans = 1;
            for (int i = 1; i < n; i++)
            {
                if(high <= s[i])
                {
                    high = Max(high, s[i]);
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

//↑template↑


ll a, b, c, k[100005], score[100005];
int main() {
	cin >> a >> b >> c;
	for (int i = 0; i < c; ++i) {
		cin >> k[i];
		++score[k[i] - 1];
	}

	for (int i = 0; i < a; ++i) {
		if (b <= c - score[i]) { cout << "No" << endl; }
		else { cout << "Yes" << endl; }
	}
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  int ans = 0;
  REP(i, (1<<H)){
    REP(j, (1<<W)){
      int cnt = 0;
      REP(x, H) REP(y, W){
        if(s[x][y] == '#'){
          if(!((i >> x)&1) && !((j >> y)&1)) cnt++;
        }
      }
      if(cnt == K) ans++;
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3612
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	A, B, C = [], [], []
	for _ in range(n):
		a, b, c = rli()
		A.append(a)
		B.append(b)
		C.append(c)
	LA, LB, LC = A[0], B[0], C[0]
	for i in range(1, n):
		nLA = A[i] + max(LB, LC)
		nLB = B[i] + max(LA, LC)
		nLC = C[i] + max(LB, LA)
		LA, LB, LC = nLA, nLB, nLC
	print(max(LA, LB, LC))
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 48412
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << (min((P + Q), min((R + Q), (P + R)))) << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int min = 10e9, max = 0;
	for (int i = 0; i < n; i++) {
		if (min > a[i])
			min = a[i];
		if (max < a[i])
			max = a[i];
	}
	cout << max - min << endl;
	return 0;
}


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

N, K = LI()
P = LI()
C = LI()

INF = 10 ** 10


def all_minus():
    for c in C:
        if c > 0:
            return False
    return True


def main():
    if all_minus():
        ans = max(C)
        print(ans)
        return
        
    ans = -INF
    for i in range(N):
        w = [0]
        d = {i: 0}
        j = 1
        x = P[i] - 1
        while x not in d:
            d[x] = j
            w.append(w[j - 1] + C[x])
            x = P[x] - 1
            j += 1

        a, b = d[x], j
        for _ in range(b - a):
            w.append(w[-1] + C[x])
            x = P[x] - 1

        if K < 2 * b - a or w[b] - w[a] <= 0:
            v = max(w[:K + 1])
            ans = max(ans, v)
            continue
        
        v = w[a]
        k = K - a
        r = k // (b - a) - 1
        k -= r * (b - a)
        v += r * (w[b] - w[a])
        v += max(w[a : a + k + 1]) - w[a]
        ans = max(ans, v)
    print(ans)
        
                
if __name__ == "__main__":
    main()


Measured memory_bytes: 219624
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
struct Point
{
    int x,y;
    long h;
};
inline long cal_h(Point& p,int x,int y)
{
    return (abs(p.x-x)+abs(p.y-y)+p.h);
}
int main(int argc, const char** argv) 
{
    int X,Y,N,maxix=0,minmx=100,maxiy=0,minmy=100,m;
    int TX,TY;
    long H,bias=0;
    cin>>N;
    Point a[100];
    for(int i=0;i!=N;i++)
    {
        cin>>a[i].x>>a[i].y>>a[i].h;
        maxix=max(maxix,a[i].x);
        minmx=min(minmx,a[i].x);
        maxiy=max(maxiy,a[i].y);
        minmy=min(minmy,a[i].y);
        if(a[i].h!=0)
        {
            m=i;
        }
    }
    for(X=minmx;X<=maxix;X++)
    {
        for(Y=minmy;Y<=maxiy;Y++)
        {
            H=cal_h(a[m],X,Y);
            int state=1;
            for(int i=0;i!=N;i++)
            {
                if(a[i].h!=max(H-abs(a[i].x-X)-abs(a[i].y-Y),bias))
                {
                    state=0;
                    break;
                }
            }
            if(state)
            {
                TX=X,TY=Y;
                cout<<TX<<' '<<TY<<' '<<H;
                return 0;
            }
        }
    }
    return 1;
}

Measured memory_bytes: 3196
#! ruby
# Try AtCoder
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gf() gets.to_f end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|r,e| r[e]+=1;r} end
############################################################

n = gi
l = gis.sort.reverse

a = 0

n.times do |i|
    a += l[i * 2 + 1]
end

puts a





Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

ll cnt[2019];

void solve() {
    string s; cin >> s;
    cnt[0] = 1;
    ll ret = 0;
    ll rem = 0;
    ll mul = 1;
    for (ll i = s.size(); i--; ) {
        rem = (rem + (s[i] - '0') * mul) % 2019;
        ret += cnt[rem]++;
        mul *= 10;
        mul %= 2019;
    }
    cout << ret << endl;
}

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

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  vector<int> b(N);
  bool can = true;
  int count = 0;
  int num = 1;
  while (num != 2) {
    if (b.at(num-1) == 1) {
      can = false;
      break;
    } else {
      b.at(num-1) = 1;
      num = a.at(num-1);
      count++;
    }
  }
  
  if (can) cout << count << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
// #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double eps = 1e-9;
struct V {
  double x, y;
  V(double x=0, double y=0): x(x), y(y) {}
  V& operator+=(const V& v) { x += v.x; y += v.y; return *this;}
  V operator+(const V& v) const { return V(*this) += v;}
  V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this;}
  V operator-(const V& v) const { return V(*this) -= v;}
  V& operator*=(double s) { x *= s; y *= s; return *this;}
  V operator*(double s) const { return V(*this) *= s;}
  V& operator/=(double s) { x /= s; y /= s; return *this;}
  V operator/(double s) const { return V(*this) /= s;}
  double dot(const V& v) const { return x*v.x + y*v.y;}
  double cross(const V& v) const { return x*v.y - v.x*y;}
  double norm2() const { return x*x + y*y;}
  double norm() const { return sqrt(norm2());}
  
  int ort() const { // orthant
    if (abs(x) < eps && abs(y) < eps) return 0;
    if (y > 0) return x>0 ? 1 : 2;
    else return x<0 ? 3 : 4;
  }
  bool operator<(const V& v) const {
    int o = ort(), vo = v.ort();
    if (o != vo) return o < vo;
    return cross(v) > 0;
  }
};
istream& operator>>(istream& is, V& v) {
  is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
  os<<"("<<v.x<<","<<v.y<<")"; return os;
}

int main() {
  int n;
  cin >> n;
  vector<V> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = 0;
  rep(l,n) {
    int r = l;
    V now;
    rep(i,n) {
      now += v[r];
      ans = max(ans, now.norm());
      r = (r+1)%n;
    }
  }
  printf("%.12f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

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

    int ans = 0;
    int l = 0, r = n - 1;
    while (true)
    {
        while (l < n && s[l] == 'R') ++l;
        while (r >= 0 && s[r] == 'W') --r;
        if (l < r)
        {
            swap(s[l], s[r]);
            ++ans;
        }
        else
        {
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}



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

#define	mp			make_pair
#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<(n);i++)

using namespace std;

typedef	vector<int>		vi;
typedef	pair<int,int>	pii;

vi cell[100][100];
int ax[100000],ay[100000];

int main(){
	for(int na,nb,R;scanf("%d%d%d",&na,&nb,&R),na||nb;){
		rep(y,100)rep(x,100)	cell[y][x].clear();
		rep(i,na){
			scanf("%d%d",ax+i,ay+i);
			int u,b,l,r;
			u=max(ay[i]-4*R,0)/100,b=min(ay[i]+4*R,9999)/100;
			l=max(ax[i]-4*R,0)/100,r=min(ax[i]+4*R,9999)/100;
			pii tmp[4];
			tmp[0]=mp(u,l),tmp[1]=mp(u,r);
			tmp[2]=mp(b,l),tmp[3]=mp(b,r);
			sort(tmp,tmp+4);
			int end=unique(tmp,tmp+4)-tmp;
			rep(j,end)	cell[tmp[j].first][tmp[j].second].pb(i);
		}

		int ans=0;
		rep(i,nb){
			int bx,by;	scanf("%d%d",&bx,&by);
			int bx2=bx/100,by2=by/100;
			rep(j,cell[by2][bx2].size()){
				int id=cell[by2][bx2][j];
				if((ax[id]-bx)*(ax[id]-bx)+(ay[id]-by)*(ay[id]-by)<=16*R*R)	ans++;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3496
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<Int> time(5);
	for (Int i = 0; i < 5; i++) {
		cin >> time[i];
	}

	Int ans = INF;
	Int temp;
	do {
		temp = 0;
		for (Int i = 0; i < 5; i++) {
			temp += time[i];
			if (i!=4) {
				while (temp % 10 != 0) {
					temp++;
				}
			}
		}
		ans = min(ans, temp);

	} while (next_permutation(time.begin(), time.end()));

	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int K, T;
  cin>>K>>T;
  int tmp;
  priority_queue<pair<int, int> > que;
  for(int i=0;i<T;++i) {
    cin>>tmp;
    que.push(mp(tmp, i));
  }
  pair<int, int> tmp1, tmp2;
  int bef = -1;
  int ans = 0;
  for(int i=0;i<K;++i) {
    if(que.size()==1) {
      tmp1 = que.top();que.pop();
      if(bef==tmp1.se) ans++;
      tmp1.fi--;
      bef = tmp1.se;
      if(tmp1.fi>0) que.push(tmp1);
    }
    else {
      tmp1 = que.top();que.pop();
      tmp2 = que.top();que.pop();
      if(bef==tmp1.se) {
        tmp2.fi--;
        bef = tmp2.se;
      }
      else {
        tmp1.fi--;
        bef = tmp1.se;
      }
      if(tmp1.fi>0) que.push(tmp1);
      if(tmp2.fi>0) que.push(tmp2);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3568
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

D, G = na()
p = []
c = []

for i in range(D):
    x, y = na()
    p.append(x)
    c.append(y)

ans = 9999999999999
for i in range(1<<D):
    score = 0
    ct = 0
    for j in range(D):
        if i >> j & 1:
            score += (p[j] * (j+1) * 100 + c[j])
            ct += p[j]
    for j in range(D-1, -1, -1):
        if i >> j & 1: continue
        if score >= G: break
        g = (j + 1) * 100
        got = (G - score + g - 1) // g
        score += min(got, p[j]) * g
        ct += min(got, p[j])
    ans = min(ans, ct)
print(ans)


Measured memory_bytes: 3064
def check(P):
	global k, T, n

	i = 0
	for j in range(k):
		s = 0
		while s + T[i] <= P:
			s += T[i]
			i += 1
			if (i == n):
				return n
	
	return i

def solve():
	left = 0
	right = 100000 * 10000

	while right - left > 1:
		mid = (left + right) // 2
		v = check(mid)
		if (v >= n):
			right = mid
		else:
			left = mid

	return right

if __name__ == '__main__':
	n, k = map(int, input().split())
	T = [int(input()) for i in range(n)]

	ans = solve()
	print(ans)

Measured memory_bytes: 11600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int A[n], B[n], C[n];
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) cin >> B[i];
    for (int i = 0; i < n - 1; i++) cin >> C[i];
    int res = 0;
    for (int i = 0; i < n; i++) {
        res += B[A[i] - 1];
        if (i + 1 < n && A[i] == A[i + 1] - 1) res += C[A[i] - 1];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <utility>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <set>
    #include <cmath>
             
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
       
    #define PI 3.14159265358979323846
             
    const double EPS = 1e-8;
            
    int main()
    {
       	ll A,B,C;
     
    	cin >> A >> B >> C;
     
    	
    	cout << ((C>=A&&C<=B) ? "Yes" : "No") <<endl;
     
       	return 0;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 110
int a[N];
int main(){
	string s;
	cin>>s;
	int n = s.size();
	rep(i, n) a[i] = 1<<(s[i]-'a');
	rep(i, n){
		rep(j, 26){
			bool ok = true;
			rep(k, n-i) if(!(1&(a[k]>>j))) ok = false;
			if(ok){
				cout<<i<<endl;
				return 0;
			}
		}
		rep(k, n-i-1) a[k] |= a[k+1];
	}
	return 0;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> ps(n);
	for (auto &&p : ps)
	{
		cin >> p;
	}

	int64_t mini = n + 1;

	int64_t ans = 0;

	for (auto &&p : ps)
	{
		if (mini < p)
		{
			continue;
		}

		mini = p;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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


int main() {
  int a,b; cin >> a >> b;

  if (a <= 8 && b <= 8) cout << "Yay!";
  else cout << ":(";
  cout << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))

int main()
{
	
	int  N[4];

	for (int i = 0; i < 3; i++)
		scanf("%d", &N[i]);

	int sum = N[0] + N[1] + N[2];

	if (sum >= 22)
		printf("bust\n");
	else
		printf("win\n");

}

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

int main(void)
{
	int x, y;
	cin >> x >> y;
	int a, b;

	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
		a = 1;
	else if (x == 4 || x == 6 || x == 9 || x == 11)
		a = 2;
	else
		a = 3;

	if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 ||y == 12)
		b = 1;
	else if (y == 4 || y == 6 || y == 9 || y == 11)
		b = 2;
	else
		b = 3;

	if (a == b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int n,k,s, a[N];

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

	for(int i = 1; i <= k; i++){
		a[i] = s;
	}
	if(s == int(1e9)){
		for(int i = k + 1; i <= n; i++){
			a[i] = 1;
		}
	}
	else for(int i = k + 1; i <= n; i++) a[i] = int(1e9);

	for(int i = 1; i <= n; i++) printf("%d ", a[i]);
 
return 0;
}

Measured memory_bytes: 1664
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;













const int INF = 1e9;
vector<vector<int> > g;
vector<pair<int,int> > edge;
vector<int> s;
vector<int> se;
vector<int> used;
vector<int> dp;
vector<int> p;
int timer = 1;
int bfs(int from, int to){
    int start = to;
  //  cout << start << endl;
    queue<int> q;
    q.push(start);
    dp[start] = 1;
    p[start] = -1;
    while(q.size()){
        int v = q.front();
    //   cout << v << "*" << endl;
        used[v] = timer;
        q.pop();
        for (int i = 0; i < g[v].size(); i++){
            int to = g[v][i];
            if (used[to] == timer) continue;
            q.push(to);
            dp[to] = dp[v] + 1;
            p[to] = v;
        }
    }
    s.pb(from);
    for (int pa = p[from]; pa != -1; pa = p[pa]){
        s.pb(pa);
    }
  // cout << from << ' ' << to << endl;
//    for (auto x : s) cout << x << ' '; cout << endl;
  //  cout << dp[from] << endl;
    return dp[from];
}
signed main(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    used.resize(n);
    dp.resize(n);
    p.resize(n);
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        edge.eb(a, b);
    }
    int ans = INF;
    for (int i = 0; i < m; i++){
         //   cout << i << ' ';
        for (int j = 0; j < n; j++){dp[j] = -1; p[j] = -1;}
        int from = edge[i].fi;
        int to = edge[i].se;
        int ke = bfs(from, to);
        if (ke != -1 && ans > ke){
            ans = ke;
            se = s;
        }
        timer++;
        s.clear();
    }
    if (ans == INF){
        cout << -1;
        return 0;
    }
    cout << ans << endl;
    for (auto x : se) cout << x + 1 << endl;

}


Measured memory_bytes: 384
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
abcd = input()
for bit in range(1 << 3):
    first = int(abcd[0])
    ans = abcd[0]
    for i in range(3):
        if bit & (1 << i):
            first += int(abcd[i+1])
            ans += '+'
            ans += abcd[i+1]
        else:
            first -= int(abcd[i+1])
            ans += '-'
            ans += abcd[i+1]
    if first == 7:
        print(ans + '=7')
        exit()


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

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

    int len=s.size();

    int v, nxt=0, ans=0;
    for (int i=0; i<len; i++) {
        v = (int)s.at(len-1-i)-'0';
        if (v+nxt <= 5) {
            if (i != len-1) {
                if (v+nxt == 5) {
                    if ((int)s.at(len-2-i)-'0' >= 5) {
                        ans += 10 - (v+nxt);
                        nxt = 1;
                    } else {
                        ans += v+nxt;
                        nxt = 0;
                    }
                } else {
                    ans += v+nxt;
                    nxt = 0;
                }
            } else {
                ans += v+nxt;
                nxt = 0;
            }

        }
        else {
            ans += 10 - (v+nxt);
            nxt = 1;
        }
    }

    ans += nxt;

    cout << ans << endl;
}

Measured memory_bytes: 1412
#include<stdio.h>
int main(void){
  int number;
  int i;
  int count[6]={0};
  double height;
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%lf",&height);
    if(height<165.0){
      count[0]++;
    }
    else if(165.0<=height && height<170.0){
      count[1]++;
    }
    else if(170.0<=height && height<175.0){
      count[2]++;
    }
    else if(175.0<=height && height<180.0){
      count[3]++;
    }
    else if(180.0<=height && height<185.0){
      count[4]++;
    }
    else{
      count[5]++;
    }
  }
  printf("1:");
  for(i=0;i<count[0];i++){
    printf("*");
  }
  printf("\n");
  printf("2:");
  for(i=0;i<count[1];i++){
    printf("*");
  }
  printf("\n");
  printf("3:");
  for(i=0;i<count[2];i++){
    printf("*");
  }
  printf("\n");
  printf("4:");
  for(i=0;i<count[3];i++){
    printf("*");
  }
  printf("\n");
  printf("5:");
  for(i=0;i<count[4];i++){
    printf("*");
  }
  printf("\n");
  printf("6:");
  for(i=0;i<count[5];i++){
    printf("*");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 624
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static long mod = 1000000007;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	long[] frac = new long[200000];
    	frac[0] = 1;
    	for(int i=1; i<200000; i++) {
    		frac[i] = frac[i-1] * i % mod;
    	}
    	long ans = 0;
    	long ApBdiv = power(A+B, mod-2);
    	for(int i=0; i<=N-1; i++) {
    		long c = frac[N-1+i] * power(frac[N-1], mod-2) % mod * power(frac[i], mod-2) % mod;
    		long pra = c * power(A * ApBdiv % mod, N) % mod * power(B * ApBdiv % mod, i) % mod;
    		long prb = c * power(B * ApBdiv % mod, N) % mod * power(A * ApBdiv % mod, i) % mod;
    		long pr = (pra + prb) % mod;
    		ans = (ans + (pr * (N + i) % mod)) % mod;
    	}
    	ans = ans * 100 % mod * ApBdiv % mod;
    	System.out.println(ans);
    }

    static long power(long m , long n){
    	if(n == 0) {
    		return 1;
    	}else if(n == 1){
            return m;
        }else if(n % 2 == 0){
            long s = power(m, n/2);
            return ( (s % mod) * (s % mod) ) % mod;
        }else{
            return ( (m % mod) * (power(m, n-1) % mod) ) % mod;
        }
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 29500
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
 
typedef long long ll;
ll n, b, a[N];
 
ll abs(ll p) {return p > 0 ? p : -p;}
 
ll f(ll p) {
	ll i, q = 0, s = 0;
	for (i = 0; i < n; i++, p = -p) {
		q += a[i];
		if (p > 0) {
			if (q <= 0) s += -q + 1, q = 1;
		} else {
			if (q >= 0) s += q + 1, q = -1;
		}
	}
	return s;
}
 
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	cout << min(f(1), f(-1));
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,  
//             tree_order_statistics_node_update>  
//     ordered_set;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;


#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define ms(dp, x) memset(dp, x, sf(dp))

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve()
{
	ld r;
	cin>>r;
	ld p = 6.28318530717958623200*r;
	cout<<fixed<<setprecision(10)<<p<<endl;
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int a,b,k;
  cin >> a >> b >> k;
  
  int n = min(a,b);
  int x[n] = {0};
  int j = 0;
  for(int i = 1; i <= n; i++){
    if(a % i == 0 && b % i == 0){
      x[j] = i;
      j++;
    }
  }
  
  sort(x,n+x,greater<int>());
  int ans = x[k-1];
  cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int main() {
    ios_base::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    if (y % 2 == 0 && y >= 2 * x && y <= 4 * x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    
    if(a+b<=16)
    {
        if(a==b||abs(a-b)==1)
        {  cout<<"Yay!"; return 0;}
        int left=16-(a+b);
        int diff=abs(a-b);
        a=(diff)+(diff-1);
        if(a<=left)
          cout<<"Yay!";
        else
          cout<<":(";
    }
    
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, string S) {
    int w = count(S.begin(), S.end(), 'W');
    int e = N - w;
    int w2 = 0;
    int e2 = 0;
    int ans = 1e9;
    for (int i = 0; i < N; i++) {
        ans = min(ans, w2 + e - (S[i] == 'E'));
        if (S[i] == 'W') w--, w2++;
        else e--, e2++;
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll N;
    string S;
    cin >> N;
    cin >> S;
    solve(N, S);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 916
def root(par: list, x: int) -> int:
    if par[x] < 0:
        return x # root
    else:
        par[x] = root(par, par[x])
        return par[x]


def same(par:list, x: int, y: int) -> bool:
    return root(par, x) == root(par, y)


def unite(par:list, x: int, y: int):
    x = root(par, x)
    y = root(par, y)
    # do nothing because already connected
    if x == y:
        return

    # want to connect y(smaller) to x(bigger)
    if size(par, x) < size(par, y):
        x,y = y,x

    # update size of x
    par[x] += par[y]
    # change parent of y to x
    par[y] = x

def size(par:list, x:int) -> int:
    return -par[root(par, x)]

N,M = map(int, input().split())
# store the parent number if not it's parent, else -(size of the union).
par = [-1 for _ in range(N)]

ans = [0] * M
ans[M-1] = N*(N-1) / 2

distructions = list(tuple())

for _ in range(M):
    distructions.append(tuple(map(lambda x: int(x) - 1, input().split())))

for i in range(M-1, 0, -1):
    x,y = distructions[i]

    if not same(par,x,y):
        ans[i-1] = ans[i] - size(par, x) * size(par, y)
        unite(par,x,y)
    else:
        ans[i-1] = ans[i]

for i in range(M):
    print(int(ans[i]))


Measured memory_bytes: 21836
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n+1)
        self.rnk = [0] * (n+1)
        
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if (x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
                
    def isSameGroup(self,x,y):
        return self.Find_Root(x) == self.Find_Root(y)
    
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M,K = map(int,input().split())
t = UnionFind(N)

friends = [0] * (N+1)
for i in range(M):
    a,b = map(int,input().split())
    friends[a] += 1
    friends[b] += 1
    t.Unite(a,b)

ans = [t.Count(i+1) - friends[i+1] - 1 for i in range(N)]

block = [0] * (N+1)
for i in range(K):
    c,d = map(int,input().split())
    if t.isSameGroup(c,d):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(' '.join(map(str,ans)))

Measured memory_bytes: 17184
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {
	
	int N; cin >> N;
	
	vector<int> x(N,0);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	vector<int> tmp = x;
	sort(tmp.begin(), tmp.end());
	int l = tmp[(N/2) - 1];
	int r = tmp[(N/2)];

	for (int i = 0; i < N; i++) {
		if (x[i] <= l) {
			cout << r << endl;
		}else {
			cout << l << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3840
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int main(){
	string a;
	cin >> a;
	if(a.find("00")!=npos or a.find("11")!=npos or a.find("22")!=npos or a.find("33")!=npos or a.find("44")!=npos or a.find("55")!=npos or a.find("66")!=npos or a.find("77")!=npos or a.find("88")!=npos or a.find("99")!=npos) cout << "Bad" << endl;
	else cout << "Good" << endl;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

const int inf = 1e9;
struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} };

template<class T> bool bellman_ford(int s, const VV<edge>& g, V<T>& d) {
  int n = g.size();
  d.assign(n, inf);
  d[s] = 0;
  for (int i = 0; i < n; i++) {
    bool upd = false;
    for (int v = 0; v < g.size(); v++) if (d[v] != inf) {
      for (auto&& e : g[v]) {
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          upd = true;
        }
      }
    }
    if (!upd) return false;
  }
  return true;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, p; cin >> n >> m >> p;
  VV<edge> g(n);

  {
    V<> a(m), b(m), c(m); 
    VV<> h(n);
    for (int i = 0; i < m; ++i) {
      cin >> a[i] >> b[i] >> c[i], --a[i], --b[i];
      h[b[i]].push_back(a[i]);
    }

    bitset<2500> bs;
    auto dfs = [&](const auto& dfs, int v) -> void {
      bs[v] = true;
      for (int w : h[v]) if (!bs[w]) {
        dfs(dfs, w);
      }
    };
    dfs(dfs, n - 1);

    for (int i = 0; i < m; ++i) {
      if (!bs[a[i]] or !bs[b[i]]) continue;
      g[a[i]].emplace_back(edge{b[i], p - c[i]});
    }
  }

  V<lint> d;
  if (bellman_ford(0, g, d)) {
    cout << -1 << '\n';
  } else {
    cout << max(-d.back(), 0LL) << '\n';
  }
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	int m,s;
	public void solve(){
		Scanner sc=new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		
		m=a*b;
		s=(a+b)*2;
		
		System.out.println(m+" "+s);
	}
	
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    ll low = A*(N-1) + B;
    ll high = A + B*(N-1);

    cout << max(0LL, high - low + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map &:to_i
cm = gets.split.map &:to_i

def cm.get_the_number_of_coin(n)
  t = Array.new(n+1, Float::INFINITY)
  t[0] = 0

  self.each do |c|
    for j in c..n
      t[j] = [t[j], t[j-c]+1].min
    end
  end
  t[n]
end

puts cm.get_the_number_of_coin(n)



Measured memory_bytes: 7256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define int long long
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

signed main() {
	int N;
	int A[302][302];
	cin >> N;

	REP(i, N) {
		REP(j, N) {
			cin >> A[i][j];
		}
	}

	int ans = 0;
	int found = 0;
	REP(i, N) {
		REP(j, N) {
			found = 0;
			REP(k, N) {
				if (k == i || k == j) continue;
				if (A[i][j] == A[i][k] + A[k][j]) {
					found = 1;
				}
				if (A[i][j] > A[i][k] + A[k][j]) {
					cout << -1 << endl;
					return 0;
				}
			}

			if (found == 0) ans += A[i][j];
		}
	}
	


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

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

N = int(input())

def li():
    return [float(x) for x in input().split()]

P = li()
# dp[i][j]: i番目のコインを投げた時に、表がj枚となる確率
dp = [[0] * (N+1) for _ in range(N)]

dp[0][1], dp[0][0] = P[0], 1 - P[0]

for i in range(1, N):
    for j in range(N+1):
        p = P[i]
        if j > 0:
            dp[i][j] = dp[i-1][j-1] * p + dp[i-1][j] * (1.0 - p)
        else:
            dp[i][0] = dp[i-1][0] * (1.0 - p)

total = 0
for j in range(N+1):
    if 2 * j > N:
        total += dp[N-1][j]

print(total)


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

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

	for(int a, b; cin >> a >> b;) {
		cout << __gcd(a, b) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1188