akhauriyash/Code-Regression huggingface dataset:
#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 n,m;
  cin >> n >> m;
  int use[m];
  rep(i,m){
    cin >> use[i];
    use[i]--;
  }
  sort(use,use+m);
  int a[9] = {2,5,5,4,5,6,3,7,6};
  vector<int> t(10005,-100000);
  t[0]=0;
  rep(i,n){
    for(auto k:use){
      if((i+1-a[k])>=0)t[i+1]=max(t[i+1],t[i+1-a[k]]+1);
    }
  }
  // rep(i,n+1){
  //   cout << t[i] << endl;
  // }
  int tmp=n;
  rep(i,t[n]-1){
    rep(j,m){
      if(t[tmp-a[use[m-j-1]]]==t[tmp]-1){
        cout << use[m-j-1]+1;
        tmp -= a[use[m-j-1]];
        break;
      }
    }
  }
  rep(j,m)if(tmp==a[use[m-j-1]]){
    cout << use[m-j-1]+1;
    break;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
 int a,b;

int main()
{
    cin >> a>>b;
    if (a>=13)
        cout<<b<<endl;
    if (a>=6 && a<=12)
        cout<<(b/2)<<endl;
    if (a<=5) 
        cout<<0<<endl;
    return 0;
}



Measured memory_bytes: 256
N = int (input())
x = []*N
y = []*N
for i in range (N):
    a,b = list(map(int,input().split()))
    x.append(a)
    y.append(b)
syou = x[0]+y[0]
dai = x[0]+y[0]
for i in range (N):
    if x[i]+y[i]>dai:
        dai = x[i]+y[i]
    if x[i]+y[i]<syou:
        syou = x[i]+y[i]
ans = dai - syou
gyakusyou = 10**9 -x[i] +y[i]
gyakudai = 10**9 -x[i] + y[i]
for i in range (N):
    if 10**9 -x[i] +y[i]>gyakudai:
        gyakudai = 10**9 -x[i] +y[i]
    if 10**9 -x[i] +y[i]<gyakusyou:
        gyakusyou = 10**9 -x[i] +y[i]
if gyakudai - gyakusyou > ans:
    ans = gyakudai - gyakusyou
print (ans)

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

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

  int total = 3;
  for (int i = 0; i < n-1; i++) total *= 3;

  int minus = 1;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    if (t % 2 == 0) minus *= 2;
  }

  cout << total - minus << endl;

  return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
Cls = []
for i in range(10):
    Cls.append(list(map(int,input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            Cls[i][j] = min(Cls[i][j], Cls[i][k] + Cls[k][j])
costls = []
for i in range(10):
    costls.append(Cls[i][1])
numls = []
for i in range(H):
    numls += list(map(int,input().split()))
ans = 0
for i in range(H*W):
    if numls[i] == -1:
        continue
    ans += costls[numls[i]]
print(ans)

Measured memory_bytes: 9476
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	//vector<int> k(n);
	//vector <vector<int>> a(n, vector<int>(k));
	vector<int> cnt(m, 0);
	for (int i = 0; i < n; i++) {
		//cin >> k[i];
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			//cin >> a.at(i).at(j);
			int a;
			cin >> a;
			//cnt[a.at(i).at(j)-1]++;
			cnt[a-1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (cnt[i] == n) { ans++; }
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define USE_IOSTREAM \
{\
	ios::sync_with_stdio(false);\
	cin.tie(0);\
	cout.tie(0);\
}

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;



int main()
{
	USE_IOSTREAM;
	ll n, m, ans;
	
	cin >> n >> m;
	ans = min(n, m / 2);
	m -= ans * 2;
	ans += m / 4;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
double p[3000], dp[3000][3000];
int main()
{
	int n, m, i, j, k; cin >> n;
	//double p[n + 1];
	for (i = 0; i < n; i++) cin >> p[i];
	//double dp[n + 1][n + 1];
	dp[0][0] = (1 - p[0]);
	dp[0][1] = p[0];
	for (i = 1; i < n; i++)
	{
		for (j = 0; j < 3000; j++)
		{
			//head
			if (j > 0)
				dp[i][j] += p[i] * dp[i - 1][j - 1];
			//tail
			dp[i][j] += (1 - p[i]) * dp[i - 1][j];
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	double ans = 0;
	for (i = n / 2 + 1; i < 3000; i++) ans += dp[n - 1][i];

	cout << setprecision(10) << fixed;
	cout << ans << endl;




}


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

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF = 1e+15;
const double EPS = 1e-8;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};

int w,h,sx,sy,gx,gy;
string field[510];

template<class T = int>
vector<vector<T>> bfs(int ind){
	using P = pair<int,int>;
	vector<vector<T>> dist(h,vector<T>(w,INF));
	queue<P> que;
	if(!ind){
		dist[gx][gy] = 0;
		que.emplace(gx,gy);
	}else{
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(field[i][j] == '*'){
					dist[i][j] = 0;
					que.emplace(i,j);
				}
			}
		}
	}
	for(T d = 0;;d++){
		int siz = que.size();
		if(siz == 0) break;
		for(int i = 0;i < siz;i++){
			int x,y;
			tie(x,y) = que.front();que.pop();
			for(int j = 0;j < 4;j++){
				int nx = x + dx[j],ny = y + dy[j];
				if(nx >= 0 && nx < h && ny >= 0 && ny < w
				&& field[nx][ny] != '#' && (ind || field[nx][ny] != '*')
				&& dist[nx][ny] == INF){ 
					dist[nx][ny] = d + 1;
					que.emplace(nx,ny);
				}
			}
		}
	}
	return dist;
}

signed main(){
	cin >> w >> h;
	for(int i = 0;i < h;i++) cin >> field[i];
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(field[i][j] == 's') sx = i,sy = j;
			if(field[i][j] == 'g') gx = i,gy = j;
		}
	}
	auto dist1 = bfs(0),dist2 = bfs(1);
	int d = 0,xcnt = 0,cnt = 0;
	vector<int> vec;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(field[i][j] != '#' && field[i][j] != '*'){
				cnt++;
				if(dist1[i][j] <= dist2[i][j]){
					if(dist1[i][j] != INF) d += dist1[i][j];
				}else{
					d += dist2[i][j];
					xcnt++;
					if(dist1[i][j] != INF) vec.push_back(dist1[i][j] - dist2[i][j]);
				}
			}
		}
	}
	double ans = dist1[sx][sy];
	sort(vec.begin(),vec.end());
	for(int v : vec){
		double x = (double)d / (cnt - xcnt - 1);
		//cout << v << " " << x << " " << d << " " << cnt - xcnt << " " << endl;
		if(x < v + EPS) chmin(ans,dist2[sx][sy] + x);
		d += v;
		xcnt--;
	}
	double x = (double)d / (cnt - xcnt - 1);
	chmin(ans,dist2[sx][sy] + x);
	printf("%.15lf\n",ans);
}


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

int main() {
  int N,K,i,j;
  cin>>N>>K;
  vector<bool> B(N,true);
  for (i=0;i<K;i++) {
    int d,a;
    cin>>d;
    for (j=0;j<d;j++) {
      cin>>a;
      B[a-1]=false;
    }
  }
  int ans=0;
  for (i=0;i<N;i++) {
    if (B[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long


main(){

	int n; cin >> n;	


	vector <int> a(n);

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

	int g = a[0];

	for(int i = 1; i < n; i++){
		g = __gcd(g, a[i]);
	}


	cout << g << endl;

	
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (size_t i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> k(n);
  for (int i = 0; i < n; i++) {
    k[i] = i;
  }
  double sum = 0;
  int cnt = 0;
  do {
    for (size_t i = 0; i + 1 < n; i++) {
      double p = x[k[i]] - x[k[i + 1]];
      p *= p;
      double q = y[k[i]] - y[k[i + 1]];
      q *= q;

      sum += sqrt(p + q);
    }

    cnt++;
  } while (next_permutation(k.begin(), k.end()));

  double ans = sum / (double)cnt;
  printf("%.12f\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char ch;
	int num;
	int counter[26] = { 0 };
	int i;

	while ( scanf("%c", &ch) != EOF )
	{
		num = tolower(ch) - 'a';
		if (num >= 0 && num < 26){
			counter[num]++;
		}
	}

	for (i = 0; i < 26; i++){
		printf("%c : %d\n", 'a' + i, counter[i]);
	}

	return 0;
}

Measured memory_bytes: 544
N = int(input())
A = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

val = 0
for i in range(N):
    temp1 = A[i]
    temp2 = C[i]
    if temp1 - temp2 > 0:
        val += temp1 - temp2
print(val)


Measured memory_bytes: 2940
/**
 * 0577-Unique number
 */
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int player = Integer.valueOf(br.readLine());

        int[][] input = new int[player][3];

        for(int i = 0; i < player; i++){
            String[] line = br.readLine().split(" " , 3);

            for(int j = 0; j < 3; j++){
                input[i][j] = Integer.valueOf(line[j]);
            }

        }

        for(int i = 0; i < 3; i++){ 
            for(int j = 0; j < player-1; j++){
                int now = input[j][i];
                for(int k = j+1; k < player; k++){
                    if(now == input[k][i]) input[j][i] = input[k][i] = 0;
                }
            }
        }

        for(int i = 0; i < player; i++){
            System.out.println(input[i][0] + input[i][1] + input[i][2]);
        }
    }
}

Measured memory_bytes: 24468
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#define INF 10e5
using namespace std;
typedef long long int ll;

int N, A, B, C;
vector<int> L;

int chmin(int &a, int b)
{
    if (a > b)
        a = b;
}

int rec(int i, int a, int b, int c)
{
    if (i == N)
    {
        if (!a || !b || !c)
            return INF;
        return abs(A - a) + abs(B - b) + abs(C - c);
    }

    int mp = rec(i + 1, a, b, c);

    chmin(mp, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(mp, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(mp, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));

    return mp;
}

int main()
{
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> L[i];

    cout << rec(0, 0, 0, 0) << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,i,j,k,t;
  unsigned int ans=0;
  scanf("%d\n",&n);
  int a[n],b[n],c[n],ac=0,bc=0,cc=0;
  char s[n];
  scanf("%s",s);
  for(i=0;i<n;i++){
    if(s[i]=='R'){
      a[ac]=i;
      ac++;
    }
    else if(s[i]=='G'){
      b[bc]=i;
      bc++;
    }
    else{
      c[cc]=i;
      cc++;
    }
  }
  for(i=0;i<ac;i++){
    for(j=0;j<bc;j++){
      for(k=0;k<cc;k++){
        t=a[i]+b[j]+c[k];
        if(t!=3*a[i]){
          if(t!=3*b[j]){
            if(t!=3*c[k]){
              ans++;
            }
          }
        }
      }
    }
  }
  printf("%lu",ans);
  return 0;
}

Measured memory_bytes: 2172
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;


	int main()
{
	char x, y;
	int A, B, C, D, E, F;
	A=10;
	B=11;
	C=12;
	D=13;
	E=14;
	F=15;
	while(~scanf(" %c %c", &x, &y))
		{
		if(x >= y)
		{
			if(x > y)
			    printf(">\n");
			else
				printf("=\n");
		}
		else
			printf("<\n");
		}
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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; }

class UnionFind{
	vector<ll> rank;
	vector<ll> diff_weight;
	vector<ll> num;
public:
	vector<ll> par;

	UnionFind(ll N):par(N),num(N),rank(N),diff_weight(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
			rank[i]=0;
			diff_weight[i]=0;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		ll r = root(par[x]);
		diff_weight[x]+=diff_weight[par[x]];
		return par[x]=r;
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if(rx == ry) return;
		if(rank[rx]<rank[ry]) swap(rx,ry);
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		num[rx] += num[ry];
	}

	void relate(ll x,ll y,ll w){
		w+=weight(x),w-=weight(y);
		ll rx = root(x);
		ll ry = root(y);
		if(rx == ry) return;
		if(rank[rx]<rank[ry]){
			swap(rx,ry);
			w = -w;
		}
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		diff_weight[ry] = w;
		num[rx] += num[ry];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}

	ll weight(ll x){
		root(x);
		return diff_weight[x];
	}

	ll diff(ll x,ll y){
		return weight(y)-weight(x);
	}
};

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

	auto N=in(),M=in();
	UnionFind uf(N);
	
	REP(i,M){
		int u=in()-1,v=in()-1,z=in();
		uf.unite(u,v);
	}
	unordered_set<ll> S;
	REP(i,N){
		S.insert(uf.root(i));
	}
	out(S.size());
	return 0;
}


Measured memory_bytes: 7460
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
def main():
    n = int(input())
    a = [int(input()) for i in range(n)]

    pairs = 0
    for i in range(n):
        pairs += a[i] // 2
        if a[i] % 2 and i < n - 1 and 0 < a[i+1]:
            pairs += 1
            a[i+1] -= 1

    print(pairs)


if __name__ == '__main__':
    main()


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);  // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

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

    UnionFind uf(N);
    rep(i, M) {
        uf.merge(A[i], B[i]);
    }


    int ans = 0;
    rep(i, N) if (uf.root(i) ==i)++ ans;
    --ans;
    cout << ans << endl;
}

Measured memory_bytes: 4516
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

bool com(int a, int b)
{
    int s = a%10;
    if(s == 0) s = 11;
    int t = b%10;
    if(t == 0) t == 11;
    return s < t;
}

int main()
{
    std::vector<int> a(5,0);
    for(int i = 0; i < 5; i++)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), com);
    int sum = 0;
    for(int i = 4; i > 0; i--)
    {
        sum += a.at(i);
        if(sum %10)
        {
            sum = ((sum/10)+1)*10;
        }
    }
    cout << sum+a.at(0);

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<vector<pair<int, ll>>> adj(N + 5);
  int a, b, c;
  for (int i = 0; i < N - 1; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    adj[a].push_back(make_pair(b, c));
    adj[b].push_back(make_pair(a, c));
  }

  int Q, K; scanf("%d %d", &Q, &K);
  vector<ll> dist(N + 5, LLINF);
  dist[K] = 0;
  priority_queue<int, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
  que.push(make_pair(0, K));
  while (not que.empty()) {
    pair<ll, int> p = que.top(); que.pop();
    ll d = p.first;
    int u = p.second;
    if (d > dist[u]) { continue; }

    for (pair<int, ll> p : adj[u]) {
      int v = p.first;
      ll d = p.second;
      if (dist[u] + d < dist[v]) {
        dist[v] = dist[u] + d;
        que.push(make_pair(dist[v], v));
      }
    }
  }

  int x, y;
  while (Q-- > 0) {
    scanf("%d %d", &x, &y);
    ll ans = dist[x]+ dist[y];
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 11120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int min(int a, int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}

typedef struct DRINK {
  long A;  // 名前
  long B;// 価格
} Drink;

bool operator<(const Drink& left, const Drink& right) {
        return left.A < right.A;
}

int main(){
    long long N, M;
    cin >> N >> M;
    vector<Drink> D(N);
    for(int i = 0 ; i < N; i++){
        long tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        D[i].A = tmp1;
        D[i].B = tmp2;
    }
    sort(D.begin(), D.end());
    long money = 0;
    long count = M;
    for(int i = 0 ; i < N; i++){
        if(count >= D[i].B){
            money += D[i].B * D[i].A;
            count -= D[i].B;
        }
        else{
            money += count * D[i].A;
            break;
        }
    }
    cout << money <<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define INF 1000000007
using namespace std;
typedef long long ll ;

ll a,b;

ll fxor ( ll x){
	if(x%4==0) return x;
	else if(x%4==1) return 1;
	else if(x%4==2) return x+1;
	//(x%4==3) return 0;
	return 0;
}

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

		
	ll fb = fxor(b);
	
	if(a==0) cout<< fb <<"\n";
	else 	{
		ll fa = fxor(a-1);
		cout<< ( fa ^ fb) <<"\n";
	}
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
food=[0]*m
for i in range(n):
    ka=list(map(int,input().split()))
    k=ka[0]
    a=ka[1:]
    for j in a:
        food[j-1]+=1

cnt=0
for i in range(m):
    if food[i]==n:
        cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
int read(){
    int s = 0,ne = 1; char c = getchar();
    while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
    return s * ne;
}
int n, ai, sum = 0, mx = 0;
signed main(){
    n = read(); for(int i = 1; i <= n; i++) ai = read(), mx = max(mx, ai), sum += mx - ai;
    printf("%lld", sum);
}

Measured memory_bytes: 3680
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
    };
    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string.h>
#include <stack>
using namespace std;

int main () {
  int n;
  cin >> n;
  string h;
  cin >> h;
  stack<char> box;
  string ans = h;
  for (int i = 0; i < h.size(); i++) {
    if (h[i] == '(') {
      box.push(h[i]);  
    }  
    else {
      if (box.empty() == false) {
        box.pop();  
      }    
      else {
        ans = "(" + ans;  
      }
    }
  }  
  while (box.empty() != true) {
    ans = ans + ")";
    box.pop();  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int kaij[214514];

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kaij[x]* mod_pow(kaij[x - y], mod - 2, mod) % mod * mod_pow(kaij[y], mod - 2, mod) % mod;
}

int n, t, a[114514], ans, ta = INF, mu;

signed main() {
	cin >> n >> t;
	rep(i, n) {
		cin >> a[i];
		ta = min(a[i], ta);
		mu = max(mu, a[i] - ta);
	}
	ta = INF;
	rep(i, n) {
		ta = min(ta, a[i]);
		if (a[i] - ta == mu)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, p;
string s;
map<int, int> mp;
int cnt, cnt2 = 1;
int ans;
signed main() {
	cin >> n >> p >> s;
	if (p == 2 || p == 5) {
		for (int i = 0; i < n; i++) {
			if (!((s[i] - '0') % p))ans += i + 1;
		}
		cout << ans << endl;
		return 0;
	}
	mp[0] = 1;
	for (int i = n - 1; i >= 0; i--) {
		cnt = (cnt + (s[i] - '0') * cnt2) % p;
		ans+= mp[cnt];
		mp[cnt]++;
		cnt2 *= 10;
		cnt2 %= p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1028
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean[][] A = new boolean[N][N];
		boolean[][] B = new boolean[M][M];
		for(int i=0; i<N; i++) {
			char[] c = sc.next().toCharArray();
			for(int j=0; j<N; j++)
				A[i][j] = c[j]=='#';
		}
		for(int i=0; i<M; i++) {
			char[] c = sc.next().toCharArray();
			for(int j=0; j<M; j++)
				B[i][j] = c[j]=='#';
		}
		
		boolean ok = false;
		for(int i=0; i<=N-M; i++) {
			for(int j=0; j<=N-M; j++) {
				ok = true;
				for(int y=0; y<M; y++) {
					for(int x=0; x<M; x++) {
						if(A[i+y][j+x]!=B[y][x]) {
							ok = false;
							break;
						}
					}
					if(!ok)
						break;
				}
				if(ok)
					break;
			}
			if(ok)
				break;
		}
		System.out.println(ok ? "Yes" : "No");
		sc.close();
	}
}


Measured memory_bytes: 10320
from sys import stdin
input = stdin.buffer.readline

def main():
    n = int(input())
    x = [-1] * n; y = [-1] * n; h = [-1] * n
    for i in range(n):
        x[i], y[i], h[i] = map(int, input().split())

    # full search
    for i in range(n):
        if h[i] > 0:
            ind = i
            break

    for cx in range(101):
        for cy in range(101):
            try:
                height = h[ind] + abs(x[ind] - cx) + abs(y[ind] - cy)
            except:
                # h == [0] * n
                height = 1

            flag = True
            for i in range(n):
                if h[i] == 0:
                    if height - abs(x[i] - cx) - abs(y[i] - cy) > 0:
                        flag = False
                        break
                else:
                    if height - abs(x[i] - cx) - abs(y[i] - cy) != h[i]:
                        flag = False
                        break
            if flag:
                print(cx, cy, height)
                exit()

main()

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

int n,d,ans;
int x[15][15];

bool ii(int a,int b){
    int td=0;
    for(int i=1;i<=d;i++){
        td+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
    }
    for(int i=0;i<=200;i++){
        if(td==i*i)return true;
    }
    return false;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>d;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=d;j++){
            cin>>x[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(ii(i,j))ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int N,t[100010],x[100010],y[100010],i;
	
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&t[i]);
		scanf("%d",&x[i]);
		scanf("%d",&y[i]);
	}
	for(i=0;i<N;i++){
		if(t[i]-x[i]-y[i]<0||(t[i]-x[i]-y[i])%2!=0){
			printf("\nNo\n");
			return 0;
		}
	}
	
	printf("\nYes\n");
	
	return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
long long h, n, ans;
vector<long long>an(1010);
vector<long long>bn(1010);
vector<long long>DP(10010);
vector<bool>used(10010);
long long dp(long long N, long long n){//NがHP, n が魔法の数
    if(used.at(N)){
        return DP.at(N);
    }
    else{
    long long num;
    num = mod;
    for (int i = 0; i < n; i++){
        if(i == 0){
            if(N - an.at(0) <= 0){
                num = bn.at(0);
            }
            else{
            num = dp(N - an.at(0), n) + bn.at(0);
            }
        }
        else{
            if(N - an.at(i) <= 0){
                num = min(num, bn.at(i));
            }
            else{
        num = min(num, dp(N - an.at(i), n) + bn.at(i));
            }
        }
        dump(num);
    }
    DP.at(N) = num;
    used.at(N) = true;
    return num;
    }
}
void solve(){
    ans = dp(h, n);
    for(int i = 0; i < h; i++){
        dump(DP.at(i));
    }
    cout << ans << endl;
}
int main(){
    //dbg = true;
    cin >> h >> n;
    for(int i = 0; i < n; i++){
        cin >> an.at(i) >> bn.at(i); //aが体力bが魔力
    }
    solve();
    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    int s = SZ(a)+SZ(b);
    string out;
    int o = 0,e = 0;
    fore(i,0,s){
        if(i%2 == 0){
            out += a[o];
            o++;
        }else{
            out += b[e];
            e++;
        }
    }
    cout<<out;
	return 0;
}

Measured memory_bytes: 256
list_after = [int(input())]
counter = 1

def f(list_):
    if list_[-1] %2 == 0:
        after = list_[-1]/2
    else:
        after = 3 * (list_[-1]) + 1
    return after

break_ = 0
while break_ == 0:
    after = f(list_after)
    if after in list_after:
        print(counter+1)
        break_ = 1
        break
    list_after.append(after)
    counter += 1

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	int i=1;
	int x;
	int y;
	while(1){
		cin>>x;
		cin>>y;
		if(x==0&&y==0){
			break;}
		else{
			if(x<=y){
				cout<<x<<" "<<y<<endl;}
			else if(x>=y){
				cout<<y<<" "<<x<<endl;}
			else if(x==y){
				cout<<x<<" "<<y<<endl;}
		i++;}
		
	}
	return 0;
}

Measured memory_bytes: 2996
using System;

namespace Atc_0019
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var nums = str.Split(' ');

            for (int i = 0; i < nums.Length; i++)
            {
                if (int.Parse(nums[i]) == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 27480
use proconio::{input, fastout};
use std::collections::BinaryHeap;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    _: usize,
    t: usize,
    aa: [usize; t]
  };

  let mut que = BinaryHeap::new();
  for (i, a) in aa.iter().enumerate() {
    que.push((*a, i));
  }

  let mut pre = que.peek().unwrap().1 + 1;
  let mut ans = 0;
  while que.len() > 0 {
    let top = que.pop().unwrap();
    if pre != top.1 {
      pre = top.1;
      let a = top.0;
      if a > 1 {
        que.push((a - 1, pre));
      }
    } else if que.len() > 0 {
      let sec = que.pop().unwrap();
      pre = sec.1;
      let a = sec.0;
      if a > 1 {
        que.push((a - 1, pre));
      }
      que.push(top);
    } else {
      ans += 1;
      let a = top.0;
      if a > 1 {
        que.push((a - 1, pre));
      }
    }
  }
  echo!(ans);
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int X; cin >> X;
  int ans = 0;
  for(int i = 0; i < X; ++i) {
    if(100 * i <= X && X <= 105 * i) {
      ans = 1;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3444
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4,avx2,abm,fma")
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 998244353;
const ld EPS = 1e-11;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 1 << 19;
int far[N], dp[N];

int st[2*N];
void insert(int x, int v) {
	x += N;
	for(;x;x/=2) {
		st[x] = max(st[x], v);
	}
}
int query(int l, int r) {
	int res = 0;
	for(l+=N, r+=N+1; l<r; l/=2, r/=2) {
		if(l&1) res = max(res, st[l++]);
		if(r&1) res = max(res, st[--r]);
	}
	return res;
}

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

	int n;
	cin >> n;
	map<int,int> rmp;
	map<int,int> maxd;
	vector<pair<int,int>> p;
	for(int i=0; i<n; i++) {
		int x, d;
		cin >> x >> d;
		maxd[x] = max(maxd[x], d);
		rmp[x]; rmp[x+d-1];
	}

	int rid = 0;
	for(auto& it : rmp) {
		it.second = rid++;
	}

	for(auto it = maxd.rbegin(); it != maxd.rend(); it++) {
		int x, d; tie(x, d) = *it;
		int y = rmp[x];
		far[y] = max(query(y, rmp[x+d-1]), rmp[x+d-1]);
		insert(y, far[y]);
	}

	dp[rid] = 1;
	for(int i=rid-1; i>=0; i--) {
		// skip + take
		dp[i] = (dp[i+1] + dp[far[i] + 1]) % MOD;
	}
	cout << dp[0] << nl;

	return 0;
}


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

#define int long long

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  map<int,int> m;
  int ans=0;
  for(int i=n-1;i>=0;i--){
    ans+=m[v[i]+i];
    m[i-v[i]]++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 27384
N, M = map(int, input().split())

no = {}
ken = [[] for i in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    no[i] = str(p)+'_'+str(y)
    ken[p-1].append(y)

ans = {}
for i in range(N):
    ken[i].sort()
    for j in range(len(ken[i])):
        ans[str(i+1)+'_'+str(ken[i][j])] = str(i+1).zfill(6) + str(j+1).zfill(6)

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


Measured memory_bytes: 60200
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
using namespace std;

int INF = 1000;

void printVec(vector<int>h) {
    for (int i = 0; i < h.size(); i++) {
        cout << h[i] << " ";
    }
    cout << endl;
}

int solve(int l, int r,vector<int>&h) {
    int ans=0;
    if (l == r) {
        ans = h[l];
        h[l] = 0;
        return ans;
    }

    //既に0があったら
    for (int i = l; i <= r; i++) {
        if (h[i] == 0) {
            if (i == l)ans = solve(i + 1, r, h);
            else if (i == r)ans = solve(l, i - 1, h);
            else ans = solve(l, i - 1, h) + solve(i + 1, r, h);
            return ans;
        }
    }

    //0が無かったら
    int min = INF;
    int pos;
    for (int i = l; i <= r; i++) {
        if (h[i] <= min) {
            min = h[i];
            pos = i;
        }
    }
    for (int i = l; i <= r; i++) {
        h[i] -= min;
    }

    ans += min;
    if (pos == l)ans += solve(pos + 1, r, h);
    else if (pos == r)ans += solve(l, pos - 1, h);
    else ans += solve(l, pos - 1, h) + solve(pos + 1, r, h);
    return ans;

}

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

    cout << solve(0, h.size() - 1, h) << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q;
vector<int> ed[200010];
int val[200010];
void dfs(int v,int p,int x){
    val[v]+=x;
    for(auto i:ed[v]){
        if(i==p){continue;}
        dfs(i,v,val[v]);
    }
}
int main(){
    cin>>n>>q;
    int a,b,p,x;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--;b--;
        ed[a].push_back(b);
        ed[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p>>x;
        p--;
        val[p]+=x;
    }
    dfs(0,-1,0);
    for(int i=0;i<n;i++){
        if(i){cout<<' ';}
        cout<<val[i];
    }
    cout<<endl;
}

Measured memory_bytes: 23424
#include<bits/stdc++.h>
using namespace std;
#define maxn 1010
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize(2)
#define ll long long
#define makefa(n) for(int i=1;i<=(n);i++)f[i]=i;
#define hh puts("");
int main(){
    int a[32]={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};
    int k;
    cin>>k;
    cout<<a[k-1];
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
count = 0
ans = 0
for i in 1..n do
  ans = 1 if n === 1
  cur_element = i
  cur_count = 0
  while cur_element % 2 == 0
    cur_count += 1
    cur_element /= 2
  end
  if count < cur_count
    ans = i
    count = cur_count
  end
end
puts ans

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
bool ok(string x, string y) {
	int mn = INT_MAX, mx = INT_MIN;
	int sz1 = (int)x.size(), sz2 = (int)y.size();
	for (int i = 0; i < sz1; ++i)
		mn = min(mn, (int)x[i]);
	for (int i = 0; i < sz2; ++i)
		mx = max(mx, (int)y[i]);
	return mn < mx ? 1 : 0;
}
int main() {
	string x, y; cin >> x >> y;
	if (ok(x, y) || x < y) cout << "Yes";
	else cout << "No";
	return 0;
}

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

int main() {
	int	N;
	cin >> N;
	map<string, int> m;
	rep(i, N)
	{
		int	a;
		string b;
		cin >> a >> b;
		if (a == 0)
		{
			int c;
			cin >> c;
			m[b] = c;
		}
		else if (a == 1)
		{
			if (m.count(b))
				cout << m.at(b) << endl;
			else
				cout << 0 << endl;
		}
		else if (a == 2)
			m.erase(b);
		else
		{
			string	c;
			cin >> c;
			/* for (map<string, int>::iterator it = m.lower_bound(b); it != m.upper_bound(c); it++) */
			for (auto it = m.lower_bound(b); it != m.upper_bound(c); it++)
				cout << it->first << ' ' << it->second << endl;
		}
	}
}



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

#define f first
#define s second
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;

int n,t;
vi ans[N];

int main()
{
    IOS
    cin>>n;
    int k=sqrt(2*n);
    if(k*(k+1)!=2*n) return cout<<"No",0;
    cout<<"Yes"<<'\n'<<k+1<<endl;
    for(int i=1; i<=k+1; i++)
        for(int j=i+1; j<=k+1; j++)
        ans[i].pb(++t),ans[j].pb(t);
    for(int i=1; i<=k+1; i++)
    {
        cout<<k;
        for(auto x: ans[i]) cout<<' '<<x;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
void fun(ll h,vector<ll> &v)
{
  ll sum=0;
  for(ll i=0;i<v.size();i++)
     sum+=v[i];
   if(sum >= h)
     cout<<"Yes";
  else if(sum < h)
    cout<<"No";
  
}
int main()
{
ll h;cin>>h;
ll n;cin>>n;
  vector<ll> v(n);
  for(ll i=0;i<n;i++)
     cin>>v[i];
 fun(h,v);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




#define INF INT_MAX/2
int N, MA, MB;
int A[40], B[40], C[40];
//-----------------------------------------------------------------
int dp[50][500][500];
int main() {
	cin >> N >> MA >> MB;
	rep(i, 0, N) cin >> A[i] >> B[i] >> C[i];

	rep(i, 0, 50) rep(j, 0, 500) rep(k, 0, 500) dp[i][j][k] = INF;
	dp[0][0][0] = 0;

	rep(i, 0, N) rep(j, 0, 500) rep(k, 0, 500) if(dp[i][j][k] != INF){
		dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
		dp[i + 1][j + A[i]][k + B[i]] = min(dp[i + 1][j + A[i]][k + B[i]], dp[i][j][k] + C[i]);
	}

	int ans = INF;
	rep(a, 1, 500) rep(b, 1, 500) if (dp[N][a][b] != INF) {
		if (a * MB == b * MA) ans = min(ans, dp[N][a][b]);
	}
	if (ans == INF) ans = -1;
	cout << ans << endl;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, d, x, a[100];

int main(){
	cin >> n >> d >> x;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; j < d; j+=a[i]){
			x++;
		}
	}
	
	cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

template<class T> inline T sq(const T &x){return x*x;}

double g[101][101];
double dp[101][101];
int main(){
	cout.setf(ios::fixed);
	cout.precision(2);

	int n, m;
	while(cin >> n >> m, n|m){
		memset(dp, 0, sizeof(dp));
		rep(i, n) rep(j, n) cin >> g[i][j];
		rep(i, n) dp[0][i] = 1;
		m--;
		rep(i, m){
			rep(j, n){
				rep(k, n){
					dp[i+1][j] = max(dp[i+1][j], dp[i][k]*g[k][j]);
				}
			}
		}
		cout << *max_element(dp[m], dp[m+1]) << endl;
	}


	return 0;
}

Measured memory_bytes: 1452
s = list(input())
t = list(input())
Rs = {}
Rt = {}
for i in range(len(s)):
    if s[i] in Rs:
        if Rs[s[i]] != t[i]:
            print('No')
            exit()
    else:
        Rs[s[i]] = t[i]
    if t[i] in Rt:
        if Rt[t[i]] != s[i]:
            print('No')
            exit()
    else:
        Rt[t[i]] = s[i]
print('Yes')

Measured memory_bytes: 6704
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		Set<Integer> set = new HashSet<>();
		set.add(a);
		set.add(b);
		set.add(c);
		System.out.println(set.size());
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    vector<int> rsum(n+1, 0);
    vector<int> gsum(n+1, 0);
    vector<int> bsum(n+1, 0);
    if (n<=3) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, n){
        if (s[i]=='R') rsum[i+1] = rsum[i] + 1;
        else rsum[i+1] = rsum[i];

        if (s[i]=='G') gsum[i+1] = gsum[i] + 1;
        else gsum[i+1] = gsum[i];

        if (s[i]=='B') bsum[i+1] = bsum[i] + 1;
        else bsum[i+1] = bsum[i];
    }


    rep(i, n-2){
        char ci = s[i];
        for(int k=n-1; k>i+1; k--){
            char ck = s[k];
            if (ci==ck) continue;
            if ((ci=='R' and ck=='G') or (ci=='G' and ck=='R')){
                ans += bsum[k+1]-bsum[i];
            }else if ((ci=='R' and ck=='B') or (ci=='B' and ck=='R')){
                ans += gsum[k+1]-gsum[i];
            }else if ((ci=='G' and ck=='B') or (ci=='B' and ck=='G')){
                ans += rsum[k+1]-rsum[i];
            }
            if ((k-i)%2==0){
                int mid = (k-i)/2 + i;
                if(s[mid]!=ci and s[mid]!=ck){
                    ans--;
                }
            }
        }

    }

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	int N; cin>>N;
	ll ans=0;
	map<ll,ll> mp;
	rep(i,0,N){
		ll a;cin>>a;
		mp[a]++;
	}
	for(auto c:mp){
		if(c.first>c.second) ans+=c.second;
		else ans+=c.second-c.first;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>   // 追加
using namespace std;
 
int main() {
    int a[3];
    for(int i = 0; i < 3; i++) {
      cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]<<" ";
    cout <<a[1]<<" ";
    cout <<a[2]<<endl;
}


Measured memory_bytes: 3120