akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,target;
    cin>>n>>target;
    vector<int> w(n,0);
    vector<int> price(n,0);
    vector<vector<long long int>> dp(n+1,vector<long long int>(target+1,0));
    for(int i=0;i<n;i++)
    cin>>w[i]>>price[i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=target;j++){
            if(w[i-1]<=j)
            dp[i][j]=max(dp[i-1][j-w[i-1]]+price[i-1],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][target];
	return 0;
}

Measured memory_bytes: 83080
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   string s;
   cin >> s;

   int ans = 0;

   int l = 0, r = sz(s) - 1;

   while(l < r){
      if(s[l] != s[r])
         ans++;
      l++;
      r--;
   }

   cout<<ans;
   

   return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#define re register
using namespace std;
typedef long long ll;
const int M = 200010;
int T,m,tot1 = 0,tot2 = 0;
ll ans = 0;
template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch > '9' || ch < '0'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch <= '9' && ch >= '0'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
struct query{
    int w,k;//权值和限制
    inline bool operator < (const query &x) const {
        return k < x.k;//以k为第一关键字升序排序(为了贪心)
    }
}q1[M],q2[M];
priority_queue <int ,vector<int> , greater <int> > q;//小根堆(升序)
inline void solve(){
    read(m); ans = tot1 = tot2 = 0;
    for(re int i = 1,k,l,r;i <= m; i++){
        read(k); read(l); read(r);
        if(l > r) ans += r, q1[++tot1] = (query){l - r,k};
        else ans += l, q2[++tot2] = (query){r - l,m - k};
    }
    sort(q1 + 1,q1 + tot1 + 1);
    sort(q2 + 1,q2 + tot2 + 1);
    for(re int i = 1;i <= tot1; i++)
        if(q1[i].k)
            if(q.size() < q1[i].k) q.push(q1[i].w);
            else if(q.size() == q1[i].k && q1[i].w > q.top())
                q.pop(), q.push(q1[i].w);//如果后来的不论条件还是值都更优秀就直接取代
    for(;!q.empty(); q.pop()) ans += q.top();//直接算上所有可得的答案
    for(re int i = 1;i <= tot2; i++)
        if(q2[i].k)
            if(q.size() < q2[i].k) q.push(q2[i].w);
            else if(q.size() == q2[i].k && q2[i].w > q.top())
                q.pop(), q.push(q2[i].w);
    for(;!q.empty(); q.pop()) ans += q.top();
    printf("%lld\n",ans);
}
int main(){
    read(T);
    while(T--) solve();
    return 0;
}
/*
3
2
1 5 10
2 15 5
3
2 93 78
1 71 59
3 57 96
19
19 23 16
5 90 13
12 85 70
19 67 78
12 16 60
18 48 28
5 4 24
12 97 97
4 57 87
19 91 74
18 100 76
7 86 46
9 100 57
3 76 73
6 84 93
1 6 84
11 75 94
19 15 3
12 11 34

25
221
1354
*/

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int H, N; cin >> H >> N;
    int all = 0;
    rep(i, N) {
        int a; cin >> a;
        all += a;
    }
    if (all >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var param = lines[0].split(' ').map(Number);
  var result = (function(a,b) {
  	return [
  		~~(a / b)
  		,(a % b)
  		,(a / b).toFixed(6)
  	].join(' ');
  }(param[0],param[1]
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7648
#include<bits/stdc++.h>
#include<queue>
using namespace std;
 
#define what_is(x) cerr << #x << " is " << x << endl; 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 10000000009
#define eps 1e-9
#define MAX 10
//#define N 100001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX]; 
ll fact[MAX];

const long long INF64 = 1e18;



ll find(vll &a,ll mx){
    ll ans=0;
    rep(i,0,sz(a)){
        ans+=(ll)ceil((1.0*a[i])/(1.0*mx));
        ans--;
    }
    return ans;
}
void solve(ll ttt){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,0,n)
    cin>>a[i];
  ll low=1,high=10000000000;
  if(k==0){
    ll mx=INT_MIN;
    rep(i,0,n){
        mx=max(mx,a[i]);
    }
    cout<<mx<<endl;
    return ;
  }
  while(low<high){
    ll mid=low+(high-low)/2;
    
    ll req_cut=find(a,mid);
    //cout<<"For mid = "<<mid<<" cuts req = "<<req_cut<<endl;
    if(req_cut>k){
        low=mid+1;
    }
    else
        high=mid;
  }
  cout<<(ll)low<<endl;

}
int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
     // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     //cin>>t;
    fix(12);
    rep(q,1,t+1){
        // cout<<"Case #"<<q<<": ";
         solve(q);
        //solve2();
    }
    return 0;
    
}        




Measured memory_bytes: 4652
#include<stdio.h>
#include<string.h>
int main()
{
   char S[101];
   scanf("%s",S);
   int l,i,b=0;
   l=strlen(S);
  
    for(i=0;i<l/2;i++)
    {
      if(S[i]!=S[l-i-1])
       b++;
    }
    printf("%d",b);
 
  return 0;
}
      


Measured memory_bytes: 1708
n, y = list(map(int, input().split()))

for m in range(n + 1):
    for g in range(n + 1 - m):
        s = n - m - g
        yen = 10000 * m + 5000 * g + 1000 * s
        if yen == y:
            break
    if yen == y:
        break
if yen == y:
    print(m, g, s)
else:
    print(-1, -1, -1)


Measured memory_bytes: 3060
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools

# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N = int(readline())
P = [int(i) for i in readline().split()]
Q = [int(i) for i in readline().split()]

S = list(itertools.permutations(range(1, N + 1)))
print(abs(S.index(tuple(P)) - S.index(tuple(Q))))


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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll n,p;
    cin >>n;
    p=n;

    if(n%2==0){
        p /= 2;
        while(p > 0){
            p /= 5;
            ans += p;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int	main() {
	int A, B, C, D, E, F;
	cin >>A >>B >>C >>D >>E >>F;
	vector<int> AB;
	vector<int> CD;
	A *=100;
	B *=100;
	for (int i=0; i*A<=F; i++) {
		int AA=A*i;
		for (int j=0; j*B<=F; j++) {
			int BB=j*B+AA;
			if (BB<=F)
				AB.push_back(BB);
			else
				break;
		}
	}
	int EE=F*E/100;
	for (int i=0; i*C<=EE; i++) {
		int AA=C*i;
		for (int j=0; j*D<=EE; j++) {
			int BB=j*D+AA;
			if (BB<=EE)
				CD.push_back(BB);
			else
				break;
		}
	}
	sort(AB.begin(), AB.end());
	AB.erase(unique(AB.begin(), AB.end()), AB.end());
	sort(CD.begin(), CD.end());
	CD.erase(unique(CD.begin(), CD.end()), CD.end());
	int AAA, CCC;
	int i=0;
	int j=0;
	int W=AB.at(i);
	int S=CD.at(j);
	while(true) {
		if (i==AB.size())
			break;
		int WN=AB.at(i);
		int SN=CD.at(j);
		if (F<WN+SN)
			break;
		if(SN*100>WN*E) {
			i++;
		} else {
			if ((WN+SN)*S<=(W+S)*SN) {
				W=WN;
				S=SN;
			}
			j++;
			if (j==CD.size()) {
				j--;
				i++;
				continue;
			}
		}
	}
	cout <<S+W <<' ' <<S <<endl;
	return 0;
};


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

int main(){
  int n;
  cin>>n;
  int a =n%100%10;
  if(a==3)
    cout<<"bon"<<endl;
  else if(a==2||a==4||a==5||a==7||a==9)
    cout<<"hon"<<endl;
  else if(a==0||a==1||a==6||a==8)
    cout<<"pon"<<endl;
}

Measured memory_bytes: 3504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int dd,i;	

	while(cin >> dd){
		int ws = 600 /dd;
		int ss =0;
		rep2(i,1,ws){
			ss += dd * i * dd * i * dd; 
		}
		cout << ss << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int n = N % 10;

            if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) 
            Console.WriteLine("hon");
            else if(n == 0 || n == 1 || n == 6 || n == 8)
            Console.WriteLine("pon");
            else
                Console.WriteLine("bon");
        }
    }
}


Measured memory_bytes: 27384
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main(){
  string s;
  cin >> s;
  bool ans = false;
  rep0(i,s.size()-1){
    if(s[i] == 'A' && s[i+1] == 'C')ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
k=int(input())


def nibai(n):
    return n*2

def tasu_k(n,k):
    return n+k

num=1
for i in range(n):
    if(num>k):
        num=tasu_k(num,k)
    else:
        num=nibai(num)
print(num)   
    


Measured memory_bytes: 2940
// 5/4
// 過去問ガリガリ

#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 Graph = vector<vector<int>>;

// int mod = 1000000007;

// const ll MAX = 1000000010;
const ll MOD = 1000000007;

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

// x^nのmodを返す
ll f(ll x, ll n) {
    if (n == 0) return 1;
    
    ll r = f(x, n / 2);
    r *= r;
    r %= MOD;

    if (n % 2 == 1) r *= x;

    return r % MOD;
}

ll comb(ll n, ll a) {
    ll X = 1, Y = 1;  // Xが分母、Yが分子
    
    for(ll i = 0; i < a; i++) {
        Y *= n - i;
        X *= i + 1;

        Y %= MOD;
        X %= MOD;
    }

    return (Y * f(X, MOD - 2)) % MOD;
}


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

    // int mod2_10000 = 1;
    // rep(i, 10000) {
    //     mod2_10000 *= 2;
    //     mod2_10000 %= 1000000007;
    // }

    // COMinit();

    // int ans_a = 1, ans_b = 1;
    // rep(i, a) {
    //     ans_a = (ans_a * (a - i) / (i + 1)) % mod;
    // }
    // rep(i, b) {
    //     ans_b = (ans_b * (b - i) / (i + 1)) % mod;
    // }

    // cout << mod2_10000 << endl;

    // cout << modpow(2, n, MOD) - 1 - COM(n, a) - COM(n, b) << endl;

    ll ans = f(2, n) - 1;
    // cout << f(5) << endl;

    // ll X = 1, Y = 1;
    // rep(i, a) {
    //     Y *= n - i;
    //     X *= i + 1;

    //     Y %= MOD;
    //     X %= MOD;
    // }
    // cout << X << " " << Y << endl;

    // cout << ans << endl;

    ans -= comb(n, a);
    ans = (ans + MOD) % MOD;
    // cout << ans << endl;
    ans -= comb(n, b);
    ans = (ans + MOD) % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

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

intmax_t digitsum(intmax_t n, intmax_t base=10) {
  intmax_t res = 0;
  for (; n; n /= base) res += n % base;
  return res;
}

int main() {
  intmax_t n, s;
  scanf("%jd %jd", &n, &s);

  if (n == s)
    return !printf("%jd\n", n+1);

  for (intmax_t b = 2; b*b <= n; ++b)
    if (digitsum(n, b) == s)
      return !printf("%jd\n", b);

  for (auto b1: divisor(n-s))
    if (digitsum(n, b1+1) == s)
      return !printf("%jd\n", b1+1);

  puts("-1");
}


Measured memory_bytes: 512
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
y = x // 100
z = x % 100
if 0 <= z <= 5*y:
    print(1)
else:
    print(0)


Measured memory_bytes: 65456
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, t;
    cin >> n >> t;
    const ll cmax = 10000;
    ll ans = cmax;
    for(ll i = 0; i < n; i++) {
        ll c, tt;
        cin >> c >> tt;
        if(tt <= t) chmin(ans, c);
    }
    if(ans == cmax) cout << "TLE" << endl;
    else cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    int main()
    {
        fastread;
        ll n,i,j,k,l,m;
        cin>>n>>k;
        if(n%k==0)
        cout<<n/k;
        else
        cout<<n/k+1;
    	return 0;
    }

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

struct edge{long long  to, cost;};
typedef pair<long long,long long> P;

long long INF = 1e15;
struct graph{
  long long V;
  vector<vector<edge> > G;
  vector<long long> d;

  graph(long long n){
      init(n);
  }
  void init(long long n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(long long i = 0; i < V; i++){
        d[i] = INF;
    }
  }
  void add_edge(long long s, long long t, long long cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }
  void dijkstra(long long s){
    for(long long i = 0; i < V; i++){
        d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      long long v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};


int main(){
    long long n, m;
    cin >> n >> m;

    graph g(n);

    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        a--, b--;
        g.add_edge(a, b, 1);
        g.add_edge(b, a, 1);
    }

    g.dijkstra(0);

    if(g.d[n-1] <= 2) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");

    return 0;
}

Measured memory_bytes: 21812
#include <stdio.h>
int main(void){
    char op;
    int a,b;
    do{
    scanf("%d %[+-*/?] %d",&a,&op,&b);
    switch(op){
    case'+' :printf("%d\n",a+b); break;
    case'-' :printf("%d\n",a-b); break;
    case'*' :printf("%d\n",a*b); break;
    case'/' :printf("%d\n",a/b); break;
    }
    }while(op!='?');
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define int long long
#define md 1000000007
using namespace std;
int power(int x ,int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 

main()
{
	int n;
	cin>>n;
	int arr[n];
	vector<string>ma;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		string binary = bitset<60>(arr[i]).to_string();
		//cout<<binary<<endl;
		ma.push_back(binary);
	}
	int p =0;
	int ans =0;
	for(int i= 59;i>=0;i--)
	{
		int z = 0;
		int o = 0;
		for(int j=0;j<n;j++)
		{
			//cout<<ma[j]<<endl;
			if(ma[j][i] == '0')
			{
				z++;
			}
			else
			{
				o++;
			}
		}
		int t = 2;
	//	cout<<z<<" "<<o<<" "<<modpow(t,p,md)<<endl;
		//cout<<z*o*modpow(t,p,md)<<endl;
//		int y = (z * o)%md;
//		y = (y%md * modpow(t,p,md))%md;
        int tt = (z*o)%md;
		ans = ans + (tt*power(t,p,md))%md;
		ans %= md;
	//	cout<<"ans "<<ans<<endl;
		p++;
	}
	ans %= md;
	cout<<ans<<endl;
}

Measured memory_bytes: 34668
#include<bits/stdc++.h>
using namespace std;
main() 
{
   int h,w,k;
   cin>>h>>w>>k;
   char v[h+1][w+1];
   int tot=0;
   for(int i=0;i<h;i++)for(int j=0;j<w;j++){cin>>v[i][j];if(v[i][j]=='#')tot++;}
   int black=tot,ans=0;
   for(int a=0;a<(1<<h);a++)
   {
    for(int b=0;b<(1<<w);b++)
    {
      bitset<6>x(a);
      bitset<6>y(b);
      map<pair<int,int>,int>chk;
      black=tot;

      for(int i=0;i<6;i++)
      {
        if(x[i])
        {
          for(int j=0;j<w;j++)
          {
            if(v[i][j]=='#' && chk[{i,j}]==0){chk[{i,j}]++;black--;}
          }
        }
      }
      for(int i=0;i<6;i++)
      {
        if(y[i])
        {
          for(int j=0;j<h;j++)
          {
            if(v[j][i]=='#' && chk[{j,i}]==0){black--;chk[{j,i}]++;}
          }
        }
      }
      if(black==k){ans++;}
    }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3632
h,w = gets.chomp.split(' ').map(&:to_i)

a = [''] * h
h.times { |y| a[y] = gets.chomp }

puts ('#' * (w + 2))
h.times do |y|
  puts ('#' + a[y] + '#')
end
puts ('#' * (w + 2))

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<pair<pair<string, ll>, ll>> d(N);
	for (ll i = 0; i < N; ++i)
	{
		cin >> d[i].first.first >> d[i].first.second;
		d[i].second = i + 1;
	}

	sort(d.begin(), d.end(), [](pair<pair<string, ll>, ll> const &lhs, pair<pair<string, ll>, ll> const &rhs)
	{
		const auto& lname = lhs.first.first;
		const auto& rname = rhs.first.first;
		if (lname != rname)
		{
			return lname < rname;
		}
		else
		{
			const auto& lval = lhs.first.second;
			const auto& rval = rhs.first.second;
			return lval > rval;
		}
	});

	for (const auto& e : d)
	{
		cout << e.second << endl;
	}

	//system("pause");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	map<string, int> table;

	string blood;
	char c;
	int num;
	while(cin >> num >> c >> blood){
		if(cin.eof()) break;
		if(table.count(blood)) table[blood]++;
		else table[blood] = 1;
	}
	cout << table["A"] << endl << table["B"] << endl << table["AB"] << endl << table["O"] << endl;
	return 0;
}

Measured memory_bytes: 1212
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    s = input()
    r = s[::-1]
    l = len(s)
    count = 0
    if l % 2 == 0:
        for i in range(l//2):
            if s[i] != r[i]:
                count += 1
        print(count)
        return
    for i in range(l//2 + 1):
        if s[i] != r[i]:
            count += 1
    print(count)
    

main()


Measured memory_bytes: 5076
#include<iostream>
using namespace std;
int a[50],n;
bool pd(int i,int k){
	if(k==0) return 1;
	if(i>=n) return 0;
	int res=pd(i+1,k)||pd(i+1,k-a[i]);
	return res;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int q,k;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>k;
		if(pd(0,k)) cout<<"yes"<<endl;
		else cout<<"no"<<endl; 
	} 
	return 0;
}



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



int main(){
	int a,b;
	cin >> a >> b;
	if(a==b) cout << a+b << endl;
	else if(a>=b+1) cout << a+a-1 << endl;
	else cout << b+b-1 << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	var n int
	fmt.Scanln(&n)

	var official_house [4][3][10]int

	for i := 0; i < n; i++ {
		scanner.Scan()
		string := scanner.Text()
		words := strings.Split(string, " ")

		b, _ := strconv.Atoi(words[0])
		f, _ := strconv.Atoi(words[1])
		r, _ := strconv.Atoi(words[2])
		v, _ := strconv.Atoi(words[3])

		official_house[b-1][f-1][r-1] += v
	}


	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 10; k++ {
				fmt.Printf(" %d", official_house[i][j][k])
			}
			fmt.Printf("\n")
		}
		if i < 3 {
			fmt.Printf("####################\n")
		}
	}
}



Measured memory_bytes: 1152
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

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


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

const int N = 2e5 + 5;
int a[N];

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

    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long long ans = 0;
    int mx = 0;
    for(int i = 0; i < n; i++)
    {
        mx = max(mx, a[i]);
        ans += mx - a[i];
    }
    cout << ans << '\n';



    return 0;
}



Measured memory_bytes: 4376
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		ll a[5];
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
		if (cin.fail()) break;

		ll result = 0;
		ll last = 0;
		for (ll i = 1; i < 5; i++) {
			if (a[i] % 10 != 0 && a[i] % 10 < a[last] % 10) last = i;
		}
		for (ll i = 0; i < 5; i++) {
			if (i == last) continue;
			result += (a[i] + 9) / 10;
		}
		cout << result * 10 + a[last] << endl;
	}

	return 0;
}


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

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

int main(){
    int H, W;
    cin >> H >> W;
    int N;
    cin >> N;
    //入力された回数分(a_i)だけ、iを追加する
    queue<int> q;
    for(int i = 1; i <= N; i++){
        int a;
        cin >> a;
        rep(j, a) q.push(i);
    }

    //色を塗るマス目の2次元配列
    vector<vector<int>> grid(H, vector<int>(W, 0));
    rep(i, H){
        //左から右に数字を追加していく
        if(i % 2 == 0){
            rep(j, W){
                grid[i][j] = q.front();
                q.pop();
            }
        }else{ //右から左に数字を追加していく
            for(int j = W-1; j >= 0; j--){
                grid[i][j] = q.front();
                q.pop();
            }
        }
    }

    rep(i, H){
        rep(j, W) cout << grid[i][j] << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
import sys
from fractions import gcd
input = sys.stdin.readline


def mod_inverse(n, mod=10**9+7):
    return pow(n, mod-2, mod)

    
def lcm(a, b):
    return a * b // gcd(a, b)


mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))

ans = 0
inv_sum = 0
l = A[0]
for a in A:
    l = lcm(l, a)
    inv_sum = (inv_sum + mod_inverse(a)) % mod
print(l * inv_sum % mod)


Measured memory_bytes: 6136
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root,*NIL;

void insert(int k);
void inorder(struct Node *n);
void preorder(struct Node *n);
struct Node *find(struct Node *n,int i);


int main(){

  int i,n,s;
  char code[10];
  struct Node *t;


  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%s",code);

    if(strcmp(code,"find") == 0){
      scanf("%d",&s);

      t = find(root,s);

      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }

    if(strcmp(code,"insert") == 0){
      scanf("%d",&s);
      insert(s);
    
    }

    else if(strcmp(code,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }

 
  }

  return 0;
}
      
    
void insert(int k){
  struct Node *b=NIL, *a = root, *c;

  c = malloc(sizeof(struct Node));
  c->key = k;
  c->right = NIL;
  c->left = NIL;

  while(a != NIL){

    b = a;
    
    if(c->key < a->key) a = a->left;

    else a = a->right;
  }

  c->parent = b;

  if(b == NIL)root = c;

  else{
    if(c->key < b->key) b->left = c;
    
    else b->right = c;
  }
  
}


void inorder(struct Node *n){
  if(n == NIL)return;

  inorder(n->left);

  printf(" %d",n->key);

  inorder(n->right);
}


void preorder(struct Node *n){

  if(n == NIL)return;

  printf(" %d",n->key);

  preorder(n->left);
  preorder(n->right);

}

struct Node *find(struct Node *n,int s){

   while(n != NIL && s != n->key){

     if(s < n->key)n = n->left;
     else n = n->right;
   }

   return n;
 }



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    unsigned long long int n;
    cin >> n;

    if(n == 2)
    {
        unsigned long long int x, y;
        cin >> x >> y;

        cout << max(x,y) << endl;
        return 0;
    }

    vector<unsigned long long int> v(n);

    for(unsigned long long int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    sort(v.begin(), v.end(), greater<unsigned long long int>());

    unsigned long long int counter = 0;
    unsigned long long int j = 1;

    counter += v[0];

    for(unsigned long long int i = 2; i < n; i++)
    {
        counter += v[j];
        i++;
        if(i < n)
        {
            counter += v[j];
        }
        j++;
    }

    cout << counter << endl;

}



Measured memory_bytes: 4764
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,sum,aum;
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	if(a%c==0){
		sum=a/c;
	}
	else{
		sum=a/c+1;
	}
	if(b%d==0){
		aum=b/d;
	}
	else{
		aum=b/d+1;
	}
	if(aum>sum){
		printf("%d\n",l-aum);
	}
	else{
		printf("%d\n",l-sum);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)
bool arr[21][21];
int n;
int dp[21][1<<21];
ll inline rec(int m,int f)
{
    if(m==-1) return 1;
    if(dp[m][f]==-1)
    {
        int i;
        dp[m][f]=0;
        rep(i,0,n)
        {
            if(arr[m][i] && (f&(1<<i)))
            {
                dp[m][f]+=rec(m-1,f^(1<<i));
                dp[m][f]%=mod;
            }
        }
    }
    return dp[m][f];
}

int main()
{
    int i,j,t;
   // boost;
    cin>>n;
    rep(i,0,n)
    {
        rep(j,0,n)
        {
            cin>>arr[i][j];
        }
    }
    rep(i,0,n)
    {
        rep(j,0,1<<21)
        {
            dp[i][j]=-1;
        }
    }
    int f=1<<n ;
    f--;
    cout<<rec(n-1,f);
    

    return 0;
}



Measured memory_bytes: 172416
#include<bits/stdc++.h>
using namespace std;
long long a[100001],b[100001];
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	int n,x,i,d;
	cin>>n;
	cin>>x;
	for(i=1;i<=n;i++){
		cin>>a[i];
		b[i]=abs(a[i]-x);
	}
	
	d=b[1];
	for(i=2;i<=n;i++){
		//cout<<d<<" "<<b[i];
		d=gcd(b[i],d);
		//cout<<" "<<d<<endl;
	}	
	cout<<d<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{

    int N, A, B;
    int ans=0;

    scanf("%d", &N);
    scanf("%d", &A);
    scanf("%d", &B);

    if(N<=0 || 20<N) return 0;
    if(A<=0 || 50<A) return 0;
    if(B<=0 || 50<B) return 0;

    ans=A*N;

    if(ans > B) ans=B; 

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
N = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'

_N = list(map(int, N.split(', ')))
K = int(input())
print(_N[K-1])


Measured memory_bytes: 2940
use std::io;
use std::io::{stdout, BufWriter, Write};

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let out = stdout();
    let mut writer = BufWriter::new(out.lock());
    solve(&mut writer);
    writer.flush().unwrap();
}

fn solve<W: Write>(mut writer: W) {
    #[allow(unused_macros)]
    macro_rules! print {
        ($fmt:expr) => {
            write!(writer, $fmt).unwrap()
        };
        ($fmt:expr, $($arg:tt)*) => {
            write!(writer, $fmt, $($arg)*).unwrap()
        };
    }
    #[allow(unused_macros)]
    macro_rules! println {
        ($fmt:expr) => {
            writeln!(writer, $fmt).unwrap()
        };
        ($fmt:expr, $($arg:tt)*) => {
            writeln!(writer, $fmt, $($arg)*).unwrap()
        };
    }

    // Main Code
    let x = read_vec::<usize>();
    let h = x[0];
    let w = x[1];
    let mut a = vec![vec![0; w]; h];
    let mut b = vec![vec![0; w]; h];
    for i in 0..h {
        let x = read_vec::<i32>();
        for j in 0..w {
            a[i][j] = x[j];
        }
    }
    for i in 0..h {
        let x = read_vec::<i32>();
        for j in 0..w {
            b[i][j] = x[j];
        }
    }
    let mut c = vec![vec![0; w]; h];
    for i in 0..h {
        for j in 0..w {
            c[i][j] = (a[i][j] - b[i][j]).abs() as usize;
        }
    }
    let size = 13000;
    let mut dp = vec![vec![vec![false; size]; w]; h];
    dp[0][0][c[0][0]] = true;
    for i in 0..h {
        for j in 0..w {
            for k in 0..size {
                if (i > 0 && dp[i - 1][j][k]) || (j > 0 && dp[i][j - 1][k]) {
                    if k >= c[i][j] {
                        dp[i][j][k-c[i][j]] = true;
                    }
                    if k + c[i][j] < size {
                        dp[i][j][k+c[i][j]] = true;
                    }
                    if c[i][j] >= k && c[i][j] - k < size {
                        dp[i][j][c[i][j] - k] = true;
                    }
                }
            }
        }
    }
    for i in 0..size {
        if dp[h - 1][w - 1][i] {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 96508
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll arr[5] = {};
ll A[100000] = {};

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

int main(void)
{

	ll a, b, c;
	cin >> a >> b >> c;

	if (c <= a + b) {
		puts("Yes");
	}
	else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
from math import factorial

N = int(input())
points = [tuple([int(x) for x in input().split()]) for _ in range(N)]

routes = permutations(range(N), r=N)

sum_dist = 0
for r in routes:
    for i in range(N - 1):
        (x_0, y_0), (x_1, y_1) = points[r[i]], points[r[i + 1]]
        sum_dist += ((x_0 - x_1)**2 + (y_0 - y_1)**2)**0.5

print(sum_dist / factorial(N))


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

int main()
{
  uint64_t n;
  cin >> n;
  uint64_t ans = 0;
  vector<uint64_t> primes;

  for (uint64_t i = 2; i <= 1'000'000; i++) {
    if (i * i > n) break;
    bool f = true;
    for (uint64_t p : primes) {
      if (p * p > i) break;
      if (i % p == 0) {
        f = false;
        break;
      }
    }
    if (f) {
      primes.push_back(i);
    }
  }

  for (uint64_t p : primes) {
    if (p * p > n) break;
    for (uint64_t x = p; x <= n; x *= p) {
      if (n % x == 0) {
        n /= x;
        ans++;
      }
    }
    while (n % p == 0) {
      n /= p;
    }
  }

  if (n > 1) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 4316
(n, m, l) = [int(i) for i in input().split()]

A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])

B = []
for mc in range(m):
    B.append([int(i) for i in input().split()])

product = [[0 for d in range(l)] for dd in range(n)]

for nc in range(n):
    for lc in range(l):
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc]
        
for r in product:
    print(' '.join([str(d) for d in r]))

Measured memory_bytes: 7760
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    S[K-1] = S[K-1] - 'A' + 'a';
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#define N 110
#define M 1000

int main(void){
  int i,num,j,k;
  char ch[N],ach[M];

  for(i=0;scanf("%c",&ch[i])==1;i++){}
  num=i;
  for(i=0,j=0;i<num;i++){
    if(ch[i]=='@'){
      for(k=j;k<j+ch[i+1]-'0';k++){
        ach[k]=ch[i+2];
      }
      j+=ch[i+1]-'0';
      i+=2;
    }else{
      ach[j]=ch[i];
      j++;
    }
  }
  for(i=0;i<j;i++){
    printf("%c",ach[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
    int a[3];
    int temp;
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    if(a[0]>a[1]){
        temp=a[0];
        a[0]=a[1];
        a[1]=temp;
    }
    if(a[1]>a[2]){
        temp=a[1];
        a[1]=a[2];
        a[2]=temp;
    }
    if(a[0]>a[1]){
        temp=a[0];
        a[0]=a[1];
        a[1]=temp;
    } 
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    
}


Measured memory_bytes: 3120
from collections import defaultdict

n=int(input())
a=[int(_) for _ in input().split()]
q=int(input())
dic=defaultdict(lambda :0 )
for i in a:
    dic[i]+=1
ans = sum(a)
for i in range(q):
    b,c=[int(_) for _ in input().split()]
    ans +=(c-b)*dic[b]
    print(ans)
    dic[c]+=dic[b]
    dic[b]=0

Measured memory_bytes: 24132
#define REP(i, n) for (int i = 0; i < (n); i++)
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;

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

  ll delta = b - a;
  bool flag = false;
  REP(i, n - 1) {
    ll min_ = i * c - (n - 1 - i) * d;
    ll max_ = -(n - 1 - i) * c + d * i;
    if (min_ <= b - a && b - a <= max_) {
      flag = true;
      break;
    }
  }
  cout << ((flag) ? "YES" : "NO") << endl;

  return 0;
}

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


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];

            wr.wri(n / 3);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n; cin>>n;

    ll p = 1;
    vector<ll> a(n);

    int z = 0;
    for(int i = 0; i < n; i++){
        cin>>a[i];
        if(a[i] == 0)z++;
    }

    if(z > 0){
        cout<<0<<"\n";
        return 0;
    }

    for(int i = 0; i < n; i++){
         if(p > (ll)1e18/a[i]){
            cout<<-1<<"\n";
            return 0;
        }
        p *= a[i];       
    }
 
    cout<<p<<"\n";






}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back

int mod=1e9+7;

int32_t main() {
    int n,m;
    cin>>n>>m;

    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

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

using namespace std;

typedef long long  ll;

typedef double Weight;
const Weight INF = 1e9;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int f, int t, Weight c) :
        src(f), dst(t), weight(c) {}
};
bool operator<(const Edge &a, const Edge &b) {
    return a.weight != b.weight ? a.weight > b.weight :
        a.src != b.src ? a.src < b.src : a.dst < b.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

Weight Prim(const Graph &g, int r = 0) {
    int n = g.size();
    Edges T;
    Weight total = 0;

    vector<bool> visited(n);
    priority_queue<Edge> que;
    que.push(Edge(-1, r, 0));

    while (!que.empty()) {
        Edge e = que.top();  que.pop();
        if (visited[e.dst])
            continue;
        T.push_back(e);
        total += e.weight;
        visited[e.dst] = true;
        for (auto f = g[e.dst].begin(); f != g[e.dst].end(); ++f)
            if (!visited[f->dst])
                que.push(*f);
    }

    return total;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(3) << setiosflags(ios::fixed); // printf("%.4f", x);

    int n;

    while (cin >> n, n) {
        vector<double> x(n), y(n), z(n), r(n);

        for (int i = 0; i < n; ++i)
            cin >> x[i] >> y[i] >> z[i] >> r[i];

        Graph g(n);
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j) {
                double d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])
                    + (z[i] - z[j]) * (z[i] - z[j]);

                if (d <= (r[i] + r[j]) * (r[i] + r[j]))
                    d = 0.0;
                else
                    d = sqrt(d) - r[i] - r[j];

                g[i].push_back(Edge(i, j, d));
                g[j].push_back(Edge(j, i, d));
            }

        cout << Prim(g) << endl;
    }

    return 0;
}

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

bool isPalindrom(string s) {
	if (s == string(s.rbegin(), s.rend())) {
		return true;
	}
	else return false;
	
}

int main() {
	string s;
	cin >> s;
	int len = s.length();
	
	string s1(s.begin(), s.begin()+(len-1)/2);
	string s2(s.begin()+(len+3-1)/2, s.end());
	
	
	if(isPalindrom(s) && isPalindrom(s1) && isPalindrom(s2)) {
		cout << "Yes" << endl;
	}
	
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import queue

k = int(input())
q = queue.Queue()
for l in range(10)[1:]:
    q.put(l)
if k < 10:
    print(q.queue[k-1])
    exit()
k -= 9
for l in range(k):
    dequeued = q.get()
    mod = dequeued % 10
    if mod != 0:
        q.put(dequeued * 10 + mod - 1)
    q.put(dequeued * 10 + mod)
    if mod != 9:
        q.put(dequeued * 10 + mod + 1)
print(q.queue[8])

Measured memory_bytes: 12480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  vector<int> edge(3);
  scanf("%d",&n);
  for(int i=0;i<n;++i){
    scanf("%d %d %d",&edge[0],&edge[1],&edge[2]);
    sort(edge.begin(),edge.end());
    printf("%s\n",edge[0]*edge[0]+edge[1]*edge[1]==edge[2]*edge[2] ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 3128
import java.io.*
import java.util.*

fun solve(N: Long, d: LongArray){
    println(d.distinct().size)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val d = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        d[i] = sc.next().toLong()
    }
    solve(N, d)
}



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

int main(){
    
    ll ans = 1145141919;
    ll N;
    cin >> N;
    vector<ll>vec(N, 0);
    for(ll i = 0; i < N; i++)cin >> vec[i];
    for(ll i = 0; i + 1 < N; i++){
        ll a = 0, b = 0;
        for(ll j = 0; j < N; j++){
            if(j <= i)a += vec[j];
            else b += vec[j];
        }
        ans = min(ans, abs(a - b));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <stdio.h>
 
int i, t, y = 1, d[10000] = {1};
long long r;
char s[200002];
 
int main(n, p) {
  assert(scanf("%d%d%s", &n, &p, s + 1) == 3);
  if (10 % p == 0) {
    while(i++<n) {
      if((s[i] - '0') % p == 0)
        r += i;
    }
  }
  else {
    for(; n; n--) {
      t = (t + (s[n] - '0') * y) % p;
      d[t]++;
      y = y * 10 % p;
    }
    for(i = 0; i < p; i++)
      r += (long long) d[i] * (d[i] - 1);
    r /= 2;
  }
  printf("%lld\n", r);
  return 0;
}


Measured memory_bytes: 384