akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

void swap(int &x, int &y) {
	int a;
	a = x;
	x = y;
	y = a;
}

int main() {
	int a[10],max,mid,min;
	for (int i=0; i<10; i++) {
		cin >> a[i];
	}
	max = a[0];
	mid = a[1];
	min = a[2];
	if (mid > max) {
		swap(max,mid);
	}
	if (min > max) {
		swap(min,max);	
	}
	if (min > mid) {
		swap(min, mid);
	}
	for (int j=3; j<10; j++) {
		if (a[j] > max) {
			min = mid;
			mid = max;
			max = a[j];
		}else if (a[j] > mid) {
			min = mid;
			mid = a[j];
		}else if (a[j] > min) {
			min = a[j];
		}
	}
	cout << max << endl << mid << endl << min << endl;
} 


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    string s; cin >> s;
    int ans = 0;
    stack <char> st;
    FOR(i, 0, s.size() - 1) {
        if (!st.empty() && s[i] != st.top()) {
            ans += 2;
            st.pop();
        }
        else st.push(s[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <array>
#include <algorithm>
 
int main(void) {
    std::array<u_int, 10> heights;
	//??\???
    for (u_int i = 0; i < 10; ++i) {
        std::cin >> heights[i];
    }
	//?????????
    std::sort(heights.begin(), heights.end(), std::greater<u_int>());
	//??????
    for (u_int i = 0; i < 3; ++i) {
        std::cout << heights[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1164
using System;

public class C
{
    public const long INF = 999999999999;
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var e = int.Parse(line[1]);
        var dp = new long[n, n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (i == j) dp[i, j] = 0;
                else dp[i, j] = C.INF;
        for (int i = 0; i < e; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var s = int.Parse(line2[0]);
            var t = int.Parse(line2[1]);
            var d = int.Parse(line2[2]);
            dp[s, t] = d;
        }
        goWarshall(dp);
        display(dp);
    }
    public static void display(long[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (i == j && dp[i, j] < 0)
                { Console.WriteLine("NEGATIVE CYCLE"); return; }
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (j == n - 1)
                {
                    if (dp[i, j] == C.INF) Console.WriteLine("INF");
                    else Console.WriteLine(dp[i, j]);
                }
                else if (dp[i, j] == C.INF) Console.Write("INF ");
                else Console.Write("{0} ", dp[i, j]);
    }
    public static void goWarshall(long[,] dp)
    {

        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                {
                    if (dp[j, i] != C.INF && dp[i, k] != C.INF)
                        dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
                }
    }
}

Measured memory_bytes: 9492
int main(){
int a,b,c,i;
char op;
for(i=1;i;i++){
scanf("%d %c %d",&a,&op,&b);
if(op== '+'){
c=a+b;
}
if(op == '-'){
c=a-b;
}
if(op== '*'){
c=a*b;
}
if(op== '/'){
c=a/b;
}
if(op== '?'){
break;
}
printf("%d\n",c);
}
return 0;
}

Measured memory_bytes: 600
N, M = map(int, input().split())
a, b, d = [0]*M, [0]*M, [0]*M
hoge, piyo = set(), set()
for i in range(M):
    ai, bi = map(int, input().split())
    if ai == 1 and bi == N:
        print('POSSIBLE')
        exit()
    elif ai == 1:
        hoge.add(bi)
    elif bi == N:
        piyo.add(ai)
if len(hoge.intersection(piyo)) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

int main(){

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

    int ans = 1;

    for(int i = 0; i < n-1; ++i){
        if(s.at(i) != s.at(i+1))++ans;
    }

    cout << ans << endl;

}

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

int main() {
    int N; cin >> N;
    float ans = 0.0;

    for (int i = 0; i < N; ++i) {
        float x; cin >> x;
        string u; cin >> u;
        if (u=="BTC"){
            ans += 380000.0 * x;
        } else {
            ans += x;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type rs []rune

func (s rs) Len() int           { return len(s) }
func (s rs) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s rs) Less(i, j int) bool { return s[i] < s[j] }

func solve() {
	s, t := getRunes(), getRunes()
	sort.Sort(rs(s))
	sort.Sort(sort.Reverse(rs(t)))

	s1, t1 := string(s), string(t)
	ans := "Yes"
	if s1 >= t1 {
		ans = "No"
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int l=0;
//  int r=n;
  int r=n;
  for(int i=0;i<n;i++){
    if(a[i]>=k){
      r=i;
      break;
    }
  }

  int mid;
  for(int x=0;x<13;x++){
    mid=(l+r)/2;
    //cout<<l<<" "<<mid<<" "<<r<<endl;
    vector<vector<int> > dp(n+1,vector<int>(k+2,0));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
      for(int j=0;j<k+2;j++){
        if(dp[i][j]==1){
          dp[i+1][j]=1;
          if(i!=mid&&j+a[i]<k+2)dp[i+1][j+a[i]]=1;
        }
      }
    }
    bool f=false;
    for(int i=max(0LL,k-a[mid]);i<k;i++)if(dp[n][i])f=true;
    if(!f){
      l=mid;
    }else{
      r=mid;
    }
  }
  cout<<r<<endl;
  /*
  if(r>n)cout<<0<<endl;
  else cout<<r<<endl;*/
}


Measured memory_bytes: 196032
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
	char *s[101], *c;
	int n,i,l,j;
	scanf("%d %d", &n, &l);
	for(i=0; i<n; i++)
		s[i]= (char *)malloc((l+1)*sizeof(char));
	for(i=0; i<n; i++)
		scanf("%s", s[i]);
	for(i=0; i<n-1; i++)
		for(j=i+1; j<n; j++)
		{
			if(strcmp(s[i], s[j])>0)
			{
				c=s[i];
				s[i]=s[j];
				s[j]=c;
			}
		}
	for(i=0; i<n;i++)
		printf("%s", s[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  string s;
  cin >> s;
  vi a(26,0);
  rep(i,sz(s)) {
    a[s[i]-'a']++;
  }
  rep(i,26) {
    if(a[i]==0) {
      cout << (char)(i+'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;


char S[3];

int main() {

	cin >> S;
	sort(S, S + 3);
	if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    map<ll,ll>mp;
    ll s=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
        if(!mp.count(a[i])){
            mp[a[i]]=1;
        }
        else{
            mp[a[i]]++;

        }
    }
    ll q;
    cin>>q;
    while(q--){
            ll b,c;
    cin>>b>>c;
    ll k=mp[b];
    s=s-k*b+k*c;
    cout<<s<<endl;
    mp[b]=0;
    if(!mp.count(c))mp[c]=k;
    else{
        mp[c]+=k;
    }

    }
    return 0;
}


Measured memory_bytes: 10056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
//#define ivorysi
#define MAXN 100005
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) out(x / 10);
	putchar('0' + x % 10);
}
int H,W;
char s[305][305];
int sum[605][605];
vector<int> row[605],col[605];
int Query1(int x1,int x2,int y) {
	if(x2 < x1) return 0;
	if(y < 1 || y > H + W) return 0;
	x2 = min(x2,H + W);
	x1 = max(x1,1);
	return sum[x2][y] - sum[x1 - 1][y] - sum[x2][y - 1] + sum[x1 - 1][y - 1];
}
int Query2(int x,int y1,int y2) {
	if(y2 < y1) return 0;
	if(x < 1 || x > H + W) return 0;
	y2 = min(y2,H + W);
	y1 = max(y1,1);
	return sum[x][y2] - sum[x][y1 - 1] - sum[x - 1][y2] + sum[x - 1][y1 - 1];
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	read(H);read(W);
	for(int i = 1 ; i <= H ; ++i) {
		scanf("%s",s[i] + 1);
	}
	for(int i = 1 ; i <= H ; ++i) {
		for(int j = 1 ; j <= W ; ++j) {
			if(s[i][j] == '#') {
				sum[i + j][i - j + W]++;
				row[i + j].pb(i - j + W);
				col[i - j + W].pb(i + j);
			}
		}
	}
	for(int i = 1 ; i <= H + W ; ++i) {
		for(int j = 1 ; j <= H + W ; ++j) {
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		}
	}
	int64 ans = 0;
	for(int i = 1 ; i <= H + W ; ++i) {
		int s = row[i].size();
		sort(row[i].begin(),row[i].end());
		for(int j = 0 ; j < s ; ++j) {
			for(int k = j + 1 ; k < s ; ++k) {
				int l = row[i][k] - row[i][j];
				ans += Query2(i - l,row[i][j],row[i][k]);
				ans += Query2(i + l,row[i][j],row[i][k]);
			}
		}
	}
	for(int i = 1 ; i <= H + W ; ++i) {
		int s = col[i].size();
		sort(col[i].begin(),col[i].end());
		for(int j = 0 ; j < s ; ++j) {
			for(int k = j + 1 ; k < s ; ++k) {
				int l = col[i][k] - col[i][j];
				ans += Query1(col[i][j] + 1,col[i][k] - 1,i - l);
				ans += Query1(col[i][j] + 1,col[i][k] - 1,i + l);
			}
		}
	}
	out(ans);enter;
	return 0;
}


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

signed main(){
  vector<int> A(9);
  rep(i,9)cin>>A[i];
  int N;
  cin>>N;
  vector<int> B(N);
  rep(i,N)cin>>B[i];
  rep(i,9){
    rep(j,N){
      if(A[i]==B[j])A[i]=0;
    }
  }
  string ans="No";
  if(A[0]==0&&A[1]==0&&A[2]==0)ans="Yes";
  if(A[3]==0&&A[4]==0&&A[5]==0)ans="Yes";
  if(A[6]==0&&A[7]==0&&A[8]==0)ans="Yes";
  if(A[0]==0&&A[3]==0&&A[6]==0)ans="Yes";
  if(A[1]==0&&A[4]==0&&A[7]==0)ans="Yes";
  if(A[2]==0&&A[5]==0&&A[8]==0)ans="Yes";
  if(A[0]==0&&A[4]==0&&A[8]==0)ans="Yes";
  if(A[2]==0&&A[4]==0&&A[6]==0)ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iostream>
using namespace std;
typedef long long LL;
typedef double DB;
const int Max = 1e5;
const int MOD = 1e9 + 7;


int n, m, all;
int pre[100005], last[100005], other[100005], seq[100005];
bool In[100005];
LL c[100005], dis[100005];
LL cost[20][20];


void Build(int x, int y, LL z)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	c[all] = z;
}

void Bfs(int s)
{
	int h = 1, t = 1, now, ed, dr;
	seq[t] = s;
	for(int i = 0; i <= 9; i++) {
		if(i == s) {
			dis[i] = 0;
		}
		else dis[i] = 1ll << 60;
	}
	In[s] = 1;
	while(h <= t)
	{
		now = seq[h];
		ed = last[now];
		while(ed != -1){
			dr = other[ed];
			if(dis[now] + c[ed] < dis[dr])
			{
				dis[dr] = dis[now] + c[ed];
				if(!In[dr])
				{
					In[dr] = 1;
					seq[++t] = dr;
				}
			}
			ed = pre[ed];
		}
		In[now] = 0;
		h++;
	}
}
int main()
{
	memset(last, -1, sizeof(last));
	all = -1;
	scanf("%d%d", &n, &m);
	for(int i = 0; i <= 9; i++) {
		for(int j = 0; j <= 9; j++) {
			LL x;
			scanf("%lld", &x);
			Build(i, j, x);
		}
	}
	LL sum = 0;
	for(int i = 0; i <= 9; i++){
		memset(dis, 0, sizeof(dis));
		memset(seq, 0, sizeof(seq));
		memset(In, 0, sizeof(In));
		Bfs(i);
		for(int j = 0; j <= 9; j++) cost[i][j] = dis[j];
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			LL x;
			scanf("%lld", &x);
			if(x != -1 && x != 1){
				sum += cost[x][1];
			}
		}
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

ll n;
int main()
{
    cin >> n;
    string s;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "AC")
        {
            ac++;
        }
        else if (s == "WA")
        {
            wa++;
        }
        else if (s == "TLE")
        {
            tle++;
        }
        else if (s == "RE")
        {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}


Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[n-1])

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
//const ll mod = 1000 * 1000 * 1000 + 7;




void solve() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << "A" << s2[0] << "C\n";

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define NMAX 100

int calc_max(int c[],int n,int k){
	int sc=1;
	int max=-1;
	for(int i=0;i<n;i++){
		sc*=c[i];
		if(i>=k-1){
			if(sc>max){
				max=sc;
			}
			sc/=c[i-k+1];
		}
	}
	return max;
}

int main(){

	int n,k;
	int card[NMAX];
	int chcard[NMAX];
	int befmax,afmax;

	while(1){

		cin>>n>>k;
		if(n==0&&k==0) break;

		for(int i=0;i<n;i++){
			cin>>card[i];
		}

		befmax=calc_max(card,n,k);

		afmax=-1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j) break;
				for(int k=0;k<n;k++){
					if(k==i) chcard[k]=card[j];
					else if(k==j) chcard[k]=card[i];
					else chcard[k]=card[k];
				}
				int tmp=calc_max(chcard,n,k);
				if(tmp>afmax) afmax=tmp;
			}
		}

		if(afmax<befmax) cout<<"NO GAME"<<endl;
		else cout<<afmax-befmax<<endl;

	}



	return 0;
}

Measured memory_bytes: 1160
def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 72628
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    double m=0;
    for(int i=0;i<n;i++){
      double k=sc.nextDouble();
      if(sc.next().equals("JPY")){
        m+=k;
      }else{
        m+=k*380000;
      }
    }
    System.out.println(m);
  }
}

Measured memory_bytes: 25172
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    int n=in(),m=in();
    vector<int> v;
    rep(i,n){
        v.pb(in());
    }
    sort(all(v));
    vector<pii> cnt(m+1);
    for(int i=0;i<v.size();i++){
        int j=0;
        while(i+j<v.size()&&v[i+j]==v[i]){
            j++;
        }
        cnt[v[i]%m].first+=j;
        cnt[v[i]%m].second+=j/2;
        i+=j;
        i--;
    }
    rep(i,m){
        //cout<<cnt[i].first<<" "<<cnt[i].second<<endl;
    }
    ll ans=0;
    rep(i,m/2+1){
        if(i*2==m||i==0){
            ans+=cnt[i].first/2;
        }
        else{
            pii p=cnt[i],q=cnt[m-i];
            ans+=min(p.first,q.first);
            //cout<<ans<<endl;
            if(p.first>q.first){
                ans+=min(p.first-q.first,p.second*2)/2;
            }
            else{
                ans+=min(-p.first+q.first,q.second*2)/2;
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int val=0;
for(int i=0;i<(1<<(n));i++)
{if(i!=k)
    val^=i;
}
if(val==k||k==0)
{
    if(k==0)
    {
        for(int i=0;i<(1<<(n));i++)
            cout<<i<<" "<<i<<" ";
    }
    else
    {
        cout<<k<<" ";
        for(int i=0;i<(1<<n);i++)
        {  if(i!=k)
            cout<<i<<" ";
        }
        cout<<k<<" ";
        for(int i=(1<<n)-1;i>=0;i--)
        {
            if(i!=k)
                cout<<i<<" ";
        }
        cout<<endl;
    }
}
else
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N, K;
vector<int> X;

int main() {
	cin >> N >> K;
	X.resize(N);
	for (int n = 0; n < N; n++)cin >> X[n];
	int ans = 0;
	for (int n = 0; n < N; n++) {
		ans += min(X[n], K - X[n]);
	}
	cout << 2 * ans << endl;
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    H,A = LMIIS()
    from math import ceil
    print(ceil(H/A))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
          int n=sc.nextInt();
          int x[][]=new int[3][9];
          int y[]=new int[9];
         while((n--)!=0){
            int count=0;
             for(int i=0;i<3;i++){
                 for(int j=0;j<9;j++){
                     x[i][j]=0;
                 }
             }
             for(int i=0;i<9;i++){
                 y[i]=sc.nextInt();
                 y[i]--;
             }
             for(int i=0;i<9;i++){
                String a=sc.next();
                if(a.equals("R"))x[0][y[i]]++;
                if(a.equals("G"))x[1][y[i]]++;
                if(a.equals("B"))x[2][y[i]]++;
            }
           
            for(int i=0;i<3;i++){
                for(int j=0;j<7;j++){
                    if(x[i][j]>=1&&x[i][j+1]>=1&&x[i][j+2]>=1){
                        x[i][j]--;x[i][j+1]--;x[i][j+2]--;
                        count++;
                        j--;
                    }
                    }
                }
                    for(int i=0;i<3;i++){
                        for(int j=0;j<9;j++){
                            if(x[i][j]==3){
                                x[i][j]-=3;
                                count++;
                            }
                        }
                    }
                        if(count==3)System.out.println(1);
                        else System.out.println(0);
            }
            
         
}
}



Measured memory_bytes: 28488
#include<stdio.h>

int dp[50];
/*フィボナッチ関数*/
int fib(int n){
  if(n==0||n==1)
    return dp[n]=1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;

  for(i=0;i<50;i++)
    dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



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

int main() {
    int a,b;
    cin >> a >>b;
    if(a<6) b=0;
    else if(a>=6 && a<=12) b /=2;

    cout << b << endl;

}


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

int main() {
	int n,m;cin>>n>>m;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	double st=double(sum)/(4*m);
	int count=0;
	for(int i=0;i<n;i++){
		if(st<=a[i]){
			count++;
		}
	}
	if(count>=m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;
typedef long long LL;
typedef long double DD;
const int inf = 1e9;
const int mo= 1e9+7;
const int N = 200010;
int n,m,a[N];
set<int> s;

int main(){
	scanf("%d%d",&n,&m);
	int mn=inf,d=0;
	for(int i = 1; i<= n; i++){
		scanf("%d", a+i);
		d=max(d,a[i]-mn);
		mn=min(a[i],mn);
	}
	int ans=0;
	for(int i= 1; i<= n; i++){
		set<int>::iterator it=s.find(a[i]-d);
		if(it != s.end())
			ans++;
		s.insert(a[i]);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0)
{
  if (fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 5e6+ 2;

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < n; i++)
    cnt += s[i] == 'R';
  int ans = 0;
  for(int i = 0; i < cnt ; i++)
    ans += s[i] == 'R';
  
  cout << (cnt - ans) << endl;
  return 0;
}

Measured memory_bytes: 3776
class UnionFind
  def initialize(n)
    @parents = Array.new(n, -1) # if negative value means size
  end

  def unite(a, b)
    a = root(a)
    b = root(b)

    return false if a == b

    a, b = b, a if -@parents[a] < -@parents[b]
    @parents[a] += @parents[b] # if negative value means size
    @parents[b] = a
    true
  end

  def root(a)
    @parents[a] < 0 ? a : (@parents[a] = root(@parents[a]))
  end

  def same?(a, b)
    root(a) == root(b)
  end

  def size(a)
    -@parents[root(a)]
  end
end

n, q = gets.split.map { |e| e.to_i }

uf = UnionFind.new(n)

q.times do
  t, u, v = gets.split.map { |e| e.to_i }
  
  if t == 0
    uf.unite(u, v)
  else
    puts (uf.same?(u, v) ? 1 : 0)
  end
end


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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

template <class S, S (*op)(S, S), S (*el)()> class SegmentTree {
private:
  int N, size, log;
  vector<S> D;
  void apply(int k) { D.at(k) = op(D.at(2 * k), D.at(2 * k + 1)); }
  int ceil_pow(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
  }

public:
  SegmentTree() : SegmentTree(0) {}
  SegmentTree(int n) : SegmentTree(vector<S>(n, el())) {}
  SegmentTree(const vector<S>& v) : N(int(v.size())) {
    log = ceil_pow(N);
    size = 1 << log;
    D = vector<S>(2 * size, el());
    for (int i = 0; i < N; i++) D.at(size + i) = v.at(i);
    for (int i = size - 1; i >= 1; i--) {
      apply(i);
    }
  }
  void set(int p, S x) {
    p += size;
    D.at(p) = x;
    for (int i = 1; i <= log; i++) apply(p >> i);
  }
  S get(int p) { return D.at(p + size); }
  S query(int l, int r) {
    r++;
    S sml = el(), smr = el();
    l += size, r += size;
    while (l < r) {
      if (l & 1) sml = op(sml, D.at(l++));
      if (r & 1) smr = op(D.at(--r), smr);
      l >>= 1, r >>= 1;
    }
    return op(sml, smr);
  }
  S query_all() { return D.at(1); }
  template <bool (*f)(S)> int max_right(int l) {
    return max_right(l, [](S x) { return f(x); });
  }
  template <class F> int max_right(int l, F f) {
    if (l == N) return N;
    l += size;
    S sm = el();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!f(op(sm, D.at(l)))) {
        while (l < size) {
          l = (2 * l);
          if (f(op(sm, D.at(l)))) sm = op(sm, D.at(l++));
        }
        return l - size;
      }
      sm = op(sm, D.at(l++));
    } while ((l & -l) != l);
    return N;
  }
  template <bool (*f)(S)> int min_left(int r) {
    return min_left(r, [](S x) { return f(x); });
  }
  template <class F> int min_left(int r, F f) {
    if (r == 0) return 0;
    r += size;
    S sm = el();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!f(op(D.at(r), sm))) {
        while (r < size) {
          r = (2 * r + 1);
          if (f(op(D.at(r), sm))) sm = op(D.at(r--), sm);
        }
        return r + 1 - size;
      }
      sm = op(D.at(r), sm);
    } while ((r & -r) != r);
    return 0;
  }
};

int op(int a, int b) { return gcd(a, b); };
int el() { return 0; };

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  SegmentTree<int, op, el> ST(A);

  int ans = 1;
  cmax(ans, ST.query(1, N - 1));
  for (int i = 1; i + 1 < N; i++) {
    cmax(ans, gcd(ST.query(0, i - 1), ST.query(i + 1, N - 1)));
  }
  cmax(ans, ST.query(0, N - 2));
  cout << ans << "\n";
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll a, b, x, y;
    double ans;
    cin >> a >> b >> x;
    if (x > a*a*b/2.0){
        x = a*a*b-x;
        ans = atan2(2.0*x/a/a, a) / PI * 180.0;
    }
    else ans = 90 - atan2(2.0*x/b/a, b) / PI * 180.0;
    cout << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from numba import njit

input = sys.stdin.readline


@njit
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N * h * n
            b = 4 * h * n - (h + n) * N
            if b > 0 and a % b == 0:
                w = a // b
                return h, n, w


def main():
    N = int(input())
    h, n, w = solve(N)
    print(h, n, w)


if __name__ == "__main__":
    main()


Measured memory_bytes: 109372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int a, p;
  cin >> a >> p;
  cout << (3 * a + p) / 2 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};




int main() {

	ll N;
	cin >> N;

	vector<pair<ll, ll>> r(N + 1);

	repn(i, N) cin >> r[i].first >> r[i].second;

	sort(++r.begin(), r.end());

	vector<ll> x(N + 1);
	repn(i, N) x[i] = r[i].first;

	vector<ll> a(N + 1);

	repn(i, N) {
		auto itr = lower_bound(++x.begin(), x.end(), r[i].first + r[i].second);
		a[i] = distance(x.begin(), itr);
	}

	vector<ll> R(N + 1);

	Segment_Tree<ll> sg(N, [](ll a, ll b) {return max(a, b); }, 0);

	repn(i, N) sg.update(i, i+1);

	for (ll i = N; i >= 1; i--) {
		R[i] = sg.query(i, a[i]);
		sg.update(i, R[i]);
	}

	vector<ll> dp(N + 2);

	dp[N + 1] = 1;

	for (ll i = N; i >= 1; i--) {
		dp[i] = dp[i + 1] + dp[R[i]];
		dp[i] %= MOD;
	}

	cout << dp[1];


	system("PAUSE");

}





Measured memory_bytes: 13944
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<tuple>
#include<iomanip>
using namespace std;
#define int                  int64_t
#define double               long double
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define all(a)               (a).begin(),(a).end()
#define rall(a)              (a).rbegin(),(a).rend()
#define PI                   3.1415926535897932384626433832795
#define read(a)              for(auto& x:a) cin>>x
#define speak(a)             for(auto x:a) cout<<x<<' '
#define rep(i,s,n)           for(int i=s;i<n;++i)
#define repe(i,s,n)          for(int i=s;i<=n;++i)
#define repr(i,n,s)          for(int i=n;i>=s;--i)
#define endl                 '\n'
#define gap                  ' '
#define MAX                  LLONG_MAX
#define MIN                  LLONG_MIN
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define MOD                  1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;cin>>n>>k;
    int x=n/k;
    int a=abs(n-k*x);
    int b=abs(a-k);
    cout<<min(a,b);
}


Measured memory_bytes: 3520
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
     int n;
     cin>>n;
    vector<ll>arr(n);
    ll k;
     for(int i=0;i<n;i++)
     {
     	cin>>k;
     	arr[i]=k;
	 }
	 sort(arr.begin(),arr.end());
	 long long ans=0;
	 int i=0;
	 int j=n-2;
	 ans+=arr[n-1];
	 k=2;
	 while(j>=0&&k<n)
	 {
	 	ans+=2*arr[j];
	 	j--;
	 	k+=2;
	 }
	 if(k==n)
	 cout<<ans;
	 else
	 {
	 	j++;
	 	ans-=arr[j];
	 	cout<<ans;
	 }
	
		
		   
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi 1
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

#define MAX_N 305
#define MAX_M 305

int N, M;
int A[MAX_N][MAX_M];
int SA[MAX_N];

bool removed[MAX_M];
int tmp[MAX_M];

int solve(int depth = 0)
{
  if(depth == M){
    return N;
  }

  memset(tmp, 0, sizeof(tmp));
  for (int i = 0; i < N; i++) {
    for (int j = SA[i]; j < M; j++) {
      if(!removed[A[i][j]]){
        tmp[A[i][j]]++;
        SA[i] = j;
        break;
      }
    }
  }

  int ret = 0;
  int k = 0;

  for (int i = 0; i < M; i++) {
    if(ret < tmp[i]){
      ret = tmp[i];
      k = i;
    }
  }

  removed[k] = true;
  return min(ret, solve(depth + 1));
}

int main()
{
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j]; A[i][j]--;
    }
  }

  memset(removed, 0, sizeof(removed));
  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N; cin >> N;
    vector<pair<ll,ll> > p(N);
    for (int i = 0; i < N; i++){
        cin >> p[i].second >> p[i].first;
    }
    sort(p.begin(), p.end());
    ll now = 0;
    for (int i = 0; i < N; i++){
        now += p[i].second;
        if (now > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int[] a = new int[N];
  for(int i = 0;i < N;i++)a[i] = sc.nextInt();
  Arrays.sort(a);
  System.out.println(a[N-1] - a[0]);
}}


Measured memory_bytes: 19156
(let* ((a (read))
    (b (read))
    (c (read))
    (max_num (* 3 (max a b c)))
    (ans 0))
    (if (zerop(rem (- max_num (+ a b c)) 2))
        (setq ans (/ (- max_num (+ a b c)) 2))
        (setq ans (+ (floor (/ (- max_num (+ a b c)) 2)) 2))
    )
    

    (princ ans)
)

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

using namespace std;

using ll = long long;

ll dp[3000][51] = {};

int main() {
  ll ans = 0;
  int n, a;
  cin >> n >> a;
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    for (int j = 2700; j >= 0; --j) {
      for (int k = n; k >= 0; --k)
        dp[j + b][k + 1] += dp[j][k];
    }
  }
  for (int i = 0; i < 2700; ++i) {
    for (int j = 1; j < n + 1; ++j) {
      if (i % j == 0) {
        if (i / j == a) {
          ans += dp[i][j];
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1280
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w[] = new int[n];
        int wa = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            wa += w[i];
        }
        int s1 = 0;
        int ans = wa;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            wa -= w[i];
            if (Math.abs(s1 - wa) < ans) {
                ans = Math.abs(s1 - wa);
            }
        }
        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 22996
#include <iostream>                                             
#include <iomanip>                                              
#include <cmath>                                                
using namespace std;                                            
                                                                
int main(void) {                                                
  double x1, y1, x2, y2;                                        
  cin >> x1 >> y1 >> x2 >> y2;                                  
  double P1_P2 = sqrt(pow(x2-x1,2)+pow(y2-y1,2));               
  cout << fixed << setprecision(8) << P1_P2 << endl;            
  return 0;                                                     
}                                                               
                                                                
                       

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

int main(){
  int N;
  cin >> N;
  vector<double> Ai(N);
  
  rep(i,N){
    double A;
    cin >> A;
    Ai.at(i) = 1/A;
  }
  
  double sum = accumulate(Ai.begin(), Ai.end(), 0.0);
  cout << 1/sum << endl;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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


int main(){
  int D,G;
  cin>>D>>G;
  vector<pair<int,int>> A(D);
  REP(i,D) cin>>A[i].fi>>A[i].se;
  int ans = inf;
  REP(i,(1<<D)) {
    vector<bool> used(D,false);
    int point = 0;
    int num = 0;
    int t = i;
    REP(j,D) {
      if (t%2==0) {
        point += A[j].fi * (j + 1) * 100 + A[j].se;
        num += A[j].fi;
        used[j] = true;
      }
      t /= 2;
    }
    if (point >= G) {
        ans = min(num,ans);
        continue;
    }
    for (int j=D-1;j>=0;j--) {
        if (!used[j]) {
            if (A[j].fi*(j+1)*100 >= G - point) {
                int d = G -point;
                num += d / ((j+1)*100);
                ans = min(ans,num);
            }
            break;
        }
    }
  }
  cout<<max(ans,1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 1;
	vector<int> con;
	
	
	cin>>N;
	
	con.resize(N+1);
	
	for(int i = 2; i <= N; i++){
		int x = i;
		for(int j = 2; j*j <= x; j++){
			
			while(x%j == 0){
				con[j]++;
				x /= j;
			}
		}
		con[x]++;
	}
	
	for(int i = 2; i <= N; i++){
		ans *= (con[i]+1)%MOD;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    long long d; cin >> d;
    int ans = 0;
    while (n--) {
        long long x, y; cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
from itertools import product

n,m,x = list(map(int, input().split()))
book = []
for i in range(n):
    book.append(list(map(int, input().split())))

ans = 10 ** 5 * n
flag = False
for i in product([0,1], repeat=n):
    price = 0
    skill = [0] * m
    for index_, bit in enumerate(i):
        if bit:
            for j in range(m):
                skill[j] += book[index_][ j + 1]
            price += book[index_][0]
    if all(v >= x for v in skill):
        ans = min(ans, price)
        flag = True
if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9216