akhauriyash/Code-Regression huggingface dataset:
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s;
  int c = 0;
  cin >> s;
  for (int i = 0; i < (s.size())/2; ++i)
  {
    if(s[i] != s[s.size() - i-1])
      c++;
  }
  cout << c << endl;
  return 0;
} 

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

typedef long long ll;

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()


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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    cout << a[n-1]-a[0] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll dp[20010][260];

int main() {
    while (1) {
        int N, M;
        cin >> N >> M;
        if (N == 0) {
            break;
        }
        int c[M];
        for (int i = 0; i < M; i++) {
            cin >> c[i];
        }
        int x[N];
        for (int i = 0; i < N; i++) {
            cin >> x[i];
        }
        for (int i = 0; i < N + 10; i++) {
            fill(dp[i], dp[i] + 260, inf);
        }
        dp[0][128] = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <=255; j++) {
                if (dp[i][j] != inf) {
                    for (int k = 0; k < M; k++) {
                        int num = j + c[k];
                        num = min(num, 255);
                        num = max(num, 0);
                        dp[i + 1][num] = min(dp[i + 1][num], dp[i][j] + (num - x[i]) * (num - x[i]));
                    }
                }
            }
        }
        ll ans = inf;
        for (int i = 0; i <= 255; i++) {
            ans = min(ans, dp[N][i]);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 43776
a = [list(map(int, input().split())) for _ in range(3)]

n = int(input())
b = [int(input()) for _ in range(n)]
c = [[0, 0, 0] for _ in range(3)]
for k in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[k]:
                c[i][j] = 1

ans = False
if c[0][0] and c[1][1] and c[2][2]:
    ans = True
if c[0][2] and c[1][1] and c[2][0]:
    ans = True
for i in range(3):
    if c[i][0] and c[i][1] and c[i][2]:
        ans = True
    if c[0][i] and c[1][i] and c[2][i]:
        ans = True

if ans:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

const int NODE = 51;
const int INF = (1<<25);

int CHOT[NODE][NODE]; // cost from hot springs to districts
int CDIS[NODE][NODE]; // cost between districts
int S,D;
int mincos[NODE];

void input(){
  fill(mincos,mincos+NODE,INF);

  for(int i = 0; i < S; i++)
    for(int j = 0; j < D; j++) {
      cin >> CHOT[i][j];
      if(CHOT[i][j] == 0) CHOT[i][j] = INF;
      mincos[j] = min(mincos[j],CHOT[i][j]);
    }

  for(int i = 0; i < D; i++)
    for(int j = 1; j < D-i; j++){
      int in;
      cin >> in;
      if(in == 0) CDIS[i][i+j] = CDIS[i+j][i] = INF;
      else CDIS[i][i+j] = CDIS[i+j][i] = in;
    }
}

void prim(){
  bool used[NODE];
  memset(used,false,sizeof(used));

  int res = 0;
  while(1){
    int v = -1;
    
    for(int i = 0; i < D; i++)
      if(!used[i] && (v == -1 || mincos[i] < mincos[v])) v = i;

    //   cout << "v " << v << endl;
    if(v == -1) break;
    used[v] = true;
    res += mincos[v];

    for(int i = 0; i < D; i++)
      mincos[i] = min(mincos[i],CDIS[v][i]);
  }
  cout << res << endl;
}

int main(){

  while(cin >> S >> D && S+D){
    input();
    prim();
  }
  
  return 0;
}

Measured memory_bytes: 1172
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var tr, hr int
	for i := 0; i < n; i++ {
		var ts, hs string
		fmt.Scan(&ts, &hs)

		switch {
		case ts == hs:
			tr++
			hr++
		case ts < hs:
			hr += 3
		case ts > hs:
			tr += 3
		default:
			panic("cant compare")
		}
	}

	fmt.Println(tr, hr)
}



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

int main() {
	int K,N;
  	cin>> K >> N;
  	int A[N];
    int B[N];
  	int sum=0,m=0;
  	long long int min=100000000000;
  
  	for(int i=0;i<N;i++){
     	cin>>A[i]; 
    }
  
  	sort(A,A+N);
  
  	B[0]=K+A[0]-A[N-1];
  	for(int i=1;i<N;i++){
     	B[i]=A[i]-A[i-1];
       	sum+=B[i];
        m=max(m,B[i]);
    }
  
  	m=max(m,B[0]);
    sum+=B[0];
  	
  cout<<sum-m<<endl;
  
}

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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 1e6+5;
int cnt[N];

void solve(){
    
    int n; cin >> n;
    memset(cnt, 0, sizeof(cnt));
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int val = x * x + y * y + z *z + x * y + y * z + x * z;
                cnt[val]++;
            }
        }
    }
    for(int i = 1; i <= n; i++)
        cout << cnt[i] << '\n';
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

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

int main(){
	int A, B, C, D, T;
	cin >> A >> B >> C >> D;
	
	T = min(B,D) - max(A, C);
	if(T<0)	cout << "0" << endl;
	else	cout << T << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld",i)
#define fendl printf("\n")
//Library-End

int n,k,a[100004],ans,cnt[40],ta;
priority_queue<pair<int, int>> q;
signed main() {
    cin>>n>>k;
    rep(i,n){
        fin(a[i]);
        rep(j,41){
            if (a[i]&(1ll<<j)) {
                cnt[j]++;
            }
        }
    }
    rep(i,41){
        if ((cnt[i])<(n-cnt[i])) {
            q.push({(1ll<<i)*(n-cnt[i]),i});
        }
    }
    while (q.size()) {
        if (ans+(1ll<<q.top().second)<=k) {
            ans+=(1ll<<q.top().second);
        }
        q.pop();
    }
    rep(i,n){
        ta+=a[i]^ans;
    }
    cout<<ta<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
void solve(){
	if(n == 1){
		cout << 1 << endl;
	}
	else if(n & 1){
		printf("%.12lf",1.0*(n/2+1)/n);
	}
	else{
		printf("%.12lf",0.5);
	}
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <bits/stdc++.h>
#define PI acos(-1)
#define fs first
#define sc second
#define debug freopen("1.in","r",stdin),freopen("1.out","w",stdout);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll maxn = 1e4 + 10;
const ll mod = 998244353;

string s[maxn];
int n, l, ans = 0, cnt[5];

int main(){
    ios;
    cin >> n;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i ++) {
        cin >> s[i];
        l = s[i].size();
        for (int j = 1; j < l; j++)
            if (s[i][j - 1] == 'A' && s[i][j] == 'B')
                ans++;
        if (s[i][0] == 'B')
            cnt[1]++;
        if (s[i][l - 1] == 'A')
            cnt[2]++;
        if (s[i][0] == 'B' && s[i][l - 1] == 'A')
            cnt[0]++;
    }
    int tmp = min (cnt[1], cnt[2]);
    ans += tmp;
    if(cnt[0] != 0 && cnt[0] == cnt[1] && cnt[0] == cnt[2])
        ans --;
    cout << ans;

    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;
int H,W;
int S[1111][1111];

int memo[1111][1111];

int dfs(int y,int x){
    int &ret=memo[y][x];
    if(y==H&&x==W)return 0;
    if(ret!=INF)return ret;

    int t=(y+x)&1;
    if(t==0){
        ret=-INF;
        if(y!=H)chmax(ret,dfs(y+1,x));
        if(x!=W)chmax(ret,dfs(y,x+1)+S[y][x]);
    }
    else{
        ret=INF;
        if(y!=H)chmin(ret,dfs(y+1,x));
        if(x!=W)chmin(ret,dfs(y,x+1)+S[y][x]);
    }
    return ret;
}

signed main(){
    scanf("%lld%lld",&W,&H);
    rep(i,H)rep(j,W)scanf("%lld",&S[i+1][j]),S[i+1][j]+=S[i][j];

    fill_n(*memo,1111*1111,INF);
    int sum=0;
    rep(i,W)sum+=S[H][i];
    cout<<abs(sum-2*dfs(0,0))<<endl;
    return 0;
}

Measured memory_bytes: 21492
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() { 
  int a,b;cin>>a>>b;
  print(6 - a - b);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    sll arr;
    for(i=0;i<3;i++){cin>>v;arr.insert(v);}
    cout<<arr.size();
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = -A[i]
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)*(-1)
    if a ==0:#最大値が0になったら終了
        break
    a//=2
    heapq.heappush(A, -a)
print(-sum(A))

Measured memory_bytes: 86152
#include <iostream>
using namespace std;
int main()
{
	char sh[10];
	int s=0;
	scanf("%s",sh);
	for(int i=0;sh[i]!='\0';i++)
	{
		if(sh[i]=='1')s++;
	} 
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int mx6[] = {1,0,-1,1,-1,0};
int my6[] = {1,1,1,0,0,-1};

int main(){
    int x,n; cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    int X = x,ans1 = 100000,ans2=100000;

    bool ok;
    while(X>-200){
        ok = false;
        for(int i = n-1; i >= 0;i--){
            if(p[i] == X){
                ok = true;
                break;
            }
        }if(!ok){
            ans1 = X;
            break;
        }
        X--;
    }
    X = x;
    while(X<=200){
        ok = false;
        for(int i = 0; i < n;i++){
            if(p[i] == X){
                ok = true;
                break;
            }
        }if(!ok){
            ans2 = X;
            break;
        }
        X++;
    }
    if(abs(x-ans1) <= abs(x-ans2)){
        cout << ans1 << endl;
    }else cout << ans2 << endl;
  //cout << ans2 << endl;

}



Measured memory_bytes: 3636
object Main extends App {
  val src = io.Source.stdin.getLines.toList.map(_.toInt)

  def checkComb(n: Int): IndexedSeq[Int] =
    for {
      a <- 0 to 9
      b <- 0 to 9
      c <- 0 to 9
      d <- 0 to 9
      if a + b + c + d == n
    } yield n

  for (i <- src) println(checkComb(i).length)
}

Measured memory_bytes: 75156
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b, c] <- map BS.unpack . BS.split ',' <$> BS.getLine
  putStrLn $ a ++ " " ++ b ++ " " ++ c

  

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

using namespace std;

int a[100005] , n , m , d[100005] , k;

int main()
{
    int s;
    cin >> m >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i];
    sort(a + 1 , a + n + 1);
    k = 0;
    for(int i = 2 ; i <= n ; i++)
        d[++k] = a[i] - a[i - 1];
    sort(d + 1 , d + k + 1 , greater < int > ());
    s = a[n] - a[1];
    for(int i = 1 ; i <= min(n - 1 , m - 1) ; i++)
        s -= d[i];
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
bool seen[20][20];
int Gc[20][20];
int h,w;
//4方向ベクトル
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
typedef pair<int,int> P;


int dfs(const string G[],int sx,int sy){
   queue<P> q;
   q.push(P(sx,sy));
   seen[sy][sx] = true;
   int MAX=0;
   while(true){
      int x=q.front().first;
      int y=q.front().second;
      //cout << x << " " <<y<<endl;
      q.pop();
      for(int i=0;i<4;i++){
         int nx=x+dx[i];
         int ny=y+dy[i];
         //cout << nx<<" "<<ny<<endl;
         
         if(nx<0||nx>=w||ny<0||ny>=h) continue;//順番を間違えるとseen[-1][]などはcore dumped
         if(seen[ny][nx]) continue;
         if(G[ny][nx] == '#') continue;

         Gc[ny][nx] = 1 + Gc[y][x];
         if(MAX < Gc[ny][nx]) MAX =Gc[ny][nx];
         seen[ny][nx] = true;
         q.push(P(nx,ny));
      }

      //cout <<"SIZE IS "<<q.size()<<endl;
      if(q.size() == 0) break;
   }

   return MAX;
}
  


int main(){
 cin >> h >>w;
 string G[h]; 
 for(int i=0;i<h;i++) cin >> G[i];
 int MAX=0;

 for(int i=0;i<h;i++){
    for(int k=0;k<w;k++){
       if(G[i][k]== '#') continue;
       memset(Gc,0,sizeof(Gc));
       memset(seen,false,sizeof(seen));
       int d= dfs(G,k,i);
       if(d > MAX)MAX =d;
    }
 }

 cout << MAX <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N; cin >> N;
    vector<long long > a(N);
    for (int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    
    long long sum = 0;
    int ans = 0;
    for (int i=0; i<N; i++){
        if (2 * sum < a[i]){
            ans = i;
        }
        sum += a[i];
    }

    cout << N - ans  << endl;
    
}
    


Measured memory_bytes: 4032
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.NoSuchElementException;
public class Main {
	private static final PrintStream ps = System.out;
	private static final InputStream IS = System.in;
	private static final byte[] BUFFER = new byte[1024];
	private static int ptr = 0;
	private static int buflen = 0;

	public static void main(String[] args) {
		int n = ni();
		char[] c = n().toCharArray();
//		char[] c2 = n().toCharArray();
		
		if (n == 1) {
			ps.println(3);
			return;
		}
		
		boolean b = c[0] == c[1]; // 横置きかどうか
		long p = (b ? 6 : 3);
		int i = (b ? 2 : 1);
		while (i < n) {
			boolean b2 = i == n-1 ? false : c[i] == c[i+1];
			p *= ( b &&  b2 ? 3 : 
				   b && !b2 ? 1 : 2);
			
			i += b2 ? 2 : 1;
			b = b2;
			p = p % 1000000007;
		}
		ps.println(p);
	}

	private static boolean hasNextByte() {
		if (ptr < buflen)
			return true;
		else {
			ptr = 0;
			try {
				buflen = IS.read(BUFFER);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0)
				return false;
		}
		return true;
	}

	private static int readByte() {
		if (hasNextByte())
			return BUFFER[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public static boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(BUFFER[ptr]))
			ptr++;
		return hasNextByte();
	}

	public static String n() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public static long nl() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b)
			throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b))
				return minus ? -n : n;
			else
				throw new NumberFormatException();
			b = readByte();
		}
	}

	public static int ni() {
		long nl = nl();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public static double nextDouble() {
		return Double.parseDouble(n());
	}

	private static int[] nia(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

vi arr; 
int k;
void in(){
    rep(i,0,5) arr.push_back(input());
    k = input();
}

void solve(){


    bool isok = true;
    rep(i,0,5){
        rep(j,0,5){
            if(abs(arr[i] - arr[j]) > k) isok = false;
        }
    }

    if(isok){
        print("Yay!");
    }else{
        print(":(");
    }
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int x, ll int y){
	ll int jhogeo = 1;
	rep(jinto,0,y) jhogeo=jhogeo*x;
	return jhogeo;
}


int main(){
int N;
char a,b;
  cin>>a>>b;
  if(a==b) cout<<"H";
  else cout<<"D";
      
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <stdio.h>

main(){
  int count1=0,count2=0,a,b,c;

  while(1){
    if(scanf("%d,%d,%d", &a, &b, &c)==EOF) break;

    if(a*a+b*b==c*c) count1++;
    if(a==b) count2++;
  }
  printf("%d\n%d\n", count1,count2);
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void)
{
	int i,n,cnt,mi,ii;
	double x[100],y[100],x0,y0,x1,y1,mx,x2,y2,kos,mkos;
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			scanf("%lf,%lf",&x[i],&y[i]);
		}
		mx=999.0;
		for(i=0;i<n;i++)	{
			if(mx>x[i])	{
				mx=x[i];	mi=i;
			}
		}
		cnt=1;
		x0=x[mi];	y0=y[mi]+1.0;	x1=x[mi];	y1=y[mi];	ii=mi;
		while(1)	{
//			printf("x1=%lf y1=%lf\n",x1,y1);
			mkos=2.0;
			for(i=0;i<n;i++)	{
				if(i!=ii)	{
					x2=x[i];	y2=y[i];
					kos=((double)(x0-x1)*(x2-x1)+(double)(y0-y1)*(y2-y1))/
					(sqrt((double)(x0-x1)*(x0-x1)+(double)(y0-y1)*(y0-y1))*
					 sqrt((double)(x2-x1)*(x2-x1)+(double)(y2-y1)*(y2-y1)));
					if(mkos>kos)	{
						mkos=kos;
						ii=i;
					}
				}
			}
			if(mi==ii)	break;
			x0=x1;	y0=y1;	x1=x[ii];	y1=y[ii];
			cnt++;
		}	
		printf("%d\n",n-cnt);
	}
	return 0;
}


Measured memory_bytes: 2576
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
v = list(map(int, input().split()))

odd = v[::-2]
even = v[::2]
#一個飛ばしもこうすれば簡単に書ける

o_elm = Counter(odd).most_common(2)+[(0,0)]
e_elm = Counter(even).most_common(2)+[(0,0)]
if o_elm[0][0]==e_elm[0][0]:
  print(N -max(o_elm[0][1]+e_elm[1][1], o_elm[1][1]+e_elm[0][1]))
else:
  print(N -o_elm[0][1] -e_elm[0][1])

Measured memory_bytes: 23448
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		string s,t;
		cin>>s>>t;
		int n=s.size();
		bool f=1;
		FOR(i,0,n)
		{
			if(s[i]!=t[i])
			{
				f=0;
				break;
			}
		}
		if(f)
		{
			cout<<"Yes";
		}
		else
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    vi  c(26);
    REP(i, 26) cin >> c[i];
    vvl s(d, vl(26));
    REP(i, d) REP(j, 26) cin >> s[i][j];

    vi last(26);
    ll ans = 0;
    vi a(d);
    REP(i, d) {
        ll ans2 = -LINF;
        ll ans_i = -1;
        REP(x, 26) {
            ll tmp = s[i][x];
            REP(j, 26) {
                if (x != j) tmp -= c[j] * ((i + 1) - last[j]);
            }
            if (chmax(ans2, tmp)) ans_i = x;
        }
        last[ans_i] = i + 1;
        ans += ans2;
        // cout << ans_i + 1 << endl;
        a[i] = ans_i + 1;
    }
    mt19937 mt{ random_device{}() };
    uniform_int_distribution<int> dist_d(1, d);
    uniform_int_distribution<int> dist_c(1, 10);
    REP(_, 200000) {
        vi lst(26);
        ll ans_n = 0;
        int x = dist_d(mt);
        int y = dist_c(mt);
        int x2 = x + (x + 10 > d ? -y : y);
        swap(a[x - 1], a[x2 - 1]);
        REP(i, d) {
            int t = a[i];
            ans_n += s[i][t - 1];
            lst[t - 1] = i + 1;
            REP(j, 26) if (t - 1 != j) ans_n -= c[j] * ((i + 1) - lst[j]);
        }

        if (ans_n > ans) {
            ans = ans_n;
        } else {
            swap(a[x - 1], a[x2 - 1]);
        }
    }
    printlnv(a);
}


Measured memory_bytes: 3744
def f(a):
	s=0;q=[]
	for i in range(n):s+=a[i];heappush(q,a[i])
	r=[s]
	for i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s]
	return r
import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(map(sum,zip(f(a),list(reversed(f(list(reversed([-e for e in a])))))))))

Measured memory_bytes: 127704
from numba import njit
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

@njit
def main(N):
    ans = N * (N + 1) // 2

    for n in range(1,N+1):
        for i in range(2*n, N+1, n):
            ans += i

    print(ans)


if __name__ == "__main__":
    N = int(readline())
    main(N)


Measured memory_bytes: 109412
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack> 
#include <set>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;
const int INF = 1000000002;
const int mod = 1000000007;

#define N 100010

int a[N], pre[N], pw[N], ans[N];
int fac[N], fac_inv[N], inv[N];


int C(int n, int m)
{
	if (m == 0) return 1;
	if (n == 0) return 0;
	if (n < m) return 0;

	int ans = 1ll * fac[n] * fac_inv[m] % mod;
	ans = 1ll * ans * fac_inv[n - m] % mod;
	return ans;
}

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
	
	pw[0] = 1;
	for (int i = 1; i < N; ++i) pw[i] = pw[i - 1] * 2 % mod;
	fac[0] = fac_inv[0] = fac[1] = fac_inv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < N; ++i) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i < N; ++i) 
	{
		fac[i] = 1ll * fac[i - 1] * i % mod;
		fac_inv[i] = 1ll * fac_inv[i - 1] * inv[i] % mod;
		//if (i <= 5) cout << fac[i] << " " << fac_inv[i] << endl;
	}

	int n, l, r;
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; ++i)
	{
		scanf("%d", &a[i]);	
		if (pre[a[i]]) r = i, l = pre[a[i]];
		pre[a[i]] = i;
	}
	l = l - 1, r = n + 1 - r;
	ans[1] = n;
	//cout << C(n + 1, 11) <<endl;
	for (int k = 2; k <= n + 1; ++k)
	{
		ans[k] = C(n + 1, k) - C(l + r, k - 1);
		if (ans[k] < 0) ans[k] += mod;
	}
	for (int i = 1; i <= n + 1; ++i)
		printf("%d\n", ans[i]);



	return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i,B,W,L,mini;
  B=0;
  W=0;
  L=0;
  cin>>N;
  string S;
  cin>>S;

  for(i=0;i<N;i++){
     
   if(S.at(N-i-1)=='.'){
     W++;
   }else{
   B++;
   }

 }
  mini=W;
     for(i=0;i<N;i++){
   if(S.at(i)=='.'){
     W--;
     if(mini>W){
     mini=W;
     }
   }else{
   W++;
   }

 }
  L=min(B,mini);
  
  cout<<L<<endl;
  
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INF (1<<30)
using namespace std;

/* references <https://en.wikipedia.org/wiki/Levenshtein_distance> */
int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	string s1, s2; cin >> s1 >> s2;
	vector<vector<int>> dp(s1.length() + 1, vector<int>(s2.length() + 1));

	//	initialize
	dp[0][0] = 0;
	for (int i = 1; i <= s1.length();i++) dp[i][0] = i;
	for (int i = 1; i <= s2.length();i++) dp[0][i] = i;

	int cost;
	for (int i = 1;i <= s1.length();i++) {
		for (int j = 1;j <= s2.length();j++) {
			if (s1[i - 1] == s2[j - 1])	cost = 0;
			else cost = 1;
			dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1);
			dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + cost);
		}
	}
	cout << dp[s1.length()][s2.length()] << endl;
}

Measured memory_bytes: 6784
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
constexpr int INF = 1 << 30;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

int dfs(VI &memo, VI&a, VI &need, int n) {
    if (n < 0) return -INF;
    if (n == 0) return 0;
    if (memo[n] != 0) return memo[n];
    int ret = -INF;
    for (auto i: a) {
        if (n - need[i] >= 0) ret = max(ret, dfs(memo, a, need, n - need[i]) + 1);
    }
    return memo[n] = ret;
}

void solve() {
    int n,m;
    cin >> n >> m;
    VI a(m);
    REP(i,0,m) cin >> a[i];
    // 1,7,4,2,3,5,6,9,8
    VI need = {-1,2,5,5,4,5,6,3,7,6};
    sort(all(a), [&need](auto &l, auto &r) {
        return need[l] == need[r] ? l > r : need[l] < need[r];
    });
    VI memo(n+1);
    int len = dfs(memo, a, need, n);
    sort(all(a));
    reverse(all(a));
    //REP(i,0,m) cerr << a[i] << endl;
    //REP(i,0,n+1) cerr << i << " " << memo[i] << endl;
    while (n > 0) {
        //cerr << n << endl;
        for (auto &i: a) {
            if (n - need[i] >= 0 && memo[n - need[i]] == len - 1) {
                cout << i;
                --len;
                n -= need[i];
                break;
            }
        }
    }
    cout << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 640
S = input()
T = input()
N = len(S)
 
d = {chr(i):chr(i) for i in range(97,97+26)}
 
ans = 'Yes'
for i in range(N):
    now_si = d[S[i]]
    for k,v in d.items():
        if v == now_si:
            d[k] = T[i]
        elif v == T[i]:
            d[k] = now_si
 
for i in range(N):
    if d[S[i]] != T[i]:
        ans = 'No'
        break
 
 
print(ans)

Measured memory_bytes: 3632
#include<stdio.h>
signed main(){
  int x,n,p[105];
  scanf("%d %d",&x,&n);
  int i;
  for(i=0;i<n;i++){
  scanf("%d",&p[i]);
  }
  int flog[105]={};
  int ans=0;
  for(i=0;i<n;i++){
    flog[p[i]]=1;
  }
for(i=1;i<=101;i++){
  if(flog[i]==0){
    int ans1,ans2;
    ans1=x-ans;
    ans2=x-i;
    if(ans1<0){
      ans1=ans1*-1;
    }
    if(ans2<0){
      ans2=ans2*-1; 
    }
    if(ans1>ans2){
      ans=i;
    }
  }
}
printf("%d\n",ans);
return(0);
}

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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  int N, T;
  cin >> N >> T;
  Int ans = 0;
  Int begin = 0;
  Int end = 0;
  for (int i = 0; i < N; ++i) {
    int t;
    cin >> t;
    if (t < end) {
      end = t + T;
    }
    else {
      ans += end - begin;
      begin = t;
      end = t + T;
    }
  }
  ans += end - begin;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#include<limits>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    ll h,h2,count,ans=0;
    cin>>h;
    vector<ll> a;
    ll t = 1;
    ll o = 2;
    //cout << log2(h) << endl;
    while(t<h){
        t += o;
        o *= 2;
    }

    //ans = (log2(h)*(2 + (log2(h) - 1) * 2)) / 2;
    //cout << ans << endl;
    //pow(2, log2(h)) - 1;
    //cout<< (ll)(pow(2, log2(h)) + log2(h)) << endl;
    cout << t << endl;
    //cout << (ll)(ans + log(h)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
/*char __wzp[1<<15|1],*__S=__wzp+32768;
#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))*/
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
const int Mod =1e9+7;
const int maxn = 205050;
int n,A[maxn],B[maxn],f[4005][4005];
int fac[8005],inv[8005];
int C(int n,int m){
//	printf("(%d %d) = %d\n",n,m,1ll * fac[n] * inv[m] % Mod * inv[n-m] % Mod);
	return 1ll * fac[n] * inv[m] % Mod * inv[n-m] % Mod;
}
int qpow(int a,int b){
	int ans = 1;
	for(;b;b>>=1,a=1ll*a*a%Mod){
		if(b&1) ans = 1ll*ans*a%Mod;
	}return ans;
}
int main(){
	n = rd();
	fac[0] = 1;
	Rep(i,1,8001) fac[i] = 1ll * fac[i-1] * i % Mod;
	inv[8001] = qpow(fac[8001],Mod-2);
	Dep(i,8000,0) inv[i] = 1ll * inv[i+1] * (i+1) % Mod;
	Rep(i,1,n){
		A[i] = rd(),B[i] = rd();
		f[-A[i]+2000][-B[i]+2000]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++){
			if(j) f[i][j] = (f[i][j] + f[i][j-1]) % Mod;
			if(i) f[i][j] = (f[i][j] + f[i-1][j]) % Mod;
		}
	int ans = 0;
	Rep(i,1,n){
		ans = (ans + f[A[i]+2000][B[i]+2000]) % Mod;
		ans = (ans - C(A[i]+A[i]+B[i]+B[i],A[i]+A[i]) + Mod) % Mod;
	}
	writeln(1ll*ans*inv[2]%Mod);
	return 0;
}

Measured memory_bytes: 64512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int r, c, h, w; cin >> r >> c >> h >> w;
  if (!(r % h) and !(c % w)) cout << "No" << '\n';
  else {
    cout << "Yes" << '\n';
    for (int i = 0; i < r; i++) for (int j = 0; j < c; j++) cout << (i % h == h - 1 and j % w == w - 1 ? -(1000 * (h * w - 1) + 1) : 1000) << (j != c - 1 ? ' ' : '\n');
  }
}

Measured memory_bytes: 1536
#include <cstdio>
#include <set>

int main()
{
  std::set<int> s;
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  s.insert(a);
  s.insert(b);
  s.insert(c);
  printf("%d\n", s.size());
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end() );
	ll sum = 0;
	for( auto &k : a ){
		sum += abs(k);
	}
	bool same = true;
	if( a.front() * a.back() < 0 ) same = false;
	if( same ){
		if( a[0] < 0 ) reverse( a.begin(), a.end() );
		sum -= 2*abs(a.front());
	}
	cout << sum << endl;
	if( same ){
		if( n == 2 ){
			int x = a[0], y = a[1];
			if( x < y ) swap(x, y);
			cout << x << ' ' << y << endl;
			return 0;
		}
		ll cur = 0;
		cout << a[0] << ' ' << a[1] << endl;
		cur = a[0]-a[1];
		for( ll i = 2; i < n-1; ++i ){
			cout << cur << ' ' << a[i] << endl;
			cur -= a[i];
		}
		if( a[n-1] < cur ){
			cout << cur << ' ' << a[n-1] << endl;
		} else {
			cout << a[n-1] << ' ' << cur << endl;
		}
	} else {
		ll pnt = n-1;
		for( ll i = 0; i < n-1; ++i ){
			if( a[i] > 0 ){
				pnt = i;
				break;
			}
		}
		ll cur = a[0];
		for( ll i = pnt; i < n-1; ++i ){
			cout << cur << ' ' << a[i] << endl;
			cur -= a[i];
		}
		ll sum = a[n-1];
		for( ll i = 1; i < pnt; ++i ){
			cout << sum << ' ' << a[i] << endl;
			sum -= a[i];
		}
		cout << sum << ' ' << cur << endl;
	}
	return 0;
}

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


vector<vector<int>> G(200,vector<int>(200,1e9));
int A[201];

int main() {
	int n,m,r;
	cin >> n >> m >> r;
	for(int i=0;i<r;i++){
		cin >> A[i];
		A[i]--;
	}
	sort(A,A+r);
	
	int a,b,c;
	for(int i=0;i<m;i++){
		cin >> a >> b >> c;
		a--,b--;
		G[a][b] = G[b][a] = c;
	}
	
	for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		G[i][j]=min(G[i][j], G[i][k]+G[k][j]);
	}
	
	int sum,MN=1e9;
	do{
		sum=0;
		for(int i=0;i<r-1;i++){
			sum+=G[A[i]][A[i+1]];
		}
		MN=min(MN,sum);
	}while(next_permutation(A,A+r));
	

	cout << MN << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    
    for(int i=0; i<s.length(); i++){
        if ( ( (i+1) % 2 == 0 && s[i] == 'R') || ( (i+1) % 2 != 0 && s[i] == 'L') ) {
                cout << "No" << endl;
                return 0;
        }
    }
    
    cout << "Yes" << endl;
}

Measured memory_bytes: 256