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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


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

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 3000;

int dp[N+1][N+1];
//array<ll, 3> dp;
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
//ll v[N], m[N];

int n, m;
string s1, s2;

string ans(int i, int j){
	if(i==0||j==0)
		return string("");

	if(s1[i-1]==s2[j-1])
		return ans(i-1, j-1)+s1[i-1];
	else if(dp[i-1][j]>=dp[i][j-1])
		return ans(i-1, j);
	else
		return ans(i, j-1);
}


int main(){
	cin >> s1 >> s2;
	n=sz(s1), m=sz(s2);

	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			if(s1[i-1]==s2[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);

	cout << ans(n, m) << space;

}

Measured memory_bytes: 39048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,ans;
    cin>>a>>b;
    if(a==1)
        ans=b-2;
    else if(b==1)
        ans=a-2;
    else
        ans=(b-2)*(a-2);
    if(a==1&&b==1)
        ans=1;
    cout<<ans<<endl;
    return 0;
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n, r;
    while(cin>>n>>r, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) v[i] = n-i;
        for(int j=0; j<r; ++j) {
            int p, c;
            cin >> p >> c;
            p--;
            vector<int> tmp;
            for(int i=p; i<p+c; ++i) tmp.push_back(v[i]);
            for(int i=0; i<p; ++i) tmp.push_back(v[i]);
            for(int i=p+c; i<n; ++i) tmp.push_back(v[i]);
            v = tmp;
        }
        cout <<v[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3020
#include <cstdio>
#include <iostream>
#define rep(i,k,n) for(int i=k;i<(int)(n);i++)
using namespace std;
int n,c,x;
int d[30][39];
int t[3][30];

int main(){
  cin >> n >> c;
  rep(y,0,c) rep(x,0,c) cin >> d[y][x];
  rep(y,0,n) rep(x,0,n){ int a;cin >> a; t[(x+y)%3][a-1]++;}
  int mi = 1<<30;
  rep(i1,0,c)rep(i2,0,c)if(i1!=i2)rep(i3,0,c)if(i1!=i3&&i2!=i3){
    int tt = 0;
    int a[3] = {i1,i2,i3};
    rep(cc,0,3) rep(l,0,c) tt+=d[l][a[cc]]*t[cc][l];
    if(tt<mi) mi = tt;
  }

  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#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>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

template<class ll>
inline ll getCeilExponent(ll a)
{
	if (a <= 0)
	{
		throw invalid_argument("vaule equal to or less than 0 should not be valid");
	}

	ll index = 0;
	--a;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

template<class ll>
inline ll getFloorExponent(ll a)
{
	if (a <= 0)
	{
		throw invalid_argument("vaule equal to or less than 0 should not be valid");
	}

	ll index = 0;
	a >>= 1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

// computational complexity: o(log(max(a, b))) 
template<class ll>
inline ll getGcd(ll a, ll b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

// computational complexity: o(log(max(a, b))) 
template<class ll>
inline pair<ll, ll> getBezoutsIdentitySolution(ll a, ll b)
{
	if (b == 0)
	{
		return { 1, 0 };
	}
	auto sol = getBezoutsIdentitySolution(b, a % b);
	return { sol.second, sol.first - (a / b) * sol.second };
}

template<class Integer>
inline Integer getPower(Integer base, unsigned exponential)
{
	Integer res = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			res *= base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return res;
}

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

	string S;
	cin >> S;

	ll res = 0;
	for (ll i = 0; i < S.size(); ++i)
	{
		if (S[i] == 'o')
		{
			++res;
		}
	}

	if (res + 15 - S.size() >= 8)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
k,s = gets.chomp.split(' ').map(&:to_i)
i = 0
c = 0
while i <= k
  j = 0
  while j <= k
    l = s-i-j
    c += 1 if l>=0 && l<=k
    # p "i:#{i},j:#{j},l:#{l}"
    j += 1
  end
  i += 1
end
p c

Measured memory_bytes: 14244
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
	int N;
	cin>>N;
	int H[N];
	for(int n = 0; n<N; n++)
	{
		cin>>H[n];
	}
	int dp[N+1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(H[1]-H[0]);
	for(int n = 3; n<=N; n++)
	{
		dp[n] = min(dp[n-1] + abs(H[n-1]-H[n-2]), dp[n-2] + abs(H[n-1]-H[n-3]));
	}
	cout<<dp[N]<<endl;
	return 0;	
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
        int i;
        int s[] = new int[3];
        
        for(i=0;i<3;i++){
            s[i] = sc.nextInt();
        }
        Arrays.sort(s);
        for(i=0;i<3;i++){
            System.out.print(s[i]);
            if(i==2){
                System.out.println();
                break;
            }
            System.out.print(' ');
        }
        
        sc.close();

	}

}


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

int main() {
    int cnt[200000] = {0};
    int N, K;
    queue<int> que;
    cin >> N >> K;
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        que.push(a);
    }
    for (int i=0; i<N; i++) {
        int a = que.front();
        cnt[a-1]++;
        que.pop();
    }
    sort(cnt, cnt+200000, greater<int>());
    int sum = std::accumulate(cnt, cnt+K, 0);
    cout << max(N-sum, 0) << endl;     
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, cn[N];
vector<int> v[N];
lli ans = INT_MAX, lf, maxdep;

void dfs(int x, int back, int d, bool fr) {
	maxdep = max(maxdep, (lli)d);
	if(fr)
		cn[d] = max(cn[d], (int)v[x].size());
	else
		cn[d] = max(cn[d], (int)v[x].size() - 1);
	for(auto i : v[x])
		if(i != back)
			dfs(i, x, d + 1, false);
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n - 1; i++) {
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= n; j++)
			cn[j] = 0;
		maxdep = 0;
		dfs(i, 0, 0, true);
		lli leaf = 1;
		for(int j = 0; j <= n; j++) {
			if(cn[j] == 0)
				break;
			leaf *= cn[j];
		}
		if(ans == maxdep + 1)
			lf = min(lf, leaf);
		if(ans > maxdep + 1) {
			ans = maxdep + 1;
			lf = leaf;
		}
	}
	for(int i = 1; i <= n; i++) {
		for(auto j : v[i]) {
			for(int j = 0; j <= n; j++)
			cn[j] = 0;
			maxdep = 0;
			dfs(i, j, 0, false);
			dfs(j, i, 0, false);
			lli leaf = 1;
			for(int j = 0; j <= n; j++) {
				if(cn[j] == 0)
					break;
				leaf *= cn[j];
			}

			if(ans == maxdep + 1)
				lf = min(lf, 2 * leaf);
			if(ans > maxdep + 1) {
				ans = maxdep + 1;
				lf = 2 * leaf;
			}
		}
	}
	cout << ans << spc << lf;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  vector<pair<int, int>> v;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    v.emplace_back(pair<int, int>(b, a));
  }
  sort(v);
  p(v[0].first + v[0].second);
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int inputCount = Integer.parseInt(br.readLine());
        for( int i = 0; i < inputCount; i++) {
            String line = br.readLine();
            List<Integer> sideLengthList = new ArrayList<>();
            for( String s : line.split(" ")  ) {
                sideLengthList.add( Integer.parseInt(s) );
            }
            Collections.sort(sideLengthList, Collections.reverseOrder());
            int cSide = sideLengthList.get(0);
            int aSide = sideLengthList.get(1);
            int bSide = sideLengthList.get(2);
            if( cSide * cSide == aSide * aSide + bSide * bSide) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}



Measured memory_bytes: 25852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)	ret.push_back(n / i);
        }
    }
    return ret;
}
int main()
{
    /*int a, b; cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
    */

    /*int n; cin >> n;
    rep(i, 10) rep(j, 10) {
        if (n == i * j) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    */

    /*ll n; cin >> n;
    vector<ll> d;
    d = divisor(n);
    sort(ALL(d));
    ll ans = 0;
    if (d.size() % 2 == 1) {
        ans += d[d.size() / 2] - 1;
        ans += d[d.size() / 2] - 1;
    }
    else {
        ans += d[d.size() / 2] - 1;
        ans += d[d.size() / 2 - 1] - 1;
    }
    cout << ans << endl;
    */

    /*int a, b, x; cin >> a >> b >> x;
    double c = 2.0 * x / double(a * a) - double(b);
    double ans;
    if (0 < c) {
        ans = atan(double(a) / (double(b) - double(c))) * 180.0 / M_PI;
    }
    else {
        ans = atan((2 * x) / (double(a) * double(b) * double(b))) * 180.0 / M_PI;
    }
    if (ans < 0) ans += 180;
    ans = 90 - ans;
    cout << setprecision(15) << ans << endl;
    */

    ll n, k; cin >> n >> k;
    vector<int> a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(rALL(a));
    sort(ALL(f));
    ll l = -1, r = 1e12;
    while (l + 1 < r) {
        ll mid = (l + r) / 2;
        bool ok = [&] {
            ll s = 0;
            rep(i, n) {
                s += max(0ll, a[i] - mid / f[i]);
            }
            return s <= k;
        }();
        if (ok) r = mid; else l = mid;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4784
//include
//------------------------------------------
#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 <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	string s, t;
	cin >> s >> t;

	ll res = 0;
	for (ll i = 0; i < s.size(); ++i) {
		if (s[i] != t[i]) ++res;
	}

	cout << res << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> vp(M);
    for (auto& p : vp) cin >> p.second >> p.first;
    sort(vp.begin(), vp.end());

    int ans = 0;
    int t = 0;
    for (int i = 0; i < M; i++) {
        if (t < vp[i].first && t >= vp[i].second) continue;
        t = vp[i].first - 1;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    ll i,j,c=0;
    string S;
    cin>>S;
    for(i=0;i<1;i++){
        if(S[i]=='R'){
            if(S[i+1]=='R'&&S[i+2]=='R'){
                c=3;break;
            }
            else if(S[i+1]=='R'&&S[i+2]=='S'){
                c=2;break;
            }
            else if(S[i+1]=='S'&&S[i+2]=='R'){
                c=1;break;
            }
            else{
                c=1;break;
            }
        }
        else{
            if(S[i+1]=='R'&&S[i+2]=='R'){
                c=2;break;
            }
            else if(S[i+1]=='R'&&S[i+2]=='S'){
                c=1;break;
            }
            else if(S[i+1]=='S'&&S[i+2]=='R'){
                c=1;break;
            }
            else{
                c=0;break;
            }
        }
    }
    cout<<c<<endl;
}
int main()
{
    solve();
}

Measured memory_bytes: 3624
n = int(input())
l = list(set([int(c) for c in input().split() if int(c) % 2 == 0]))
c = 0
for i in range(len(l)):
  if l[i] % 3 == 0 or l[i] % 5 == 0:
    c += 1
if c == len(l):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int cx[] = {0, w};
        int cy[] = {0, h};
        for(int i = 0; i < n; i++){
        	int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();
            if(a == 1 && cx[0] < x){
            	cx[0] = x;
            }else if(a == 2 && cx[1] > x){
            	cx[1] = x;
            }else if(a == 3 && cy[0] < y){
            	cy[0] = y;
            }else if(a == 4 && cy[1] > y){
            	cy[1] = y;
            }
            if(cx[0] >= cx[1] || cy[0] >= cy[1]){
            	System.out.println(0);
                return;
            }
        }
        int yoko = cx[1] - cx[0];
        int tate = cy[1] - cy[0];
        System.out.println(yoko * tate);
	}
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  ll ans = k;
  for (int i = 0; i < n - 1; ++i) {
    ans *= k - 1;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        long n = sc.nextLong();
        long k = sc.nextLong();

        n %= k;
        out.println(Math.min(k - n, n));
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 32780
#include <iostream>
#include <iomanip>
using namespace std;
constexpr double PI = 3.14'159'265'358'973;

int main(int argc, char *argv[]) {
    int r;
    cin >> r;
    cout << setprecision(16) << scientific;
    cout << r * 2 * PI << endl;
    return 0;
}


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

using namespace std;
const int N=3e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<=n;i++)
        cin>>a[i];
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        int r=min(x,a[i]);
        x-=r;
        ans+=r;

        r=min(x,a[i+1]);
        a[i+1]-=r;
        ans+=r;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import kotlin.comparisons.compareBy

fun main(arg: Array<String>) {
    val n = readLine()!!.toInt()
    val po = Array(n) {
        val (s, p) = readLine()!!.split(' ')
        Triple(s, p.toInt(), it + 1)
    }
    po.sortWith(compareBy({ it.first }, { -it.second }))
    po.forEach { println(it.third) }
}


Measured memory_bytes: 36444
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int n, k;
int ans = 0;
vector<vector<int>> edge;

int dfs(int v, int p){
    int h = 0;

    for(int u : edge[v]){
        h = max(h, dfs(u, v) + 1);
    }

    if(p <= 1){
        return h;
    }

    if(h == k - 1){
        ans++;
        h = -1;
    }
    return h;
}

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

    cin >> n >> k;
    edge = initVec2<int>(n + 1, 0);
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(i == 1){
            if(a != 1){
                ans++;
            }
            continue;
        }
        if(k == 1 && a != 1){
            ans++;
        }
        edge[a].push_back(i);
    }

    if(k == 1){
        cout << ans << endl;
        return 0;
    }

    dfs(1, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3 ;
  cin >> s1s2s3 ;
  if ( s1s2s3 == 111) {
    cout << 3 << endl;
  }
  else if (s1s2s3 == 110 ) {
    cout << 2 << endl;
  }
  else if (s1s2s3 == 101 ) {
    cout << 2 << endl;
  }  
  else if (s1s2s3 == 100 ) {
    cout << 1 << endl;
  }
  else if (s1s2s3 == 11 ) {
    cout << 2 << endl;
  }
  else if (s1s2s3 == 10 ) {
    cout << 1 << endl;
  }
  else if (s1s2s3 == 001 ) {
    cout << 1 << endl;
  }
  else if (s1s2s3 == 000 ) {
    cout << 0 << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

int main() {
  ll k, n;
  cin >> k >> n;

  vector<ll> v(n);
  rep(i, n) { cin >> v[i]; }

  vector<ll> ku(n);

  ku[0] = k - v[n - 1] + v[0];
  rep(i, n - 1) {
    ku[i + 1] = v[i + 1] - v[i];
    debug(ku[i + 1]);
  }
  sort(all(ku));
  ll ans = 0;

  rep(i, n - 1) {
    ans += ku[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        int c=s[i]-'A';
        c+=n;
        c%=26;
        cout<<char(c+'A');
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<Pi> Vp;
typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n; cin>>n; int a[n];
    for (int i = 0; i < n; i++)cin>>a[i];
    sort(a,a+n); int key=1; Vi s;
    for (int i = 1; i < n; i++){
        if(a[i]==a[i-1])key++;
        else{s.push_back(key%2?1:2); key=1;}
    }
    s.push_back(key%2?1:2);
    int ans=s.size(); key=0;
    for (int i = 0; i < ans; i++)if(s[i]==2)key++;
    cout<<(key%2?ans-1:ans)<<'\n';
}

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

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

	double ans = 0;
	double x; string u;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;

		if (u == "JPY") {
			ans += x;
		} else {
			ans += 380000.0 * x;
		}
	}

	cout << ans << endl;
}

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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		decimal ans = 0;
        for(var i = 0; i < N; i++)
		{
			var xu = Console.ReadLine().Split().ToArray();
			decimal x = decimal.Parse(xu[0]);
			if (xu[1] == "JPY")
			{
				ans += x;
			}
			else
			{
				ans += 380000 * x;
			}
		}
		Console.WriteLine(ans);

        
	}
}


Measured memory_bytes: 13268
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=753;

int changtiint(string a){
	int l=a.length();
	int sum=0;
	for(int i=0;i<l;i++){
		sum=sum*10+a[i]-'0';
	}
	return sum;
}

int main(){
	string str;
	cin>>str;
	int ans=10000000;
	int l=str.length();
	for(int i=0;i<=l-3;i++){
		string temp;
		for(int j=i;j<i+3;j++){
			temp.push_back(str[j]);
		}
		int now=changtiint(temp);
		now=abs(now-INF);
		ans=min(ans,now);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include <iterator>

using namespace std;

int main(){
    string S;
    cin >> S;
    int onenum = 0;
    int zeronum = 0;
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == '1') ++onenum;
    }
    zeronum = S.size()-onenum;
    cout << 2 * min(zeronum, onenum) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9


int main(){

   string S;
   cin >> S;
   int N = S.size();    //Sのサイズを確保する

   int M = (N-1)/2;
   int U = (N+1)/2;
   string P,L;

   P = S.substr(0,M); //0番目から最後までの文字列を切り取る
   L = S.substr(U); // U番目から最後までの文字列を切り取る

   string P_rev=P,L_rev=L;
    reverse(P_rev.begin(),P_rev.end());
    reverse(L_rev.begin(),L_rev.end());

   if(P==P_rev && L==L_rev && L==P){
       cout << "Yes"<< endl;
   }else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}
using namespace std;
//using namespace __gnu_pbds;
#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
double PI=3.1415926535897932384626;
//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	vi arr(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	stack<int>st;
	for(int count=0;count<n;count++)
	{
	    int flag=1;
		for(int j=n-1-count;j>=0;j--)
		{
			if(arr[j]==(j+1))
			{
				st.push(arr[j]);
				arr.erase(arr.begin()+j);
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
		    cout<<-1<<endl;
		    return 0;
		}
	}
	if(st.size()!=n)
		cout<<-1<<endl;
	else
	{
		while(!st.empty())
		{
			cout<< st.top() <<endl;
			st.pop();
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>

int main()
{
    int n,i;
    scanf("%d",&n);
    char s[101],t[101];
    scanf("%s %s",s,t);
    for(i=0;i<n;i++){
        printf("%c%c",s[i],t[i]);
    }
    return 0;
}


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

void solved()
{
    int s,w;
    cin >> s >> w;
    if(w >= s)cout <<"unsafe";
    else cout <<"safe";
}

int main()
{
#ifdef ONLINE_JUEDGE
    ios::sycn_with_stdio(false);cin.tie(0);cout.tie(0);
#endif
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solved();
    }



#ifndef ONLINE_JUEDGE
    system("pause");
#endif 
    return 0;
}

Measured memory_bytes: 3688
s=int(input())
a=[s]
b=0
i=0

while b == 0:
    if a[i]%2 == 0:
        a.append(a[i]/2)
    else:
        a.append(3*a[i]+1)
    i += 1
    for j in range(i-1):
        if a[j] == a[i]:
            b = i
            break
print(b+1)


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

int main(){
    int n, p[100], a, b, x[3] = {0};
    cin >> n >> a >> b;
    for(int i=0;i<n;++i) cin >> p[i];

    for(int i=0;i<n;++i){
        if(p[i] <= a) ++x[0];
        else if(p[i] <= b) ++x[1];
        else ++x[2];
    }
    cout << min({x[0], x[1], x[2]}) << endl;
    
    return 0;
}

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


int main() {

  int n,m,x,y;
  cin>>n>>m>>x>>y;

  vector<int> xi(n);
  for(int i=0;i<n;i++){
    cin>>xi.at(i);
  }

  vector<int> yi(m);
  for(int i=0;i<m;i++){
    cin>>yi.at(i);
  }

  sort(xi.begin(),xi.end());
  sort(yi.begin(),yi.end());

  if(xi.at(n-1)<yi.at(0)&&x<yi.at(0)&&y>xi.at(n-1))
    cout<<"No War"<<endl;
  else
    cout<<"War"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
//const int INF=1e9+5;
int main()
{
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int l=0;l<n;l++)
	{
		vector<int> c(3);
		std::vector<int> new_dp(3,0);

		for(int k=0;k<3;k++)
			cin>>c[k];
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i != j)
				{
					new_dp[j]=max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp=new_dp;
	}
	int maxi=max({dp[0],dp[1],dp[2]});
	cout<<maxi;

}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<char> t, d;
  rep(i, q) {
    char a, b;
    cin >> a >> b;

    t.push_back(a);
    d.push_back(b);
  }

  ll ans = 0;
  rep(_, 2) {
    ll l = -1;
    ll r = n - 1;
    while (l < r) {
      ll c = (l + r + 1) / 2;
      ll idx = c;
      rep(i, q) {
        if (idx < 0)
          break;
        if (idx >= n)
          break;

        if (s[idx] == t[i]) {
          if (d[i] == 'L')
            idx--;
          else
            idx++;
        }
      }
      if (idx < 0)
        l = c;
      else
        r = c - 1;
    }
    ans += l + 1;

    reverse(all(s));
    rep(i, q) {
      if (d[i] == 'L')
        d[i] = 'R';
      else
        d[i] = 'L';
    }
  }

  ans = n - ans;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  REP(i, N) { cin >> A[i] >> B[i]; }
  int ans = 0;
  REPR(i, N - 1) {
    if((ans + A[i]) % B[i] != 0) { ans += B[i] - (ans + A[i]) % B[i]; }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(long long int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;
const long long int INF_=1<<60;

bool Exists(int s){
	int x=1;
	while(x*x+x<=s){
		if((s-x)%(2*x+1)==0) return true;
		++x;
	}
	return false;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	int ans=0;
	REP(i,0,N){
		int S;
		cin >> S;
		if(!Exists(S)) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	priority_queue<ll>q;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		q.push(x);
	}
	for(ll i=0;i<k;i++){
		ll now=q.top();
		q.pop();
		q.push(now/2);
	}
	ll ans=0;
	while(q.size()!=0){
		ans+=q.top();
		q.pop();
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int MAX = 50;

int n, m;
char a[MAX + 1][MAX + 1], b[MAX + 1][MAX + 1];

bool f(int i, int j) {
    bool match = true;
    int x = i + m - 1, y = j + m - 1;
    for (int k = 0; i <= x; i++, k++) {
        for (int t = 0, nj = j; nj <= y; nj++, t++) {
            if (a[i][nj] != b[k][t]) match = false;
        }
    }
    return match;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
    for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) cin >> b[i][j];
    bool flag = false;
    for (int i = 0; i <= n - m; i++) {
        for (int j = 0; j <= n - m; j++) {
            if (f(i, j)) flag = true;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=200100;
int n,m,a[maxn];
ll c[maxn<<1],save[maxn<<1],sum;
int lowbit(int x)
{
	return (x&(-x));
}
void add(int x,int pl)
{
	while(pl<=2*m+1)
	{
		c[pl]=c[pl]+x;
		pl+=lowbit(pl);
	}
}
ll getsum(int pl)
{
	ll re=0;
	while(pl>0)
	{
		re=re+c[pl];
		pl-=lowbit(pl);
	}
	return re;
}
void stc(int l,int r)
{
	//cout<<l<<' '<<r<<endl;
	if(l>r) return ;	
	add(1,l);
	add(l-r-2,r+1);
	add(r-l+1,r+2);
}
int main()
{
	//freopen("E.in","r",stdin);
	//freopen("E.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n-1;i++)
		if(a[i]<=a[i+1]) sum=sum+a[i+1]-a[i];
		else sum=sum+a[i+1]+m-a[i];
	for(int i=1;i<=n-1;i++)
		if(a[i]<=a[i+1]) stc(a[i]+2,a[i+1]);
		else stc(a[i]+2,a[i+1]+m);	
	save[0]=0;
	for(int i=1;i<=2*m+1;i++)
		save[i]=getsum(i)+save[i-1];
	//cout<<sum<<endl;	
	//	for(int i=1;i<=2*m+1;i++)
	//	cout<<save[i]<<' ';
	//cout<<endl;				
	ll ans=0;
	for(int i=1;i<=m;i++)
		ans=max(ans,save[i]+save[i+m]);
	printf("%lld",sum-ans);	
	return 0;
}
/*
5 6
1 5 2 6 3*/

Measured memory_bytes: 6272
<?php

fscanf(STDIN, "%d", $N);
$V = explode(' ', trim(fgets(STDIN)));
$C = explode(' ', trim(fgets(STDIN)));

$max = 0;
for ( $i = 0; $i <= $N; $i++ ) {
    if (($V[$i] - $C[$i]) > 0) {
        $max += ($V[$i] - $C[$i]);
    }
}

echo $max;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#include <bitset> 
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define dd(x) cout<<#x<<" = "<<x<<" "
#define mes(p) memset(p,0,sizeof(p))
#define all(x) x.begin(),x.end()
#define rson mid+1,r,rt<<1|1
#define sz(x) (int)x.size()
#define lson l,mid,rt<<1
#define mp make_pair 
#define pb push_back
#define ls (rt<<1)
#define se second
#define rs (ls|1)
#define fi first
typedef pair <int ,int > pi;
typedef vector <int > vi;
typedef long long ll;
const int maxn=2e6+5;
const int mod= 1e9+7;
int solve(){
	int n;
	cin >> n;
	rep(i,1,10) if(n%i==0 && n/i <=9) return 1;
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	if(solve()) cout << "Yes";
	else cout << "No";
	return 0; 
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
k = gets.to_i

char = s[k-1]
ss = s.gsub(char, "A").chars

tmp = ""
n.times do |i|
  if ss[i] == "A"
    tmp << s[i]
  else
    tmp << "*"
  end
end

puts tmp


Measured memory_bytes: 1788
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

/*

12
1
//=> 1

121
3
//=> 2

*/

fn main() {
    let S = rl();
    let mut K = read!(usize);

    let mut x = '1';

    for c in S.chars() {
        if K == 1 {
            x = c;
            break;
        }
        K -= 1;

        if c != '1' {
            x = c;
            break;
        }
    }

    println!("{}", x)
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        int b = a.IndexOf("a");
        int c = a.IndexOf("b");
        int d = a.IndexOf("c");
        if(b+c+d == 3){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 11348
import copy

N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

B = copy.deepcopy(A)
for i in range(N):
    for j in range(i, N):
        for k in range(N):
            if not (i != j and j != k and k != i):
                continue
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            if A[i][j] == A[i][k] + A[k][j]:
                B[i][j] = 0

ans = 0
for i in range(N):
    for j in range(i, N):
        ans += B[i][j]

print(ans)



Measured memory_bytes: 55388
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n=in(); 
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vi g; g.reserve(n);
  g.pb(a[n-1]);

  for(int i=n-2;i>=0;--i){
    auto it = upper_bound(all(g), a[i]);
    if(it==g.end()){ g.pb(a[i]); }
    else{
      (*it) = a[i];
      if(it!=g.begin()){
        if((*it)<*(it-1)){
          swap(*it, *(it-1));
        }
      }
    }
  }
  cout << g.size() << endl;
  return 0;
}


Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc133/tasks/abc133_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: u64, a: u64, b: u64
    };
    println!("{}", min(n*a, b));
}


Measured memory_bytes: 4352