akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int n,count=0;

long long luka(long long a,long long b){
if(n-2==count)return a+b;
else{
count++;
luka(b,a+b);
}
}
int main(){
scanf("%d",&n);
if(n==1){
puts("1");
return 0;
}
long long ans=luka(2,1);
printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c;
    
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
        
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl; 
        
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
        
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
        
    else
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <cstdio>
using namespace std;

struct drink{
  int price;
  int stock;
};

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  drink D[N];
  int a, b;
  for (int i=0; i<N; i++) {
    scanf("%d %d", &a, &b);
    D[i].price = a;
    D[i].stock = b;
  }
  sort(D, D+N, [](const drink& x, const drink& y){return x.price < y.price; });

  unsigned long sum_price = 0;
  for (int i=0; i<N; i++) {
    if (D[i].stock < M) {
      sum_price += long(D[i].price) * D[i].stock;
      M -= D[i].stock;
    } else {
      sum_price += long(D[i].price) * M;
      break;
    }
  }
  printf("%ld\n", sum_price);
}


Measured memory_bytes: 896
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      a: usize,
      b: usize,
      c: usize,
      x: usize,
      y: usize,
   }
   let mut x = x;
   let mut y = y;
   if a <= c && b <= c {
      println!("{}", a * x + b * y);
      return;
   }
   let mut ans = 0;
   if a >= 2 * c {
      ans += 2 * c * x;
      if y > x {
         y -= x;
      } else {
         y = 0;
      }
      x = 0;
   }
   if b >= 2 * c {
      ans += 2 * c * y;
      if x > y {
         x -= y;
      } else {
         x = 0;
      }
      y = 0;
   }
   if 2 * c <= a + b {
      let d = std::cmp::min(x, y);
      ans += 2 * c * d;
      x -= d;
      y -= d;
   }
   ans += a * x;
   ans += b * y;
   println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <array>
#include <tuple>
#include <vector>

using namespace std;

array<array<array<int, 401>, 401>, 41> table;

const int INF = 1000000000;

int main()
{
    for (auto &vv : table) for (auto &v : vv) fill(v.begin(), v.end(), INF);

    int n, ma, mb;
    cin >> n >> ma >> mb;

    table[0][0][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j = 0; j <= 400; j++) 
        {
            for (int k = 0; k <= 400; k++)
            {
                if (table[i - 1][j][k] != INF) {
                    table[i][j][k] = min(table[i][j][k], table[i - 1][j][k]);
                    table[i][j + a][k + b] = min(table[i][j + a][k + b], table[i - 1][j][k] + c);
                }
            }
        }
    }
    int ans = INF;
    for (int i = 1; i <= 400; i++)
    {
        for (int j = 1; j <= 400; j++)
        {
            if (i * mb == j * ma) {
                ans = min(ans, table[n][i][j]);
            }
        }
    }
    if (ans != INF) 
    {
        cout << ans << endl;
    } 
    else 
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 25984
#include <iostream>

using namespace std;

int main()
{
  int N;
  while (scanf("%d ", &N) == 1) {
    if (N == 0) {
      break;
    }
    int a = 0, b = 0, ta, tb;
    for (int i = 0; i < N; i++) {
      scanf("%d %d ", &ta, &tb);
      if (ta > tb) {
	a += ta + tb;
      } else if (ta < tb) {
	b += ta + tb;
      } else {
	a += ta, b += tb;
      }
    }
    printf("%d %d\n", a, b);
  }
  return 0;
}

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

int n;
pair<int, int> points[50];

int calc(int p, int q) {
  set<int> removed;
  int start = 0;
  int cost = 0;
  while (removed.size() != n) {
    for (int i=0; i<n; i++) {
      if (removed.find(i) == removed.end()) {
        start = i;
        break;
      }
    }
    removed.insert(start);
    ++cost;
    int prev_x = points[start].first;
    int prev_y = points[start].second;
    for (int i=start+1; i<n; i++) {
      if (removed.find(i) != removed.end()) {
        continue;
      }
      int x = points[i].first;
      int y = points[i].second;
      if (x == prev_x + p && y == prev_y + q) {
        prev_x = x;
        prev_y = y;
        removed.insert(i);
      }
    }
  }
  return cost;
}
int main() {
  cin>>n;
  for (int i=0; i<n; i++) {
    int x, y;
    cin>>x>>y;
    points[i] = make_pair(x, y);
  }
  if (n == 1) {
    cout<<1<<endl;
    return 0;
  }
  sort(points, points + n);
  int cost = 50;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int p = points[j].first - points[i].first;
      int q = points[j].second - points[i].second;
      cost = min(cost, calc(p, q));
    }
  }
  cout<<cost<<endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

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

  int n;
  cin >> n;
  
  vector<int> ps(n);
  vector<vector<Edge>> graph(n);
  vector<int> out_ds(n);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    p--;
    ps[i] = p;
    graph[p].push_back(Edge(p, i));
    out_ds[p]++;
  }

  auto grundy_fn = [](const vector<vector<Edge>>& graph, const vector<int>& gs, int v) -> int {
    set<int> s;
    for (const auto& e : graph[v]) {
      if (gs[e.to] >= 0) s.insert(gs[e.to]);
    }
    int c = 0;
    while (true) {
      if (s.find(c) == s.end()) return c;
      c++;
    }
  };

  vector<int> gs(n, -1);
  deque<int> q;
  for (int v = 0; v < n; v++) {
    if (out_ds[v] == 0) {
      q.push_back(v);
    }
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop_front();
    gs[v] = grundy_fn(graph, gs, v);
    out_ds[ps[v]]--;
    if (out_ds[ps[v]] == 0) {
      q.push_back(ps[v]);
    }
  }

  vector<int> cycle;
  for (int v = 0; v < n; v++) {
    if (out_ds[v] > 0) {
      cycle.push_back(v);
      int u = ps[v];
      while (true) {
        cycle.push_back(u);
        u = ps[u];
        if (u == v) break;
      }
      break;
    }
  }
  reverse(cycle.begin(), cycle.end());

  if (cycle.empty()) {
    cerr << "Unexpected: No cycle!" << endl;
    exit(1);
  }

  int v1 = cycle[cycle.size() - 1];
  vector<int> g1s(2);
  g1s[0] = grundy_fn(graph, gs, v1);
  gs[cycle[0]] = g1s[0];
  g1s[1] = grundy_fn(graph, gs, v1);
  gs[cycle[0]] = -1;

  bool ans = false;
  for (int g1 : g1s) {
    vector<int> hs(gs.begin(), gs.end());
    hs[v1] = g1;
    for (int i = cycle.size() - 2; i >= 0; i--) {
      hs[cycle[i]] = grundy_fn(graph, hs, cycle[i]);
    }
    if (grundy_fn(graph, hs, v1) == hs[v1]) {
      ans = true;
    }
  }

  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

void solve1();void solve2();
int main(){
  solve1();
  return 0;
}

void solve1(){

  double n;
  cin>>n;
  using pdd = pair<double,double>;
  vector<pdd> a(n);
  cin>>a;
  sort(a.begin(),a.end());
  double ans = 0.0;

  auto calc =[](pdd a,pdd b){
    double x = a.first-b.first;
    double y = a.second-b.second;
    x*=x;
    y*=y;
    return sqrt(x+y);
  };

  do{
    double ret = 0.0;
    rep(i,n-1){
      ret += calc(a[i],a[i+1]);
    }
    ans += ret;
  }while(next_permutation(a.begin(),a.end()));


  auto frac = [](double a){
    double x = 1.0;
    for(double i=2.0;i<=a;++i){
      x*=i;
    }
    return x;
  };

  ans /= frac(n);
  cout<<fixed<<setprecision(10);
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
def main():

    import sys, math
    #from bisect import bisect_left as bl, bisect_right as br, insort
    #from heapq import heapify, heappush, heappop
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n=int(data())
    l1=[]
    l2=[]
    cnt1=0
    cnt2=0
    for i in range(n):
        s=data()
        o=c=0
        for j in s:
            if j=='(':
                o+=1
            else:
                if o>0:
                    o-=1
                else:
                    c+=1
        if o==0:
            if c!=0:
                cnt2+=c
        elif c==0:
            cnt1+=o
        else:
            if c>o:
                l2.append([c,o])
            else:
                l1.append([c,o])
    l1.sort(key=lambda x:x[0])
    flag=True
    for i in l1:
        if cnt1>=i[0]:
            cnt1=cnt1-i[0]+i[1]
        else:
            flag=False
            break
    l2.sort(key=lambda x: x[1],reverse=True)
    l2.sort(key=lambda x: x[0],reverse=True)
    for i in l2:
        if cnt1>=i[0]:
            cnt1=cnt1-i[0]+i[1]
        else:
            flag=False
            break
    if flag==True:
        if cnt1-cnt2==0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 105304
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

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

    ll ac = a * c;
    ll ad = a * d;
    ll bc = b * c;
    ll bd = b * d;

    cout << max({ac, ad, bc, bd}) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<ll,ll>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

ll A, B, N;

ll f(ll x){
  return floor(A*x/B) - A*floor(x/B);
}

int main(){

  cin >> A >> B >> N;

  if(N >= B-1){
    cout << f(B-1) << endl;
  }else{
    cout << f(N) << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int binsearch(long *ary, long val, int imin, int imax){
  while(1){
    int imid=imin+(imax-imin)/2;
    if(ary[imid]<val && ary[imid+1]>=val) return imid;
    else if(ary[imid]>=val) imax=imid-1;
    else imin=imid+1;
  }
}

int main()
{
  int i, j, k, n;
  long a[100000];
  long bicolor[300020];
  long *color= &bicolor[100010];
  int numcolor=0;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%ld", &a[i]);
    if(numcolor==0){
      color[numcolor]=a[i];
      numcolor++;
    }else{
      if(a[i]<=color[0]){
//        for(j=numcolor; j>0; j--){
//          color[j]=color[j-1];
//        }
        color--;
        color[0]=a[i];
        numcolor++;
      }else{
        color[numcolor]=1000000001;
        j=binsearch(color,a[i],0,numcolor-1);
        color[j]=a[i];
      }
    }
  }

  printf("%d\n", numcolor);

  return 0;
}

Measured memory_bytes: 3200
import sys

while True:
	n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 == n and 0 == x:
		break
		
	cnt = 0
	goto = False
	for i in range( 1, n-1 ):
		if  x < 3*(i+1):
			break
		for j in range( i+1, n ):
			if  x <= ( i+j ):
				break
			for k in range( j+1, n+1 ):
				s = ( i + j + k )
				if x == s:
					cnt += 1
					break
				elif   x < s:
					goto = True
					break
			goto = False
	
	print( cnt )

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

int main() {
  int n,pos;
  cin >> n;
  vector<int> data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  for(int count = 0;count < n;count++){
    if(count == 0){
      pos = data.at(0)-1;
    }
    else{
      pos = data.at(pos)-1;
    }
    if(pos == 1){
      cout << count+1 << endl;
      return 0;
    }
    else if(count == n-1){
      cout << -1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> minus(1,0) , plus(1,0);
    bool flag = false;
    rep(i,n){
        int a; cin >> a;
        if(a<0) minus.push_back(-1*a);
        if(a>0) plus.push_back(a);
        if(a == 0) flag = true;
    }
    if(flag) n--,k--;
    int ans = INF;
    sort(minus.begin(),minus.end());
    int ms = minus.size(), ps = plus.size();
  
    for(int i=0;i<=k;i++){
        int p = k - i;
        if(p>=ps) continue;
        if(i>=ms) continue;
        ans = min ( ans , 2*minus.at(i) + plus.at(p) );
    }
    for(int i=0;i<=k;i++){
        int m = k - i;
        if(m>=ms) continue;
        if(i>=ps) continue;
        ans = min ( ans, 2*plus.at(i) + minus.at(m) );
    }
    cout << ans << endl;  
    
}

Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
using ulong = unsigned long;
using ll = long long;

set<int> ds;

bool ok(int num){
	while(num){
		if(ds.count(num % 10)){
			return false;
		}
		num /= 10;
	}
	return true;
}

int main(){
	int n, k;
	cin >> n >> k;
	for(int i=0;i<k;i++){
		int d;
		cin >> d;
		ds.insert(d);
	}
	for(int i=n;;i++){
		if(ok(i)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void) {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	ans += min(a, k);
	k -= a;
	k -= b;
	if (k > 0) ans -= min(c, k);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3664
N = gets.to_i
A0 = gets.split.map(&:to_i)
A1 = gets.split.map(&:to_i)
max = 0

0.upto(N-1) do |i|
  tmp = 0
  0.upto(i) {|j| tmp += A0[j] }
  i.upto(N-1) {|j| tmp += A1[j] }
  max = tmp if max < tmp
end

puts max

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

int main(){
    int n;
    int ans = 0;
    cin >> n;
    
    vector <int> mochis(n);
    for (int i = 0; i < n; i++) {
        cin >> mochis.at(i);
    }
    sort(mochis.begin(), mochis.end());

    int just_before = 0;

    for (int i = 0; i < n; i++) {
        if (mochis.at(i) != just_before) {
            ans++;
            just_before = mochis.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n, k; cin >> n >> k;
    int a[n+1];
    memset(a, 0, sizeof(a));
    for(int i = 0; i < n; i++)
    {
        int d; cin >> d;
        for(int j = 0, x; j < d; j++)
        {
            cin >> x; a[x]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(!a[i])
            ans++;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3636
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

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


int n;

void solve () {
	vpii ans;
	fi(0, n - 1) fj(i + 1, n - 1) {
		if (n % 2 == 1) {
			if (i + j != n - 2) {
				ans.pb(mp(i, j));
			}
		} else {
			if (i + j != n - 1) {
				ans.pb(mp(i, j));
			}
		}
	}
	printf("%d\n", sz(ans));
	for (auto z : ans) {
		printf("%d %d\n", z.first + 1, z.second + 1);
	}	
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%d", &n);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 384
#include<stdio.h>
int partition(int[],int,int);

int main(){
  int i,j,n,A[100000],k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  k = partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==k){
      printf("[");
    }
    printf("%d",A[i]);

    if(i==k){
      printf("]");
    }
  }
  printf("\n");
  return 0;
}

int partition(int A[],int p,int r){
  int x,i,j,B[100000],C[100000];
  x = A[r];
  i = p-1;
  for(j=p;j<=r-1;j++){
    if(A[j] <= x){
      i = i + 1;
      C[i] = A[i];
      A[i] = A[j];
      A[j] = C[i];
    }
  }
  B[i+1]=A[i+1];
  A[i+1] = A[r];
  A[r] = B[i+1];
  return i+1;
}



Measured memory_bytes: 2240
#include <bits/stdc++.h>
// clang-format off
#define FOR(i, n) for (int i=0; i<(int)n; ++i)
#define RFOR(i, n) for (int i=n-1; i>=0; --i)
#define OUTV(x) FOR(j,x.size()) cerr<<x[j]<<(x.size()-j-1?' ':'\n');
#define OUTM(x) FOR(i,x.size()) {OUTV(x[i])}
#define DEBUG(x) cerr<<"DEBUG: "<<#x<<" = "<<x<<endl;
#define PB push_back
#define MP make_pair
// clang-format on
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  //  std::random_device rd;std::mt19937 ran(rd());

  int N, M;
  cin >> N >> M;

  vector<pair<long long, long long>> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i].first >> a[i].second;
  }

  sort(a.begin(), a.end());

  long long totalCans = 0;
  long long yen = 0;
  for (int i = 0; i < N; ++i) {
    if (totalCans > M)
      break;
    if (totalCans + a[i].second <= M) {
      yen += a[i].second * a[i].first;
      totalCans += a[i].second;
    } else {
      yen += (M - totalCans) * a[i].first;
      totalCans = M;
      break;
    }
  }
  cout << yen << endl;

  return 0;
}


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

int main() {
  string s;cin>>s;
  string t="NWSE";
  vector<int> vec(4);
  rep(i,s.size()){
    rep(j,4){
      if(s[i]==t[j])vec[j]++;
    }
  }
  bool ok=true;
  rep(i,2){
    if((vec[i]==0&&vec[i+2]>0)||(vec[i+2]==0&&vec[i]>0))ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<math.h>

int main(void)
{
	int a,b,c;
	double s=0,l=0,h=0,ra,pi=3.141592653589;
	scanf("%d%d%d",&a,&b,&c);
	ra=c*pi/180;
	s=0.5*a*b*sin(ra);
	l=sqrt(a*a+b*b-2*a*b*cos(ra))+a+b;
	h=s*2/a;
	printf("%8lf\n%8lf\n%8lf\n",s,l,h);
    return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = 1e9 + 7;
#define SAFE 1e8

int main()
{
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
using namespace std;
 
int main(){
 
  int n, m, a[100], b, sum[100]={}, x;
 
  cin>>n>>m;
 
  for(int i=0;i<m;i++) cin>>a[i];
 
  for(int i=0;i<m;i++){
    x=0;
    for(int j=0;j<n;j++){
      cin>>b;
      if(a[i]==b) sum[j]++;
      else x++;
    }
    sum[a[i]-1]+=x;
  }
 
  for(int i=0;i<n;i++) cout<<sum[i]<<endl;
 
  return 0;
}

Measured memory_bytes: 3088
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a);a=(a*a);b=b/2;}return res;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
vector<ll>adj[60];
ll n;
ll par[60];
ll lca[60];
void dfs(ll s,ll pa)
{
  par[s]=pa;
  for(auto it : adj[s])
  {
    if(it!=pa)
    {
      dfs(it,s);
    }
  }
}
signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         cin>>n;
         for(int i=0;i<n-1;i++)
         {
          ll a1,b1;
          cin>>a1>>b1;
          adj[a1].pb(b1);
          adj[b1].pb(a1);
         }
         dfs(1,-1);
         ll m;
         cin>>m;
         ll a11[m+1],b11[m+1];
         for(ll i=1;i<=m;i++)
        {
            cin>>a11[i]>>b11[i];
            ll a1 = a11[i];
            ll b1 = b11[i];
            vector<ll>vis(n+5,0);
            while(a1!=-1)
            {
              vis[a1]=1;
              a1=par[a1];
            }
            while(vis[b1]!=1)
            {
                  b1 = par[b1];
            }
            lca[i]=b1;
        }
        ll ans =0;
        for(ll i=0;i<(1<<m);i++)
        {
           ll mask=0;
           vector<ll>vis(n+5,0);
           for(ll j=0;j<m;j++)
           {
            if(i&(1<<j))
            {
                  ll p1 = lca[j+1];
                  ll a1 = a11[j+1];
                  ll b1 = b11[j+1];
                  while(a1!=p1)
                  {
                      if(vis[a1]==0)
                      {
                        mask++;
                      }
                      vis[a1]=1;
                      a1 = par[a1];
                  }
                  while(b1!=p1)
                  {
                    if(vis[b1]==0)
                    {
                      mask++;
                    }
                    vis[b1]=1;
                    b1=par[b1];
                  }
            }
           }
           if(__builtin_popcountll(i) & 1)
            ans -=((1LL<<(n-1-mask)))*1LL;
          else
            ans+=((1LL<<(n-1-mask)))*1LL;
        }
        cout<<ans<<endl;
         

      }
      






}



























Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  if(a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl;
  }else{
  	cout << "Odd" << endl;
  }
}

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

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int a, b, k; cin >> a >> b >> k;
	int g = gcd(a, b);
	int c = 0;
	for (int i = g; i >= 1; i--) {
		if (g % i == 0) {
			c++;
			if (c == k) {
				cout << i << '\n';
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cmax(a,b)		a = max (a, b)
#define cmin(a,b)		a = min (a, b)

const int MAXN = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int N, r[MAXN], X, Q;

int main(){
	scanf("%d%d", &X, &N);
	up (i, 1, N) scanf("%d", &r[i]);
	scanf("%d", &Q);
	int cur = 1, c = 0, lower = 0, upper = X, tt = -1;
	while (Q--) {
		int t, a;
		scanf("%d%d", &t, &a);
		while (r[cur] <= t && cur <= N) {
			int d = r[cur] - r[cur - 1];
			c += tt * d;
			if (lower + c < 0) {
				if (c >= -X) lower = -c;
				else {
					lower = X;
					c = -X;
				}
			}else if (lower + c > X) {
				if (c <= X) lower = X - c;
				else {
					lower = 0;
					c = X;
				}
			}
			if (upper + c < 0) {
				if (c >= -X) upper = -c;
				else {
					upper = X;
					c = -X;
				}
			}else if (upper + c > X) {
				if (c <= X) upper = X - c;
				else {
					upper = 0;
					c = X;
				}
			}
			tt *= -1;
			cur++;
		}
		int d = t - r[cur - 1];
		cmax (a, lower);
		cmin (a, upper);
		a += c + tt * d;
		if (a < 0) a = 0;
		if (a > X) a = X;
		printf("%d\n", a);
	}
	return 0;
}


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

es = [None] * M
for i in range(M):
    a,b,c = map(int, input().split())
    es[i] = (a,b,c)

INF = float("inf")
d = [INF] * N # 頂点１からの最短距離
d[0] = 0

for i in range(N):
    for f, t, c in es:
        f, t = f-1, t-1
        c = c * -1 # ここで負にしておくと最小経路を選んだ時に絶対値としては最大になるので最後にマイナスをかけて出せばよい
        if d[f] != INF and d[t] > d[f] + c: # fromまで到達できる、かつ、toまでのコストがfromまでのコスト＋from->toのコストより大きいとき
            d[t] = d[f] + c
            if i == N-1 and t == N-1: #N回目の更新でそれでも頂点Nが更新された→負の閉路がある
                print("inf")
                exit()

print(-d[-1])

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>

using namespace std;

#define endl '\n'

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  int n, W; cin >> n >> W;
  vector<ll> dp(1e5+10, W+1);

  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    ll w, v; cin >>  w >> v;
    for (int j = 1e5; j - v >= 0; --j) {
      dp[j] = min(dp[j], dp[j-v] + w);
    }
  }

  int ans = 0;
  for (int i = 1; i <= 1e5; ++i) {
    if (dp[i] <= W) {
      ans = max(ans, i);
    }
  }
  cout << ans << endl;

  return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int64_t x, y;
  int ans = 1;

  cin >> x >> y;
  while (x <= (y / 2))
  {
    x *= 2;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

red,blue = 0,0
N = int(input())
s = input()
if len(s)!=N or 1 > N or N > 100:
    sys.exit()
for color in s:
    if color == 'R':
        red += 1
    elif color == 'B':
        blue += 1
    else:
        sys.exit()
if red > blue:
    print('Yes')
else:
    print('No')

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


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((c>a && c<b) || (c<a && c>b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char pal[207][207];
int sol[207][207];
int pri[207][207];
int h, w;
bool flag;

void rec_sol(int i, int j)
{
	if (j+1 < w) if (sol[i][j+1] > sol[i][j]+1 && (pal[i][j+1]=='.'||pal[i][j+1]=='%'||pal[i][j+1]=='@')) {
		sol[i][j+1] = sol[i][j]+1;
		rec_sol(i, j+1);
	}
	if (j-1 > -1) if (sol[i][j-1] > sol[i][j]+1 && (pal[i][j-1]=='.'||pal[i][j-1]=='%'||pal[i][j-1]=='@')) {
		sol[i][j-1] = sol[i][j]+1;
		rec_sol(i, j-1);
	}
	if (i+1 < h) if (sol[i+1][j] > sol[i][j]+1 && (pal[i+1][j]=='.'||pal[i+1][j]=='%'||pal[i+1][j]=='@')) {
		sol[i+1][j] = sol[i][j]+1;
		rec_sol(i+1, j);
	}
	if (i-1 > -1) if (sol[i-1][j] > sol[i][j]+1 && (pal[i-1][j]=='.'||pal[i-1][j]=='%'||pal[i-1][j]=='@')) {
		sol[i-1][j] = sol[i][j]+1;
		rec_sol(i-1, j);
	}
}

void rec_pri(int i, int j)
{
	if (pal[i][j]=='%'&&pri[i][j] < sol[i][j]) flag = 1;
	if (j+1 < w) if (pri[i][j+1] > pri[i][j]+1 && (pal[i][j+1]=='.'|| pal[i][j+1]=='%')) {
		pri[i][j+1] = pri[i][j]+1;
		rec_pri(i, j+1);
	}
	if (j-1 > -1) if (pri[i][j-1] > pri[i][j]+1 && (pal[i][j-1]=='.'|| pal[i][j-1]=='%')) {
		pri[i][j-1] = pri[i][j]+1;
		rec_pri(i, j-1);
	}
	if (i+1 < h) if (pri[i+1][j] > pri[i][j]+1 && (pal[i+1][j]=='.'|| pal[i+1][j]=='%')) {
		pri[i+1][j] = pri[i][j]+1;
		rec_pri(i+1, j);
	}
	if (i-1 > -1) if (pri[i-1][j] > pri[i][j]+1 && (pal[i-1][j]=='.'|| pal[i-1][j]=='%')) {
		pri[i-1][j] = pri[i][j]+1;
		rec_pri(i-1, j);
	}
	
}

int main(void)
{
	int i, j, p, q;
	scanf("%d %d", &h, &w);
	for (i = 0; i < h; i++) scanf("%s", pal[i]);
	for (i = 0; i < h; i++) 
		for (j = 0; j < w; j++) {
			sol[i][j] = 1000;
			pri[i][j] = 1000;
		}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (pal[i][j]=='$') {
				sol[i][j] = 0;
				rec_sol(i, j);
			}
			if (pal[i][j]=='@') {
				p = i; q = j;
			}
		}
	}
	flag = 0;
	pri[p][q] = 0;
	rec_pri(p, q);
	/* for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) printf(" %d", sol[i][j]);
		printf("\n"); 
	}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) printf(" %d", pri[i][j]);
		printf("\n"); 
	} */
	if (flag) printf("Yes\n");
	else printf("No\n");
	
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    ll even_sum = 0;
    rep(i, n) {
        ll tmp_a;
        cin >> tmp_a;
        a[i] = tmp_a;
        sum += a[i];
        if ( i&1 ) {
            even_sum += a[i];
        }
    }
    ll x1 = sum - 2 * even_sum;
    vector<ll> ans(n);
    ans[0] = x1;
    for ( int i = 0; i < n-1; ++i ) {
        ans[i+1] = 2 * a[i] - ans[i];
    }
    rep(i, n) {
        if ( i >= 1 ) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<fstream>

using namespace std;

	ifstream fin;
	ofstream fout;

	//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1160&lang=jp

	int gomi = 0;

	int a[52][52] = {};
	int check(int, int);

	int main(){

		fin.open("input.txt");
		fout.open("output.txt");

		//		int w = 0, h = 0;
		int width = 0, height = 0;
		int count = 0;


		while (1){
			for (int i = 0; i < 50; i++)
				for (int j = 0; j < 50; j++)
					a[i + 1][j + 1] = 0;

			cin >> width >> height;
			if (width == 0 && height == 0)break;

			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					//初期化
					gomi = a[i + 1][j + 1] = 0;

					cin >> a[i + 1][j + 1];
				}
			}

			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
				}
			}
			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					if (a[i + 1][j + 1] == 1){
						check(i + 1, j + 1);
						a[i + 1][j + 1] = 1;
						count++;
					//	cout << i + 1 << "  " << j + 1 << endl;
					}
				}
			}
//			cout << count << endl;
			fout << count << endl;

			//初期化
			count = 0;
			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					a[i + 1][j + 1] = 0;
				}
			}
		}
	}

	int check(int y, int x){
		if (a[y + 1][x] == 1){
			a[y + 1][x] = 0;
			check(y + 1, x);
		}
		//-----------------------------
		if (a[y][x + 1] == 1){
			a[y][x + 1] = 0;
			check(y, x + 1);
		}
		//-----------------------------
		if (a[y - 1][x] == 1){
			a[y - 1][x] = 0;
			check(y - 1, x);
		}
		//-----------------------------
		if (a[y][x - 1] == 1){
			a[y][x - 1] = 0;
			check(y, x - 1);
		}
		//-----------------------------
		if (a[y + 1][x + 1] == 1){
			a[y + 1][x + 1] = 0;
			check(y + 1, x + 1);
		}
		//-----------------------------
		if (a[y + 1][x - 1] == 1){
			a[y + 1][x - 1] = 0;
			check(y + 1, x - 1);
		}
		//-----------------------------
		if (a[y - 1][x + 1] == 1){
			a[y - 1][x + 1] = 0;
			check(y - 1, x + 1);
		}
		//-----------------------------
		if (a[y - 1][x - 1] == 1){
			a[y - 1][x - 1] = 0;
			check(y - 1, x - 1);
		}
		//-----------------------------
		return 0;
	}

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

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
	dice(int top,int front,int right,int left,int back,int bottom) {
		id[TOP] = top; id[FRONT] = front; id[RIGHT] = right;
		id[LEFT] = left; id[BACK] = back; id[BOTTOM] = bottom;
	}
	int& operator[] (FACE f) { return id[f]; }
	const int& operator[] (FACE f) const { return id[f]; }
	bool operator==(const dice &b) const {
		const dice &a = *this;
		return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
			a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
			 a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
	}
	void roll_north() { roll(TOP, FRONT, BOTTOM, BACK); }
	void roll_south() { roll(TOP, BACK, BOTTOM, FRONT); }
	void roll_east() { roll(TOP, LEFT, BOTTOM, RIGHT); }
	void roll_west() { roll(TOP, RIGHT, BOTTOM, LEFT); }
	void roll_right() { roll(FRONT, LEFT, BACK, RIGHT); }
	void roll_left() { roll(FRONT, RIGHT, BACK, LEFT); }
	bool equivalent_to(const dice& di){
		for (int k = 0; k < 6; (k&1?roll_east():roll_north()),++k)
			for (int i = 0; i < 4; roll_right(), ++i)
				if (*this == di) return true;
		return false;
	}
private:
	void roll(FACE a, FACE b, FACE c, FACE d){
		int tmp = id[a];
		id[a] = id[b]; id[b] = id[c];
		id[c] = id[d]; id[d] = tmp;
	}
	int id[6];
};

int main(){
	int n,d[6];
	cin>>n;
	vector<dice>v;
	for(int j=0;j<n;j++){
		for(int i=0;i<6;i++)cin>>d[i];
		v.push_back(dice(d[0],d[1],d[2],d[3],d[4],d[5]));
	}
	for(int j=0;j<n-1;j++)for(int i=j+1;i<n;i++)if(v[j].equivalent_to(v[i])){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
class Main {
	int H,W,x,y;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 || W != 0){
			for(x = 0;x < H;x++){
				for(y = 0;y < W;y++){
					if(x == 0 || x == H - 1 || y == 0 || y == W - 1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

Measured memory_bytes: 25896
#include <cstdio>
#include <cstring>
#define MAX(a,b)((a)>=(b)?(a):(b))
int dp[1001],v[1000],w[1000];
int main() {
	int W,N,Case=1;
	while(scanf("%d",&W),W) {
		scanf("%d",&N);
		for(int i=0;i<N;i++) {
			scanf("%d,%d",&v[i],&w[i]);
		}
		memset(dp,0,sizeof(dp));
		for(int i=0;i<N;i++) {
			for(int j=W;j>=w[i];j--) {
				dp[j]=MAX(dp[j],dp[j-w[i]]+v[i]);
			}
		}
		int ans_w=W;
		for(int i=W-1;i>=0;i--) {
			if(dp[W]!=dp[i]) {ans_w=i+1; break;} 
		}
		printf("Case %d:\n",Case++);
		printf("%d\n%d\n",dp[W],ans_w);
	}
}

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

int main()
{
	int sw_Number, divine_Number=0, i, number_All, hako[201];
	cin>>number_All;
	
	for(i=0; i<number_All;i++)
	{
	        cin>>sw_Number;
	        
	        while(sw_Number%2==0)
	        {
	            sw_Number = sw_Number/2;
	            divine_Number++;
	        }
	        
	        hako[ i ] = divine_Number;
	        divine_Number = 0;
	}
	
	    sort(hako,hako + number_All);
	    cout<<hako[0];
	    
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1000000007;
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), num(N + 1, 0);
    rep(i, N) {
        cin >> A[i];
    }

    ll ans = 1;
    rep(i, N) {
        if (A[i] == 0) {
            ans *= (3 - num[0]);
        }
        else {
            ans *= (num[A[i] - 1] - num[A[i]]);
        }
        ans %= MOD;
        num[A[i]]++;
    }

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

Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto W = new int[](N);
    auto V = new long[](N);
    foreach (i; 0..N) {
        s = readln.split.map!(to!int);
        W[i] = s[0];
        V[i] = s[1];
    }

    auto dp = new long[][](N+1, M+1);

    foreach (i; 0..N) {
        dp[i+1] = dp[i].dup;
        foreach (j; 0..M+1) {
            if (j + W[i] > M) break;
            dp[i+1][j+W[i]] = max(dp[i+1][j+W[i]], dp[i][j] + V[i]);
        }
    }

    dp[N].reduce!max.writeln;
}


Measured memory_bytes: 146428
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int sum;
	sum = 0;
	cin >> s;
	if (s[0] == '1') {
		sum++;
	}
	if (s[1] == '1') {
		sum++;
	}
	if (s[2] == '1') {
		sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  string s; cin >> s;
  map<char, int> M;
  for (auto&&c: s) M[c]++;
  cout << 700+100*M['o'] << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
ll a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    sort(a,a+n);

    priority_queue<ll> pq;
    ll res = 0;
    pq.push(a[n-1]);
    for (int i=n-2; i>=0; i--) {
	res += pq.top();
	//watch(res);
	pq.pop();
	pq.push(a[i]);
	pq.push(a[i]);
    }

    cout<<res<<endl;    
    return 0;
}


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

using namespace std;

int main()
{
    int n,m;
    cin>>n;
    int maks=3*1e5;
    int ile = 0;
    for(int i = 0;i<n;i++)
    {
        int a;
        cin>>a;
        if(a<maks)
        {
            maks=a;
            ile++;
        }
    }
    cout<<ile;
}


Measured memory_bytes: 256
using Yorukatsu021.Questions;
using Yorukatsu021.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Yorukatsu021.Questions
{
    /// <summary>
    /// ABC100 C
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var a = inputStream.ReadIntArray();
            yield return a.Sum(i => GetPrimeFactor2(i));
        }

        int GetPrimeFactor2(int n)
        {
            var count = 0;
            while ((n & 0x01) == 0)
            {
                n >>= 1;
                count++;
            }
            return count;
        }
    }
}


namespace Yorukatsu021
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu021.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu021.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 14176
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 200007;
const LD EPS = 1e-7;

int A[MAXN], B[MAXN], CA[MAXN], CB[MAXN], ans = 0;
vector <int> C, G[MAXN];
map <int, int> M;
bool used[MAXN], V[MAXN];

void dfs(int v)
{
	used[v] = true;
	REP(i, SZ(G[v]))
	{
		int to = G[v][i];
		if (!used[to])
			dfs(to);
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, s = 0, cnts = 0;
	cin >> n;
	REP(i, n)
	{
		cin >> A[i];
		s ^= A[i];
		C.push_back(A[i]);
	}
	REP(i, n)
	{
		cin >> B[i];
		cnts += B[i] == s;
		C.push_back(B[i]);
	}
	C.push_back(s);
	sort(C.begin(), C.end());
	int nv = 0;
	REP(i, SZ(C))
	{
		if (i == 0 || C[i] > C[i - 1])
			M[C[i]] = nv++;
	}
	REP(i, n)
	{
		++CA[M[A[i]]];
		++CB[M[B[i]]];
	}
	int cntd = 0;
	REP(i, MAXN)
	{
		cntd += (CA[i] != CB[i]);
		if (cntd == 3 || CB[i] > CA[i] && i != M[s] || CB[i] > CA[i] + 1)
		{
			cout << -1;
			return 0;
		}
	}
	REP(i, n)
	{
		if (A[i] != B[i])
		{
			V[M[B[i]]] = true;
			G[M[A[i]]].push_back(M[B[i]]);
			G[M[B[i]]].push_back(M[A[i]]);
			++ans;
		}
	}
	REP(i, nv)
	{
		if (V[i] && !used[i])
		{
			dfs(i);
			++ans;
		}
	}
	ans -= cnts > 0 && V[M[s]];
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 19444
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let r: f64 = read();
    let pi = std::f64::consts::PI;
    println!("{:.6} {:.6}", r * r * pi, 2.0 * pi * r);
}



Measured memory_bytes: 5060