akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i != n / i) {
                v.push_back(n / i);
            }
        }
    }
    sort(all(v));
    mint res = 0;
    vector<mint> dp(v.size());
    for (int i = 0; i < v.size(); i++) {
        dp[i] = mint(k) ^ (v[i] % 2 + v[i] / 2LL);
        for (int j = 0; j < i; j++) {
            if (v[i] % v[j] == 0) {
                dp[i] -= dp[j];
            }
        }
        if (v[i] % 2 == 0) {
            res += dp[i] * v[i] / mint(2LL);
        } else {
            res += dp[i] * v[i];
        }
    }
    cout << res.a << endl;
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  int sum = (n-2)*(n-1)/2;
  if(sum < k) {
    cout << -1 << endl;
    return 0;
  }
  vector<P> ans;
  for(int i = 2; i <= n; ++i) ans.emplace_back(1, i);

  if(sum == k) {
    cout << ans.size() << endl;
    for(auto x : ans) cout << x.first << " " << x.second << endl;
    return 0;
  }

  for(int i = 2; i < n; ++i) {
    for(int j = i+1; j <= n; ++j) {
      ans.emplace_back(i, j);
      --sum;
      if(sum == k) {
        cout << ans.size() << endl;
        for(auto x : ans) cout << x.first << " " << x.second << endl;
        return 0;
      }
    }
  }
}


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

int main() {
  int N, K, s = 1;
  cin >> N >> K;
  for (int i=0; i<N ; i++){
    if(s <= K) s *= 2;
    else s += K;
  }
  cout  <<  s <<  endl;
}


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

const int MAX_N = 2e5 + 10;
int n, m;
string s;
vector <int> G[MAX_N];
int cnt_A[MAX_N];
int cnt_B[MAX_N];
bool Mark[MAX_N];
vector <int> Q;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> s;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		G[v].push_back(u);
		G[u].push_back(v);
		if (s[u] == 'A')
			cnt_A[v]++;
		else
			cnt_B[v]++;
		if (s[v] == 'A')
			cnt_A[u]++;
		else
			cnt_B[u]++;	
	}
	
	for (int i = 0; i < n; i++)
		if (cnt_A[i] == 0 || cnt_B[i] == 0) {
			Q.push_back(i);
			Mark[i] = true;
		}
	
	while (Q.size()) {
		int v = Q.back();
		Q.pop_back();
		
		for (int i = 0; i < G[v].size(); i++)
			if (!Mark[G[v][i]]) {
				if (s[v] == 'A')
					cnt_A[G[v][i]]--;
				else
					cnt_B[G[v][i]]--;
				if (cnt_A[G[v][i]] == 0 || cnt_B[G[v][i]] == 0) {
					Q.push_back(G[v][i]);
					Mark[G[v][i]] = true;
				}
			}
	}
	
	bool ok = false;
	for (int i = 0; i < n; i++)
		if (!Mark[i])
			ok = true;
	
	cout << (ok? "Yes": "No");
	return 0;
}

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

int main()
{
  
  while(1){
    int h;
    cin >> h;
    if(h == 0) break;
    int s[h+1][5];
    fill(&s[0][0], &s[0][5], -1);
    for(int i = 1; i < h+1; i++){
      for(int j = 0; j < 5; j++){
        cin >> s[i][j];
      }
    }
    int ans = 0;
    int c = 0;
    while(1){
      for(int i = h; i > 0; i--){
        if(s[i][0] == s[i][1] && s[i][1] == s[i][2] && s[i][2] == s[i][3] && s[i][3] == s[i][4] && s[i][0] > 0){
          ans += s[i][0]*5;
          fill(&s[i][0], &s[i][5], 0);
        }else if(s[i][0] == s[i][1] && s[i][1] == s[i][2] && s[i][2] == s[i][3] && s[i][0] > 0){
          ans += s[i][0]*4;
          fill(&s[i][0], &s[i][4], 0);
        }else if(s[i][1] == s[i][2] && s[i][2] == s[i][3] && s[i][3] == s[i][4] && s[i][1] > 0){
          ans += s[i][1]*4;
          fill(&s[i][1], &s[i][5], 0);
        }else if(s[i][0] == s[i][1] && s[i][1] == s[i][2] && s[i][0] > 0){
          ans += s[i][0]*3;
          fill(&s[i][0], &s[i][3], 0);
        }else if(s[i][2] == s[i][3] && s[i][3] == s[i][4] && s[i][2] > 0){
          ans += s[i][2]*3;
          fill(&s[i][2], &s[i][5], 0);
        }else if(s[i][1] == s[i][2] && s[i][2] == s[i][3] && s[i][1] > 0){
          ans += s[i][1]*3;
          fill(&s[i][1], &s[i][4], 0);
        }else{
          c++;
        }
      }
      if(c == h) break;
      c = 0;
      for(int i = 0; i < 5; i++){
        for(int j = h; j > 0; j--){
          if(s[j][i] == -1){
            for(int k = j; k >= 0; k--){
              s[k][i] = -1;
            }
            break;
          }
          while(s[j][i] == 0){
            for(int k = j; k > 0; k--){
              swap(s[k][i], s[k-1][i]);
            }
            s[0][i] = -1;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
while True:    
    n, k = map(int, raw_input().split())
    if n==0: break
    t = [0]*(n+2)
    for i in xrange(k):
        t[input()] += 1
    for i in xrange(2,n+1):
        if t[i] > 0: t[i] += t[i-1]
    ans = 0
    if t[0]==0:
        for x in t:
            if ans < x: ans = x
    else:
        for i in xrange(2,n+2):
            if t[i]==0:
                t[i-t[i-1]] = t[i-1]
        for i in xrange(2,n+1):
            if t[i]==0:
                x = t[i-1] + 1 + t[i+1]
                if ans < x: ans = x
            else: 
                if ans < t[i]: ans = t[i]
    print ans

Measured memory_bytes: 7208
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n;
  bool cango[200][200];
  int vy[6] = {1,0,-1,-1,0,1};
  int vx[6] = {1,1,0,-1,-1,0};
  while(cin>>t>>n,t||n) {
    FOR(i,0,200) FOR(j,0,200) cango[i][j] = true;
    FOR(i,0,n) {
      int x, y; cin >> x >> y;
      cango[y+100][x+100] = false;
    }
    int sx, sy; cin >> sx >> sy;
    int ans = 1;
    queue<P> Q;
    Q.push(P(sy+100, sx+100));
    cango[sy+100][sx+100] = false;
    FOR(i,0,t) {
      vector<P> tmp;
      while(!Q.empty()) {
        P p = Q.front(); Q.pop();
        int y = p.first;
        int x = p.second;
        FOR(j,0,6) {
          int ny = y + vy[j];
          int nx = x + vx[j];
          if(!cango[ny][nx]) continue;
          ans++;
          tmp.push_back(P(ny, nx));
          cango[ny][nx] = false;
        }
      }
      FOR(j,0,tmp.size()) {
        Q.push(tmp[j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3156
import string
# string.ascii_lowercase

N = int(input()) - 1
strs= [string.ascii_lowercase[N % 26]]

while(N >= 26):
    N //= 26
    N -= 1
    strs.append(string.ascii_lowercase[N % 26])

for s in strs[::-1]:
    print(s, end='')
print()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N;
vector<ll> A(20);

ll dfs(ll left, ll right, ll x, ll y){
  if(right-left<=1) return 0;
  ll res = (1ll << 60);
  for(int i=left+1;i<right;i++){
    ll tmp = 0;
    tmp += A[i] * (x+y);
    tmp += dfs(left, i, x, x+y);
    tmp += dfs(i, right, x+y, y);
    res = min(res, tmp);
  }
  //printf("%lld, %lld, %lld, %lld\n", left, right, x, y);
  //cout << res << endl;
  return res;
}

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

    cin >> N;
    REP(i, N) cin >> A[i];

    ll res = dfs(0, N-1, 1, 1);
    cout << res + A[0] + A[N-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = 0
t = 0
for i in range(n):
	s = i+1
	cnt = 0
	while s < k:
		s *= 2
		cnt +=1
	p = (1/n)*0.5**cnt
	t += p
	#s += (1/n) * 0.5 ** cnt
print (t)

Measured memory_bytes: 3060
<?php

$s=new Scanner();

$a=$s->nextInt();
$b=$s->nextInt();
$c=$s->nextInt();
$d=$s->nextInt();


//a b c d || c d a b
if($b<=$c||$d<=$a){

 $ans=0;
}
//a c b d
else if(($a<=$c)&&($b<=$d)){

 $ans=0;
 $ans=$b-$c;
}

//c a d b
else if(($c<=$a)&&($d<=$b)){

 $ans=0;
 $ans=$d-$a;
}
//a c d b || c a b d
else {

 $ans=0;
 $ans=($d-$c)<($b-$a)?($d-$c):($b-$a);
}
out::println($ans);


class Scanner
{
 private $arr = [];
 private $count = 0;
 private $pointer = 0;
 public function next() {
   if ($this->pointer >= $this->count) {
       $str = trim(fgets(STDIN));
       $this->arr = explode(' ', $str);
       $this->count = count($this->arr);
       $this->pointer = 0;
     }
      $result = $this->arr[$this->pointer];
      $this->pointer++;
      return $result;
  }
 public function hasNext(){
      return $this->pointer < $this->count;
  }
 public function nextInt(){
      return (int)$this->next();
  }
 public function nextDouble(){
      return (double)$this->next();
  }
}

#改行ありの標準出力クラス
class out
{
 public static function println($str = ""){
  echo $str . PHP_EOL;
 }
}

Measured memory_bytes: 3576
if __name__ == '__main__':
    A, B = map(int, input().split())
    S = list(str(input()))
    flag = True
    if S[A] == '-':
        S[A] = 0
    else:
        flag = False
    for i in range(A+B+1):
        try:
            int(S[i])
        except ValueError:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    int r;
    cin >> r;
    cout << r*r << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
int prime_number[1000005] = {};
int main() {
	int n;
	cin >> n;
	vector<long long int> s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		int a = s[i];
		for (int j = 2; j <= 1000; j++) {
			int b = 0;
			while (a % j == 0) {
				b++;
				a = a / j;
			}
			if (b > prime_number[j]) {
				prime_number[j] = b;
			}
		}
		if (a != 1) {
			if (prime_number[a] == 0) {
				prime_number[a] = 1;
			}
		}
	}
	long long int c = 1;
	for (int i = 0; i <= 1000000; i++) {
		for (int j = 1; j <= prime_number[i]; j++) {
			c = c * i % MOD;
		}
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		long long int k = c * modinv(s[i], MOD) % MOD;
		ans = (ans + k) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
    //freopen("input.txt","r",stdin);
    lli n;
    cin >> n;
    vector <lli> v(n);
    for(int i =0;i<n;i++)cin >> v[i];
    vector < vector <lli> > dp(n,vector <lli> (n));
   for(int i =n-1;i>=0;i--){
    for(int j =i;j<n;j++){
        if(i == j){
            dp[i][i] = v[i];
        }else{
            dp[i][j] = max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
        }
    }
   }
    cout << dp[0][n-1]<<endl;
}


Measured memory_bytes: 70784
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int N;
    scanf("%d",&N);
    char a[N];
    scanf("%s",a);
    int max=0;
    int x=0;
    rep(i,N){
        if(a[i]=='I'){
            x++;
        }else if(a[i]=='D'){
            x--;
        }else{
            ;
        }
        if(x>max){
            max=x;
        }
    }
    printf("%d",max);
}



Measured memory_bytes: 1736
def resolve():
    n, a, b = map(int, input().split())
    sum = a + b
    d = n // sum
    mod = n % sum
    if mod > a:
        c = (a * d) + a
    else:
        c = (a * d) + mod
    print(c)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>

#define MAX_N 100010
#define range(vec) vec.begin(), vec.end()
#define rrange(vec) vec.rbegin(), vec.rend()

using namespace std;

typedef pair<int, int> P;

struct uftree {
    int par[MAX_N], rank[MAX_N], size[MAX_N];
    uftree(int N) {
        for (int i=0; i<N; i++) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            size[x] = size[par[x]];
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) par[y] = x;
        else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
        size[x] += size[y];
        size[y] = size[x];
    }
    int tsize(int x) {
        root(x);
        return size[x];
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    size_t n, m;
    cin >> n >> m;
    vector<P> ab(m);
    for (auto &p:ab)
        cin >> p.first >> p.second;
    uftree uft((int)n);
    long scores[m];
    scores[m-1] = n * (n-1) / 2;
    for (size_t i=m-1; i>0; i--) {
        int a = ab[i].first-1, b = ab[i].second-1;
        if (!uft.same(a, b)) {
            long as = uft.tsize(a), bs = uft.tsize(b);
            scores[i-1] = scores[i] - as * bs;
            uft.unite(a, b);
        } else 
            scores[i-1] = scores[i];
    }
    for (auto s:scores)
        cout << s << '\n';
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
string s[105];
bool cmp(string a,string b) {
	return a<b;
}
int n,l;
int main() {
    scanf("%d %d",&n,&l);
    for (int i=0;i<=n;i++) {
        getline(cin,s[i]);
    }
    sort (s,s+n+1,cmp);
    for (int i=0;i<=n;i++) cout<<s[i];
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if K == 0:
        break
    else:
        if (123 - ord(sArr[i])) <= K:
            K -= (123 - ord(sArr[i])) % 26
            sArr[i] = "a"

if K > 0:
    K %= 26
    sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Measured memory_bytes: 4212
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,red=0,ans=0; cin>>n;
  string s; cin>>s;
  rep(i,n){
    if(s[i]=='R'){
      red++;
    }
  }
  for(int i=0;i<=red-1;i++){
    if(s[i]=='W'){
      ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

int n, m;
double l;
double p[100], t[100], v[100];
double cb[100][51];

void init(){
	rep(u,n){
		rep(i,m+1){
			int j = m-i;
			cb[u][i] = 1.0;
			int cnt1 = i, cnt2 = j;
			for(int k = 1; k <= i; k++){
				cb[u][i] = cb[u][i]*(m-k+1)/k;
				while(cb[u][i] > 1.0){
					if(cnt1 > 0){
						cb[u][i] *= p[u];
						cnt1--;
					} else if(cnt2 > 0){
						cb[u][i] *= (1-p[u]);
						cnt2--;
					}
					if(cnt1 == 0 && cnt2 == 0) break;
				}
			}
			rep(k,cnt1) cb[u][i] *= p[u];
			rep(k,cnt2) cb[u][i] *= (1-p[u]);
		}
	}
}

int main(){
	cin >> n >> m >> l;
	rep(i,n){
		cin >> p[i] >> t[i] >> v[i];
		p[i] *= 0.01;
	}
	init();
	rep(i,n){
		double pos;
		//double ti;
		double ans = 0.0;
		if(v[i] == 0.0){
			puts("0.00000000000");
			continue;
		}
		for(int j = 0; j <= m; j++){
			pos = cb[i][j];
			rep(k,n){
				if(k == i) continue;
				if(v[k] == 0.0) continue;
				if(t[k] == 0.0){
					if((int)l*(int)v[k]-(int)l*(int)v[i]+(int)t[i]*j*(int)v[i]*(int)v[k] >= 0) pos *= 0.0;
					else pos *= 1.0;
					continue;
				}
				int c;
				if((int)l*(int)v[k]-(int)l*(int)v[i]+(int)t[i]*j*(int)v[i]*(int)v[k] < 0) c = 0;
				else c = ((int)l*(int)v[k]-(int)l*(int)v[i]+(int)t[i]*j*(int)v[i]*(int)v[k])/((int)t[k]*(int)v[i]*(int)v[k]) + 1;
				double tmp = 0.0;
				for(int l = c; l <= m; l++){
					tmp += cb[k][l];
				}
				pos *= tmp;
			}
			ans += pos;
		}
		printf("%.9f\n", ans);
	}
}

Measured memory_bytes: 1284
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  char output[2] = {'#', '.'};
  while (true) {
    int h, w; cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++) {
      int k;
      if (i % 2 == 0) {
	k = 0;
      } else {
	k = 1;
      }
      for (int j = 0; j < w; j++) {
	cout << output[k];
	k ^= 1;
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
  
}

Measured memory_bytes: 1152
#include <iostream>

int main() {
  long long int n,y;
  std::cin >> n >> y;

  long long int a,b,c;
  for (long long int i = 0; i <= n; i++) {
    a = i;
    c = (5000 * (n + i) - y) / 4000;
    b = n - (a + c);
    if (0 <= a && a <= n && 0 <= b && b <= n && 0 <= c && c <= n) {
      if (10000 * a + 5000 * b + 1000 * c == y) {
        std::cout << a << " " << b << " " << c << std::endl;
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}

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

int main(){
    string n;
	cin >> n;
	ll sum = 0;
	rep(i,n.size()){
		sum += n[i] - '0';
	}
	if(sum%9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    i64 a, b;
    cin >> a >> b;
    i64 c = 0;
    int cur;
    cin >> cur;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        if ((x - cur) * a < b) {
            c += (x - cur) * a;
        } else {
            c += b;
        }
        cur = x;
    }

    cout << c << endl;
}

Measured memory_bytes: 256
n   = int(input())
li  = list(map(int,input().split()))
ans  = [0]*n
ans2 = 0
ans3 = []
mtp  = 0

for i in range(n,0,-1):
    tmp = 0
    if n//i == 1:
        ans[i-1] = li[i-1]
    else:
        mtp = n//i
        for j in range(1,mtp):
            tmp += ans[i*(j+1)-1]
        tmp %= 2

        ans[i-1] = (tmp^li[i-1])

for i in range(n):
    if ans[i]==1:
        ans2 += 1
        ans3.append(i+1)

print(ans2)
print(*ans3)

Measured memory_bytes: 14132
#include<iostream>
#include<algorithm>
#include<cmath>
using lint=int64_t;
using namespace std;

lint f(lint B)
{
	if(B%2==0)
		return (lint)((B/2)%2)^B;
	else
		return (lint)((B+1)/2)%2;
}

int main()
{
	lint A,B;
	cin >> A >> B;
	cout << (f(B)^f(A)^A) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int r, d, x[11];
  cin >> r >> d >> x[0];
  for(int i=0; i<10; i++){
    x[i+1]=r*x[i]-d;
    cout << x[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

class UnionFind {
  std::vector<int> p;

public:
  /// @brief
  /// $0$ から $n - 1$ までそれぞれに対して，その要素だけを格納した集合を作る．
  /// @complexity $O(n)$
  UnionFind(int n) : p(n, -1) {}

  /// @brief
  /// $x$ を含む集合の代表元を返す．
  /// @complexity amortized $O(\\alpha(n))$
  int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

  /// @brief
  /// $x$ と $y$ が同一の集合に属するかどうかを返す．
  /// @complexity amortized $O(\\alpha(n))$
  bool same(int x, int y) { return root(x) == root(y); }

  /// @brief
  /// $x$ を含む集合と $y$ を含む集合を併合する．
  /// 既に $x$ を含む集合と $y$ を含む集合が同じ集合である場合は false を返し，
  /// そうでない場合は true を返す．
  /// @complexity amortized $O(\\alpha(n))$
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) std::swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};

int main(void)
{
  int n;
  cin >> n;
  vector<pair<int,int>> xi,yi;
  vector<int> vx(n),vy(n);
  REP(i,n) {
    cin >> vx[i] >> vy[i];
    xi.emplace_back(vx[i], i);
    yi.emplace_back(vy[i], i);
  }
  sort(xi.begin(),xi.end());
  sort(yi.begin(),yi.end());
  vector<tuple<int,int,int>> edge;
  REP(i,n-1) {
    edge.emplace_back(xi[i+1].first - xi[i].first,
                      xi[i].second,
                      xi[i+1].second);
    edge.emplace_back(yi[i+1].first - yi[i].first,
                      yi[i].second,
                      yi[i+1].second);
  }
  sort(edge.begin(),edge.end());
  LL answer = 0ll;
  UnionFind uf(n);
  for(auto e:edge) {
    int cost, l, r;
    tie(cost, l, r) = e;
    if(uf.unite(l,r)) answer += cost;
  }
  cout << answer << endl;
  return 0;
}


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

using namespace std;

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int n;
    long long t[105];
    unsigned long long y=1000000000000000000;

    cin>>n;
    for(int i=0; i<n; i++){
        cin>>t[i];
        if(n==1){
            cout<<t[i]<<"\n";
            break;
        }
    }
    if(n!=1){
    long long  d=0;
    for(int i=1; i<n; i++){
        if(i<=1){
            d=t[i]/__gcd(t[i],t[i-1]) * t[i-1];
        }
        if(i>1){
            d=d/__gcd(d,t[i]) * t[i];
        }
    }
    if(d>y){
        cout<<y<<"\n";
    }else{
        cout<<d<<"\n";
    }
    }
    return 0;

}

Measured memory_bytes: 3648
def fer(n, r, p):
    # calculate n_C_k mod p
    # a,pが互いに素のとき a ^ (p-2) = a ^ -1 (mod p)
    x, y = 1, 1
    for i in range(r):
        x = x * (n - i) % p
        y = y * (i + 1) % p
    # x -> n * (n-1) * ... * (n-r+1)
    # y -> 1 * 2 * ... * r
    return x * pow(y, p - 2, p) % p


def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7

    x = pow(2, n, mod) - 1
    y = fer(n, a, mod)
    z = fer(n, b, mod)
    ans = (x - y - z) % mod
    print(ans)



if __name__ == '__main__':
    main()


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

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
ll MinCM(ll,ll);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
  int N;
  cin >> N;
  vector<int> a = igets(N);
  ll ANS = 0;
  REP(i,N)ANS+=a[i]-1;
  cout << ANS << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

ll MinCM(ll a, ll b) {
  ll c = a * b;
  if (a < b)
    swap(a, b);
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}


Measured memory_bytes: 256
S=input()
 
ls = len(S)
res = 0

for i in range(0,ls):
    x = S[ls-i-1]
    a = 0    
    b = 2**(ls-1)
    for j in range(0,i+1):
        if j == i:
            b = b
        
        else:
            b = b//2
        a = a+(10**j)*b
    res  =  res + int(x)*a

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
	double r, m, l;
	std::cin >> r;
	r *= 1.000000000;
	m = r * r * 3.141592653589;
	l = r * 2 * 3.141592653589;
	std::cout << std::fixed << m << " " << std::fixed << l << std::endl;
}

Measured memory_bytes: 3236
#include <iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(void){
    
   int n=0; 
   string s;
   
   cin>>s;
   
   for(int i=0;i<((s.size())/2);i++){
       if(s[i]!=s[s.size()-i-1]){
           n+=1;
           
       }
   }
   cout<<n<<endl;
   
   
   
  
       
      
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n, mx;
int a[100005];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    for(int i = -1; i <= 100001; i++)
    {
        int p, x, m;
        p = upper_bound(a, a + n, i + 1) - lower_bound(a, a + n, i + 1);
        x = upper_bound(a, a + n, i + 0) - lower_bound(a, a + n, i + 0);
        m = upper_bound(a, a + n, i - 1) - lower_bound(a, a + n, i - 1);
        mx = max(mx, p + x + m);
    }
    printf("%d", mx);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
  int number = 0,A=0,B=0;
  scanf("%d",&number);
  
  if(number == 1)
  {
    printf("Hello World");
  }else{
    scanf("%d%d",&A,&B);
    printf("%d",A+B);
  }
  
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll int ans=0;
    ll int r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
    ans=r*b*g;
    rep(i,n-2){
        for(int j=1;i+2*j<n;++j){
            if(s[i]!=s[i+j] && s[i+j]!=s[i+2*j] && s[i]!=s[i+2*j]){
                ans--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
MAXV = 10**4

if __name__ == '__main__':
    n = int(raw_input())
    # input, range[1, n], according to counting sort
    A = [0] + map(int, raw_input().split())
    # counter, range: [0, k]
    # so why use counting sort?
    # because it's easy to find where an element go after sorting
    C = [0 for i in range(MAXV + 1)]
    min_of_all = MAXV + 1

    for i in range(1, n + 1):
        C[A[i]] += 1
        min_of_all = min(min_of_all, A[i])

    for i in range(1, MAXV + 1):
        C[i] += C[i - 1]

    # find all cycles of moves
    # if V[i] is 1, then A[i] is already covered in some cycle
    V = [0 for i in range(n + 1)]
    total_cost = 0
    for i in range(1, n + 1):
        if V[i] == 1:
            continue
        V[i] = 1  # mark as visited
        size_of_cycle = 1  # the number of elements in the cycle
        min_of_cycle = A[i]
        sum_of_cycle = A[i]
        j = i  # iterator
        while True:
            j = C[A[j]]
            if i == j:
                break
            V[j] = 1
            size_of_cycle += 1
            sum_of_cycle += A[j]
            min_of_cycle = min(min_of_cycle, A[j])
        if size_of_cycle == 1:
            # only one element, no move, cost is zero
            continue

        cost = sum_of_cycle + (size_of_cycle - 2) * min_of_cycle
        if min_of_all < min_of_cycle:
            # swap back and forth, positive
            diff = 2 * (min_of_all + min_of_cycle)
            # diff in the sum of the cycle, negative
            diff += min_of_all - min_of_cycle
            # diff in (n-2)*min(w), negative
            diff += (size_of_cycle - 2) * (min_of_all - min_of_cycle)
            if diff < 0:
                cost += diff
        total_cost += cost

    print total_cost


Measured memory_bytes: 5316
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005
vector<int> odd,even;
vector<int> v[200005];
void dfs(int x,int f,int sum=0){
    if(sum%2)odd.pb(x);
    else even.pb(x);
    for(auto it:v[x]){
        if(it!=f)
            dfs(it,x,sum+1);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(1,0);
    vector<int> mod[3];
    for(int i = 1;i<=n;i++){
        mod[i%3].pb(i);
    }
    int ans[200005];
    if(odd.size()<=mod[0].size()){
        for(auto it:odd){
            ans[it]=mod[0].back();
            mod[0].pop_back();
        }
        for(auto it:even){
            for(int i = 0;i<3;i++){
                if(mod[i].size()){
                    ans[it]=mod[i].back();
                    mod[i].pop_back();
                    break;
                }
            }
        }
    }
    else if(even.size()<=mod[0].size()){
        for(auto it:even){
            ans[it]=mod[0].back();
            mod[0].pop_back();
        }
        for(auto it:odd){
            for(int i = 0;i<3;i++){
                if(mod[i].size()){
                    ans[it]=mod[i].back();
                    mod[i].pop_back();
                    break;
                }
            }
        }
    }
    else{
        for(auto it:odd){
            if(mod[1].size()){
                ans[it]=mod[1].back();
                mod[1].pop_back();
            }
            else{
                ans[it]=mod[0].back();
                mod[0].pop_back();
            }
        }
        for(auto it:even){
            if(mod[2].size()){
                ans[it]=mod[2].back();
                mod[2].pop_back();
            }
            else{
                ans[it]=mod[0].back();
                mod[0].pop_back();
            }
        }
    }
    for(int i = 1;i<=n;i++){
        printf("%d ",ans[i]);
    }
    printf("\n");
}
/*
[1,2,4,3,5,6]
concat(sorted([4,2,1]),sorted([5,3,6]))
concat(shuffle([2,1]),shuffle([2,3]))
concat(shuffle([2,1,3]),shuffle([3]))
*/

Measured memory_bytes: 22388
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n*2];
		int sum=0;
		for(int i=0;i<n*2;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		for(int i=0;i<n*2;i+=2) {
			sum+=a[i];
		}
		System.out.println(sum);
	}
}


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

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

int main() {
  ll n, h;
  cin >> n >> h;
  priority_queue<ll> a; 
  priority_queue<ll> b;
  rep(i, n){
    int t1, t2;
    cin >> t1 >> t2;
    a.push(t1);
    b.push(t2);
  }

  ll ans = 0;
  ll mx_a = a.top();
  while(!b.empty()){
    ll cur_b = b.top();
    b.pop();
    if(mx_a < cur_b){
      h -= cur_b;
      ans++;
    }
    if(h <= 0){
      break;
    }
  }

  if(h > 0){
    ans += (h + mx_a - 1) / mx_a;
  }

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


Measured memory_bytes: 2036
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	maxIndex := 0
	max := A[0]
	for i := 1; i < N; i++ {
		if A[i] > max {
			maxIndex = i
			max = A[i]
		}
	}
	sort.Ints(A)
	for i := 0; i < N; i++ {
		if i == maxIndex {
			fmt.Fprintln(wtr, A[N-2])
		} else {
			fmt.Fprintln(wtr, max)
		}
	}
	wtr.Flush()
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> ans(n,0);
    REP(i,m*2){
        int tmp;
        cin>>tmp;
        ans.at(tmp-1)+=1;
    }
    REP(i,n)cout<<ans.at(i)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t,a,b,ans=1e9;
    cin >> n >> t;
    vector<pair<int,int>> q;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        q.emplace_back(make_pair(a,b));
    }
    for(int i=0;i<n;i++){
        if(q[i].second <= t){
            ans = min(ans,q[i].first);
        }
    }
    if(ans == 1e9){cout << "TLE" << endl;}
    else cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
S = list(input())

n = len(S)

ans = [0] * n

# print(ans)

# まず R について解き、反転して L について解く
for i in range(2):
  ## solve R##
  cnt = 0 
  for k in range(n):
    if S[k] == "R":
      cnt += 1
    else:
      ans[k] += cnt // 2
      ans[k-1] += (cnt + 1) // 2
      cnt = 0
  
  
  ans = list(reversed(ans))
  S = list(reversed(S))
  # print(S)
 
  for j in range(n):
    if S[j] == "R":
      S[j] = "L"
    else:
      S[j] = "R"
      
  # print(S)
  
# print(ans)
# print(" ".join([str(item) for item in ans]))
for item in ans:
  print(item, end=" ")

Measured memory_bytes: 5544
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll N,M;
vector<ll> A;

vector<ll> sum;

bool judge(ll lim){
  ll res=0;
  int itr=0;
  for(int i=N-1;i>=0;i--){
    while(itr<N&&A[i]+A[itr]>=lim){
      itr++;
    }
    res+=itr;
  }

  if(res>=M) return true;
  else return false;
}

int main(){
  cin>>N>>M;
  A.resize(N);
  rep(i,N) cin>>A[i];

  sort(A.rbegin(),A.rend());

  sum.resize(N+1,0);
  rep(i,N) sum[i+1]=sum[i]+A[i];

  ll ok=0,ng=(A[0]*2+1)*M;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(judge(mid)) ok=mid;
    else ng=mid;
  }

  ll ans=0;
  ll itr=0;
  ll num=0;
  for(int i=N-1;i>=0;i--){
    while(itr<N&&A[i]+A[itr]>=ok) itr++;
    ans+=A[i]*itr+sum[itr];
    num+=itr;
  }

  ans-=ok*(num-M);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

int main(){
	ll n, m, u, v, s, t; cin >> n >> m;
	vector<vector<ll>> conn(3*n);
	REP(i,m){
		cin >> u >> v;
		conn[3*u-3].pb(3*v-2);
		conn[3*u-2].pb(3*v-1);
		conn[3*u-1].pb(3*v-3);
	}
	cin >> s >> t;
	vector<ll> ansl(3*n,-1);
	priority_queue<vector<ll>, vector<vector<ll>>, greater<vector<ll>>> q;
	ansl[3*s-3] = 0;
	q.push({0, 3*s-3});
	while (q.size()>0){
		ll nowat = q.top().at(1);
		ll dist = q.top().at(0);
		ll edas = conn[nowat].size();
		REP(i,edas){
			ll nex = conn[nowat][i];
			if (ansl[nex]==-1 || ansl[nex]>1+dist){
				q.push({1+dist,nex});
				ansl[nex] = 1+dist;
			}
		}
		q.pop();
	}
	if (ansl[3*t-3]==-1){
		cout << -1 << endl;
	}
	else{
		cout << ansl[3*t-3]/3 << endl;
	}
}

Measured memory_bytes: 18944
#include <cstdint>
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>

using namespace std;

struct Node {
  Node(int64_t u) : v(u) {}
  int64_t v;
  Node* next = nullptr;
};

vector<int64_t> MakeVec(unordered_map<int64_t, Node*>& nodes, int64_t st) {
  Node* st_adr = nodes[st];
  vector<int64_t> vec;
  vec.push_back(st_adr->v);
  Node* cur = st_adr->next;
  while (cur != nullptr && cur != st_adr) {
    vec.push_back(cur->v);
    cur = cur->next;
  }
  return vec;
}

int main() {
  int64_t N, X, M;
  cin >> N >> X >> M;

  unordered_map<int64_t, Node*> nodes;
  
  Node* pre = new Node(X);
  nodes[X] = pre;
  vector<int64_t> loop;
  int64_t sum = X;
  int64_t n = 1;
  for (; n < N; ++n) {
    int64_t cur = (pre->v * pre->v) % M;
    if (nodes.count(cur)) {
      loop = MakeVec(nodes, cur);
      break;
    }
    Node* cur_node = new Node(cur);
    pre->next = cur_node;
    pre = cur_node;
    nodes[cur] = cur_node;
    sum += cur;
  }
  if (n == N) {
    cout << sum << endl;
  } else {
    int64_t loop_sum = loop[0];
    vector<int64_t> sums(loop.size()+1, 0);
    sums[1] = loop[0];
    for (size_t i = 1, size = loop.size(); i < size; ++i) {
      sums[i+1] = sums[i] + loop[i];
      loop_sum += loop[i];
    }
    int64_t rest = N - n;
    cout << sum + loop_sum * (rest / loop.size()) + sums[rest % loop.size()] << endl;
  }
  
  for (auto& p : nodes) {
    delete p.second;
  }
  return 0;
}


Measured memory_bytes: 7696