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

constexpr int INF = 1e9;

//// spagetthi source
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :  // !!INVERSE!!
             e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define RESIDUE(s, t) (capacity[s][t] - flow[s][t])
#define RESIDUE(s, t) (capacity[s][t] - flow[s][t])
Weight maximumFlow(const Graph &g, int s, int t) {
  int n = g.size();
  Matrix flow(n, Array(n)), capacity(n, Array(n));
  REP(u, n) FOR(e, g[u]) capacity[e->src][e->dst] += e->weight;

  Weight total = 0;
  while (1) {
    queue<int> Q;
    Q.push(s);
    vector<int> prev(n, -1);
    prev[s] = s;
    while (!Q.empty() && prev[t] < 0) {
      int u = Q.front();
      Q.pop();
      FOR(e, g[u]) if (prev[e->dst] < 0 && RESIDUE(u, e->dst) > 0) {
        prev[e->dst] = u;
        Q.push(e->dst);
      }
    }
    if (prev[t] < 0) return total;  // prev[x] == -1 <=> t-side
    Weight inc = INF;
    for (int j = t; prev[j] != j; j = prev[j]) inc = min(inc, RESIDUE(prev[j], j));
    for (int j = t; prev[j] != j; j = prev[j]) flow[prev[j]][j] += inc, flow[j][prev[j]] -= inc;
    total += inc;
  }
}
////end

int main() {
  std::size_t h, w;
  std::cin >> h >> w;
  Graph g(h + w + 2);
  for (size_t i = 0; i < h; i++) {
    for (size_t j = 0; j < w; j++) {
      char a;
      cin >> a;
      if (a == 'o') {
        g[i].emplace_back(i, h + j, 1);
        g[h + j].emplace_back(h + j, i, 1);
      } else if (a == 'S') {
        g[h + w].emplace_back(h + w, i, INF);
        g[h + w].emplace_back(h + w, h + j, INF);
      } else if (a == 'T') {
        g[i].emplace_back(i, h + w + 1, INF);
        g[h + j].emplace_back(h + j, h + w + 1, INF);
      }
    }
  }
  auto ans = maximumFlow(g, h + w, h + w + 1);
  if (ans >= INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  LL H;
  cin >> H;
  LL ans = 0;
  LL cur = 1;
  while (H > 0) {
    ans += cur;
    H /= 2;
    cur *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	var p float64
	fmt.Scan(&N, &K)
	for i := 1; i <= N; i++ {
		j := 0
		t := i
		for {
			if t >= K {
				break
			}
			j++
			t *= 2
		}
		p += (1 / float64(N)) * math.Pow(0.5, float64(j))
	}
	fmt.Println(p)
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;

int main() {
    // input
    int n, q; scanf("%d%d", &n, &q);
    vector<ll> a(q); repeat (i,q) scanf("%lld", &a[i]);
    { // remove unnecessary queries
        vector<ll> b;
        b.push_back(n);
        repeat (i,q) {
            while (not b.empty() and a[i] <= b.back()) {
                b.pop_back();
            }
            b.push_back(a[i]);
        }
        a = b;
        q = b.size();
    }
    assert (whole(is_sorted, a));
    // compute
    vector<ll> cnt(n);
    map<ll, ll> que;
    que[a.back()] += 1;
    repeat_reverse (i,q-1) {
        ll t = 0;
        while (not que.empty() and que.rbegin()->first >= a[i]) {
            ll delta, k; tie(delta, k) = *que.rbegin(); que.erase(delta);
            ll q = delta / a[i];
            t += k*q;
            ll r = delta % a[i];
            if (r == 0) {
                // nop
            } else if (r <= a[0]) {
                cnt[r-1] += k;
            } else {
                que[r] += k;
            }
        }
        que[a[i]] += t;
    }
    assert (que.size() == 1 and que.begin()->first == a[0]);
    cnt[a[0]-1] += que.begin()->second;
    repeat_reverse (i,n-1) {
        cnt[i] += cnt[i+1];
    }
    // output
    repeat (i,n) {
        printf("%lld\n", cnt[i]);
    }
    return 0;
}


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

int main() {
  vector<int> a(3);
  for(int i=0;i<3;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  if(a.at(0)==5 && a.at(1)==5 && a.at(2)==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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


int main() {
  long long N;
  cin >> N;
  int result = 11;
  for (long long A=1; A*A<=N; ++A) {
    if (N % A == 0) {
      long long B = N / A;
      long long C = max(A, B);
      for (int j=1; j<=10; ++j) {
        long long ans = C / pow(10, j);
        if (ans == 0) {
          result = min(j, result);
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    rep(i,b){
        if(a*i%b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		if ("AAA".equals(s) || "BBB".equals(s)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

bool done(int& A, int& B, int& C){
  if(A&1||B&1||C&1)return false;
  int a = A, b = B, c = C;
  A = b/2 + c/2;
  B = c/2 + a/2;
  C = a/2 + b/2;
  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C;cin >> A >> B >> C;
  if(A==B && B==C){
    if(A&1) cout << 0 << endl;
    else cout << -1 << endl;
    return 0;
  }
  int count = 0;
  while(done(A,B,C))++count;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll kai[100010];
ll bit[200010];
ll sum[100010];
ll ans[100010];
ll N, K, S;


/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

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

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y)
{
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

void init()
{
	/*kai[0] = 1;
	for (int i = 1; i <= 10000; i++)
	{
		kai[i] = kai[i - 1] * i % mod;
	}*/
	cin >> N >> K >> S;
}

void output()
{
	for (int i = 0; i < N; i++)
	{
		if (i < K)
		{
			cout << S;
		}
		else
		{
			if (S == 1000000000)
			{
				cout << 1;
			}
			else
			{
				cout << S + 1;
			}
		}


		if (i == N - 1)
		{
			cout << endl;
		}
		else
		{
			cout << ' ';
		}
	}
}

void solve()
{
	
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}


Measured memory_bytes: 1280
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

N,M = map(int,input().split())
p = list(map(int,input().split()))


tree = UnionFind(N)
for i in range(M):
    x,y= map(int,input().split())
    tree.union(x,y)

ans = 0
for i in range(1,N+1):
    if tree.find(p[i-1]) == tree.find(i):
        ans += 1
print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string S;
	cin >> S;
	int res = 0;
	FOR(i, 1, S.length()) if (S[i] != S[i - 1]) ++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String n = br.readLine();
        String[] str = n.split(" ");
        
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int w;
        
        if(a>b){
        	w = a;
        	a = b;
        	b = w;
        }
        //System.out.println(a+""+b+""+c);
        if(b>c){
        	w = b;
        	b = c;
        	c = w;
        }
        //System.out.println(a+""+b+""+c);
        
        if(a>b){
        	w = a;
        	a = b;
        	b = w;
        }
        
        System.out.println(a+" "+b+" "+c);
	}
}

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

int main()
{
  int n, i;
  int m;
  int left, right, count;
  vector<int> v;
  while (cin>>n, n) {
    v.clear();
    v.resize(n);
    for (i = 0; i < n; i++) cin>>v[i];

    cin>>m;
    count = 0;
    left = 0;
    right = n-1;
    while (left <= right) {
      count++;
      if (v[(right-left)/2+left] > m) right = (right-left)/2+left-1;
      else if (v[(right-left)/2+left] < m) left = (right-left)/2+left+1;
      else {
	left = right = (right-left)/2+left;
	break;
      }
    }
    cout<<count<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# template


def resolve():
    ofs = 6400
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(h)]
    B = [list(map(int, readline().split())) for _ in range(h)]
    dp = [[0]*w for _ in range(h)]
    x = abs(A[0][0]-B[0][0])
    dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))

    from itertools import product
    for i, j in product(range(h), range(w)):
        x = abs(A[i][j]-B[i][j])
        t = 0
        if(i-1 >= 0):
            t |= dp[i-1][j]
        if(j-1 >= 0):
            t |= dp[i][j-1]
        dp[i][j] |= ((t << x) | (t >> x))

    for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):
        if(s == '1'):
            print(i)
            return


if __name__ == "__main__":
    INF = float("inf")
    MOD = 10**9+7
    resolve()


Measured memory_bytes: 51548
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    int ans=0;
    for(int i=0;i<s1.length();i++)
        if(s1[i]!=s2[i])
            ans+=1;
    cout << ans << endl;
}

Measured memory_bytes: 3924
ar = gets.chomp.split.map(&:to_i)
flg = 1

if ar[0] < ar[2] + ar[4]
    flg = 0
end

if ar[2] - ar[4] < 0  
    flg = 0
end

if ar[1] < ar[3] + ar[4]
    flg = 0
end

if ar[3] - ar[4] < 0 
    flg = 0
end

if flg == 1
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 8652
import math
def myAnswer(N:int,A:list,B:list) -> int:
   ans = 0
   A.reverse()
   B.reverse()
   for a,b in zip(A,B):
      a += ans
      target =math.ceil(a/b) * b - a
      ans += target
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   A = []
   B = []
   for _ in range(N):
      a,b = map(int,input().split())
      A.append(a)
      B.append(b)
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

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

using namespace std;
#define rep(i,n) for(int i =0;i<n;++i)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define FOR(it,a ) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
typedef pair<int,int> PI;

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


int n;

int x[30];
int y[30];
int r[30];
int c[30];

bool ok[1<<24];

int st[24];

int overlap(int a,int b){
  int dx=x[a]-x[b];
  int dy=y[a]-y[b];
  
  if(dx*dx+dy*dy < (r[a]+r[b])*(r[a]+r[b]))
    return 1;
  return 0;
}

int ans;

void dfs(int cst){
  if(ok[cst]) return;
  ok[cst] =  1;
  ans = max(ans, __builtin_popcount(cst));
  
  rep(i,n)if(~cst&(1<<i)) if((cst&st[i]) == st[i])rep(j,i){
    if(c[i] != c[j]) continue;
    if(cst&(1<<j)) continue;
    if(overlap(i,j)) continue;
    if((cst&st[j]) != st[j]) continue;
    dfs(cst | (1<<i)|(1<<j));
  }
}

void solve(){
  rep(i,n) cin >> x[i] >> y[i] >> r[i] >> c[i];
  memset(ok,0,sizeof(ok));
  ans = 0;
  memset(st,0,sizeof(st));
  rep(i,n)rep(j,i){
    //cout << i << " " << j << " " << overlap(i,j) << endl;
    st[i] |= overlap(i,j) << j;
  }
  
  rep(i,n)rep(j,i)
    if(c[i]==c[j] && !overlap(i,j) && st[i]==0 && st[j]==0)
      dfs((1<<i)|(1<<j));
    
  cout << ans << endl;
}

int main(){
  while(cin >> n,n) solve();
}

Measured memory_bytes: 17556
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll a[4];
  rep(i,4)cin >> a[i];
  ll n;
  cin >> n;
  a[0]*=4;
  a[1]*=2;
  if(n%2==0){
    rep(i,3)a[i]*=2;
    sort(a,a+4);
    cout << n/2*a[0] << endl;
    return 0;
  }
  sort(a,a+3);
  if(2*a[0]<a[3]){
    cout << n*a[0] << endl;
  }else{
    cout << n/2*a[3]+a[0] << endl;
  }
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string s;
  cin>>s;
  int K;
  cin>>K;
  set<string> a;
  int l=1;
  while(l<=min(int(s.size()),5)){
    REP(i,s.size()-l+1){
      a.insert(s.substr(i,l));
    }
    l++;
  }
  auto ans=a.begin();
  FOR(i,1,K)++ans;
  cout<<*ans<<endl;
  return 0;
}


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

int main() {
    string s;
    s.push_back('.');
    s.push_back('.');
    cin >> s;
    int n=s.size()-2;
    vector<string> t={"erase","dream","eraser","dreamer"};
    int c=n+1;
    bool ansflag=true;
    while (c>0) {
        bool rflag=false;
        for (int i=0;i<4;i++) {
            bool flag=true;
            int nt=t[i].size();
            for (int j=0;j<nt;j++) {
                if (s[c-j]!=t[i][nt-1-j]) flag=false;
            }
            if (flag) {
                rflag=true;
                c-=nt;
            }
        }
        if (!rflag) {
            ansflag=false;
            break;
        }
    }
    if (ansflag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

struct Square {
	int width, depth;
	bool operator<(const Square& rhs) const {
		return width * depth < rhs.width * rhs.depth;
	}
};

int main() {
	int n, w, d;
	Square s;
	while (std::cin >> n >> w >> d && (n || w || d)) {
		std::vector<Square> squares; //???????????????????????????????????\???????????????
		squares.push_back(s);
		squares.back().width = w; squares.back().depth = d;

		for (int i = 0; i < n; i++) {
			int no, pos;
			std::cin >> no >> pos;
			no--;
			auto square = squares[no];
			pos %= (squares[no].width * 2 + squares[no].depth * 2);

			//??????
			int direction = 0; //0?¨??????? 1???
			int cutPos = 0; //??????????????????????????????????????????
			if (pos <= squares[no].width) {
				direction = 1;
				cutPos = pos;
			}
			else if (pos <= squares[no].width + squares[no].depth) {
				direction = 0;
				cutPos = pos - squares[no].width;
			}
			else if (pos <= squares[no].width * 2 + squares[no].depth) {
				direction = 1;
				cutPos = squares[no].width - (pos - (squares[no].depth + squares[no].width));
			}
			else {
				direction = 0;
				cutPos = squares[no].depth - (pos - (squares[no].width * 2 + squares[no].depth));
			}

			squares.erase(squares.begin() + no);

			Square newSquare[2] = { square, square };
			switch (direction)
			{
			case 0: //?¨???????
				newSquare[0].depth = cutPos;
				newSquare[1].depth = square.depth - cutPos;
				break;
			case 1: //???
				newSquare[0].width = cutPos;
				newSquare[1].width = square.width - cutPos;
				break;
			default:
				break;
			}

			//?°??????????????????????
			if (newSquare[0].depth * newSquare[0].width < newSquare[1].depth * newSquare[1].width) {
				squares.push_back(newSquare[0]);
				squares.push_back(newSquare[1]);
			}
			else {
				squares.push_back(newSquare[1]);
				squares.push_back(newSquare[0]);
			}
		}

		//?°??????????????????????
		std::sort(squares.begin(), squares.end());

		for (int i = 0; i < squares.size(); i++) {
			std::cout << squares[i].width * squares[i].depth;
			if (i == squares.size() - 1) {
				std::cout << std::endl;
			}
			else {
				std::cout << " ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3164
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b;
            cin>>a>>b;
            ll ct=1,ans=0;
            while(ct<b)
            {
                ct=(ct-1)+a;
                ++ans;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
import java.util.Scanner;

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();
		}
		boolean flag = true;
		
		for(int i=0;i<N;i++) {
			if(A[i]%2==0) {
				if(A[i]%3==0 || A[i]%5==0) {
					
				}else {
					flag = false;
				}
			}
		}
		
		if(flag) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
	}

}

Measured memory_bytes: 23252
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
bool color[200001];
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    string s;cin>>s;
    int r=0;
    for(int i=0;i<n;i++)if(s[i]=='R')r++;
    int b=n-r;
    if(r>b)cout<<"Yes"<<Endl;
    else cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

/*
ll n;cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
 
ll n;cin>>s;
string s;cin>>s;

ll n,m;cin>>n>>m;
vector<ll>a(n),b(m);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<m;i++){
    cin>>b[i];
}

ll n;cin>>n;
vector<Pll>xy;
for(ll i=0;i<n;i++){
    ll x,y;cin>>x>>y;
    xy.pb({x,y});
}
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll fact[100005]; // N!
ll facti[100005];

ll mod_pow(ll x,ll n){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x) % mod;
        n >>= 1;
        x = (x*x) % mod;
    }
    return res;
}

// nCk = N! / K! / (N-K)!
ll comb(ll n,ll k){
    if(n-k < 0) return 0;
    ll ret = fact[n];
    ret = (ret * facti[k]) % mod;
    ret = (ret * facti[n-k]) % mod;
    return ret;
}

int main(){
    fact[0] = 1;
    fact[1] = 1;
    for(ll i=2;i<100005;i++){
        fact[i] = fact[i-1] * i % mod;
    }
    for(ll i=0;i<100005;i++){
        facti[i] = mod_pow(fact[i],mod-2);
    }

    ll n; cin >> n;
    ll k; cin >> k;
    vector<ll> A(n); rep(i,n) cin >> A[i];
    sort(all(A));
    for(int i=0;i<n;i++){
        A[i] = (A[i] + mod) % mod;
    }

    ll a = 0;
    for(int i=0;i<n;i++){
        if(n-1-i>=k-1){
            a += A[i] * comb(n-1-i,k-1) % mod;
            a %= mod;
        }
    }

    ll b = 0;
    for(int i=n-1;i>=0;i--){
        if(i >= k-1){
            b += A[i]  * comb(i, k-1) % mod;
            b %= mod;
        }
    }

    cout << ((b+mod)-a) % mod << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,m,hsh1[200005],hsh2[200005],a,b,type=-1;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		if(a==1)
		{
			++hsh1[b];
		}
		if(b==n)
		{
			++hsh2[a];
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(hsh1[i]==1&&hsh2[i]==1)
		{
			type=0;
		}
	}
	if(type==0)
	{
		printf("POSSIBLE\n");
	}else
	{
		printf("IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 5228
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n, m = map(int, input().split())

    #output
    mod = pow(10, 9) + 7

    n_ = 5 * pow(10, 5) + 5
    fun = [1] * (n_+1)
    for i in range(1, n_+1):
        fun[i] = fun[i-1] * i % mod
    rev = [1] * (n_+1)
    rev[n_] = pow(fun[n_], mod-2, mod)
    for i in range(n_-1, 0, -1):
        rev[i] = rev[i+1] * (i+1) % mod
    def cmb(n,r):
        if n < 0 or r < 0 or r > n: return 0
        return fun[n] * rev[r] % mod * rev[n-r] % mod
    def perm(n, r):
        if n < 0 or r < 0 or r > n: return 0
        return fun[n] * rev[n-r] % mod

    #Aを1, 2, ..., nとする。
    #求める写像の総数をs(n, m)とする。
    #s(n, m) = sum(k=0, n)(cmb(n, k)* (-1)^k * cmb(m-k, n-k)*(n-k)!)

    import math
    answer = 0
    for i in range(n+1):
        temp = perm(n, i) * cmb(m, i) * pow(perm(m-i, n-i), 2)
        temp %= mod
        if i % 2 == 0:
            answer += temp
        else:
            answer -= temp
    print(answer % mod)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()


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

using namespace std;

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

	int arr[n];

	for(int i=0;i<n;i++)
		cin>>arr[i];

	for(int i=k;i<n;i++)
	{
		if(arr[i-k]<arr[i])
			cout<<"Yes"<<"\n";

		else
			cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define ll long long

using namespace std;

// input
int N;

void dfs(string s,char mx) {
  if(s.length() == N) {
    cout << s << endl;
    return;
  } else {
    for(char c = 'a';c <= mx; c++) {
      dfs(s + c,(c == mx)? c+1:mx);
    }
  }
}


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

  dfs("",'a');
}

Measured memory_bytes: 1536
#include<stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
    int parent;
    int left;
    int right;
}node;

node T[MAX];
int n, D[MAX], H[MAX];

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

void setDepth(int u, int d){
    if(u==NIL){
        return;
    }
    D[u]=d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1=0, h2=0;
    if(T[u].left!=NIL){
        h1=setHeight(T[u].left)+1;
    }
    if(T[u].right!=NIL){
        h2=setHeight(T[u].right)+1;
    }

    return H[u]=max(h1, h2);

}

int getSibling(int u){
    if(T[u].parent==NIL){
        return NIL;
    }
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
        return T[T[u].parent].left;
    }
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
        return T[T[u].parent].right;
    }

    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg=0;
    if(T[u].left!=NIL){
        deg++;
    }
    if(T[u].right!=NIL){
        deg++;
    }

    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if(T[u].parent==NIL){
        printf("root\n");
    }
    else if(T[u].left==NIL && T[u].right==NIL){
        printf("leaf\n");
    }
    else{
        printf("internal node\n");
    }

}

int main(void){
    int v, l, r;
    int root=0;

    scanf("%d", &n);

    for(int i=0; i<n; i++){
        T[i].parent=NIL;
    }

    for(int i=0; i<n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL){
            T[l].parent=v;
        }
        if(r!=NIL){
            T[r].parent=v;
        }

    }
    for(int i=0; i<n; i++){
        if(T[i].parent==NIL){
            root=i;
        }
    }

    setDepth(root, 0);
    setHeight(root);


    for(int i=0; i<n; i++){
        print(i);
    }

    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll sum[2010][2010];
ll sum2[2010][2010];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	if (n == m)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3588
import sys
import collections
from operator import mul
from functools import reduce


def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


n = int(input())
l = [int(x) for x in input().split()]
c = collections.Counter(l)

# cl = [0 for i in range(n)]
cd = {}

# print(ll)

if not c:
    for _ in range(len(l)):
        print(0)
    sys.exit()

sum = 0
for a in c:
    nc = combinations_count(c[a], 2)
    sum += nc
    # print(nc)
    # cl[i-1] = nc - int(nc*(m-2)/m)
    cd[a] = (nc - int(nc * (c[a] - 2) / c[a]))

"""
def my_index(lv):
    if lv not in c.keys():
        return sum
    else:
        return cd[lv]
"""

for lv in l:
    print(sum-cd[lv])


Measured memory_bytes: 31892
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
s = LS()[1]
print("A"+s[0]+"C")
#B

#C
"""
n,x = LI()
a = LI()
ans = 0
for i in range(n-1):
    if a[i]+a[i+1] > x:
        ans += a[i+1]+a[i]-x
        if x > a[i]:
            a[i+1] = x-a[i]
        else:
            a[i+1] = 0
            a[i] = x
print(ans)
"""

#D
"""
s = S()
l = len(s)
k = (s[0] == s[-1])
if (l%2)^k:
    print("First")
else:
    print("Second")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main() {

  int A, B, first, latter, sum;
  cin >> A >> B;
  sum = 0;
  for (int i = A; i <= B; i++) {
    first = i / 1000;
    latter = i % 10 * 10 + i / 10 % 10;
    if (first == latter)
      sum += 1;
    else
      continue;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[60][60],t[60][60];
int main(){
	int n,m;
	int flag,res;
	while(scanf("%d %d",&n,&m)==2)
	{
		res=0;
		for(int i=0;i<n;i++)
		scanf("%s",&s[i]);
		for(int i=0;i<m;i++)
		scanf("%s",&t[i]);
		
		for(int h=0;h<=n-m;h++)
		{
			for(int l=0;l<=n-m;l++)
		    {
			flag=1;
			int a=h,b=l;
			for(int i=0;i<m;i++)
			for(int j=0;j<m;j++)
			{
				if(t[i][j]!=s[a+i][b+j])
				flag=0;
			}
			if(flag==1)
			{
				res=1;
				printf("Yes\n");
				break;
			}
		    }
		if(res)
	    break;
		}
		if(!res)
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
S = list(input()) + [None]

ans = 1
i = 0
prev = None

while i < n:
    if S[i]==S[i+1]:
        if prev == None:
            ans *= 6
        elif prev == 0:
            ans *= 3
        else:
            ans *= 2
        prev = 0
        i += 2
    else:
        if prev == None:
            ans *= 3
        elif prev == 0:
            ans *= 1
        elif prev == 1:
            ans *= 2
        prev = 1
        i += 1
        
print(ans%1000000007)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
char f[256];
int main()
{
	 string s,a;
	 f['b']='d';
	 f['d']='b';
	 f['p']='q';
	 f['q']='p';
	 cin>>s;
	 for(int i=s.length()-1;i>=0;i--)
		 a=a+s[i];
	 //cout<<a<<endl;
	 for(int i=0;i<s.length();i++)
		 a[i]=f[a[i]];
	 if(a==s) cout<<"Yes";
		   else cout<<"No";
}

Measured memory_bytes: 696
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ


int main()
{
    int s;
    int w;

    cin >> s;
    cin >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
 

    return 0;
}

Measured memory_bytes: 3636
import Control.Applicative
import Data.List(tails, intersperse)

type Sorted    = [Int]
type NotSorted = [Int]

insert :: Int -> Sorted -> Sorted
insert x [] = [x]
insert x (y:ys) | x < y     = x : y : ys
                | otherwise = y : (insert x ys)

step :: ([String], Sorted) -> NotSorted -> ([String], Sorted)
step pair []         = pair
step (ss, ys) (x:xs) = let ns = insert x ys
                           rs = if xs == [] then [] else (" " ++ toS xs)
                        in ((toS ns ++ rs) : ss, ns)

toS :: Sorted -> String
toS = concat . intersperse " " . map show

main = do
    getLine
    qs <- map read . words <$> getLine
    let st = fst (foldl step ([], []) (tails qs))
    mapM_ putStrLn (reverse st)


Measured memory_bytes: 4804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
  int n;
  cin >>n;
  int c[n];
  int v[n];
  int ans =0;
  fr(i,n){
    cin >>v[i];
  }
  fr(i,n){
    cin >>c[i];
  }
  fr(i,n){
    if(v[i]>c[i]){
      ans += v[i]-c[i];
    }
  }
  cout << ans << endl;
}

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

vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool IsPrime(int64_t num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

  int64_t tmp;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }

  int64_t r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  vector<int64_t> c = divisor(b);
  int64_t ans = 1;

  for (int i = 0; i < c.size(); i++) {
    if (IsPrime(c[i])) {
      ans++;
    }
  }

  cout << ans << endl;
}

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

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

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,ans=0;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n-1;i++){
    ans+=v[i];
  }
  ans+=v[n-1]/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int a,b,c,k; cin >> a >> b >> c >> k;
    if (a >= k) cout << k << endl;
    else if (a+b >= k) cout << a << endl;
    else cout << 2*a+b-k << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	vl DIJ(int s){
		priority_queue<pll> q;
		vl d(n,INF);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			pll p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				ll u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
	}
};

const int M=3000;
int n,m,k;

int main(){
	cin>>n>>m>>k;
	k=min(k,M-1);
	Graph g(n*M);
	for(int i=0;i<m;i++){
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		u--;v--;
		for(int j=a;j<M;j++){
			g.add_edge(u*M+j,v*M+j-a,b);
			g.add_edge(v*M+j,u*M+j-a,b);
		}
	}
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		for(int j=x;j<M;j++) g.add_edge(i*M+j-x,i*M+j,y);
	}
	vl d=g.DIJ(k);
	for(int i=1;i<n;i++){
		ll mn=INF;
		for(int j=0;j<M;j++) mn=min(mn,d[i*M+j]);
		cout<<mn<<endl;
	}
}

Measured memory_bytes: 20024
import java.util.*;
import java.io.*;
class Main{
  public static final int N = 9;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    char c[] = new char[N];
    String end = "123456780";
    String puzzle="";
    // int right = 1, left = -1, on = -3, under = 3;
    int index[] = {1,-1,-3,3};
    HashMap<String, Integer> hash = new HashMap<String, Integer>();
    Queue<String> queue = new ArrayDeque<String>();
    for(int i = 0; i<N; i++){
      c[i] += (char)(sc.nextInt()+48);
      puzzle +=c[i];
    }
    // for(int i = 0; i<N; i++){
    //   System.out.print(c[i]);
    // }
    // puzzle = toString(c);
    queue.add(puzzle);
    hash.put(puzzle,0);

    while(!queue.isEmpty()){
      String comfirm = queue.remove();
      if(comfirm.equals(end)){
        // String comfirm = queue.remove();
        System.out.println(hash.get(comfirm));
        break;
      }

      StringBuffer s = new StringBuffer(comfirm);
      int vacancy = s.indexOf("0");
      for(int i = 0; i<4; i++){
        if(vacancy + index[i] >= 0 && vacancy + index[i]<N){//範囲外でない（上下）
          if( !((index[i] == -1)&& ((index[i]+vacancy) % 3==2))  &&  !((index[i] == 1) &&((index[i]+vacancy) % 3 == 0))  ){//左右の範囲外確認
            //交換作業して存在しなければキューとハッシュ追加。
            s.setCharAt(vacancy, s.charAt(vacancy + index[i]));
            s.setCharAt(vacancy + index[i], '0');
            if (!hash.containsKey(s.toString())) {
              queue.add(s.toString());
              hash.put(s.toString(), hash.get(comfirm)+1);
            }
            //そして戻す。
            s.setCharAt(vacancy + index[i], s.charAt(vacancy));
            s.setCharAt(vacancy, '0');
          }
        }
      }

      // @Override
      // public String toString() {
      // }
    }
  }
}




Measured memory_bytes: 89132
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int H = sc.nextInt();
int W= sc.nextInt();
if (H == 0 && W == 0) {
break;
}
for(int i=1; i<=H;i++){
for(int j=1; j<=W;j++)
if(i==1||i==H||j==1||j==W)
System.out.printf("#");
else System.out.printf(".");
System.out.printf("\n");
}
System.out.printf("\n");
}
}
}


Measured memory_bytes: 61244
#include<bits/stdc++.h>
int a[100010];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    std::sort(a,a+n);
    int m=1000000000;
    for(int i=0;i+k-1<n;i++){
        if(m>(a[i+k-1]-a[i])) m=a[i+k-1]-a[i];
    }
    printf("%d",m);
}

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

int main()
{
    int n, m, t, d;

    cin >> n >> m >> t;

    bool a[t+1];
    for( int i = 0; i < t + 1; i++ )
        a[i] = 0;

    for( int i = 0; i < n; i++ )
    {
        cin >> d;
        int b = d - m < 0 ? 0 : d - m;
        int c = d + m > t ? t : d + m;
        for( int j = b; j <= c; j++ )
            a[j] = 1;
    }

    int cnt = 0;
    for( int i = 1; i < t + 1; i++ )
        if( !a[i] || !a[i-1] )
            cnt++;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3108
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {    
    int n; cin >> n;
    vector<string> S(n);
    rep(i, n) cin >> S[i];

    vector<char> alp;
    for(char c = 'a'; c <= 'z'; c++)
        alp.push_back(c);

    vector<vector<int>> count(n, vector<int>(26, 0));
    rep(i, n){
        rep(j, S[i].size()){
            int index = S[i][j] - 'a';
            count[i][index]++;
        }
    }

    rep(i, 26){
        int mx = INF;
        rep(j, n){
            chmin(mx, count[j][i]);
        }
        rep(j, mx){
            cout << alp[i];
        }
    }
    cout << ln;
} 


Measured memory_bytes: 256