akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


void still_TBD()
{
  string s;
  cin >> s;

  if (s[5] == '1' || s[6] >= '5') cout << "TBD\n";
  else cout << "Heisei\n";
}


void favorite_sound()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << "\n";
}


int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  //A_118();
  //still_TBD();
  favorite_sound();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n;
  cin>>n;
  vector<string> s(10);
   s[0]="pon";
   s[1]="pon";
   s[2]="hon";
   s[3]="bon";
   s[4]="hon";
   s[5]="hon";
   s[6]="pon";
   s[7]="hon";
   s[8]="pon";
   s[9]="hon";
     cout<<s[n%10]<<endl;
}


Measured memory_bytes: 3632
N = input()
A = {int(x) for x in input().split()}

while True:
    if len(A) == 1:
        break
    tmp = list(A)
    mn = min(tmp)
    for idx in range(len(tmp)):
        if tmp[idx] != mn:
            tmp[idx] = tmp[idx] % mn if tmp[idx] % mn != 0 else mn
    A = set(tmp)

print(A.pop())


Measured memory_bytes: 19724
n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)

max = 0
(1..(n/2 - 1)).each do |i|
  sum = 0
  left, right = i, n-1-i
  while i < right do
    sum += s[left] + s[right]
    break if right%i==0 && left >= right
    max = sum if max < sum
    left += i
    right -= i
  end
end
puts(max)

Measured memory_bytes: 11676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, h[100005] = {}, u, v, z = 0;
    vector<int> g[100005] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> h[i];
    while (m--) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    for (int i = 1; i <= n; i++) {
        bool y = 0;
        for (int j : g[i]) if (h[j] >= h[i]) y = 1;
        if (!y) z++;
    }
    cout << z;
}


Measured memory_bytes: 9184
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
z = x.zip(y).map{|a, b| (a - b).abs}

[1,2,3].each{|p|
    puts '%.5f' % z.map{|c|
        c ** p
    }.inject(0, :+) ** (1.0 / p)
}

puts '%.5f' % z.max


Measured memory_bytes: 6964
N, Q = map(int, input().split())
S = str(input())
t = [0] * (N+1)

for i in range(N):
  if S[i:i+2] == "AC":
    x = 1
  else:
    x = 0
  t[i+1] = t[i] + x

for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])

Measured memory_bytes: 50776
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	vector<int> dp(100000, INT32_MAX);
	dp[0] = 0;
	int h, n;
	cin >> h >> n;
	vector<pair<int, int>> a(n);
	int best = INT32_MAX;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < h; i++) {
		if (dp[i] == INT32_MAX)continue;
		for (int j = 0; j < n; j++) {
			dp[i + a[j].first] = min(dp[i + a[j].first], dp[i] + a[j].second);
		}
	}
	for (int i = h; i < 100000; i++) {
		best = min(best, dp[i]);
	}
	cout << best;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    int *v = new int[n];
    for (int i = 0; i < n; i++) cin >> v[i];

    int m = min(n, k);
    int score = 0;
    int *w = new int[n];
    for (int l = 0; l <= m; l++) {
        for (int r = 0; r <= m - l; r++) {
            int i = 0;
            int tmp = 0;
            for (int ll = 0; ll < l; ll++) {
                w[i] = v[ll];
                tmp += w[i];
                i++;
            }
            for (int rr = 1; rr <= r; rr++) {
                w[i] = v[n - rr];
                tmp += w[i];
                i++;
            }
            sort(w, w + i);

            int rem = min(k - i, i);
            for (int ii = 0; ii < rem; ii++) {
                if (w[ii] < 0) {
                    tmp -= w[ii];
                }
                else {
                    break;
                }
            }
            if (score < tmp) score = tmp;
        }
    }

    cout << score << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

struct edge{ll to, cost;};

vector<ll> dijkstra(ll s,ll n,vector<edge> G[]){
    vector<ll> d={};
    d.resize(n);
    REP(i,n) d[i]=LINF;
    // 最短距離firstが小さい順に取り出せるようにする
    priority_queue<LP, vector<LP>, greater<LP>> que;
    d[s] = 0;// スタート地点を0で初期化
    que.push(LP(0,s));// キューに初期位置のコスト、初期位置をpush

    while(que.size()){
        LP p = que.top();que.pop(); // p: 今の{最短距離、頂点番号}
        ll v = p.second;//今の頂点番号
        if(d[v] < p.first) continue;// 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離
        for(int i=0; i < G[v].size();i++){// 今の頂点に隣接する頂点を調べる
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){// 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト
                d[e.to] = d[v] + e.cost;// 歴代最小距離の更新
                que.push(P(d[e.to],e.to));// 更新した遷移先の頂点をキューに突っ込む
            }
        }
    }
    return d;
}

ll i,j,k;
vector<edge> edge_yen[202020];
vector<edge> edge_snu[202020];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,s,t;
    cin>>n>>m>>s>>t;
    REP(i,m){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        edge e1;
        e1.to = v,e1.cost=a;
        edge_yen[u].push_back(e1);
        edge e2;
        e2.to = u,e2.cost = a;
        edge_yen[v].push_back(e2);
        edge e3;
        e3.to=v,e3.cost=b;
        edge_snu[u].push_back(e3);
        edge e4;
        e4.to=u,e4.cost=b;
        edge_snu[v].push_back(e4);
    }

    vector<ll> dist_yen=dijkstra(s,n+1,edge_yen);
    vector<ll> dist_snu=dijkstra(t,n+1,edge_snu);

    ll ans[202020];
    ll ma=0;
    ll first=1e15;
    for(i=n;i>=1;i--){
        ll val=first-(dist_yen[i]+dist_snu[i]);
        ma=max(val,ma);
        ans[i]=ma;
    }
    for(i=1;i<=n;i++) cout<<ans[i]<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;
ll a[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n-k;i++){
        if(a[i]<a[i+k]) puts("Yes");
        else puts("No");
    }
    return 0;
}



Measured memory_bytes: 5180
n=int(input())
h=list(map(int,input().split()))

#ダメなパターンは以下の二つ
#２以上下がる
#連続して1ずつ下がる
import sys
flg=0
for i in range(n-1):
  if h[i+1]-h[i]<=-2:
    print("No")
    sys.exit()
  elif h[i+1]-h[i]==-1 and flg==1:
    print("No")
    sys.exit()
  elif h[i+1]-h[i]==-1 and flg==0:
    flg=1
  elif h[i+1]-h[i]!=0:
    flg=0
print("Yes")


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).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;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}

template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	long n, m, d;
	cin >> n >> m >> d;
	int cnt = 0;

	cnt = max(n - d, (long)0);

	//cout << cnt << endl;
	long double pr;
	if (cnt == n)
	{
		pr = cnt / (long double)(n * n);
	}
	else
	{
		pr = cnt * 2 / (long double)(n * n);
	}
	//cout<<pr<<endl;
	cout << setprecision(9) << pr * (m - 1) << endl;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())
ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000
if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000
if X == 1 and Y == 1:
    ans += 400000
print(ans)



Measured memory_bytes: 9184
program atcoder
    implicit none
    integer(8) :: N,A(0:2),K=1,i,j,s(0:5),cut(0:5),ans,p;
    integer(8),allocatable,dimension(:) :: L;
    read*,N,A(0),A(1),A(2)
    allocate(L(N))
    read(*,*)(L(i),i=1,N)
    do i=1,N
        K = K * 4
    enddo
    ans = 100000000000000000_8
    do j = 1,K
        s = 0
        cut = 0
        p = j
        do i = 1,N
            s(mod(p,4)) = s(mod(p,4)) + L(i)
            cut(mod(p,4)) = cut(mod(p,4)) + 1
            p = int(p/4)
        enddo
        do i=0,2
            p=p + abs(s(i)-A(i))
            p=p + (cut(i)-1)*10
            if(cut(i)==0)then
                p= 100000000000000000_8
            endif
        enddo
        ans = min(ans,p)
    enddo
    write(*,'(I0)')ans
    stop 
contains
end program atcoder

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var max = 0;
            for (var i = 0; i < N; i++)
            {
                var dict = new Dictionary<int, int>();
                for (var k = 0; k <= i; k++)
                {
                    for (var j = i + 1; j < N; j++)
                    {
                        if (S[k] == S[j])
                        {
                            if (dict.ContainsKey(S[k]))
                                dict[S[k]]++;
                            else
                                dict[S[k]] = 1;
                        }
                    }
                }
                max = Math.Max(dict.Count, max);
            }
            Console.WriteLine(max);
        }
    }
}

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

int main(){
    int a[2][2];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0;;i++){
        if(a[i%2][0] <= 0){
            cout << (i%2==0 ? "No" : "Yes") << endl;
            return 0;
        }
        a[1-i%2][0] -= a[i%2][1];
    }
    return 0;
}

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

int main() {
	long n;
  	cin >> n;
  	vector<long> a(n);
  	for(long i = 0; i< n; i++){
      cin >> a[i];
    }
  	for(long i = 0; i < n; i++){
      if(a[i] % 2 == 0){
        if(a[i] % 3 == 0 || a[i] % 5 == 0){
          continue;
        }else{
          cout << "DENIED" << endl;
          return 0;
        }
      }
    }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll N;

vector<bool > prime;

//primeListには素数は入ってません
void isPrime(ll N){
    prime[0] = false;
    prime[1] = false;

    //ルートN以下まで繰り返す
    for(ll i = 2; i < ceil(sqrt(N)) ; i++){
        //素数になりえないとき
        if(prime[i] == false) continue;
        
        //Nまでのi(素数)の倍数を斑入り落とす
        for(ll j = i * i; j < N; j += i){
            prime[j] = false;
        }
        
    }
}

int main(){

    ll Q;
    cin >> Q;
    
    //cin >> N;
    prime.assign(100001, true);
    isPrime(100001);

    vector<ll > kukan(100001, 0);

    for(ll i = 2; i < prime.size(); i++){
        //cout << prime[i] << endl;
        if(prime[i] == true && i % 2 == 1){
            if(prime[(i + 1) / 2] == true){
                kukan[i] = kukan[i - 1] + 1;
            }else{
                kukan[i] = kukan[i - 1];
            }
        }else{
            kukan[i] = kukan[i - 1];
        }
    }

    vector<ll > ans(Q, 0);
    for(ll i = 0; i < Q; i++){
        ll l = 0; 
        ll r = 0;
        cin >> l >> r;
        //ans += kukan[r] - kukan[l - 1];
        ans[i] = kukan[r] - kukan[l - 1];
    }

    for(ll i = 0; i < Q; i++){
        cout << ans[i] << endl;
    }
} 

Measured memory_bytes: 2176
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false;}
const ll INF = 1e18;

ll n, res, xbit, ybit, cnt; 
V<> x(15), y(15), p(15), ans(16, INF), xp, yp;
VV<> xans(100000, V<>(15)), yans(100000, V<>(15));

void solve(string s){
    xp.clear(); yp.clear();
    res = xbit = ybit = cnt = 0;
    REP(i, n){
        if(s[i] == '1'){
            xp.pb(x[i]);
            xbit += (1 << i);
            cnt++;
        }
        if(s[i] == '2'){
            yp.pb(y[i]);
            ybit += (1 << i);
            cnt++;
        }
    }
    if(cnt > n) return;
    REP(i, n) if(s[i] == '0') res += min(xans[xbit][i], yans[ybit][i]);
    chmin(ans[cnt], res);
}

void dfs(string s){
    if(SZ(s) == n){
        solve(s);
        return;
    }
    dfs(s + "0");
    dfs(s + "1");
    dfs(s + "2");
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    REP(i, n) cin >> x[i] >> y[i] >> p[i];
    REP(bit, (1 << n)){
        xp.clear(); yp.clear();
        REP(i, n) if((bit >> i) & 1){
            xp.pb(x[i]);
            yp.pb(y[i]);
        }
        xp.pb(INF); xp.pb(-INF); xp.pb(0);
        yp.pb(INF); yp.pb(-INF); yp.pb(0);
        sort(all(xp)); sort(all(yp));
        REP(i, n){
            auto itr0 = lower_bound(all(xp),x[i]);
            auto itr1 = itr0; itr1--;
            xans[bit][i] = min(*itr0 - x[i], x[i] - *itr1) * p[i];
            itr0 = lower_bound(all(yp), y[i]);
            itr1 = itr0; itr1--;
            yans[bit][i] = min(*itr0 - y[i], y[i] - *itr1) * p[i];
        }
    }
    dfs("");
    REP(i, n + 1) cout << ans[i] << '\n';
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,X,T;
  cin >> N >> X >> T;

  cout << (N+X-1)/X*T << endl;

  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main {
    public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int k = scan.nextInt();
      String s = scan.next();
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < s.length(); i++) {
        char temp = s.charAt(i);
        if(i==k-1) {
          temp = (char)(temp+32);
        }
        sb.append(temp);
      }
      
			System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {
    lli N;
    cin >> N;

    vector<lli> d(N);
    for (lli i = 0; i < N; ++i) {
        cin >> d[i];
    }

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

    lli center = N / 2;
    lli abc = d[center - 1];
    lli arc = d[center];

    cout << arc - abc << endl;


    return 0;
}


Measured memory_bytes: 1024
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll k, a, b;
  cin >> k >> a >> b;
  ll x = 1;
  int d = min(a - 1, k);
  k -= d;
  x += d;
  if(x >= a && b - a > 2) {
    x += k / 2 * (b - a);
    if(k & 1) x++;
  } else {
    x += k;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  map <string, int> mp;
  REP(i, n) {
	string s;
	cin >> s;
	mp[s] = mp[s] + 1;
  }
  vector <pair <int, string> > ps;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
	  ps.push_back(make_pair(-itr->second, itr->first));
	}
  sort(all(ps));
  cout << ps[0].second << endl;
  for (int i = 1; i < SZ(ps); i++) {
	  if (ps[i].first == ps[i - 1].first) {
		  cout << ps[i].second << endl;
		} else {
		  break;
		}
	}
  return 0;
}


Measured memory_bytes: 29172
#include<stdio.h>
int main()
{   
    
  int A[100],N; 
  int i,j,temp,c=0;

  scanf("%d\n",&N);
 for(i = 0; i < N; i++){ 
  scanf("%d",&A[i]); 
 }

   for(i = 0; i < N-1; i++){ 
    for (j = N - 1; j > i; j--) {
      if (A[j-1] > A[j]) {
        temp = A[j-1];
       A[j-1] = A[j];
        A[j] = temp;
	c++;
      }
    }
  }

  for(i=0;i<N;i++) {
    if(N-1>i) printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n%d\n",c);
  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll INF=1e15,MOD=1e9+7,MAX=3e5+1;

ll add(ll x, ll y)
{
    x += y;
    while(x >= MOD)
        x -= MOD;
    while(x < 0)
        x += MOD;
    return x;
}

ll mult(ll x, ll y)
{
    return (1LL * x * y) % MOD;
}

int main() {
    IOS;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    multiset<pair<ll,bool>,greater<pair<ll,bool>>>s;
    lp(i,0,n){
        cin>>a[i];
        s.insert({abs(a[i]),a[i]>=0});
    }
    int cnt=0,neg=0,idxN=-1,idxP=-1,vN=1,vP=-1;
    vi res;
    for(auto i:s){
        if(cnt++>=k){
            if(i.S&&neg%2&&vP<0)
                vP=i.F;
            else if(neg%2&&!i.S&&vN>0)
                vN=i.F*-1;
        }
        else{
            if(!i.S)
                neg++;
            ll x=i.F*(i.S?1:-1);
            res.pb(x);
            if(x<0)
                idxN=sz(res)-1;
            else
                idxP=sz(res)-1;
        }
    }
    if((neg&1)&&((vP>=0&&idxN!=-1)||(vN<0&&idxP!=-1))){

        if((vP>=0&&idxN!=-1)&&(vN<0&&idxP!=-1)){
            ll x=vP*res[idxP],y=abs(vN*res[idxN]);
            if(x>y)
                res[idxN]=vP;
            else
                res[idxP]=vN;
        }
        else if((vP>=0&&idxN!=-1))
            res[idxN]=vP;
        else
            res[idxP]=vN;
        neg--;
    }
    if(neg&1){
        res.clear();
        sort(a,a+n);
        for(int i=n-1;i>=0&&k--;i--)
            res.pb(a[i]);
    }
    ll ans=1;
    for(auto i:res)
        ans=mult(ans,abs(i));
    cout<<add(ans*(neg%2?-1:1),0);
}
/*

*/


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

long long int nCr(int n, int r){
    if(n < r) return 0;

    if(r == 0) return 1;
    else if(r == 1) return n;
    else if(r == 2) return n * (n-1) / 2;
    else if(r == 3) return n * (n-1) * (n-2) / 6;
    else return 0;
}

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

    int d = n.length();
    vector<int> num(d);
    for(int i=0; i<d; i++){
        num[i] = n[i] - '0';
    }

    vector<int> pow9(4,1);
    for(int i=1; i<4; i++){
        pow9[i] = pow9[i-1] * 9;
    }

    long long int ans = 0;
    for(int i=0; i<d; i++){
        if(i == d-1){
            if(k == 1) ans += num[i];
            if(k == 0) ans += 1;
            break;
        }

        if(num[i] != 0){
            ans += nCr(d-1-i,k) * pow9[k];
            //cout << nCr(d-1-i,k) << " " << pow9[k] << " " << ans << endl;
            ans += (num[i] - 1) * nCr(d-1-i,k-1) * pow9[k-1];
            k -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

// Returns the longest repeating non-overlapping 
// substring in str 
string LRSUB(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    // If we have non-empty result, then insert all 
    // characters from first character to last 
    // character of string 
    if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res; 
} 
  
// Driver program to test the above function 
int main() 
{
    int n; cin >> n;
    string str; cin >> str;
    cout << LRSUB(str).size() << '\n'; 
    return 0; 
}

Measured memory_bytes: 97920
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string t = s;
	reverse(all(t));
	int cnt = 0;
	rep(i,s.size()){
		cnt += (s[i] != t[i]);
	}
	cout << cnt / 2 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <string.h>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <map>
#include <set>
#include <fstream>
#define maxn 2000000

using namespace std;
int a, b;
struct pp
{
	int a, b;
}po[maxn];
bool cmp(pp x, pp y)
{
	if (x.a == y.a)
		return x.b > y.b;
	else
		return x.a < y.a;
}
int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> a >> b;
		po[i].a = a; po[i].b = b;
	}
	sort(po, po + m, cmp);
	int f = 0, i = 0;
	while (1)
	{
		if (po[i++].a == 1)
		{

			int l = i - 1, r = n, mid = 0, pos = -1;
			while (l <= r)
			{
				mid = (l + r) / 2;
				if (po[mid].a > po[i - 1].b)
					r = mid - 1;
				else if (po[mid].a == po[i - 1].b)
				{
					pos = mid;
					break;
				}
				else
					l = mid + 1;

			}
			if (pos == -1 || pos >= m) continue;
			if (po[pos].b == n)
			{
				cout << "POSSIBLE" << endl;
				break;
			}
			else
				continue;
		}
		else if (i - 1 >= m)
		{
			cout << "IMPOSSIBLE" << endl;
			break;
		}
		else if (i - 1 < m&&po[i - 1].a > 1)
		{
			cout << "IMPOSSIBLE" << endl;
			break;
		}
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 int main(){
   string s;
   cin>>s;
   int a=s.size();
     int ans=0;
   if(a%2==0){
     
     for(int i=0;i<a/2;i++){
       if(s[i]!=s[a-i-1]){
         ans++;
       }
     }
   }else{
     
     for(int i=0;i<(a-1)/2;i++){
       if(s[i]!=s[a-i-1]){
         ans++;
       }
     }
   }
   cout<<ans<<endl;
 }

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

void insertionSort( vector<int>& data, int n );
void trace( vector<int>& data, int n );

int main() {
	int n;

	cin >> n;
	vector<int> data(n);
	for( int i = 0; i < n; ++i ) {
		cin >> data.at(i);
	}
	trace( data, n );
	insertionSort( data, n );

}

void insertionSort( vector<int>& data, int n ) {
	for( int i = 1; i < n; ++i ) {
		int tmp = data.at( i );
		int j = i - 1;
		while( j >= 0 && tmp < data.at( j ) ) {
			data.at( j + 1 ) = data.at( j );
			j--;
		}
		data.at( j + 1 ) = tmp;
		trace( data, n );
	}
}

void trace( vector<int>& data, int n ) {
	for( int i = 1; i <= n; ++i ) {
		cout << data.at( i - 1 ) << ( ( i == n ) ? "\n" : " " );
	}
}


Measured memory_bytes: 3040
// ABC158B - Count Balls

#include <bits/stdc++.h>
using namespace std;

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

	long long int answer;

	answer = N /(A + B) * A;
	if (N %(A + B) >= A) {
		answer += A;
	} else {
		answer += N %(A + B);
	}

	cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100009];
main(){
   long long n;
   cin >> n;
   for(long long i = 0; i < n; i++){
        cin >> a[i];
   }
   sort(a, a + n);
   if((n - 1) % 2 == 1){
        long long ans = 0;
        for(long long i = 0; i < n/2 - 1; i++)
            ans += a[n - 1 - i] * 2 - a[i] * 2;
        ans += a[n/2] - a[n/2-1];
        cout << ans << endl;
        return 0;
   }
   long long ans = 0;
    for(long long i = 0; i < n/2 - 1; i++)
            ans += a[n - 1 - i] * 2 - a[i] * 2;
    long long x = n/2;
    ans += max(2*a[x+1] - a[x] - a[x - 1], a[x + 1] + a[x] - 2 * a[x - 1]);
    cout << ans << endl;


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;

int main()
{
	fastIO;
	ll d,t,s;
	cin >> d >> t >> s;
	if (t*s >= d) cout << "Yes\n";
	else cout << "No\n";	
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

int main() {
	int n;	cin >> n;
	vint t(n), x(n), y(n);
	rep(i, n)	cin >> t[i] >> x[i] >> y[i];
	bool ok = 0;
	int cx = 0, cy = 0, ct = 0;
	rep(i, n) {
		int dt = t[i] - ct;
		int dx = abs(x[i] - cx), dy = abs(y[i] - cy);
		if (dx + dy <= dt && (dt - dx - dy) % 2 == 0) {
			cx = x[i];	cy = y[i];	ct = t[i];
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;
/**************************************************************************/
int main()
{
	fastIO;
	map < ll , ll > cnt;
	ll t,n,m,i,j,k,a[100001],ans=0,s=0,dp[100001];
	dp[0] = 0;
	cin>>n>>m;
	fo(i,n)
	{
		ll temp = 0;
		cin>>a[i+1];
		s = ((s + a[i+1])%m+m)%m;
		ans += cnt[s];
		if(s==0)ans++;
		cnt[s]++;
		//cout<<ans<<endl;
	}
	//fo(i,n)ans+=dp[i+1];
	cout<<ans;
}
/*************************************************************************/ 

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
int n;
int a;
int i,j=1;
int x=0;
int z=0;
scanf("%d",&n);
scanf("%d",&a);
/*
if(n<a){
	printf("Yes\n");
	z=1;
}
if(a<n){
	do{
		for(i=1;i<a;i++){
			x=i+500*j;
			if(x==n){
				z=1;
				printf("Yes\n");
				break;
				
			}
			
			
		}
		
		j++;
		x=0;
		
		
	}while(!(500*j>=n));
	
}
if(z==0){
	
	printf("No\n");
	
}*/
if(n%500<=a){
	printf("Yes\n");
	
}else{
	printf("No\n");
	
}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }


int main(){
  cin.tie(0); ios::sync_with_stdio(false);
    
  int h,w,ans=1; cin>>h>>w; bool gri[h][w]={}; P ho[h][w],ve[h][w];
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      char c; cin>>c; if(c=='#')gri[i][j]=1;
    }
  }
  for (int i = 0; i < h; i++){
    int l=-1;
    for (int j = 0; j < w; j++){
      if(gri[i][j])l=j;
      else ho[i][j].first=j-l;
    }
    int r=w;
    for (int j = w-1; j >= 0; j--){
      if(gri[i][j])r=j;
      else ho[i][j].second=r-j;
    }
  }
  for (int i = 0; i < w; i++){
    int u=-1;
    for (int j = 0; j < h; j++){
      if(gri[j][i])u=j;
      else ve[j][i].first=j-u;
    }
    int d=h;
    for (int j = h-1; j >= 0; j--){
      if(gri[j][i])d=j;
      else ve[j][i].second=d-j;
    }
  }
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if(!gri[i][j])chmax(ans,ho[i][j].first+ho[i][j].second+ve[i][j].first+ve[i][j].second-3);
    }
  }
  cout<<ans<<'\n';
}

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

int main() {
    int n, k; cin >> n >> k;
    for(int i = 0; i < k; ++i) {
        int x, y; cin >> x >> y;
        x--, y--;
        if(x >= n / 2) x = n - x - 1;
        if(y >= n / 2) y = n - y - 1;
        cout << (min(x, y) % 3) + 1 << endl;
    }
}



Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var rck = ReadLine().Split().Select(int.Parse).ToArray();
        int R = rck[0];
        int C = rck[1];
        int K = rck[2];
        var map = new long[R, C];
        for (int i = 0; i < K; i++)
        {
            var r = ReadLine().Split().Select(int.Parse).ToArray();
            map[r[0] - 1, r[1] - 1] = r[2];
        }
        var dp = new long[R, C][];

        for (int i = 0; i < R; i++)
        {
            for (int j = 0; j < C; j++)
            {
                dp[i, j] = new long[4];
            }
        }
        for (int i = 0; i < R; i++)
        {
            for (int j = 0; j < C; j++)
            {
                if (i > 0)
                {
                    dp[i, j][0] = dp[i - 1, j].Max();
                }
                for (int k = 3; k >= 0; k--)
                {
                    if (j > 0)
                    {
                        dp[i, j][k] = Max(dp[i, j][0], dp[i, j - 1][k]);
                    }
                    if (map[i, j] > 0&&k<3)
                    {
                        dp[i, j][k+1] = Max(dp[i, j][k+1], dp[i, j][k] + map[i, j]);
                    }
                }
            }
        }
        WriteLine(dp[R-1,C-1].Max());
        
    }
}


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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<long> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long cnt = 0;

    for (int i = 0; i < n; i++) {
        long a_ok = lower_bound(a.begin(), a.end(), b[i]) - a.begin();

        long c_ok = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());

        cnt += a_ok * c_ok;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2560
import sys

def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    nums = tuple(x for x in range(2, limit+1))
    while nums[0] <= x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = tuple(x for x in nums if x % current_prime != 0)
    primes.extend(nums)
    return primes


if __name__ == '__main__':
    # ?´???°?????§?????¨???
    primes = create_prime_list(999999)

    # ??????????????\???
    for line in sys.stdin:
        target = int(line)

        ans = tuple(x for x in primes if x <= target)
        print(len(ans))

Measured memory_bytes: 51380
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,a[301],tot[4];double dp[301][301][301]; 
int TOT[301][301][301];
int main(){
	//freopen("hack.in","r",stdin);
	//freopen("mine.out","w",stdout);
	scanf("%d",&n);
	rb(i,1,n){scanf("%d",&a[i]);tot[a[i]]++;	}
	//cout<<tot[3]<<" "<<tot[2]<<" "<<tot[1]<<endl;
	for(int i=0;i<=n;i++){
		for(int j=0;j+i<=n;j++){
			for(int k=0;i+j+k<=n;k++){
				if (i+j+k==0) continue;
				dp[i][j][k] = n;
				if(k-1>=0) dp[i][j][k] += k*dp[i][j][k-1];
				if(j-1>=0){					
					dp[i][j][k]+= j*dp[i][j-1][k+1];
				}
				if(i-1>=0){
					dp[i][j][k]+= i*dp[i-1][j+1][k];
				}
				dp[i][j][k] = dp[i][j][k]/double(i+j+k);
				//cout<<"--"<<i<<" "<<j<<" "<<k<<"--"<<dp[i][j][k]<<endl;
			}
		}
	}
	printf("%.10lf\n",dp[tot[3]][tot[2]][tot[1]]);
	return 0;
}

Measured memory_bytes: 213248
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, x;
    cin >> n >> m >> x;
    vi a(m);
    rep(i, m) cin >> a[i];
    int cost1 = 0, cost2 = 0;
    rep(i, m) {
        if (a[i] < x) cost1++;
        else if (a[i] > x) cost2++;
    }
    cout << min(cost1, cost2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int N = 100005;
int a[N];
double b[N];
int main()
{
	int n, maxa = -1;
	int ans;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	double mid = 1.0 * a[n] / 2, minb = 1000000009.0;
	for (int i = 1; i < n; i++) 
	{
		if (fabs(mid - (1.0 * a[n] - 1.0 * a[i])) < minb)
		{
			ans = a[i];
			minb = fabs(mid - (1.0 * a[n] - 1.0 * a[i]));
		}
	}
	printf("%d %d\n", a[n], ans);
}


Measured memory_bytes: 512
(let* ((s (concatenate 'list (read-line)))
       (l '()))

  (loop for i in s
        if (char= i #\0) do (push i l)
        else if (char= i #\1) do (push i l)
        else do (pop l))

  (format t "~A~%" (concatenate 'string (reverse l))))




Measured memory_bytes: 23528
#include <iostream>
#include <vector>
using namespace std;
vector<bool> primeTable(int n) {
    vector<bool> prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
    return prime;
}
int main() {
    int N;
    cin >> N;
    auto p = primeTable(55555);
    for (int i = 1; i < 55555 && N > 0; i++) {
        if (p[i] && i % 5 == 1) {
            cout << i << " ";
            N--;
        }
    }
    cout << endl;
}

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

int main() {
	int N;
	int ans;
	int tmp;

	while(cin >> N, N) {
		ans = 0;

		for(int i = 1; i < N / 2 + N % 2; i++) {
			tmp = i;
			for(int j = 1; tmp < N; tmp += i + j++);
			if(tmp == N)
				ans++;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System;

public class AtCoder{
	public static void Main(){
		int n;
		n = int.Parse(Console.ReadLine().Trim());
		bool f = false;
		int k = 0;
		
		for(int i=1; i<1000; i++){
			if(i*(i-1)/2==n){
				f = true;
				k = i;
			}
		}
		
		if(f){
			Console.WriteLine("Yes");
			Console.WriteLine(k);
			int[][] s = new int[k][];
			for (int i=0; i<k; i++){
				s[i] = new int[k-1];
			}
			int c = 1;
			for(int i=k-1; i>0; i--){
				for(int j=0; j<i; j++){
					s[k-1-i][k-1-i+j] = c;
					s[k-1-i+j+1][k-1-i] = c;
					c++;
				}
			}
			for(int i=0; i<k; i++){
				Console.Write(k-1);
				Console.Write(" ");
				for(int j=0; j<k-1; j++){
					Console.Write(s[i][j]);
					Console.Write(" ");
				}
				Console.WriteLine();
			}
		}else{
			Console.WriteLine("No");
		}
	}
}

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

int main() {
  int N, K, dis;
  cin >> N >> K;
  dis = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    int a, b;
    a = 2 * x;
    b = 2 * (K-x);
    if (a <= b) {
      dis += a;
    }
    else {
      dis += b;
    }
  }
  cout << dis << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b[111], i, z, dai;
	dai = 0;
	i = 1;
	for (i = 1; i <= 100; i++) {
		b[i] = 0;
	}
	while (cin >> a) {
		b[a]++;
	}
	for (i = 1; i <= 100; i++) {
		if (dai < b[i]) {
			dai = b[i];
		}
	}
	for (i = 1; i <= 100; i++) {
		if (dai == b[i]) {
			cout << i << endl;
		}
	}
}


Measured memory_bytes: 3016
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		boolean ok=true;
		int okcnt=0;
		int ans=0;
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		
		while(ok==true) {
			
		for(int i=0;i<a.length;i++) {
			if(a[i]%2==0) {
				okcnt++;
			}
		}
		if(okcnt==n) {
			ok=true;
			for(int i=0;i<a.length;i++) {
				a[i]=a[i]/2;
			}
			ans++;
			okcnt=0;
		}else {
			ok=false;
			break;
		}
		
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
#include <stdio.h>
#include <vector>
#include <queue>
#include <string.h>

using namespace std;

vector <int> node[202];

int S = 0, E = 201;
int red[100][2];
int blue[100][2];

int n, ans;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d %d", &red[i][0], &red[i][1]);
    for(int i = 0; i < n; i++) scanf("%d %d", &blue[i][0], &blue[i][1]);

    for(int i = 1; i <= n; i++) node[S].push_back(i);
    for(int i = n + 1; i <= 2 * n; i++) node[i].push_back(E);

    for(int st = 0; st < n; st++)
    for(int ed = 0; ed < n; ed++)
        if((red[st][0] < blue[ed][0]) && (red[st][1] < blue[ed][1])) node[st + 1].push_back(n + 1 + ed);

    while(1){
        int visited[202];
        memset(visited, -1, 202 * sizeof(int));
        queue <int> visit;
        visit.push(0);
        visited[0] = 0;
        while(visit.empty() == 0){
            int mem = visit.front();
            visit.pop();
            int sz = node[mem].size();
            for(int i = 0; i < sz; i++){
                int next = node[mem][i];
                if(visited[next] != -1) continue;
                visited[next] = mem;
                visit.push(next);
            }
        }
        if(visited[E] == -1) break;
        int pos = E;
        while(pos != S){
            int next = pos;
            pos = visited[pos];
            vector <int>::iterator it;
            it = node[pos].begin();
            while(*it != next) it++;
            node[pos].erase(it);
            node[next].push_back(pos);
        }
        ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 256