akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int N;

int dfs(ll a){
    if(a > N) return 0;
    
    int ret = 0;
    string s = to_string(a);
    bool s7 = false, s5 = false, s3 = false;
    rep(i, s.size()){
        if(s.at(i) == '7') s7 = true;
        else if(s.at(i) == '5') s5 = true;
        else if(s.at(i) == '3') s3 = true;
    }
    if(s7 && s5 && s3) ret++;
    
    ret += dfs(10 * a + 3) + dfs(10 * a + 5) + dfs(10 * a + 7);
    return ret;    
}

int main(){
    cin >> N;
    cout << dfs(0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String N = sc.next();

		int ans = 0;

		for (int i = 0; i < N.length(); i++) {
			String in = N.substring(i, i+1);
			if (in.equals("2")) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char c[101];
  int h;
  int l;
  while(cin>>c){
    l = strlen(c);
    for(int i=0;i<l;i++){
      if(c[i]!='@') cout << c[i]; 
      else{
	i++;
	h = c[i] - '0';
	i++;
      for(int j=0;j<h;j++) cout << c[i];
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Vsort(v) sort(All(v))
#define VsortR(v) sort(All(v), std::greater<__typeof(v[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    string s, t;

	cin >> s;
	cin >> t;

	if (s == t) {
		Out("Yes");
	} else {
		int i, j, len = s.size() - 1;

		rep(i, len) {
		    nepi(j, len + 1, 1) swap(s[j], s[j - 1]);

			if (s == t) {
				Out("Yes");

				return 0;
			}
		}

		Out("No");
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		int[] a = new int[scan.nextInt()];
		for(int i=0; i<a.length; i++){
			a[i] = scan.nextInt();
		}
		for(int i=0; i<a.length; i++){
			System.out.print(a[a.length-1-i]+((i==a.length-1)?"":" "));
		}
		System.out.println();

	}

}

Measured memory_bytes: 19000
#include<stdio.h>
int main(void)
{
	int A,B,C;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	if(C>A-B){
		printf("%d", C-A+B);}
		else {
			printf("0");}
	return 0;
}	
	

Measured memory_bytes: 128
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
S = input()
Q = int(input())
k = list(map(int, input().split()))

DM_total = [(0,0,0)]
C_list = []

for i in range(N):
	if S[i] == "D":
		DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
	elif S[i] == "M":
		DM_total.append((DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0]))
	else:
		DM_total.append(DM_total[-1])
	if S[i] == "C":
		C_list.append(i)

ans_list = [0]*Q

for c in C_list:
	for q in range(Q):
		if k[q] > c:
			ans_list[q] += DM_total[c + 1][2]
		else:
			ans_list[q] += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
			ans_list[q] -= DM_total[c + 1 - k[q]][0] * (DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1])

for q in range(Q):
	print(ans_list[q])

Measured memory_bytes: 143060
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int fiveHundred;
        fiveHundred = x/500;
        int xx = x - fiveHundred * 500;
        int five;
        five = xx/5;
        int a = fiveHundred * 1000;
        int b = five * 5;
        System.out.println(a + b);
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
ll INF = 1e12;

int main() {
  int N, M, L;
  cin >> N >> M >> L;
  VVI d(N, VI(N, INF));
  VVI d2(N, VI(N, INF));
  rep(i, N) {
    d.at(i).at(i) = 0;
    d2.at(i).at(i) = 0;
  }
  rep(i, M) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--;
    b--;
    d.at(a).at(b) = c;
    d.at(b).at(a) = c;
  }
  rep(k, N) {
    rep(i, N) {
      for (int j = i + 1; j < N; j++) {
        d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
        d.at(j).at(i) = d.at(i).at(j);
      }
    }
  }
  rep(i, N) {
    for (int j = i + 1; j < N; j++) {
      if (d.at(i).at(j) < L + 1) {
        d2.at(i).at(j) = 1;
        d2.at(j).at(i) = 1;
      }
    }
  }

  rep(k, N) {
    rep(i, N) {
      for (int j = i + 1; j < N; j++) {
        d2.at(i).at(j) = min(d2.at(i).at(j), d2.at(i).at(k) + d2.at(k).at(j));
        d2.at(j).at(i) = d2.at(i).at(j);
      }
    }
  }
  int Q;
  cin >> Q;
  rep(i, Q) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if (d2.at(s).at(t) > INF - 1) {
      d2.at(s).at(t) = 0;
    }
    cout << d2.at(s).at(t) - 1 << endl;
  }

  return 0;
}


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

int main(){
  int a[15],b[15][14][2],c[15];
  int n,i,j,k,kotae=0,kari=0,check=1;
  for(i=0;i<15;i++){
    a[i]=-1;
    for(j=0;j<14;j++){
      for(k=0;k<2;k++){
        b[i][j][k]=0;
      }
    }
  }
  cin>>n;
  for(i=0;i<n;i++){
    cin>>c[i];
    for(j=0;j<c[i];j++){
      cin>>b[i][j][0]>>b[i][j][1];
    }
  }
  for(a[0]=0;a[0]<2;a[0]++){
  for(a[1]=0;a[1]<2;a[1]++){
  for(a[2]=0;a[2]<2;a[2]++){
  for(a[3]=0;a[3]<2;a[3]++){
  for(a[4]=0;a[4]<2;a[4]++){
  for(a[5]=0;a[5]<2;a[5]++){
  for(a[6]=0;a[6]<2;a[6]++){
  for(a[7]=0;a[7]<2;a[7]++){
  for(a[8]=0;a[8]<2;a[8]++){
  for(a[9]=0;a[9]<2;a[9]++){
  for(a[10]=0;a[10]<2;a[10]++){
  for(a[11]=0;a[11]<2;a[11]++){
  for(a[12]=0;a[12]<2;a[12]++){
  for(a[13]=0;a[13]<2;a[13]++){
  for(a[14]=0;a[14]<2;a[14]++){
                               
  check=1;
  for(i=0;i<n;i++){
    if(a[i]==1){
      for(j=0;j<c[i];j++){
        if(a[b[i][j][0]-1]!=b[i][j][1]){
          check=0;
        }
      }
    }
  }
  if(check==1){
    kotae=max(kotae,kari);
  }
    
  kari=kari+1-2*a[14];
  }
  kari=kari+1-2*a[13];
  }
  kari=kari+1-2*a[12];
  }
  kari=kari+1-2*a[11];
  }
  kari=kari+1-2*a[10];
  }
  kari=kari+1-2*a[9];
  }
  kari=kari+1-2*a[8];
  }
  kari=kari+1-2*a[7];
  }
  kari=kari+1-2*a[6];
  }
  kari=kari+1-2*a[5];
  }
  kari=kari+1-2*a[4];
  }
  kari=kari+1-2*a[3];
  }
  kari=kari+1-2*a[2];
  }
  kari=kari+1-2*a[1];
  }
  kari=kari+1-2*a[0];
  }
    
  cout<<kotae+n-15;
  
}

Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine


main :: IO ()
main = do
  [k, s] <- readInts
  print $ numbers k s

numbers
  :: Int -> Int -> Int
numbers k = length . numbers' k 

numbers' :: Int -> Int -> [(Int,Int,Int)]
numbers' k s 
  = [ (x,y,z) | x <- [0..k]
              , y <- [0..k]
              , let z = s - x - y
              , 0 <= z && z <= k
              ]

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);

	std::priority_queue<i64> qu;
	for(int i = 0; i < n; i++) qu.push(a[i]);
	while(!qu.empty() and m--) {
		auto p = qu.top(); qu.pop();

		if((p >> 1) >= 0) qu.push(p >> 1);
	}

	i64 ans = 0;
	while(!qu.empty()) {
		ans += qu.top();
		qu.pop();
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2296
#include <iostream>
#include <string>

int main() {
    int n;
    std::cin >> n;
    std::string prefix, suffix;
    std::cin >> prefix;
    std::cin >> suffix;
    for (size_t i=0;i<n;++i) {
        bool flg = true;
        for (size_t j=0;(j+i)<n;++j) {
            if (prefix[j+i] != suffix[j]) {
                flg = false;
                break;
            }
        }
        if (flg) {
            std::cout << (n + i) << std::endl;
            return 0;
        }
    }
    std::cout << (2 * n) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int dx[2][9]={
	{-2,-1,0,1,2,-1,0,1,0},
	{-2,-1,0,1,2,-1,0,1,0}
};
int dy[2][9]={
	{1,1,1,1,1,2,2,2,3},
	{-1,-1,-1,-1,-1,-2,-2,-2,-3}
};
int main(){
	int n,m;
	while(cin>>m>>n,n+m){
		vector<vector<char> >in(n,vector<char>(m));
		rep(i,n)rep(j,m)cin>>in[i][j];
		int dp[62][32][2];
		rep(i,62)rep(j,32)rep(k,2)dp[i][j][k]=inf;
		queue<pair<pii,pii> >q;
		rep(i,m)if(in[n-1][i]=='S'){
			dp[n-1][i][0]=dp[n-1][i][1]=0;
			q.push(pair<pii,pii>(pii(n-1,i),pii(0,0)));//x,y,r or l,cost
			q.push(pair<pii,pii>(pii(n-1,i),pii(1,0)));//x,y,r or l,cost
		}
		while(!q.empty()){
			pii a=(q.front()).first;
			pii b=(q.front()).second;
			q.pop();
			if(dp[a.first][a.second][b.first]<b.second)continue;
//			cout<<a.first<<" "<<a.second<<" "<<b.first<<" "<<b.second<<endl;
			rep(i,9){
				int nx=a.first+dx[b.first][i];
				int ny=a.second+dy[b.first][i];
				int cost=dp[a.first][a.second][b.first];
				if(nx<0||ny<0||nx>=n||ny>=m)continue;
				if(isdigit(in[nx][ny]))cost+=in[nx][ny]-'0';
				if(in[nx][ny]=='X')continue;
				if(dp[nx][ny][b.first^1]>cost){
					dp[nx][ny][b.first^1]=cost;
					//if(in[nx][ny]!='T')
						q.push(pair<pii,pii>(pii(nx,ny),pii(b.first^1,cost)));
				}
			}
		}
		int out=inf;
		rep(i,m)if(in[0][i]=='T')out=min(out,min(dp[0][i][0],dp[0][i][1]));
		if(out==inf)out=-1;
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1260
import sys,math,collections
from collections import defaultdict
import math,sys
#from itertools import permutations,combinations

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
	

def get_array():
	l=list(map(int, input().split()))
	return l
def sod(n):
	n,c=str(n),0
	for i in n:	
		c+=int(i)
	return c	
#file()	
def main():
	#a,b=map(int, input().split())
	l=[]

	for _ in range(int(input())):
		s=input()
		l.append(s)
	#print(l)	
	c=collections.Counter(l)
	print('AC','x',c['AC'])
	print('WA','x',c['WA'])
	print('TLE','x',c['TLE'])
	print('RE','x',c['RE'])
	'''n,x=map(int, input().split())
		l=list(map(int, input().split()))
		l.sort()
		for i in range(len(l)):
			if(2*l[i]>x):
				ind=i
				break
		
		l=l[ind:]+l[:ind]
		print(l)
		cures=len(l)
		i,ans=0,0
		print('h')
		while(cures>0):
			print("nz")
			if(x>=l[i]):
				cures-=1
				x=2*l[i]
				i+=1
			else:
				temp=l[i]
				l[i]=l[i]-x

				l[i]=min(2*l[i],temp)
			ans+=1
		print(ans)'''



		







		
		
		











		








if __name__ == '__main__':
    main()


Measured memory_bytes: 16560
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

struct UnionFind {

	int Par[100000];
	int Rank[100000];

	UnionFind(int n) {
		for (int i = 0; i < n; i++) {
			Par[i] = i;
			Rank[i] = 0;
		}
	}

	int find(int x) {
		if (Par[x] == x) {
			return x;
		}
		else {
			return Par[x] = find(Par[x]);
		}
	}

	void unite(int  x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (Rank[x] < Rank[y]) {
			Par[x] = y;
		}
		else {
			Par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	int n;
	cin >> n;
	UnionFind uf(n);
	int q;
	cin >> q;
	REP(i, q) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 0)uf.unite(b, c);
		else cout << uf.same(b, c) << endl;
	}
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll p=n%1000;
    if(p!=0)
    cout<<1000-p;
    else
    cout<<0;
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>

using namespace std;

class Dice
{
  public:
    vector<int> diceNum;
    Dice(vector<int>& inputs);
    void toW();
    void toS();
    void ParallelRotation();
};

Dice::Dice(vector<int>& inputs)
{
  diceNum=inputs;
}

void Dice::toW()
{
  swap(diceNum[0],diceNum[3]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[2]);
}

void Dice::toS()
{
  swap(diceNum[0],diceNum[1]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[4]);
}

void Dice::ParallelRotation()
{
  swap(diceNum[1],diceNum[2]);
  swap(diceNum[2],diceNum[4]);
  swap(diceNum[4],diceNum[3]);
}

int main(int argc,char* argv[])
{
  vector<int> inputs(6);
  int count,a,b;
  for(int i=0;i<6;i++){cin >> inputs[i];}
  Dice dice(inputs);
  cin >> count;
  for(int i=0;i<count;i++)
  {
    cin >> a >> b;
    while(1)
    {
      if(dice.diceNum[0]==a) break;
      dice.toW();
      if(dice.diceNum[0]==a) break;
      dice.toS();
    }
    while(1)
    {
      if(dice.diceNum[1]==b)break;
      dice.ParallelRotation();
    }
    cout << dice.diceNum[2] << endl;
  }
}

Measured memory_bytes: 3136
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

LL A, B;

LL gcd(LL x, LL y) {
	if (!y)return x;
	return gcd(y, x % y);
}

int main() {
	cin >> A >> B;
	cout << A * B / gcd(A, B) << endl;
	return 0;
}

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

using namespace std;

int main() {
  string s,p,rs,t1,t2;
  int n,indexa,indexb;

  cin >> s >> n;

  for(int i=0;i<n;i++){
    cin >> p >> indexa >> indexb;
    rs = t2 = t1 = "";
    if(p == "replace"){
      cin >> rs;
      for(int j=0;j<s.length();j++){
        if(j<indexa){
          t1+=s[j];
        }
        else if(j>indexb){
          t2+=s[j];
        }
      }
      s = t1 + rs + t2;
    }
    if(p == "reverse"){
      for(int j=0;j<s.length();j++){
        if(j<indexa){
          t1+=s[j];
        }
        else if(j>indexb){
          t2+=s[j];
        }
        else{
          rs+=s[j];
        }
      }
      reverse(rs.begin(), rs.end());
      s = t1 + rs + t2;
    }
    if(p == "print"){
      for(int j=indexa;j<=indexb;j++){
        cout << s[j];
      }
      cout << endl;
    } 
  }
}


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

int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int num=0;
        int zz=i;
        while(zz)
        {
            zz/=10;
            num++;
        }
        if(num&1)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = n - 1;
		for (long i = 1; i*i <= n; i++) {
			if (n % i == 0) {
				ans = Math.min(ans, i + (n / i) - 2);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35760
/*input
 
*/
 
 
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll N = 1e6+5;
const ll mod=1e9+9; 
int solve()
{
	ll n;cin>>n;
	cout<<(ll)pow(n,3)<<"\n";
	return 0;
}
 
int main()
{
	auto start = chrono::high_resolution_clock::now();
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	ll test_cases=1;
	// cin>>test_cases;
	while(test_cases--)
		solve();
 
	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct edge {
    int t, i;
};

struct s_edge {
    int s, t, c;
};

using graph = vector<vector<edge>>;

int main() {
    int n; cin >> n;
    graph g(n);
    vector<s_edge> edges(n-1);

    REP(i, n-1) {
        int a, b; cin >> a >> b;
        --a; --b;
        g[a].push_back({b, i});
        g[b].push_back({a, i});
        edges[i] = {a, b, -1};
    }

    int c = 0;
    vector<int> vis(n, false);

    function<void(int, int)> rec = [&](int v, int bc) {
        vis[v] = true;

        int nc = 0;
        for (auto e : g[v]) {
            if (!vis[e.t]) {
                if (nc == bc) nc++;
                edges[e.i].c = nc;
                rec(e.t, nc);
                nc++;
            }
        }

        c = max(c, nc);
    };
    
    rec(0, -1);

    cout << c << endl;
    REP(i, n-1) cout << edges[i].c + 1 << endl;

    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n)  for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define ld long double
#define ull unsigned long long int


void solve()
{
	//freopen("input.txt","r",stdin);
        int a;
cin>>a;
cout<<a+pow(a,2)+pow(a,3)<<endl;
}


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

solve();

	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    char s;
    cin >> s;
    if(i+1==k)
      s+=32;
    cout << s;
  }
  cout << endl;
}

Measured memory_bytes: 256
ParseInt(x) = parse(Int,x)
ParseMap(x::Array{SubString{String},1}) = map(ParseInt,x)
function main()
    n = ParseInt(readline())
    s = chomp(readline())
    k = ParseInt(readline())
    S = s[k]
    for i in s
        print(i == S ? i : '*')
    end
    println("")
end
main()


Measured memory_bytes: 110216
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>

typedef long long ll;

int main(){
  ll A, B, H, M;
  std::cin >> A >> B >> H >> M;
  double pi = 3.14159265358979323846;
  double minutes = H * 60 + M;

  double angle = std::fabs((60 * H - 11 * M) * pi / 360);
  double c = std::sqrt(A * A + B * B - 2 * A * B * std::cos(angle));
  std::cout << std::setprecision(16) << c << std::endl;
  return 0;
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
    ll n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}

int main()
{
    ios_base :: sync_with_stdio(false);
    ll t,i=1;
   // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



int main()
{
	int n, m;
	cin >> n >> m;
	vector<bool> a(n + 1, true); // can't step
	for (int i = 0; i < m; i++) { int l; cin >> l; a[l] = false; }
	
	vector<long long int> dp(n + 1, 0);//dp table

	//initial condition
	// fn = fn-1 + fn-2
	dp[0] = 1;
	if (a[1]) { dp[1] = 1; }

	for (int i = 2; i < n + 1; i++)
	{
		if (a[i - 1]) { dp[i] += dp[i - 1]; } //fn-1
		if (a[i - 2]) { dp[i] += dp[i - 2]; } //fn-2
		dp[i] %= 1000000007;
	}

	cout << dp[n] << endl;

	return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 998244353;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0; 
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    char tmp='0';
    string S;
    bool flag=false;
    cin >> S;

    for(int i='a'; i<= 'z'; i++){
	for(int j =0; j<S.size(); j++){
	    if(i == S[j])
		break;
	    if(j == S.size()-1)
		flag = true;
	}

	if(flag){
	    tmp = i;
	    break;
	}
	    
	    
    }
    if(flag)
	cout <<tmp<<endl;
    else
	cout <<"None"<<endl;

}



Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    long k =sc.nextLong()-1;
    int st=0;
    while(s.length()>st&&s.charAt(st)=='1'){
      st++;
    }
    if(k<st){
      System.out.println(1);
    }else{
      System.out.println(s.charAt(st));
    }
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int a,b,c;
    cin >> a >> b >> c;
    bool k = false ;
    if ( a == b && c != a){
        k = true;
    }
    if ( a == c && c != b){
        k = true;
    }
    if ( c == b && c != a){
        k = true;
    }
    if (k){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 55;
char tmp[maxn];
string s;

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  return true;
}

void solve() {
  int n = sz(s) - 8;
  s.resize(n);
  printf("%s\n", s.c_str());
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    lr = [list(map(int, input().split())) for i in range(m)]
    l = 0
    r = 10 ** 5 + 1
    for i in range(m):
        if lr[i][0] > l:
            l = lr[i][0]

        if lr[i][1] < r:
            r = lr[i][1]

    if r < l:
        print(0)
    else:
        print(r - l + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 59864
def solve(n, m, a, b):
    islands = set()

    for i in range(m):
        if(a[i] == 1):
            islands.add(b[i])
        if(b[i] == 1):
            islands.add(a[i])

    for i in range(m):
        if(a[i] == n and b[i] in islands):
            return "POSSIBLE"
        if(b[i] == n and a[i] in islands):
            return "POSSIBLE"
    return "IMPOSSIBLE"

(n, m) = map(int, input().split())
a = []
b = []

for i in range(m):
    (ai, bi) = map(int, input().split())
    a.append(ai)
    b.append(bi)

print(solve(n, m, a, b))


Measured memory_bytes: 21888
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int X[]=new int[M];
		int S[]=new int[M];
		long sum=0;
		for(int i=0;i<M;i++){
			X[i]=stdIn.nextInt();
		}
		if(N>=M){
			System.out.println(0);
			System.exit(0);
		}
		Arrays.sort(X);
		for(int i=1;i<M;i++){
			sum+=X[i]-X[i-1];
			S[i-1]=X[i]-X[i-1];
		}
		Arrays.sort(S);
		for(int i=0;i<N-1;i++){
			sum-=S[M-1-i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 60916
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define endl "\n"
#define FILEIO freopen("test1.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
#define ALL(v) v.rbegin(),v.rend()
typedef vector<LL> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef map<LL ,LL > mii;
typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second
 

	   		    

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

	int sum=0;

	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
	     if(i%2!=0 && a%2!=0)
		    sum++;
	}
	cout<<sum<<endl;	

	
}

Measured memory_bytes: 3508
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a = 0, b = 0, t;
    for(int i =0; i < n; i++){
        cin >> t;
        if(t % 2 == 0) a++;
        if(t % 4 == 0) b++;
    }

    if(a+b >= n || b >= n/2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

typedef long long ll;

ll N;
int ans = 0;

int DigitSum(ll n) {
  int r = 0;
  while (n > 0) {
    r += n%10;
    n /= 10;
  }
  return r;
}

int main() {
  cin >> N;

  int i = 0;
  ll j = 1;
  while (N >= j) {
    if (i == 0) {
      ans = DigitSum(N);
    } else {
      ll n = (N/j)*j-j + j-1;
      ans = max(ans, DigitSum(n));
    }
    // cout << i << " " << j << " " << ans << endl;
    ++i;
    j *= 10;
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <queue>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

    if (n == 2) {
        int a, b;
        cin >> a >> b;
        if (a < b) swap(a, b);
        cout << a - b << endl;
        cout << a << " " << b << endl;
        return 0;
    }

    priority_queue<ll, vector<ll>, greater<ll>> Qpos;
    priority_queue<ll, vector<ll>> Qneg;
    ll sum = 0;
    int zero = 0;
    REP(i, 0, n) {
        int x;
        cin >> x;
        if (x > 0) {
            Qpos.emplace(x);
        } else if (x < 0) {
            Qneg.emplace(x);
        } else {
            zero++;
        }
        sum += abs(x);
    }
    if (zero == n) {
        cout << 0 << endl;
        REP(i, 0, n - 1) {
            cout << "0 0" << endl;
        }
        return 0;
    }
    while (zero && Qneg.size()) {
        Qneg.emplace(0);
        zero--;
    }
    while (zero && Qpos.size()) {
        Qpos.emplace(0);
        zero--;
    }

    if (Qneg.size() == 0) {
        ll m = Qpos.top();
        Qpos.pop();
        ll s = Qpos.top();
        Qpos.pop();

        sum -= 2 * m;
        cout << sum << endl;
        cout << m << " " << s << endl;
        Qneg.emplace(m - s);
    } else if (Qpos.size() == 0) {
        ll m = Qneg.top();
        Qneg.pop();
        ll s = Qneg.top();
        Qneg.pop();

        sum += 2 * m;
        cout << sum << endl;
        cout << m << " " << s << endl;
        Qpos.emplace(m - s);
    } else {
        cout << sum << endl;
    }

    if (zero + Qpos.size() + Qneg.size() == 1) {
        return 0;
    }

    ll base = Qpos.top();
    Qpos.pop();
    while (Qneg.size()) {
        if (Qneg.size() == 1) {
            if (Qpos.size() == 0) {
                cout << base << " " << Qneg.top() << endl;
                base -= Qneg.top();
            } else {
                cout << Qneg.top() << " " << base << endl;
                base = Qneg.top() - base;
            }
        } else {
            cout << base << " " << Qneg.top() << endl;
            base -= Qneg.top();
        }
        Qneg.pop();
    }

    while (Qpos.size()) {
        if (Qpos.size() == 1) {
            cout << Qpos.top() << " " << base << endl;
            base = Qpos.top() - base;
        } else {
            cout << base << " " << Qpos.top() << endl;
            base = base - Qpos.top();
        }
        Qpos.pop();
    }

    dump(base);
    return 0;
}


Measured memory_bytes: 2804
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long
#define pb push_back
#define mod 1000000007
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define inf 1e18
#define pre(x,y) fixed<<setprecision(y)<<x
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define gcd(x,y) __gcd(x,y)
#define mp make_pair
double dp[301][301][301];

double diceThrow(int  x,int  y,int  z,int  n)
{
	if(x==0 && y==0 && z==0) return 0;
	if(x<0 || y<0 || z<0) return 0;
	if(dp[x][y][z]>-0.9) return dp[x][y][z];
	else
	{
		double ans=n+x*diceThrow(x-1,y,z,n)+y*diceThrow(x+1,y-1,z,n)+z*diceThrow(x,y+1,z-1,n);
		ans=ans/(x+y+z);
		return dp[x][y][z]=ans;		
	}
}




int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i,j,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int x,y,z;
    x=y=z=0;
    for(i=0;i<n;i++)
    {
    	if(a[i]==1) x++;
    	if(a[i]==2) y++;
    	if(a[i]==3) z++;
    }
    memset(dp,-1,sizeof(dp));
    cout<<pre(diceThrow(x,y,z,(double)n),9)<<endl;

	return 0;
}


Measured memory_bytes: 216868
#include<bits/stdc++.h>
#define ri register int
using namespace std;
inline int read(){
	#define gc getchar
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
	#undef gc
}
const int mod=998244353;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:a-=mod;}
inline void Dec(int&a,int b){(a-=b)<0?a+=mod:a;}
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
int n;
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<max(a-b,max(a+b,a*b));
	return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int, input().split()))
count=0
stock=[]
for i in range(n-1):
 if h[i]>=h[i+1]:
  count+=1
 else:
  stock.append(count)
  count=0
stock.append(count)
stock.sort()
print(stock[-1])

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

struct trump{
    char mark; 
    int value;
};

void bubbleSort(trump C[], int N){
    for(int i = 0 ; i < N ; i++){
        for(int j = N-1 ; j >= i+1 ; j--){
            if(C[j].value < C[j-1].value){
                swap(C[j] , C[j-1]);
            }
        }
    }
}

void selectionSort(trump C[],int N){
    int minj;
    for(int i = 0 ; i < N ; i++){
        minj = i;
        for(int j = i ; j < N ; j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        swap(C[i] , C[minj]);
    }
}

void point(trump C[] , int N){
    for(int i = 0 ; i < N ; i++){
        if(i > 0){
            cout << " " ;
        }
        cout << C[i].mark << C[i].value;
    }
    cout << endl;
}

bool isStable(trump C1[] ,trump C2[] , int N){
    for(int i = 0 ; i < N ; i++){
        if(C1[i].mark != C2[i].mark){
            return false;
        }
    }
    return true;
}

int main(){
    trump C1[100];
    trump C2[100];
    int N;

    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> C1[i].mark >> C1[i].value;
    }

    for(int i = 0 ; i < N ; i++){
        C2[i] = C1[i];
    }

    bubbleSort(C1,N);
    selectionSort(C2,N);

    point(C1,N);
    cout << "Stable" << endl;
    point(C2,N);
    if(isStable(C1 , C2 , N)){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2,s3;
    ll i,j,k,l,temp=0;
    cin>>s1>>s2>>s3;
    char c;
    i=0;
    while(true)
    {
        if(c=='a' || i==0)
        {
            if(s1.length()==0)
            {
                cout<<"A\n";
                return 0;
            }
            c=s1[0];
            s1.erase(s1.begin());
        }
        else if(c=='b')
        {
            if(s2.length()==0)
            {
                cout<<"B\n";
                return 0;
            }
            c=s2[0];
            s2.erase(s2.begin());
        }
        else
        {
            if(s3.length()==0)
            {
                cout<<"C\n";
                return 0;
            }
            c=s3[0];
            s3.erase(s3.begin());
        }
        i++;
    }
    return 0;
}


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

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

using namespace std;

int main(){
  ll n;
  cin>>n;
  vector<vector<pair<int, int>>> graph(n+1);
  
  rep(i, n){
    ll u,v,w;
    cin>>u>>v>>w;
    graph[u].emplace_back(v,w);
    graph[v].emplace_back(u,w);
  }
  
  queue<int> q;
  q.push(1);
  vector<int> results(n+1, -1);
  results[1]=0;

  while(!q.empty()){
    int c = q.front();
    q.pop();
//    cout<<c<<endl;
    rep(i, graph[c].size()){
      int to = graph[c][i].first;
      int cost = graph[c][i].second;

//      cout<<to<<' '<<cost<<endl;

      if(results[to]==-1){
        q.push(to);
      }else{
        continue;
      }

      if(cost%2==0){
        results[to] = results[c];
      }else{
        results[to] = (results[c]+1)%2;
      }
    }
  }
  
  rep(i, n){
    cout<<results[i+1]<<endl;
  }

  return 0;

}


Measured memory_bytes: 6784
def main():

    N = int(input())

    # ref = 1
    # for i in range(1, N//2+1):
    #     ref *= 2*i
    # print(ref)

    if N % 2 == 1:
        return 0
    else:
        tens = []
        p = 5
        while p <= N:
            tens.append(p)
            p *= 5

        ans = 0
        for p in tens:
            ans += N // (2*p)
        return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10**7)
P=10**9+7
N=int(input())
edges = [[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    edges[a-1].append((b-1, i))
    edges[b-1].append((a-1, i))
L=[0 for i in range(N)]
def dfs(cur, x):
  res = 1
  for i in edges[cur]:
    if i[1]!=x:
      res += dfs(i[0], i[1])
  L[x]=res
  return res
dfs(0,-1)
L2=[1]
i2=pow(2,P-2,P)
for i in range(N):
  L2.append(L2[-1]*i2%P)
cnt = 0
for i in L:
  cnt+=(1-L2[i])* (1-L2[N-i])
print((-N*i2-L2[-1]+cnt+1)%P)

Measured memory_bytes: 202520
#include <iostream>

using namespace std;

int main() {
	
	int n;
	cin >> n;
	int* arr = new int[n];

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

	for (int i = n - 1; i > 0; i--) {
		cout << arr[i] << " ";
	}
	cout << arr[0] << endl;

	delete[] arr;

	return 0;
}





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

set<int> st;
int cnt;

int main() {
	int k; cin >> k;
	int curr = 7 % k;
	st.insert(curr);
	while (curr) {
		curr *= 10;
		curr += 7;
		curr %= k;
		if (st.find(curr) != st.end()) {
			cout << -1; return 0;
		}
		cnt++;
		st.insert(curr);
	}
	cout << ++cnt;
}


Measured memory_bytes: 50344
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 998244353
using namespace std;
typedef long long ll;

struct UnionFind{
  vector<int> par; // 親ノード
  vector<int> rank; // ランク

  UnionFind(int n) { //初期化
    par.resize(n); rank.resize(n);
    rep(i,n) {par[i] = i, rank[i] = 0;}
  }

  int root(int x) { //ノードの根を返す
    if (par[x] == x) return x; //親が自分なら自分を返す
    else {
      int r = root(par[x]); //根まで遡りながら経路圧縮
      return par[x] = r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x; //ランクの小さい方に接続
    return true;
  }
};

struct joho{int a; int b; int c;};

void Main(){

  ll N,M,Q;
  cin>>N>>M>>Q;

  UnionFind uf(N);

  vector<joho> jo;

  rep(i,Q){
    int a,b,c; cin>>a>>b>>c;
    jo.emplace_back((joho){a,b,c});
  }

  ll ren=N;

  rep(i,Q){
    if(jo[i].c==0){
      if(uf.merge(jo[i].a, jo[i].b)) --ren;
    }
  }

  bool onearu=false;

  rep(i,Q){
    if(jo[i].c==1){
      onearu=true;
      if(uf.issame(jo[i].a, jo[i].b)){
        cout<< "No"<<"\n";
        return;
      }
    }
  }
  //if((ren<=2 or M==N-1) and onearu){
  if((M==N-1) and onearu){
    cout<< "No"<<"\n";
    return;
  }

  if(M>(ren*(ren-1))/2+ N-ren){
    cout<< "No"<<"\n";
    return;
  }

  cout<< "Yes"<<"\n";

}

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


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

int main(){
    ll N, T;
    cin >> N >> T;

    vector<pair<ll, ll>> data(N);

    for (ll i = 0; i < N; i++){
        ll a, b;
        cin >> a >> b;
        data[i] = make_pair(a, b);
    }
    sort(data.begin(), data.end());

    vector<vector<ll>> dp(N, vector<ll>(T, 0));

    ll ans = 0;
  
  	for (ll i = 1; i < N; i++){
    	for (ll j = 0; j < T; j++){
        	if (j >= data[i-1].first){
            	dp[i][j] = max(dp[i-1][j], dp[i-1][j-data[i-1].first] + data[i-1].second);
            }else{
            	dp[i][j] = dp[i-1][j];
        	}
        }
   		ans = max(dp[i][T-1] + data[i].second, ans);
    }
  	cout << ans << "\n";
}

Measured memory_bytes: 70784
from sys import stdin, stdout


def main():
    line = stdin.readline()
    parts = line.split()
    a = int(parts[0])
    b = int(parts[1])
    c = int(parts[2])

    count5 = 0
    count7 = 0
    x = 0
    while x < 3:
        if int(parts[x]) == 5:
            count5 += 1
        elif int(parts[x]) == 7:
            count7 += 1
        x += 1

    if count5 == 2 and count7 == 1:
        rta = "YES"
    else:
        rta = "NO"

    stdout.write(rta)



main()

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    if((s[0]== 'A' and s[1]=='B') || (s[1]== 'A' and s[2]=='B' ) || (s[0]== 'B' and s[1]=='A') ||  (s[2]== 'A' and s[1]=='B'))cout<<"Yes";
    else cout<<"No";
   return 0;
}
 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n,a_i; cin >> n;
    int L[n];
    for (int i=1;i<=n;i++) {
        cin >> L[i];
    }
    int count=0,x=1;
    while (true) {
        x = L[x];
        count++;
        if (x==2) break;
        else if (count==n) {
            count = -1;
            break;
        }
    }
    cout << count<< endl;
}

Measured memory_bytes: 640