akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = list(input())

#print(s)
#65~90

for i in range(len(s)):
    a = ord(s[i])+n
    #print("a is:" + str(a))
    if a > 90:
        s[i]=chr(a-26)
    else:
        s[i]=chr(a)
print("".join(s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll x, y;

void input() { cin >> x >> y; }

string solve() {
  ll a, b;
  if ((y - 2 * x) % 2 != 0) { return "No"; }
  b = (y - 2 * x) / 2;
  a = x - b;
  if (a >= 0 && b >= 0) { return "Yes"; }
  return "No";
}

int main() {
  input();
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3636
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);       n*= -1 if st>en;st.step(en,n){|i|yield(i)} end


n, k = gi
ans = k
rep n-1 do |i|
ans *= k-1
end

puts ans

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

using i64 = long long int;

i64 cost[203][203] = {0};

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> v;
    for(int i=0;i<r;++i){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            if(i != j) cost[i][j] = LLONG_MAX;

    for(int i=0;i<m;++i){
        i64 a, b, c;
        cin >> a >> b >> c;
        cost[a][b] = c;
        cost[b][a] = c;
    }

    for(int k=1;k<=n;++k){
        for(int i=1;i<=n;++i){
            for(int j=1;j<=n;++j){
                if(cost[i][k] == LLONG_MAX || cost[k][j] == LLONG_MAX)continue;
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    sort(v.begin(), v.end());
    i64 ans = LLONG_MAX;
    do{
        int curr = v[0];
        i64 tmp = 0;
        for(int i=1;i<r;++i){
            tmp += cost[curr][v[i]];
            curr = v[i];
        }
        ans = min(tmp, ans);
    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void)

{
    int h,m,l,t;
    scanf("%d %d",&h,&m);
    while(h!=0 && m!=0){

    for( l = 0; l < h; l++){
        for( t = 0; t < m; t++){
        printf("#");
    }
    printf("\n");
    }
    printf("\n");
    scanf("%d %d",&h,&m);
    }


    return 0;
}

Measured memory_bytes: 572
#include <iostream>
using namespace std;
/*整数 n に対して，n を十進法で表したときの各桁の和を S(n) で表すことにします． たとえば，S(101)=1+0+1=2 です．
整数 N が与えられたとき，N が S(N) で割り切れるかどうかを判定してください．*/

int main(){
	string N;
	cin >> N;
	int S = 0;
	for (char n: N) {
		S += n - '0';
	}
	cout << ((stoi(N) % S == 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())

    # 第一項をプラスにする場合
    r1 = 0
    csum = 0
    parity = True # 「次の項目はプラスであるべき」のTrue/Falseを示す
    for ae in a:
        csum += ae
        if parity:
            if csum <= 0:
                plus = 1 - csum
                r1 += plus
                csum += plus
        else:
            if csum >= 0:
                minus = csum + 1
                r1 += minus
                csum -= minus
        parity ^= 1
    # 第一項をマイナスにする場合
    r2 = 0
    csum = 0
    parity = False
    for ae in a:
        csum += ae
        if parity:
            if csum <= 0:
                plus = 1 - csum
                r2 += plus
                csum += plus
        else:
            if csum >= 0:
                minus = csum + 1
                r2 += minus
                csum -= minus
        parity ^= 1
    print(min(r1, r2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 19888
#include <iostream>
#include <cmath>

using namespace std;

//aとbのうち，桁数が大きい方の桁数を返す
int F(int a, int b){
  int diga = 0, digb = 0;
  //aの桁数を数える
  while(a != 0){
    a /= 10;
    diga++;
  }
  //bの桁数を数える
  while(b != 0){
    b /= 10;
    digb++;
  }
  //桁数が大きいほうの桁数を返す
  return max(diga, digb);
}  


int main(){
  long long N;
  cin >> N;
  //ここまで入力

  int A, B;
  int root = sqrt(N);
  int min = 20;
  for(int n=1; n<=root; n++){
    //N=A*Bの形にできるとき
    if(N%n == 0){
      A = n;
      B = N/A;
      //Fの計算と最小値の更新
      if(F(A, B) < min)
	min = F(A, B);
    }
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define PB push_back
using namespace std;

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

vector<long long int> ggg(vector<long long int> v){
    vector<long long int> ret;
    for(int i=0;i<v.size()-1;i++){
	ret.PB(gcd(v[i],v[i+1]));
    }
    return ret;
}

vector<long long int> lcm(vector<long long int> v){
    vector<long long int> ret;
    for(int i=0;i<v.size()-1;i++){
	ret.PB(v[i]*v[i+1]/gcd(v[i],v[i+1]));
    }
    return ret;
}
int main(){
    while(true){
        long long int p = 1;
        long long  int d[11];
        int n;
        cin >> n;
        vector<long long int> v(n);
	vector<long long int> lc;
        if(!n) break;
        for(int i=0;i<n;i++){
            cin >> d[i] >> v[i];
	    int t = gcd(d[i],v[i]);
	    d[i] = d[i]/t;
	    v[i] = v[i]/t;
	    lc.PB(d[i]);
        }
	long long int dk=d[0];
	long long int vk=v[0];
	for(int i=1;i<n;i++){
	    dk = dk * d[i] / gcd(d[i],dk);
	    vk = gcd(vk,v[i]);
	}
	vector<long long int> ans;
	for(int i=0;i<n;i++){
	    ans.PB((v[i]/vk)*(dk/d[i]));
	}
	for(int i=0;i<n;i++){
	    cout << ans[i]<< endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int main() {

	int n, k, i;
	long long int sum = 0;

	cin >> n >> k;

	vector<long long int> h(n);

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

	std::sort(h.begin(), h.end(), std::greater<int>());

	i = 0;
	if (n <= k) {
		sum = 0;
		cout << sum << endl;
	}
	else {
		if (k != 0) {
			for (i = 0; i < k; i++) {
				h[i] = 0;
			}
		}
		while (i < n) {
			sum += h[i];
			i++;
		}
		cout << sum << endl;
	}
	
	return 0;
}

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

using namespace std;

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

int main(){
  int n;
  cin >> n;
  queue<int> que;
  rep0(i,n){
         lli temp;
         cin >> temp;
         que.push(temp);
  }
  lli ans=0;
  while(!que.empty()){                                                                                      queue<int> que_temp;                                                                                    lli temp = que.front();
    que.pop();                                                                                              que_temp = que;                                                                                         while(!que_temp.empty()){                                                                                 ans += que_temp.front()*temp;
      que_temp.pop();
    }                                                                                                     }
  cout << ans;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define testcase(t) int t;cin>>t;for(int testcnt=1;testcnt<=t;testcnt++)
#define int long long
#define double long double
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define eb emplace_back
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int nod(int n)
{
	string s = to_string(n);
	return (int)s.length();
}
int sod(int n)
{
	int ans = 0;
	while(n)
	ans+=(n%10),n/=10;
	return ans;
}
int modexpo(int x,int y,int p)
{
	int res=1;
	x%=p;
	while(y){
		if(y&1)
		res*=x,res%=p;
		x*=x,x%=p;
		y>>=1;
	}
	return res;
}
int h[100005];
int dp[100005];
int32_t main()
{
	IOS
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	dp[0]=0;
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
n,k = map(int, input().split())
s = list(input())
t = ""
if s[k-1]=="A":
    s[k-1]="a"
elif s[k-1]=="B":
    s[k-1]="b"
elif s[k-1]=="C":
    s[k-1]="c"
for i in range(n):
    t = t+s[i]
print(t)

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

int main()
{
	int arr[5];
	int o;
	for (int i=0; i<5; i++)
	{		
		cin >> arr[i];
		
	}
	for (int i=0; i<5; i++)
	{		
		if (arr[i] == 0){
			o = i;
			break;
		}
	}
	cout << o+1;
}

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

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

    vector<ll> a(n);
    rep (i, n)
        cin >> a[i];

    ll high = a[0];
    ll ans = 0;
    for (int i = 1; i < n; i++)
        if (a[i] < high)
        {
            ll temp = high - a[i];
            ans += temp;
            high = a[i] + temp;
        }
        else
            high = a[i];

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


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

using namespace std;

int gcd(int a, int b){
    while(b > 0){
        int c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n >= 3200){
        cout << s << endl;
    }
    else{
        cout <<"red" <<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;


double area(int n, vector<pair<pair<int, int>, char>> &arr, double moment) {
    double mnx = LLONG_MAX, mxx = LLONG_MIN, mny = LLONG_MAX, mxy = LLONG_MIN;
    for (int i = 0; i < n; ++i) {
        double x = arr[i].first.first;
        double y = arr[i].first.second;
        if (arr[i].second == 'R') {
            x += moment;
        } else if (arr[i].second == 'L') {
            x -= moment;
        } else if (arr[i].second == 'U') {
            y += moment;
        } else {
            y -= moment;
        }
        mnx = min(mnx, x);
        mxx = max(mxx, x);
        mny = min(mny, y);
        mxy = max(mxy, y);
    }
//    cout << mxx << ' ' << mnx << ' ' << mxy << ' ' << mny << '\n';
    return 1.0 * (mxx - mnx) * (mxy - mny);
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<pair<pair<int, int>, char>> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
    }

    double l = 0, r = inf;
    double ans = LLONG_MAX;
    for (int i = 0; i < 300; ++i) {
        double m1 = l + (r - l) / 3;
        double m2 = r - (r - l) / 3;
        double f1 = area(n, arr, m1);
        double f2 = area(n, arr, m2);
        if (f1 > f2) {
            l = m1;
        } else {
            r = m2;
        }
        ans = min(ans, min(f1, f2));
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll x[100001];
ll l[100001]={};
int main(){

	ll n,m;
	ll total=0;

	cin>>n>>m;

	rep(i,m){
		cin>>x[i];
	}
	sort(x,x+m);

	rep(i,m-1){
		if(x[i]<0&&x[i+1]>=0){
			l[i]=abs(x[i])+x[i+1];
		}else{
			l[i]=abs(x[i+1]-x[i]);
		}
	}
	sort(l,l+m-1);

	for(int i=0; i<m-n; i++){
		total+=l[i];
	}
	cout<<total<<endl;
	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

class SegTreeMin {
public:
    int n;
    vector< int > node;

    SegTreeMin(vector< int > v) {
        int sz = v.size();
        n = 1;
        while( n < sz ) n <<= 1;
        node.resize(2 * n - 1, INF);

        for( int i = 0; i < sz; ++i ) {
                node[i + n - 1] = v[i];

        }
        for( int i = n - 2; i >= 0; --i ) {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);

        }
    }

    void Update(int x, int val) {
        x += n - 1;
        node[x] = val;
        while( x > 0 ) {
            x = (x - 1) >> 1;
            node[x] = min(node[2 * x + 1], node[2 * x + 2]);

        }
    }

    int Query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if( r < 0 ) {
            r = n;

        }

        if( r <= a || b <= l ) {
            return INF;

        }
        if( a <= l && r <= b ) {
            return node[k];

        }

        int vl = Query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = Query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);

    }

};

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

    int n, q;
    cin >> n >> q;
    vector< int > v(n);
    for( int i = 0; i < n; ++i ) {
        v[i] = INF;

    }

    SegTreeMin seg(v);

    while( q-- ) {
        int com, x, y;
        cin >> com >> x >> y;
        if( com == 0 ) {
            seg.Update(x, y);

        } else {
            cout << seg.Query(x, y + 1) << endl;

        }
    }
    return 0;
}




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

int main(){
  int n, ans=1; cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin>>s[i];
  sort(s.begin(), s.end());
  
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i])continue;
    ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9544
//Swapping Two Numbers
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String input;
		String[] xy;
		int x;
		int y;
		
		while (!(input = in.readLine()).equals("0 0")){
			
			xy = input.split(" ");
			x = Integer.parseInt(xy[0]);
			y = Integer.parseInt(xy[1]);
			
			if(x <= y ){
				System.out.println(x +" " +y);
			}else{
				System.out.println(y +" " +x);
			}
			
		}
	}
}

Measured memory_bytes: 24576
#include<stdio.h>
#define N 200

int main(){
  int M[N][N];
  int n,u,k,v;

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    for(int j;j<n;j++)
      M[i][j]=0;
    
  }
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
      
    }
      
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);}
    printf("\n");


    }

  return 0;
  }




Measured memory_bytes: 2764
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<int> s(n);
		map<int, int> table;
		for(int i = 0; i < n; ++i){
			cin >> s[i];
			if(table.find(s[i]) == table.end()){
				table.insert(pair<int, int>(s[i], table.size() + 1));
			}
			s[i] = table[s[i]];
		}
		int answer = 0;
		vector<int> prev = s;
		while(true){
			vector<int> b(n + 1, 0);
			for(int i = 0; i < n; ++i){ ++b[s[i]]; }
			for(int i = 0; i < n; ++i){ s[i] = b[s[i]]; }
			if(prev == s){ break; }
			prev = s;
			++answer;
		}
		cout << answer << endl;
		for(int i = 0; i < n; ++i){
			cout << s[i] << (i == n - 1 ? '\n' : ' ');
		}
	}
	return 0;
}

Measured memory_bytes: 0
A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1):
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res <= sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))

Measured memory_bytes: 44008
import java.util.Scanner;

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

		int A = sc.nextInt();
		int odd = 0;
		int even = 0;
		for(int i=0;i<A;i++){
			if(i%2==1) odd++;
		}
		System.out.println(1-((float)odd/A));
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;

long long int mod=1e9+7;

int main(){
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    //cin>>a[i];
  }
  int i=0;
  if((n-1)%(x-1)!=0)i=1;
  cout<<(n-1)/(x-1)+i<<endl;
}


Measured memory_bytes: 640
#! usr/bin/env python
# -*- coding: utf-8 -*-


class Sword:
    def __init__(self, swing, throw):
        self.swing = swing
        self.throw = throw


def main():
    n, h = map(int, input().split())

    s = []
    for i in range(n):
        a, b = map(int, input().split())
        s.append(Sword(a, b))

    s1, s2 = s[:], s[:]
    s1.sort(key=lambda sword: sword.swing, reverse=True)
    s2.sort(key=lambda sword: sword.throw, reverse=True)

    idx, c = 0, 0
    while idx < n and s2[idx].throw >= s1[0].swing and h > 0:
        h -= s2[idx].throw
        c += 1
        idx += 1

    if h > 0:
        c += (h+s1[0].swing-1) // s1[0].swing
    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29884
#include "bits/stdc++.h"
using namespace std;
long long int powint(long long int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	else {
		long long int ans = 1;
		long long int c = powint(a, b / 2);
		ans *= c*c;
		ans *= (b % 2) ? a : 1;
		return ans;
	}

}
vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}
vector<long long int> divisor(map<long long int, int> s) {
	vector<long long int> res;
	int num = 1;
	for (auto it = s.begin(); it != s.end(); ++it) {
		num *= (*it).second + 1;
	}
	for (int i = 0; i < num; ++i) {
		int bs = i;
		long long int p = 1;
		for (auto it = s.begin(); it != s.end(); ++it) {
			int a = bs % ((*it).second + 1);
			p *= powint((*it).first, a);
			bs /= ((*it).second + 1);
		}
		res.push_back(p);
	}
	return res;
}
map<long long int, int>soinnsuu(long long int a) {
	hurui(1e5);
	map<long long int, int>ans;
	for (auto km : primes) {
		int i = km;
		if (i> a)break;
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

bool check(const long long int a) {
	if (a >= 3) {
		return a % 2;
	}
	else {
		return false;
	}
}

int main() {
	int ans = 0;
	int N; cin >> N;
	while (N--) {
		long long int a; cin >> a;
		a = 2 * a + 1;
		auto vs = divisor(soinnsuu(a));
		bool ok = false;
		for (int i = 0; i < vs.size()/2+1; ++i) {
			long long int a = vs[i];
			long long int b = vs[vs.size() - i - 1];
			if (check(a) && check(b))ok = true;
		}
		ans += !ok;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int res = 0;
  char s = 'A';
  for (int i = 0; i < N; i++) {
    if (S[i] != s) {
      s = S[i];
      res++;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 512
n = int(input())
unil = [i for i in range(n)]
unih = [0 for _ in range(n)]

def root(p):
  if unil[p] == p:
    return p
  else:
    unil[p] = root(unil[p])
    return unil[p]

def union(p, q):
  pp, qp = root(p), root(q)
  if pp == qp:
    return
  else:
    if unih[pp] > unih[qp]:
      unil[qp] = pp
    elif unih[pp] < unih[qp]:
      unil[pp] = qp
    else:
      unil[max(pp, qp)] = min(pp, qp)
      unih[min(pp, qp)] += 1

xlist, ylist = [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)

xsort = list(sorted(enumerate(xlist), key=lambda x: x[1]))
xd = [(i, j, x - prevx) for (i, prevx), (j, x) in zip(xsort, xsort[1:])]
ysort = list(sorted(enumerate(ylist), key=lambda x: x[1]))
yd = [(i, j, y - prevy) for (i, prevy), (j, y) in zip(ysort, ysort[1:])]
xyd = sorted(xd + yd, key=lambda x: x[2])

ans = 0
for i, j, d in xyd:
  if root(i) == root(j):
    continue
  else:
    ans += d
    union(i, j)
print(ans)


Measured memory_bytes: 66332
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    char a,b;
    cin>>a>>b;
    
    if(a<b)cout<<"<"<<endl;
    else if (a>b) cout<<">"<<endl;
    else cout<<"="<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll x, a, b; cin >> x >> a >> b;
	ll dif1, dif2;
	dif1 = abs(x - a), dif2 = abs(x - b);
	if (dif1 < dif2) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
	
return		0;
}

Measured memory_bytes: 256
#include <iostream>

#include <fstream>

#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>
#include <cstdlib>
#include <ctime>
#include <utility>

#include <limits>

using namespace std;

typedef long long ll;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(clock());
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1 << "\n";
    return 0;
}

/*
Ilia's tasks: 1 new tasks, 0 tasks in progress, 0 tasks are being tested, 0 tasks are done
Ivan's tasks: 3 new tasks, 0 tasks in progress, 0 tasks are being tested, 0 tasks are done
Updated Ivan's tasks: 0 new tasks, 2 tasks in progress, 0 tasks are being tested, 0 tasks are done
Untouched Ivan's tasks: 1 new tasks, 0 tasks in progress, 0 tasks are being tested, 0 tasks are done
Updated Ivan's tasks: 0 new tasks, 1 tasks in progress, 1 tasks are being tested, 0 tasks are done
Untouched Ivan's tasks: 0 new tasks, 1 tasks in progress, 0 tasks are being tested, 0 tasks are done
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
 {
 	int n=5,i;
 	int a[n];
 	for(i=0;i<n;i++)
 		cin>>a[i];
 	for(i=0;i<n;i++)
 	{
 		if(a[i]==0)
 			cout<<i+1<<endl;
	 }
 	
 	
 	return 0;
}
 	

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n;
bool c[5][20];
char suit[4]={'S','H','C','D'};

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        char s;cin>>s;
        int num;cin>>num;
        for(int j=0;j<4;j++){
            for(int k=1;k<=13;k++){
                if(s==suit[j]&&k==num)c[j][k]=true;
            }
        }
    }
    for(int i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(!c[i][j])cout<<suit[i]<<" "<<j<<endl;
        }
    }
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vll a(3);
  rep(i,3) cin>>a[i];
  vsort(a);
  ll s=0;
  rep(i,2) s+=a[i];
  if(s==a[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def is_prime(x):
    if x == 2:
        return True
    
    if x < 2 or x % 2 == 0:
        return False

    for i in range(3, int(x**0.5)+1, 2):
        if x % i == 0:
            return False
    
    return True


N = int(input())
cnt = 0
for _ in range(N):
    i = int(input())
    cnt += is_prime(i)
print(cnt)



Measured memory_bytes: 5676
(defn get-keta [x ans]
  (if (< x 1)
    ans
    (get-keta (/ x 10) (+ ans 1))
      )
  )

(defn sqrt [suu shita ue]
  ;; ギリギリ越えない整数値を返す
;  (println suu shita ue)
  (let [tansaku (bigdec (/ (+ shita ue) 2))]
    (if (<= (- ue shita) 1)
      shita
      (if (<= (* tansaku tansaku) suu)
        (sqrt suu tansaku ue)
        (sqrt suu shita tansaku)
        )
      )
    )
  )

(defn dai-dvior [n i gen ans]
  (if (> i gen)
    ans
    (dai-dvior n (+ i 1) gen
                    (if (integer? (/ n i))
                      i
                      ans
                      ))
    )
  )



(defn get-ans [n p]
  (let [the-other (/ n p)]
    (get-keta the-other 0)
    )
  )

(let*
    [n (read) limit (+ (sqrt n 0 (+ n 1)) 1)]
  (println  (get-ans n (apply max  (map (fn [x] (if (integer? (/ n x)) x 0))
                                        (seq (range 1 limit) ))
                                   )))
  )


Measured memory_bytes: 86152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define rep(i,n) for(i=0;i<n;i++)

long long ans;
int n,s;

int in(void){
	int i;
	scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;
	scanf("%lld",&i);
	return i;
}
int cmp(const void *a,const void *b){
	return *(long long *)a-*(long long *)b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long max(long long a,long long b){
	return a>b?a:b;
}
void dfs(int now,int sum,int cnt){
	int i;
	if(cnt==n){
		ans+=sum==s;
		return ;
	}
	for(i=now;i<10;i++){
		dfs(i+1,sum+i,cnt+1);
	}
	return ;
}

int main(void){
	while(1){
		n=in();
		s=in();
		if(n==0){
			break;
		}
		ans=0;
		dfs(0,0,0);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
def GCD(a, b): # a > b
    if a % b == 0: return b
    else: return GCD(b, a%b)
w, h, c = map(int, input().split())
if w > h: g = GCD(w, h)
else: g = GCD(h, w)
print(h*w*c//g**2)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int main() 
{ 
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ll n1;
	ll w1;
	cin>>n1>>w1;
	ll dp[n1+1][w1+1];
	for (ll i=0; i <=n1; ++i)
	{
		for (ll j=0; j<=w1; ++j)
		{
			dp[i][j]=0;
		}
	}
	for (int i = 1; i<=n1; ++i)
	{
		ll w, v;
		cin>>w>>v;
		for (int j = 1; j<=w1; ++j)
		{
			dp[i][j] = dp[i-1][j];
			if(j-w>=0){
				dp[i][j]=max(dp[i][j], v + dp[i-1][j-w]);
			}
		}
	}

	ll ans=0;
	for (int i = 0; i <=w1; ++i)
	{
		ans=max(ans, dp[n1][i]);
	}
	cout<<ans;
	
} 

Measured memory_bytes: 79104
from collections import deque
k=int(input())
cand=["1","2","3","4","5","6","7","8","9"]
cand=deque(cand)
lunlun=['0']
while len(lunlun)<10**5+5:
    l=cand.popleft()
    lunlun.append(l)
    if l[-1]!='0':
        cand.append(l+str(int(l[-1])-1))
    cand.append(l+str(int(l[-1])))
    if l[-1]!='9':
        cand.append(l+str(int(l[-1])+1))
print(lunlun[k])

Measured memory_bytes: 75484
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = input()

if s[-1]=="s":
	print(s+"es")
else:
	print(s+"s")

Measured memory_bytes: 9388
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}

ll dp[100005];
int n,h[100005],k;
int main() {
	rep(i,0,100005)dp[i]=INF;
	cin>>n>>k;
	rep(i,0,n){
		cin>>h[i];
	}
	dp[0]=0;
	rep(i,0,n){
		rep(j,1,k+1){
			if(i+j<n){
				dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T> using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, A, B;
ll K;
ll result;
//@verified http://codeforces.com/contest/559/submission/33876738
template <typename T> class ModUtil {
public:
  ModUtil(int N, T mod) : N(N), mod(mod), fact(N + 1), inv_fact(N + 1) {
    calc();
  }

  T get_inv(int x) { return modpow(x, mod - 2); }
  T get_fact(int n) { return fact[n]; }
  T get_inv_fact(int n) { return get_inv(fact[n]); }
  T get_P(int n, int k) {
    if (n < k)
      return 0;
    return fact[n] % mod * get_inv_fact(n - k) % mod;
  }
  T get_C(int n, int k) {
    if (n < k)
      return 0;
    return fact[n] * inv_fact[k] % mod * inv_fact[n - k] % mod;
  }
  T modpow(int a, int n) {
    if (n == 0)
      return 1;
    T res = modpow(a, n / 2);
    res *= res;
    res %= mod;
    if (n % 2)
      res *= a;
    return res % mod;
  }

private:
  vector<T> fact;
  vector<T> inv_fact;
  int N;
  T mod;
  // O(N)
  void calc() {
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      fact[i] = i * fact[i - 1] % mod;
    }
    inv_fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      inv_fact[i] = modpow(fact[i], mod - 2);
    }
  }
};
int main() {
  cin >> N >> A >> B >> K;
  ll mod = 998244353;
  ModUtil<ll> util(N + 10, mod);

  for (int a = 0; a <= N; a++) {
    ll point = 0;
    point += A * a;
    if (point > K) {
      continue;
    }
    ll res = K - point;
    if (res % B != 0) {
      continue;
    }
    ll b = res / B;
    if (b > N) {
      continue;
    }
    result += util.get_C(N, a) * util.get_C(N, b);
    result %= mod;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 5240
#include <cstdio>

using namespace std;

const int mod = 1'000'000'007;

int add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}

int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int inv(int a) {
  return pw(a, mod - 2);
}

const int N = 2'000'009;

int f[N];
int rf[N];

int choose(int n, int k) {
  return mul(f[n], mul(rf[k], rf[n - k]));
}

int calc(int n, int m) {
  int res = 0;
  for (int i = 0; i <= n; ++i) {
    res = add(res, choose(m + i + 1, i + 1));
  }
  return res;
}

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = inv(f[i]);
  }
  int ra, ca, rb, cb;
  scanf("%d%d%d%d", &ra, &ca, &rb, &cb);
  int ans = calc(rb, cb);
  ans = sub(ans, calc(ra - 1, cb));
  ans = sub(ans, calc(rb, ca - 1));
  ans = add(ans, calc(ra - 1, ca - 1));
  printf("%d\n", ans);
}


Measured memory_bytes: 15744
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    if n == 1:
        print(0)
        sys.exit()
    ans = (n*(n-1))//2
    print(ans)

if __name__ == '__main__':
    main()

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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

void dfs(int v, vector<vector<int>> const& g, vector<bool>& used, vector<int>& path) {
    if(!used[v]) {
        path.push_back(v + 1);
    }
    used[v] = true;
    for(auto to : g[v]) {
        if(used[to]) {
            continue;
        }
        dfs(to, g, used, path);
        break;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    vector<int> path;
    vector<bool> used(N);
    dfs(0, g, used, path);
    reverse(path.begin(), path.end());
    dfs(0, g, used, path);
    cout << path.size() << endl;
    for(int i = 0; i < path.size(); ++i) {
        cout << path[i] << " \n"[i + 1 == path.size()];
    }
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 101;
string s[maxn];
int dp[maxn][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m;
    cin >> n >> m;
    forn(i, n) cin >> s[i];
    forn(i, n) forn(j, m) dp[i][j] = 1e9;
    dp[0][0] = int(s[0][0] == '#');
    forn(i, n) forn(j, m) {
        if (i + 1 < n) uin(dp[i + 1][j], dp[i][j] + int(s[i][j] != s[i + 1][j]));
        if (j + 1 < m) uin(dp[i][j + 1], dp[i][j] + int(s[i][j] != s[i][j + 1]));
    }

    cout << (dp[n - 1][m - 1] + 1) / 2 << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int a[1926];
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=2*n;++i)cin>>a[i];
 	sort(a+1,a+2*n+1);
 	for(int i=1;i<=2*n;i+=2)ans+=a[i];
	printf("%d\n",ans);
  	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll a[200000];
ll sum[200000];

ll n,m;

bool C(ll d){
	ll cnt=0;
	rep(i,n){
		int id=lower_bound(a,a+n,d-a[i])-a;
		cnt+=n-id;
	}
	return cnt>=m;
}

int main(){
	cin>>n>>m;
	rep(i,n)scanf("%lld",&a[i]);
	sort(a,a+n);
	ll ok=0,ng=LLONG_MAX/3;
	while(ng-ok>1){
		ll t=(ok+ng)/2;
		if(C(t))ok=t;
		else ng=t;
	}
	rep(i,n)sum[i+1]=sum[i]+a[i];
	ll ans=0;
	ll e=0;
	rep(i,n){
		int id=lower_bound(a,a+n,ok-a[i])-a;
		ans+=sum[n]-sum[id];
		ans+=(n-id)*a[i];
		e+=(n-id);
	}
	ans-=(e-m)*ok;
	cout<<ans<<endl;
}

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

int main() {
 int N,M;
  cin >> N >> M;
  vector<int> ans(N);
  for(int i=0;i<M *2;i++){
    int a;
    cin >> a;
    a--;
    ans.at(a) += 1;
  }
  for(int i = 0;i<N; i++){
    cout<<ans.at(i)<<endl;
  }    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
int has[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{	
		int a,b,n;
		cin>>a>>b>>n;

		int x = min(b-1,n);

		int  val = (a*x)/b;
		
		cout<<val<<"\n";
	}
}

Measured memory_bytes: 3604
def main():
    s = input()
    c = s[-1]
    if c in ('2', '4', '5', '7', '9'):
        print("hon")
    elif c in ('0', '1', '6', '8'):
        print("pon")
    else:
        print("bon")
        

if __name__ == '__main__':
    main()
   

Measured memory_bytes: 9100
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a;

int main(){
  cin >> a;
  if(a>=2800) cout << "AGC" << endl;
  else if(a>=1200) cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}


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

long long T[200010];
int h[200010], a[200010];
int n;

void add(int x, long long v){
	for (int i = x; i <= n; i += i & -i){
		T[i] = max(T[i], v);
	}
}

long long query(int x){
	long long res = 0;
	for (int i = x; i; i -= i & -i){
		res = max(res, T[i]);
	}
	return res;
}

int main(){
//	freopen("data.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	long long ans = 0;
	for (int i = 0; i < n; i++){
		long long t = query(h[i] - 1) + a[i];
		ans = max(ans, t);
		add(h[i], t);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if X == i * 500 + j * 100 + k * 50:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()

using namespace std;
signed main(){
  string s;
  cin>>s;
  vector<char> a(s.size());
  vector<char> b(s.size());
  bool answer = true;
  rep(i,s.size()){
    a[i]=s[i];
    b[i]=s[i];
  }
  reverse(all(a));
  rep(i,s.size()){
    if(a[i]!=b[i]){
      answer=false;
      break;
    }
  }
  if(answer){
    rep(i,(s.size()-1)/2){
      if(a[i]!=b[(s.size()-3)/2-i]){
        answer=false;
        break;
      }
    }
  }
  if(answer){
    cout<<"Yes"<<endl;
  }
  else if(!answer){
    cout<<"No"<<endl;
  }
}

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

int main() {
	
	int a, b;
	cin >> a >> b;
	if(b > a)	swap(a, b);
	if( (a-b)%2 != 0 )	puts("IMPOSSIBLE");
	else	cout << (a+b)/2 << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
ld v[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, n) scanf("%Lf", v+i+1), v[i+1] += v[i];
	ld ans = 0;
	REP(i, n-k+1){
		LAR(ans, (k + v[i+k] - v[i]) / 2);
	}
	printf("%.30Lf\n", ans);
}


Measured memory_bytes: 3328
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
cnt=defaultdict(int)
for i in range(n):
  cnt[a[i]]+=1
tmp=[]
for key in cnt.keys():
  if cnt[key]>=2:
    tmp.append(key)
    if cnt[key]>=4:
      tmp.append(key)
tmp=sorted(tmp,reverse=True)
if len(tmp)<=1:
  print(0)
else:
  print(tmp[0]*tmp[1])

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

#define int long long

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

    int fin = 1;
    int sum = 0;
    while((fin*(fin+1))/2 < n){
        fin++;
    }

    stack<int> st;

    for(int i = fin;i >= 1;i--){
        if(n >= i){
            n -= i;
            st.push(i);
        }
    }

    while(!st.empty()){
        cout << st.top() << endl;
        st.pop();
    }

    return 0;
}



Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

int main (){
	int a,b;
	cin >>a >>b;
	int ans=0;
	int N = (b-a)-1;
	ans = (N+2)*(N+1)/2 - b;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
   int a,b;
    cin >> a >> b;
    if(a % 3 == 0){
        cout << "Possible" << endl;
    }
    else if(b % 3 == 0){
        cout << "Possible" << endl;
    }
    else if((a+b) % 3 == 0){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }

    return 0;
}



Measured memory_bytes: 256