akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
 
using namespace std;
 
using ll = long long int; 
 
void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;
 
    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}
 
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}
 
ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}
 
const int MAX = 50;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
int main(void){
 
    ll k,x;
    cin>>k>>x;

    if(500*k >= x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N; cin >> N;
	vector<int>vec(N); rep(i, 0, N)cin >> vec[i];
	sort(all(vec), greater<int>());
	int ans = N;
	rep(i, 0, N-1) {
		if (vec[i] <= vec[i + 1]) {
			--ans;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 1e9 + 1;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n, w_max;
	cin >> n >> w_max;
	VI w(n);
	VI v(n);
	REP(i, n) { cin >> w[i] >> v[i]; }
	int sum = 0;
	REP(i, n) { sum += v[i]; }
	VI2D dp(n, VI(sum + 1, INF));
	REP(i, n) {
		REP(j, sum + 1) {
			if(j == 0) {
				dp[i][0] = 0;
				continue;
			}

			if(i == 0) {
				dp[0][j] = j == v[0] ? w[0] : INF;
				continue;
			}

			if(j < v[i]) {
				dp[i][j] = dp[i - 1][j];
			} else {
				dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j]);
			}
		}
	}
	int result;
	int dpmax = 0;
	for(int i = sum; i >= 0; i--) {
		if(dp[n - 1][i] <= w_max) {
			result = i;
			break;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 42764
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
acum1=[0]
for i in range(n): #累積和ai,bjを求める
 acum1.append(acum1[-1]+arr1[i])
acum2=[0]
for i in range(m):
 acum2.append(acum2[-1]+arr2[i])
ans=0
j=m
for i in range(n+1):
 if acum1[i]>k: #ai>Kであれば、どのようにjを選んでもai+bj<=Kとなることはないので探索を終了する
   break
 while acum2[j]>k-acum1[i] and j>0: #各iについて、bj<=K-aiを満たす最大のjを求める
   j-=1
 ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47328
N = int(input())
A = list(map(int,input().split()))
A.sort()
if N%2 == 0:
  check=[2*i+1 for i in range((N-1)//2+1)]*2
  check.sort()
else:
  check=[2*(i+1) for i in range(N//2)]*2
  check.append(0)
  check.sort()
if check == A:
  print((2**(N//2))%(10**9+7))
else:
  print(0)

Measured memory_bytes: 14008
<?php
	$n = trim( fgets( STDIN ) );
	$nums = [];
	for( $i=0; $i<$n; $i++ ) {
		array_push( $nums, intval( trim( fgets( STDIN ) ) ) );
	}
	$profit = 1-1000000000;
	$min = $nums[0];
	for( $i=1; $i<$n; $i++ ) {
		$d = $nums[$i]-$min;
		if( $profit < $d ) {
			$profit = $d;
		}
		if( $nums[$i] < $min ) {
			$min = $nums[$i];
		}
	}

	print $profit;
?>

Measured memory_bytes: 44436
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const int mn=3e5+4;
int pree[mn];
int prew[mn];
void solve(int n, string s){
	for (int i=n-1;i>=1;i--) {
		pree[i]=pree[i+1]+((s[i]=='E')?1:0);
	}
	for (int i=0;i<n;i++) {
		prew[i+1]=prew[i]+((s[i]=='W')?1:0);
	}
	int ans=INT_MAX;
	for (int i=0;i<n;i++) {
		int got=prew[i]+pree[i+1];
		//printf("got:%d\n",got);
		chkmin(ans,got);
	}
	printf("%d\n",ans);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long N;
	string S;
	cin>>N;
	cin >> S;
	solve(N, S);
	return 0;
}



Measured memory_bytes: 3348
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	ans := -1
	for x := 10*(b+1) - 1; x >= 10*b; x-- {
		if (8*x)/100 == a {
			ans = x
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 512
//??????????????¨???????????¢??????
#include <iostream>
#define int long long
using namespace std;

int n, q;
int x[100], y[100], z[100], r[100], l[100];
int sx, sy, sz, gx, gy, gz;

signed main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> sx >> sy >> sz >> gx >> gy >> gz;
		
		int ans = 0;
		
		for (int j = 0; j < n; j++) {
			if ((gx - sx) * (x[j] - sx) + (gy - sy) * (y[j] - sy) + (gz - sz) * (z[j] - sz) <= 0) {
				if ((x[j] - sx) * (x[j] - sx) + (y[j] - sy) * (y[j] - sy) + (z[j] - sz) * (z[j] - sz) <= r[j] * r[j]) {
					ans += l[j];
				}
			}
			else if ((sx - gx) * (x[j] - gx) + (sy - gy) * (y[j] - gy) + (sz - gz) * (z[j] - gz) <= 0) {
				if ((x[j] - gx) * (x[j] - gx) + (y[j] - gy) * (y[j] - gy) + (z[j] - gz) * (z[j] - gz) <= r[j] * r[j]) {
					ans += l[j];
				}
			}
			else {
				int ax = gx - sx;
				int ay = gy - sy;
				int az = gz - sz;
				int bx = x[j] - sx;
				int by = y[j] - sy;
				int bz = z[j] - sz;
				
				int menseki2 = 0;
				menseki2 += (ax * by - bx * ay) * (ax * by - bx * ay);
				menseki2 += (ay * bz - by * az) * (ay * bz - by * az);
				menseki2 += (az * bx - bz * ax) * (az * bx - bz * ax);
				int length2 = ax * ax + ay * ay + az * az;
				
				if (menseki2 <= r[j] * r[j] * length2) {
					ans += l[j];
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define p(d_type1, d_type2) pair<d_type1, d_type2>
#define F first
#define S second
#define loop(i, s, n) for(int i = s; i < n; i++)
#define nl "\n"
#define fat 1000000007

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

    v(int) d(n);
    loop(i, 0, n) cin >> d[i];

    ll sum = 0;
    loop(i, 0, n - 1)
    {
        loop(j, i + 1, n)
        {
            // cout << d[j]*d[i] << nl;
            sum += d[j]*d[i];
        }
    }
    cout << sum << nl;  
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Rishabhdeep Singh
 */

// doot diddly donger cuckerino Hahahahahah
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define PB              push_back
#define EB              emplace_back
#define F               first
#define S               second
#define all(x)          begin(x), end(x)
#define rall(x)         rbegin(x), rend(x)
#define sz(x)           (long long) (x).size()
#define IOS             ios::sync_with_stdio(false);cin.tie(NULL); cout << fixed << setprecision(12);
#define IN_REP          int tt; cin >> tt; while(tt--)
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos(-1);

template<typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> void mini(T& x, T y) { x = min(x, y); }
template<typename T> void maxi(T& x, T y) { x = max(x, y); }
template<typename T, typename U> string to_string(pair<T, U> p) { return to_string(p.F) + " " + to_string(p.S); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class AStrings {
  public:

    void solveOne(istream& cin, ostream& cout) {
        string s, t;
        cin >> s >> t;
        cout << (t + s) << '\n';
    }

    void solve(std::istream& in, std::ostream& out) {
        int tc = 1;
//        cin >> tc;
        for(int test_case = 1; test_case <= tc; ++test_case){
            solveOne(in, out);
        }
    }
};

int main() {
    IOS;
	AStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main (void){
    int dif;
    int min = 753;
    long int S;
    scanf("%ld", &S);

    while(S > 99){
        dif = S % 1000 - 753;
        if (dif < 0){
            dif = -dif;
        }
        if (dif < min){
            min = dif;
        }
        S = S / 10;
    }
    printf("%d\n", min);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u){
        cout<<a-1<<" "<<b<<endl;
    }
    else{
        cout<<a<<" "<<b-1<<endl;
    }
}


Measured memory_bytes: 256
/******
	~site:    atcoder.jp
	~user:    Turkhuu
	~problem: AtCoder Beginner Contest 177 - C (abc177_c)
** **/

#include<bits/stdc++.h>

#define FFOR(i,s,e,k) for(int i=s;(k==1?i<=e:i>=e);i+=k)
#define FOR(i,n) FFOR(i,0,n-1,1)
#define FORR(i,s,e) FFOR(i,s,e,1)
#define ll long long
#define PQ priority_queue
#define pb push_back
#define ppb pop_back()
#define pp push
#define MIN(v) *min_element(v.begin(),v.end())
#define MAX(v) *max_element(v.begin(),v.end())
#define SORT(v) sort(v.begin(),v.end())
#define TROS(v) sort(v.rbegin(),v.rend())
#define CNT(v,x) count(v.begin(),v.end(),x)
#define MOD 1000000007
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	ll a[200001];
	FOR(i,n){
		cin>>a[i];
		if(i>0) a[i]+=a[i-1];
	}
	ll sum=0;
	FOR(i,n){
		int k=(i==0?a[i]:a[i]-a[i-1]);
		sum+=(k*((a[n-1]-a[i])%MOD))%MOD;
		sum%=MOD;
	}
	cout<<sum%MOD;
}

Measured memory_bytes: 5032
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int h, w, d, q;
	cin >> h >> w >> d;
	vector<int> g(h*w), score(h*w);
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			int a;
			cin >> a;
			g[a-1] = i * w + j;
		}
	for (int s = 0; s < d; s++)
	{
		for (int e = s+d; e < h * w; e += d)
		{
			int pi = g[e-d] / w, pj = g[e-d] % w;
			int ni = g[e] / w, nj = g[e] % w;
			score[e] = score[e-d] + abs(pi - ni) + abs(pj - nj);
		}
	}
	cin >> q;
	while(q--)
	{
		int l, r;
		cin >> l >> r;
		cout << score[r-1] - score[l-1] << endl;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    int mx = 0;
    int mn = 1000;
    rep(i, n){
        int a;
        cin >> a;
        mx = max(mx, a);
        mn = min(mn, a);
    }
    cout << mx - mn << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        int[] p = cin.ArrayInt(n);

        int ans = 1;
        int min = p[0];
        for (int i = 1; i < n; ++i)
        {
            if (p[i] < min)
            {
                ++ans;
                min = p[i];
            }
        }

        Write(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 33116
import bisect
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0
for i in T:
  insert_index = bisect.bisect_left(S, i)
  if insert_index == n:
    continue
  else:
    if S[insert_index] == i:
      ans += 1

print(ans)


Measured memory_bytes: 16740
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

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

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

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

    cout << 1+b-a-((b/c-(a-1)/c)+(b/d-(a-1)/d)-(b/lcm(c,d)-(a-1)/lcm(c,d))) << endl;

    return 0;
}

Measured memory_bytes: 384
/*
	*	Created By: 'Present_Sir'
	*	Created On: Wednesday 05 August 2020 11:28:54 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n,k;
    cin>>n>>k;

    vector<bool> v(10,1);
    for(int i=0; i<k; i++){
        int x;
        cin>>x;
        v[x]=0;
    }

    vector<int> ans;
    for(int i=n; i<=1e6+10; i++){
        int j = i;
        bool found = 1;
        ans.clear();
        while(j>0){
            ans.push_back(j%10);
            if(!v[j%10]){
                found = 0;
                break;
            }
            j /= 10;
        }
        if(found){
            break;
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=0; i<ans.size(); i++){
        cout<<ans[i];
    }
    cout<<endl;
}
int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



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

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

  long long count = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    if (a == b && a == c) {
      cout << -1 << endl;
      return 0;
    }
    count++;
    int ta = (b + c) / 2;
    int tb = (c + a) / 2;
    int tc = (a + b) / 2;
    a = ta;
    b = tb;
    c = tc;
  }

  cout << count << endl;
  return 0;
}

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

const int Maxn = 100005;

char tmp[10];
int n, a, b, c;
string s[Maxn];
int nxt[Maxn][3];
char res[Maxn];

void Read(string &s)
{
    scanf("%s", tmp); s = tmp;
}

int main()
{
    scanf("%d", &n);
    scanf("%d %d %d", &a, &b, &c);
    for (int i = 0; i < n; i++)
        Read(s[i]);
    nxt[n][0] = nxt[n][1] = nxt[n][2] = n;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 3; j++)
            nxt[i][j] = nxt[i + 1][j];
        nxt[i][s[i][0] - 'A'] = nxt[i][s[i][1] - 'A'] = i;
    }
    for (int i = 0; i < n; i++)
        if (s[i] == "AB")
            if (a == 0 && b == 0) { printf("No\n"); return 0; }
            else if (a == 0 || (b != 0 && nxt[i + 1][0] <= nxt[i + 1][1])) { res[i] = 'A'; a++; b--; }
            else { res[i] = 'B'; b++; a--; }
        else if (s[i] == "AC")
            if (a == 0 && c == 0) { printf("No\n"); return 0; }
            else if (a == 0 || (c != 0 && nxt[i + 1][0] <= nxt[i + 1][2])) { res[i] = 'A'; a++; c--; }
            else { res[i] = 'C'; c++; a--; }
        else if (b == 0 && c == 0) { printf("No\n"); return 0; }
             else if (b == 0 || (c != 0 && nxt[i + 1][1] <= nxt[i + 1][2])) { res[i] = 'B'; b++; c--; }
             else { res[i] = 'C'; c++; b--; }
    printf("Yes\n");
    for (int i = 0; i < n; i++)
        printf("%c\n", res[i]);
    return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;

    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    
    if(a>b)
        swap(a,b);
        
    if((a+v*t)>=(b+w*t)){
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
    
    return 0;
}


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

using namespace std;

int n;
string s1, s2;

int main() {
	cin >> n >> s1 >> s2;
	for(int i = 0; i < n; i++) {
		cout << s1[i] << s2[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  int i,flag=0;
  long long int b,c;
  scanf("%lld",&b);
  for(i=0;i<a-1;i++){
    scanf("%lld",&c);
    if(c+2<=b){
      flag+=1;
      break;
    }
    if(b<c)b=c;
  }
  if(flag==0)printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))

def main():
    n = input_int()
    a_array = input_to_int_tuple()

    money = 1000
    buy = []

    for i, now_val in enumerate(a_array):
        next_val = 0
        if (i + 1) < len(a_array):
            next_val = a_array[i + 1]

        if now_val < next_val:
            cnt = money // now_val
            buy.append((now_val, cnt))
            money = money % now_val

        elif now_val > next_val:
            for val, cnt in buy:
                money += now_val * cnt
            buy = []

    print(money)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n;
  cin >> n;
  vec1 a(n);
  for(int i = 0; i < n ; i++) {
    cin >> a.at(i);
  }
  int tmp = a.at(0);
  int c = 1;
  for(int i = 0; i < n; i++) {
    if(tmp == 2) {
      cout << c << endl;
      return 0;
    } else {
      tmp = a.at(tmp-1);
      c++;
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 768
/*
 * @Author: hesorchen
 * @Date: 2020-07-03 17:05:01
 * @LastEditTime: 2020-08-02 20:14:23
 * @Description: https://hesorchen.github.io/
 */
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI acos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pll pair<ll, ll>
#define lowbit(abcd) (abcd & (-abcd))
#define max(a, b) ((a > b) ? (a) : (b))
#define min(a, b) ((a < b) ? (a) : (b))

#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define FRE                              \
    {                                    \
        freopen("in.txt", "r", stdin);   \
        freopen("out.txt", "w", stdout); \
    }

inline ll read()
{
    ll x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
//head==============================================================================

int main()
{
    ll n, m;
    cin >> n >> m;
    ll res = 0;
    while (n--)
    {
        ll a, b;
        cin >> a >> b;
        ll temp = a * a + b * b;
        if (temp <= m * m)
            res++;
    }
    cout << res << endl;
    return 0;
}

/*
 
 */

Measured memory_bytes: 3572
# 複数の値をキーにするソートを行うため、クラスを作成した。

# レストランを紹介する本のクラス。
class Book:
    """
    =======================
    Book: レストランを紹介する本のクラス。
    =======================
    """
    # インスタンス
    def __init__(self, no, name, value):
        # レストラン番号(0から開始する)
        self.no = no
        # レストラン名
        self.name = name
        # レストラン評価
        self.value = value
	# ドキュメント
    def usage(self):
        print(self.__doc__)

# 本のクラスの配列。
book = []
n = int(input())
for i in range(n):
    # レストラン名、レストラン評価
    s, p = input().split()
    book.append(Book(i, s, int(p)))

# レストラン評価の降順で整列する。
book = sorted(book, key=lambda b: b.value, reverse=True)
# レストラン名で整列する。
book = sorted(book, key=lambda b: b.name)
for b in book:
    # 本に紹介されるレストラン順で表示する。
    print(b.no+1)
# book[0].usage()


Measured memory_bytes: 9152
def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    S = sum(A)
    X = S / (4*M)
    cnt = 0
    for a in A:
        if a >= X:
            cnt += 1
    if cnt >= M:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.io.*;
import java.util.*;
 
public class Main {
    
    class Answer {
        int X, Y, Z;
        
        public int solve() {
            int len = Y + Z;
            int count = 0;
            int i = 0;
            while (i <= X-Z) {
                count++;
                i += len;
            }
            
            return count-1;
        }
        
        public void main(FastScanner in, PrintWriter out) {
            X = in.nextInt();
            Y = in.nextInt();
            Z = in.nextInt();
            out.println( solve() );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) { p(o[i][j] + " "); }
                pl("");
            }
        }
        public void ck(Object o1, Object o2) { pl(o1 + " " + o2); }
        public void ckk(Object o1, Object o2, Object o3) { pl(o1 + " " + o2 + " " + o3); }
        public void ckkk(Object o1, Object o2, Object o3, Object o4) { 
            pl(o1 + " " + o2 + " " + o3 + " " + o4);
        }
    }
 
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        
       Main problem = new Main();
        Answer ans = problem.new Answer();
        ans.main(in, out);
        
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

Measured memory_bytes: 22740
#include<stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <map>


using namespace std;
//配列でもつアレ。隣接配列だっけ？
//vector<short, vector<short>> islands;
map<int, vector<int> > islands;

void solve(){
	int N, M;
	cin >>  N;
	cin >> M;
	for(int ship_ind=0; ship_ind < M; ship_ind ++){
		int start;
		cin >> start;
		int dest;
		cin >> dest;

		//追加
		(islands[start]).push_back(dest);
	}

	//検索していく
    for(auto itr = islands[1].begin(); itr != islands[1].end(); ++itr) {
    		int next = *itr;
    		for(auto itr_second = islands[next].begin(); itr_second != islands[next].end(); ++itr_second){
    			if(*itr_second == N){
    				printf("POSSIBLE\n");
    				return;
    			}
    		}
    }

    printf("IMPOSSIBLE\n");
    return;


	for(int i=N; i>=1; i--){
		int temp = log2(i);
		double comp = log2(i) - temp;
		if(comp == 0.0 ){
			printf("%d\n", i);
			break;
		}
	}
}

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


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

using namespace std;

#define _int64 long long

int a[210000];
int d[210000];

int main()
{
  int i,j,n,x,y,now;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  x=0;y=n-1;
  now=0;
  for (i=n-1;i>=0;i--)
  {
    if (now==0)
    {
      d[x]=a[i];
      x++;
    }
    else
    {
      d[y]=a[i];
      y--;
    }
    now=1-now;
  }
  for (i=0;i<n;i++)
  {
    if (i!=0) printf(" ");
    printf("%d",d[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3712
from collections import deque
import sys


class mEdge():

    def __init__(self, _from, _to, _cost):
        self.From = _from
        self.to = _to
        self.cost = _cost


class bellman_ford():
    def __init__(self, V):
        self.G = []
        self._V = N
        self._E = 0

    def add(self, _from, _to, _cost):
        self.G.append(mEdge(_from, _to, _cost))
        self._E += 1

    def shortest_path(self, s):
        d = [10**20]*(self._V+1)
        d[s] = 0
        for _ in range(self._V):
            flag = False
            for edge in self.G:
                newlen = d[edge.From]+edge.cost
                if newlen < d[edge.to]:
                    flag = True
                    d[edge.to] = newlen
            if not flag:
                break
        return d

    def have_negative_circle(self):
        d = [10**20]*(self._V+1)
        d[1] = 0
        for i in range(1, self._V+1):
            flag = False
            for edge in self.G:
                newlen = d[edge.From]+edge.cost
                if newlen < d[edge.to]:
                    flag = True
                    d[edge.to] = newlen
            if not flag:
                break
            if i == self._V:
                return True
        return False


# Coins Respawn
sys.setrecursionlimit(10**7)
N, M, P = map(int, input().split())
graph = []
d = deque()


from_1 = [[] for i in range(N+1)]
from_N = [[] for i in range(N+1)]

for _ in range(M):
    a, b, c = map(int, input().split())
    from_1[a].append(b)
    from_N[b].append(a)
    d.append((a, b, P-c))


accessible_1 = [False for i in range(N+1)]
accessible_N = [False for i in range(N+1)]


def dfs_1(s):
    accessible_1[s] = True
    for node in from_1[s]:
        if accessible_1[node] == False:
            dfs_1(node)


def dfs_N(s):
    accessible_N[s] = True
    for node in from_N[s]:
        if accessible_N[node] == False:
            dfs_N(node)


dfs_1(1)
dfs_N(N)

isok = [False for i in range(N+1)]
for i in range(N+1):
    if accessible_1[i] and accessible_N[i]:
        isok[i] = True
G = bellman_ford(N)

while d:
    p, q, weight = d.popleft()
    if isok[p] and isok[q]:
        G.add(p, q, weight)

if G.have_negative_circle():
    print(-1)
else:

    print(max(0, -G.shortest_path(1)[N]))


Measured memory_bytes: 90784
#include<set>
using namespace std;
#include<iostream>
int	main(){
	/*
	while(true){
	
	int A,B,C,D,E,F,G,H,I,J,answer;
		
	cin >> A;
	if(A == 0) return 0;
	cin >> B >> C >> D >> E >> F >> G >> H >> I >> J;
	answer = A - B - C - D-E-F-G-H-I-J;
	cout << answer << endl;

	}
	*/
	/*
	int A,B,C,D,E,F;

	cin >> A, B, C, D;
	if(A < B, C, D){ 
		cout << B + C + D << endl;
	}
	
	else if(B < A, C, D){
		cout << A + C + D << endl;
	}

	else if(C < A && C < B && C < D){
		cout << A + B + D << endl;
	}

	else if(D < A && D < B && D < C){
		cout << A + B + C << endl;
	}

	if(E < F){
		cout << F << endl;
	}

	else{
		cout << E << endl;
	}
	
	return 0;
}*/
	/*
	int N, M;
	cin >> N >> M;
	cout << N + M << endl << N - M << endl << N * M << endl << N / M << endl;
}*/

/*int N, M; 
	cin >> N >> M;
	cout << N % M << endl;
}*/

/*	int N;
	cin >> N;
	cout << -(N % 2)+1 ;
}*/

	/*int A, B, C, D, E ;
	cin >> A >> B >> C >> D >> E;
	cout << (A + B + C + D + E) / 5 ;
}*/

	/*int A, B, C, D ;
	cin >> A >> B >> C >> D;
	cout << (A + B + C + D) / 60 << endl << (A + B + C + D) % 60 << endl;
	*/

/*	int A,B;
	cin >> A >> B;
	cout << ( A + B ) / 2 << endl;*/

/*	int m, f, b;
	cin >> m >> f >> b;

	if ( m + f >= b && m <= b ){
		cout << b - m << endl;
	}
	
	if ( m + f > b && m > b ){
		cout << 0 << endl;
	}


	if ( m + f < b ){
		cout << "NA" << endl;
	}*/

	int X , x ;
	cin >> X ;

	x = X % 7 ;

	if ( x == 2 ){
		cout << "sat" << endl;
	}

	if ( x == 3 ){
		cout << "sun" << endl;
	}

	if ( x == 4 ){
		cout << "mon" << endl;
	}

	if ( x == 5 ){
		cout << "tue" << endl;
	}

	if ( x == 6 ){
		cout << "wed" << endl;
	}

	if ( x == 0 ){
		cout << "thu" << endl;
	}

	if ( x == 1 ){
		cout << "fri" << endl;
	}
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll n,i,j,k;
  cin >> n;
  ll a[n];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  j=1;
  k=0;
  for(i=0;i<n;i++){
    if(a[i]==j){
      j+=1;
    }
    else{
      k+=1;
    }
  }
  if(k==n)k=-1;
  cout << k;
}

Measured memory_bytes: 1792
N = gets.to_i
heights = gets.split(" ").map(&:to_i)
ary = []
(1..heights.max).each do |num|
  row_ary = []
  heights.each do |height|
    if height >= num
      row_ary << 1
    else
      row_ary << 0
    end
  end
  ary << row_ary
end

#ary [[1,1,1,1], [0,1,1,0]]みたいな形
needs_num = 0
ary.each do |row_ary|
  row_ary.each_with_index do |current_val, idx|
    if current_val == 1 && row_ary[idx+1] == 0
      needs_num += 1
    end
    if current_val == 1 && row_ary[idx+1].nil?
      needs_num += 1
    end
  end
end

puts needs_num

Measured memory_bytes: 14228
#include<iostream>
#include<utility>
#include<vector>
#include <algorithm>
#include <iostream>
typedef std::pair<bool, int> P;
std::vector<int>A;
int N;
int main(){
    bool flag=false;
    //bool rsult;
    for(int i=0; i<9; i++){
        int tmp_a;
        std::cin >> tmp_a;
        A.push_back(tmp_a);
    }
    std::cin >> N;
    for(int i=0; i<N; i++){
        int tmp_b;
        std::cin>>tmp_b;
        auto rsult = std::find(A.begin(), A.end(), tmp_b);
        if(rsult!=A.end()){
            *rsult = 0;
        }
    }
    for(int i=0; i<9; i+=3){
        int a=0+i, b=1+i, c=2+i, a_2 = i/3, b_2 = i/3+3, c_2 = i/3+6;
        if(!(A[0] || A[4] || A[8]) || !(A[2] || A[4] || A[6])){
            flag = true;
            break;
        }
        if(!(A[a] || A[b] || A[c]) || !(A[a_2] || A[b_2] || A[c_2])){
            flag = true;
            break;
        }
    }
    printf("%s\n", (flag)?"Yes":"No");
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int c=1;
	if (a % b == 0) {c=0;}
	cout << (a/b)+c;
	return 0;
}

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

// dp[i]: 山の残りの石の数がiのときにゲームを先行から始めたらどちらが勝つか。
// iのとき、どの石を取っても行き先がfirstのとき、つまりdp[石[any]] == First のときSecondの勝ち
const int maxn = 100001;
bool dp[maxn];

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < maxn; i++) dp[i] = false;

    for(int i = 1; i <= k; i++) {
        bool any_true = false;
        for (int j = 0; j < n; j++) {
            if (i - a[j] < 0) continue;
            if (!dp[i - a[j]]) {
                any_true = true;
                break;
            }
        }
        dp[i] = any_true;
    }

    string res = dp[k] ? "First" : "Second";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
bool a[2222][2222];
int L[2222][2222];
int lef[2222],rig[2222];
int toL[2222],topL;
int toR[2222],topR;
int row,col;
int main(){
	char s[2222];
	scanf("%d%d",&row,&col);
	int res = max(row,col);
	for(int i=0; i<row; i++){
		scanf("%s",s);
		for(int j=0; j<col; j++)
			a[i][j] = (s[j]=='#');
	}
	for(int i=0; i<row; i++){
		for(int j=0; j<col; j++){
			if(i == 0 || (j != 0 && (a[i][j] ^ a[i][j-1] ^ a[i-1][j] ^ a[i-1][j-1])))
				L[i][j] = 1;
			else
				L[i][j] = L[i-1][j] + 1;
		}
		topL = 0;
		for(int j=0; j<col; j++){
			while(topL > 0 && L[i][toL[topL-1]] >= L[i][j]) topL--;
			lef[j] = topL==0?-1:toL[topL-1]-1;
			toL[topL++] = j;
		}
		topR = 0;
		for(int j=col-1; j>=0; j--){
			while(topR > 0 && L[i][toR[topR-1]] >= L[i][j]) topR--;
			rig[j] = topR==0?col:toR[topR-1];
			toR[topR++] = j;
		}
		for(int j=0; j<col; j++){
			res = max(res, L[i][j] * (rig[j] - lef[j] - 1));
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 23936
#include "bits/stdc++.h"

using namespace std;

int main() {
    int x, A[200] = {};
    bool B[10] = {};

    for (int i = 1; i <= 9; ++i) {
        cin >> x;
        A[x] = i;
    }

    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x;
        B[A[x]] = true;
    }

    bool ans = false;
    if ((B[1] && B[2] && B[3])
        || (B[4] && B[5] && B[6])
        || (B[7] && B[8] && B[9])
        || (B[1] && B[4] && B[7])
        || (B[2] && B[5] && B[8])
        || (B[3] && B[6] && B[9])
        || (B[1] && B[5] && B[9])
        || (B[3] && B[5] && B[7]))
        ans = true;

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int[] counts = new int[100];
    static int[] minValue;
    static int min = Integer.MAX_VALUE;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		for (int i = 0; i < arr.length - 1; i++) {
		    counts[(arr[i] - '0') * 10 + (arr[i + 1] - '0')]++;
		}
		check(0, new int[9]);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 9; i++) {
		    sb.append(minValue[i]);
		    if (i % 3 == 2) {
		        sb.append("\n");
		    }
		}
		System.out.print(sb);
	}
	
	static void check(int idx, int[] arr) {
	    if (idx == 9) {
	        int sum = 0;
	        for (int i = 0; i < 8; i++) {
	            for (int j = i + 1; j < 9; j++) {
	                int move = Math.abs(i / 3 - j / 3) + Math.abs(i % 3 - j % 3);
	                sum += move * (counts[arr[i] * 10 + arr[j]] + counts[arr[j] * 10 + arr[i]]);
	            }
	        }
	        if (min > sum) {
	            min = sum;
	            minValue = (int[])arr.clone();
	        }
	        return;
	    }
	    for (int i = 1; i <= 9; i++) {
	        boolean flag = false;
	        for (int j = 0; j < idx; j++) {
	            if (arr[j] == i) {
	                flag = true;
	                break;
	            }
	        }
	        if (flag) {
	            continue;
	        }
	        arr[idx] = i;
	        check(idx + 1, arr);
	    }
	}
}



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

int main(void){
    int s, w;

    scanf("%d", &s);
    scanf("%d", &w);

    if(w >= s){
        printf("unsafe\n");
    }

    else printf("safe\n");

    return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int s = 114514;
    int e = -1;
    int N;
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        s = min(s, a);
        e = max(e, a);
    }
    cout << e - s << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = 998244353L;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        long[] fact = new long[n];
        fact[0] = m;
        for (int i = 1; i < n; i++) {
            fact[i] = fact[i - 1] * (m - 1) % MOD;
        }

        Combination comb = new Combination(n + 100, MOD);

        long ans = 0;
        for (int i = n - k - 1; i < n; i++) {
            ans = (ans + comb.nck(n - 1, i) * fact[i]) % MOD;
        }

        out.println(ans);

        out.flush();
    }

    public class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            return n < k ? 0 : facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 39976
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int ans = 0;
		for (int i=1; i<=N; i++) {
			ans += i;
		}

		System.out.println(ans);

	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, cnt = 0, d1, d2;
  bool ok = false;

  cin >> n;
  rep(i, n) {
    cin >> d1 >> d2;
    if (d1 == d2)
      cnt++;
    else
      cnt = 0;
    if (cnt >= 3) ok = true;
  }

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
    map<string,int>a;
    queue<string>b;
    b.push("01234567");
    while(b.size()){
	string c=b.front();
	string e=c;
	b.pop();
	int d;
	for(d=0;d<8;d++){
	    if(c[d]=='0')break;
	    }
	if(d<4){
	    swap(c[d],c[d+4]);
	    if((a[c]==0&&c!="01234567")||a[e]+1<a[c]){
		a[c]=a[e]+1;
		b.push(c);
		}
	    swap(c[d],c[d+4]);
	    }
	    else{
		swap(c[d],c[d-4]);
	    if((a[c]==0&&c!="01234567")||a[e]+1<a[c]){
		a[c]=a[e]+1;
		b.push(c);
		}
	    swap(c[d],c[d-4]);}
	if(d%4){
	   swap(c[d],c[d-1]);
	    if((a[c]==0&&c!="01234567")||a[e]+1<a[c]){
		a[c]=a[e]+1;
		b.push(c);
		}
	    swap(c[d],c[d-1]);
	    }
	    if(d%4!=3){
		swap(c[d],c[d+1]);
	    if((a[c]==0&&c!="01234567")||a[e]+1<a[c]){
		a[c]=a[e]+1;
		b.push(c);
		}
	    swap(c[d],c[d+1]);
	}
}
int x[8];
while(cin>>x[0]){
    for(int y=1;y<8;y++)cin>>x[y];
    string z="        ";
    for(int k=0;k<8;k++)z[k]=x[k]+48;
    cout<<a[z]<<endl;
    }
}

Measured memory_bytes: 5360
#include <iostream>
#include <cstring>

using namespace std;

const int MAX = 16;
typedef long long ll;
 
struct Point{
    int x,y;
};
 
int main(){
    int tcase,n;
    ll dp[MAX][MAX];
    Point g,ps,pg;
 
    cin >> tcase;
    while(tcase--){
	memset(dp,0,sizeof(dp));
 
	cin >> g.x >> g.y;
 
	bool m[MAX][MAX][MAX][MAX];
	memset(m,false,sizeof(m));
 
	cin >> n;
	while(n--){
	    cin >> ps.x >> ps.y >> pg.x >> pg.y;
	    m[ps.y][ps.x][pg.y][pg.x] = true;
	    m[pg.y][pg.x][ps.y][ps.x] = true;     
	}
 
	dp[0][0] = 1;
 
	for(int i = 0; i <= g.y ; i++){
	    for(int j = 0 ; j <= g.x ; j++){
		if(i && !m[i][j][i-1][j]){
		    dp[i][j] += dp[i-1][j];
		}
		if(j && !m[i][j][i][j-1]){
		    dp[i][j] += dp[i][j-1];
		}
	    }
	}
 
	if(!dp[g.y][g.x]){
	    cout << "Miserable Hokusai!" << endl;
	}
	else{
	    cout << dp[g.y][g.x] << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3036
#include <stdio.h>

int calculation(int a, int b, int *c){
	int i,x;
	x=1;
	b=3;
	for(i=0;i<b;i++){
		x=x*a;
	}
	*c=x;
	return 0;
}


int main(){
	int a,b,c;
	scanf("%d",&a);
	calculation(a,b,&c);
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1844
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve(){
    int n; 
    cin >> n;
    vector<ll> a(n);

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

    sort(a.begin(), a.end(), greater<int>());
    
    if(n==1){
        cout << 0 << endl;
        return;
    }
    if(n==2){
        cout << a[0] << endl;
        return;
    }
    ll cnt = a[0];
    int idx = 1;
    for(int i=2; i<n; i++){
        cnt += a[idx];
        i++;
        if(i<n){
            cnt+=a[idx];
            idx++;
        }
    }

    cout << cnt << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 4780
from collections import defaultdict

def read_input():
    s = input()
    chars = [c for c in s]
    return chars


def submit():
    chars = read_input()

    c_dic = defaultdict(int)
    for c in chars:
        c_dic[c] += 1

    c_list = list(c_dic.items())

    if len(c_list) == 2:
        if c_list[0][1] == c_list[1][1] == 2:
            print("Yes")
            return

    print("No")
    return


if __name__ == '__main__':
    submit()


Measured memory_bytes: 3436