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

int main() {
	ll a;
	cin>>a;
	string s;
	cin>>s;
	if(a>=3200)
	{
		cout<<s;
	}
	else
	{
		cout<<"red";
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

#define int long long

int dp[51][1<<18];
int cc[1<<18];
int sm[19][1<<18];
signed main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(k,(1<<18)){
        int c = 0;
        for(int j=0;j<18;j++){
            if((k>>j)&1){
                c++;
            }
        }
        cc[k] = c;
    }
    for(int i=0;i<18;i++){
        rep(k,(1<<18)){
            if((k>>i)&1)continue;
            int s = i;
            rep(j,i){
                if((k>>j)&1){
                    s--;
                }
            }
            sm[i][k] = s;
            // if(k==1)cerr << i << " " << k << " " << s << endl;
        }
    }
    
    rep(j,51){
        rep(k,(1<<18)){
            dp[j][k] = inf;
        }
    }
    
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=50;j++){
            for(int bit=0;bit<(1<<n);bit++){
                if(cc[bit]!=i)continue;
                if(dp[j][bit]<inf){
                    for(int k=0;k<n;k++){
                        if((bit>>k)&1)continue;
                        bool f = 0;
                        if((k+10000-i)%2==0){
                            f = 0;
                        }else{
                            f = 1;
                        }
                        int s;
                        if(!f){
                            s = a[k];
                        }else{
                            s = b[k];
                        }
                        if(j>s)continue;
                        dp[s][bit^(1<<k)] = min(dp[s][bit^(1<<k)],dp[j][bit]+sm[k][bit]);
                    }
                }
            }
        }
    }
    int ans = inf;
    for(int j=0;j<=50;j++){
        if(dp[j][(1<<n)-1]<inf){
            ans = min(ans,dp[j][(1<<n)-1]);
        }
    }
    if(ans==inf){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 143616
#include<cstdio>
int N,K,Ans;
int main(){
	scanf("%d %d",&N,&K);
	for(int i=1;i<=N;i++)
		scanf("%*d");
	Ans=(N-K)/(K-1);
	if((N-K)%(K-1)!=0) Ans++;
	printf("%d\n",Ans+1);
	return 0;
}

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

struct Dice{
  Int s[6];
  void roll(char c){
    //the view from above
    // N
    //W E
    // S
    //s[0]:top
    //s[1]:south
    //s[2]:east
    //s[3]:west
    //s[4]:north
    //s[5]:bottom
    Int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    
    // migi neji (not verified)
    if(c=='L'){
      b=s[1];
      s[1]=s[3];
      s[3]=s[4];
      s[4]=s[2];
      s[2]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
    
  }
  Int top() {
    return s[0];
  }
  Int hash(){
    Int res=0;
    for(Int i=0;i<6;i++) res=res*256+s[i];
    return res;
  }
};
vector<Dice> makeDices(Dice d){
  vector<Dice> res;
  for(Int i=0;i<6;i++){
    Dice t(d);
    if(i==1) t.roll('N'); 
    if(i==2) t.roll('S'); 
    if(i==3) t.roll('S'),t.roll('S');
    if(i==4) t.roll('L'); 
    if(i==5) t.roll('R'); 
    for(Int k=0;k<4;k++){
      res.push_back(t);
      t.roll('E');
    }
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    Dice d;
    for(Int i=0;i<6;i++) d.s[i]=i+1;

    Int ans=d.top();
    for(Int i=0;i<n;i++){
      string s;
      cin>>s;
      d.roll(s[0]);
      ans+=d.top();
    }
    cout<<ans<<endl;
  }
  
  return 0;
}



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

const int EXP = 2e3 + 3;
const int DIM = 4e3 + 5;
const int MOD = 1e9 + 7;

pair<int, int> arr[DIM * DIM];
int fct[DIM * 2], inv[DIM * 2], dp[DIM][DIM];

inline int lgput( int x, int n ) {
    if( n == 0 )
        return 1;
    
    int y = lgput( x, n / 2 );
    
    y = ( 1LL * y * y ) % MOD;
    if( n % 2 == 1 )
        y = ( 1LL * y * x ) % MOD;
    
    return y;
}

inline int comb( int n, int k ) {
    return ( ( ( 1LL * fct[n] * inv[k] ) % MOD ) * inv[n - k] ) % MOD;
}

int main( void ) {
    
    fct[0] = inv[0] = 1;
    for( int i = 1; i < DIM * 2; i ++ ) {
        fct[i] = ( 1LL * fct[i - 1] * i ) % MOD;
        inv[i] = lgput( fct[i], MOD - 2 );
    }
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i].first >> arr[i].second;
        dp[EXP - arr[i].first][EXP - arr[i].second] ++;
    }
    
    for( int i = 1; i < DIM; i ++ )
    for( int j = 1; j < DIM; j ++ )
        dp[i][j] = ( dp[i][j] + dp[i - 1][j] + dp[i][j - 1] ) % MOD;
    
    int ans = 0;
    for( int i = 1; i <= n; i ++ ) {
        ans = ( ans + dp[EXP + arr[i].first][EXP + arr[i].second] ) % MOD;
        ans = ( ans - comb( ( arr[i].first + arr[i].second ) * 2, arr[i].first * 2 ) + MOD ) % MOD;
    }
    
    ans = ( 1LL * ans * lgput( 2, MOD - 2 ) ) % MOD;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 65792
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	S[K - 1] = tolower(S[K - 1]);

	cout << S;

	return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
ans = len(t)
 
for i in range(len(s)):
  if (i + len(t) > len(s)): break
  dif = 0
  for j in range(len(t)):
    if (s[i + j] != t[j]):
      dif += 1
  ans = min(ans, dif)
print(ans)

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

#define rad M_PI/3

typedef struct{
  double x,y;
} Point;

void print(Point);
void rec(Point,Point,int);
Point rotate(Point,Point);

int main(){
  int n;
  Point p1 = {0,0},p2 = {100,0};
  scanf("%d",&n);
  print(p1);
  if(n > 0){  rec(p1,p2,n); }
  print(p2);
  return 0;
}

void print(Point p){
  printf("%.10f %.10f\n",p.x,p.y);
}

void rec(Point p1,Point p2,int depth){
  if(depth == 0){ return; }
  Point s = {p1.x+(p2.x-p1.x)/3.0,p1.y+(p2.y-p1.y)/3.0};
  Point t = {p1.x+(p2.x-p1.x)*2.0/3.0,p1.y+(p2.y-p1.y)*2.0/3.0};
  Point u = rotate(s,t);
  rec(p1,s,depth-1);
  print(s);
  rec(s,u,depth-1);
  print(u);
  rec(u,t,depth-1);
  print(t);
  rec(t,p2,depth-1);
}

Point rotate(Point p1,Point p2){
  double x = p2.x-p1.x,y = p2.y-p1.y;
  Point p = {x*cos(rad)-y*sin(rad)+p1.x,x*sin(rad)+y*cos(rad)+p1.y};
  return p;
}

Measured memory_bytes: 644
using System;
using System.Linq;

namespace Exa2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(abc[0] == abc[1] && abc[0] == abc[2] ? "Yes" : "No");
        }
    }
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



  //二分探索(最小値を出す問題は疑う)
ll N, K;
vector<int>A;
vector<int>F;

bool C(ll x){
    ll res = 0;
    for(int i = 0; i < N; ++i){
		res += max(0ll, A[i]-x/F[i]);
    }
    return res <= K;
}

  ll binary_search(ll ok, ll ng){
    while(abs(ok - ng) > 1){
      ll mid = (ok + ng) / 2;
      if(C(mid)) ok = mid;
      else ng = mid;
    }
    return ok;
  }



int main(){
 cin >> N >> K;
A.resize(N);
F.resize(N);
REP(i, N) cin >> A.at(i);
REP(i, N) cin >> F.at(i);

sort(all(A));
sort(all(F));
reverse(all(F));
ll l = -1, r = 1e12;
cout << binary_search(r, l) << endl;
}

Measured memory_bytes: 1792
while True:
    cards=input()
    if cards=="-":
        break
    times=int(input())
    for i in range(times):
        s=int(input())
        tmp1=""
        tmp2=""
        for j in range(s):
            tmp1+=cards[j]
        for j in range(s,len(cards)):
            tmp2+=cards[j]
        cards=tmp2+tmp1
    print(cards)


Measured memory_bytes: 5592
#include<stdio.h>
#include<algorithm>
#define P 1000000007
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int G[105],vis[105];
char a[105][105];
int i,j,k,l,s,n,m,ans;
int main() {
	scanf("%d",&n);
	for (i=1;i<=2;i++) 
	for (j=1;j<=n;j++) {
		char c=getchar();
		while (c<'A'||c>'z') c=getchar();
		a[i][j]=c;
	}
	ans=1;
	int i=1;
	while (i<=n) {
		if (a[1][i]==a[2][i]) {
			if (i==1) ans=3;
			else if (a[1][i-1]==a[2][i-1]) ans=1ll*ans*2%P;
			i++;
		}
		else {
			if (i==1) ans=6;
			else if (a[1][i-1]==a[2][i-1]) ans=1ll*ans*2%P;
			else ans=1ll*ans*3%P;
			i+=2;
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
<?php

fscanf(STDIN, '%s', $S);
fscanf(STDIN, '%s', $T);

$ans = 0;

for ($i=0; $i < strlen($S); $i++) {
    if (substr($S, $i, 1) !== substr($T, $i, 1)) {
        $ans++;
    }
}

echo $ans;

echo PHP_EOL;


Measured memory_bytes: 16800
#include <iostream>
#include <vector>
#include <iterator>

std::pair<int, std::pair<int, int>> arr[3005][3005];

std::string a, b;

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

    std::cin >> a >> b;

    for(int i=1; i< a.length()+1; i++) for(int j=1; j< b.length()+1; j++)
    {
        if(a[i-1] == b[j-1])
        {
            arr[i][j] = {arr[i-1][j-1].first + 1, {i-1, j-1}};
        }
        else
        {
            if(arr[i-1][j].first > arr[i][j-1].first) arr[i][j] = {arr[i-1][j].first, {i-1, j}};
            else arr[i][j] = {arr[i][j-1].first, {i, j-1}}; 
        }        
    }
    int x = a.length(), y = b.length();
    std::vector<char> vec;
    while(x!=0||y!=0)
    {
        //std::cout << x << ' ' << y << '\n';
        int u = x, v = y;
        x = arr[u][v].second.first;
        y = arr[u][v].second.second;
        if(arr[u][v].first != arr[x][y].first) vec.push_back(a[u-1]);          
    }
    std::copy(std::rbegin(vec), std::rend(vec), std::ostream_iterator<char>(std::cout));  
    std::cout << '\n';
}

Measured memory_bytes: 105984
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = 1; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (cnt == 0 && s[h] == 'A') { a = h; cnt++; }
		if (s[h] == 'Z' && b < h) { b = h; }
	}
	cout << b - a + 1 << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long

#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##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

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

const long long INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
inline void Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

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

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

signed main(){
	int a,b,c,d,e,f,g;
	cin>>a>>b>>c>>d>>e>>f>>g;
	int ret=0;
	int k=a,l=d,m=e;
	ret+=b;
	ret+=a/2*2;
	a-=a/2*2;
	ret+=d/2*2;
	d-=d/2*2;
	ret+=e/2*2;
	e-=e/2*2;
	if(a+d+e==3)ret+=3;
	else if(a+d+e==2){
		if(a==1&&d==1&&k>1&&l>1)ret+=1;
		if(d==1&&e==1&&l>1&&m>1)ret+=1;
		if(e==1&&a==1&&m>1&&k>1)ret+=1;
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i=0; i< n; i++)
typedef long long ll;
using namespace std;
const int INF = 100000;
char maze[21][21];
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
int sx;
int sy;
int d[21][21];
int h, w;
typedef pair<int, int> P;
int mx = 0;

void bfs(int sx,int sy) {
	queue<pair<int, int>> q;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			d[i][j] = INF;
		}
	}
	P s = make_pair(sx, sy);
	q.push(s);
	d[sx][sy] = 0;
	
	while (q.size()) {
		P p = q.front(); q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			if (0 <= nx && 0 <= ny && nx < h && ny < w && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				P next = make_pair(nx, ny);
				q.push(next);
				d[nx][ny] = d[p.first][p.second]+1;
				if (d[nx][ny] > mx) mx = d[nx][ny];
			}


		}
	}
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> maze[i][j];
		}
	}
	vector<vector<int>> v(h,vector<int> (w,-1));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (maze[i][j] != '#') bfs(i, j);
		}
	}
	cout << mx << endl;
	
	return 0;
}

Measured memory_bytes: 256
function Dfs(v, n, visited) {
  var all_visited = true;
  
  for (var i = 0; i < n; i++) {
    if (visited[i] == false) {
      all_visited = false;
    }
  }

  if (all_visited) {
    return 1;
  }

  var ret = 0;

  for (var i = 0; i < n; i++) {
    if (!g[v][i]) continue;
    if (visited[i]) continue;

    visited[i] = true;
    ret += Dfs(i, n, visited);
    visited[i] = false;
  }

  return ret;
}

function Main(s) {
  // 頂点数 (木なので辺数は N-1 で確定)
  var s = s.split("\n").map(e => e.split(" ").map(e => e*1));
  n = s[0][0], m = s[0][1];
  var e = s.slice(1, m+1);
  // グラフ入力受取 隣接行列
  g = new Array(n+1);
  for (var i = 0; i < n; i++) g[i] = new Array(n).fill(false);
  for (var i = 0; i < m; i++) {
      g[e[i][0]-1][e[i][1]-1] = true;
      g[e[i][1]-1][e[i][0]-1] = true;
  }
  var visited = new Array(8).fill(false);
  visited[0] = true;

  console.log(Dfs(0, n, visited));
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

signed main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    string s;
    cin >> s;

    while(s.size() > 0){
        if(s.size()>4&&s.at(s.size()-5)=='d'&&s.at(s.size()-4)=='r'&&s.at(s.size()-3)=='e'&&s.at(s.size()-2)=='a'&&s.at(s.size()-1)=='m'){
            for(int i = 0;i < 5;i ++) s.pop_back();
            continue;
        }
        if(s.size()>6&&s.at(s.size()-7)=='d'&&s.at(s.size()-6)=='r'&&s.at(s.size()-5)=='e'&&s.at(s.size()-4)=='a'&&s.at(s.size()-3)=='m'&&s.at(s.size()-2)=='e'&&s.at(s.size()-1)=='r'){
            for(int i = 0;i < 7;i ++) s.pop_back();
            continue;
        }
        if(s.size()>4&&s.at(s.size()-5)=='e'&&s.at(s.size()-4)=='r'&&s.at(s.size()-3)=='a'&&s.at(s.size()-2)=='s'&&s.at(s.size()-1)=='e'){
            for(int i = 0;i < 5;i ++) s.pop_back();
            continue;
        }
        if(s.size()>5&&s.at(s.size()-6)=='e'&&s.at(s.size()-5)=='r'&&s.at(s.size()-4)=='a'&&s.at(s.size()-3)=='s'&&s.at(s.size()-2)=='e'&&s.at(s.size()-1)=='r'){
            for(int i = 0;i < 6;i ++) s.pop_back();
            continue;
        }

        break;
    }

    if(s.size() == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	char a;cin>>a;
	if('a'<=a&&a<='z')cout<<'a';else cout<<'A';
		
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3648
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<char> t(Q);
	vector<char> d(Q);
	for(int i = 0; i < Q; i += 1)
	{
		cin >> t[i] >> d[i];
	}

	int left = 0, right = N - 1;
	for(int i = Q - 1; i >= 0; i -= 1)
	{
		if(s[left] == t[i] && d[i] == 'L')
		{
			left += 1;
		}
		else if(s[right] == t[i] && d[i] == 'R')
		{
			right -= 1;
		}

		if(s[left - 1] == t[i] && d[i] == 'R')
		{
			left -= 1;
		}
		else if(s[right + 1] == t[i] && d[i] == 'L')
		{
			right += 1;
		}

		if(left > right)
			break;
	}

	std::cout << std::to_string(right - left + 1) << std::endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	string S, T;
	cin >> S >> T;

	int ans = 10000;
	for (int i = 0; i < S.size() - T.size() + 1; ++i) {
		int cnt = 0;
		for (int j = 0; j < T.size(); ++j) {
			if (T[j] != S[i + j]) {
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}

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


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long long int n, t, a[200010];
    long long int ans = 0;

    cin >> n >> t;

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

    for (int i = 1; i < n; i++) {
        if (a[i] - a[i-1] <= t) {
            ans += a[i] - a[i-1];
        }
        else {
            ans += t;
        }
    }

    cout << ans+t << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    int d=1;
    vector<int> asum(100,0),bsum(100,0);
    for(int i=1;i<=n;i++){
        if(i/d>=10)d*=10;
        if(i%10==0)continue;
        asum[(i/d)*10+(i%10)]++;
        bsum[(i/d)+(i%10)*10]++;
    }
    ll ans=0;
    for(int i=0;i<100;i++){
        ans+=(ll)asum[i]*bsum[i];
    }
    out(ans);
}

Measured memory_bytes: 3768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.stream.Stream;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();

            int len = S.length();
            int[] ans = new int[len];

            int l = 0, r = 0;
            for (int i = 1; i < len; i++) {
                if (S.charAt(i - 1) == 'R' && S.charAt(i) == 'L') {
                    for (r = i; r < len; r++) {
                        if (S.charAt(r) == 'R') {
                            break;
                        }
                    }
                    r--;
                    ans[i - 1] = (i - l + 1) / 2 + (r - (i - 1)) / 2;
                    ans[i] = (i - l) / 2 + (r - (i - 1) + 1) / 2;
                    l = r + 1;
                }
            }
            String ret = Arrays.stream(ans).mapToObj(Integer::toString).collect(Collectors.joining(" "));
            out.println(ret);
        }

    }
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N, A[101010], B[101010];
ll get() {
    ll sm = 0;
    rep(i, N-1) sm += abs(B[i+1] - B[i]);
    return sm;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    ll ans = 0;
    if (N % 2 == 0) {
        rep(i, N/2) B[i*2+1] = A[i];
        rep(i, N/2) B[i*2] = A[i+N/2];
        ans = get();
    } else {
        rep(i, N/2) B[i*2+1] = A[i];
        B[N-1] = A[N/2];
        rep(i, N/2) B[i*2] = A[i+N/2+1];
        ans = get();
        B[0] = A[N/2];
        rep(i, N/2) B[i*2+2] = A[i];
        rep(i, N/2) B[i*2+1] = A[i+N/2+1];
        chmax(ans, get());
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	int m, k;cin >> m >> k;
	if(k < (1 << m) && !(m == 1 && k == 1)){
		vector<ll> a;
		vector<ll> b;
		ll mask = ((1 << m) - 1) ^ k;

		//cout << bitset<20>(k) << endl;
		//cout << bitset<20>(mask) << endl;

		REP(i, (1<<m)){
			int cou = 0;
			REP(j, 20)if(i & (1 << j))cou++;
			if(cou == 1 && ((i & k) != 0))a.PB(i);
			else b.PB(i);
		}

		//SHOW1d(a, a.size());
		//SHOW1d(b, b.size());

		REP(i, a.size())cout << a[i] << " ";
		REP(i, b.size())cout << b[i] << " ";
		REV(i, a.size())cout << a[i] << " ";
		REV(i, b.size())cout << b[i] << " ";
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 2932
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main() {
	ios::sync_with_stdio(false);
    //freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);

    int n = 1000000000;
    char ans;

    cout<<"? "<<n<<endl;
    cin>>ans;

    if(ans == 'Y') {
        int i = 1;
        cout<<"? "<<i+1<<endl;
        cin>>ans;
        while(ans == 'N') {
            i *= 10;
            cout<<"? "<<i+1<<endl;
            cin>>ans;
        }
        cout<<"! "<<i<<endl;
        return 0;
    }

    int p = 100000000;
    int q = 999999999;
    char fi, se;

    while(true) {
        cout<<"? "<<p<<endl;
        cin>>fi;
        cout<<"? "<<q<<endl;
        cin>>se;

        if(fi == 'Y' and se == 'Y') break;

        p /= 10;
        q /= 10;
    }

    p++;

    ll mid;
    while(p <= q) {
        mid = (p+q)/2;
        cout<<"? "<<mid*10<<endl;
        cin>>fi;
        if(fi == 'N') p = mid+1;
        else q = mid-1;
    }

    cout<<"! "<<p<<endl;

	return 0;
}


Measured memory_bytes: 596
n = int(input())
s = input()

ans = []
for i in range(n):
    x = s[0:i+1]
    y = s[i+1:]
    s1 = set()
    s2 = set()
    for j in x:
        s1.add(j)
    for k in y:
        s2.add(k)
    wa = s1 & s2
    ans.append(len(wa))
print(max(ans))

Measured memory_bytes: 3064
s = input()

K = int(input())

s2 = [i for i in s]
s3 = [i for i in s]
S = s2

S.sort()

S = S[:K]

S = list(set(S))

S.sort()

X = []
for w in S:
    for i in range(len(s3)):
        if s3[i]==w:
            k = min(len(s3)-i, K)
            for ki in range(k):
                word = s[i:i+ki+1]
                X.append(word)
                
X = list(set(X))
X.sort()

print(X[K-1])


Measured memory_bytes: 4468
#include <cstdio>
#include <vector>
using namespace std;

int c=0;

void merge(vector<int>& A, int left, int mid, int right) {
	int i,j,k;
	int n1=mid-left;
	int n2=right-mid;
	vector<int> L, R;
	L.resize(n1+1);
	R.resize(n2+1);
	for(i=0; i<n1; ++i) {
		L[i]=A[left+i];
	}
	for(i=0; i<n2; ++i) {
		R[i]=A[mid+i];
	}
	L[n1]=1000000001;
	R[n2]=1000000001;
	i=j=0;
	for(k=left; k<right; ++k) {
		++c;
		if(L[i]<=R[j]) {
			A[k]=L[i];
			++i;
		} else {
			A[k]=R[j];
			++j;
		}
	}
	return;
}

void mergeSort(vector<int>&A, int left, int right) {
	if(left+1<right) {
		int mid=left+(right-left)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
	return;
}

int main() {
	vector<int> A;
	int n;
	int i;
	scanf("%d",&n);
	A.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d", &A[i]);
	}
	mergeSort(A,0,n);
	for(i=0; i<n-1; ++i) {
		printf("%d ",A[i]);
	}
	printf("%d\n%d\n",A[n-1],c);
	return 0;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d",&n);
	int rem = 0;
	long long ans = 0;
	for (int i=0;i<n;i++) {
		int x;
		scanf("%d",&x);
		ans += (x+rem)/2;
		if ((x+rem)%2 && (x > 0)) rem = 1;
		else rem = 0;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import Control.Monad (replicateM)
import Data.List (sort, group)

main = do
    [n, m] <- map read . words <$> getLine :: IO [Int]
    a <- replicateM n (map read . tail . words <$> getLine) :: IO [[Int]]
    print $ (length . filter ((== n) . length) . group . sort . mconcat) a

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

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

    if (a==b)
        cout<<"Draw";
    else if (a!=1 && b!=1)
    {
        if (a>b)
            cout<<"Alice";
        else
            cout<<"Bob";
    }
    else
    {
        if(a==1)
            cout<<"Alice";
        else
            cout<<"Bob";
    }
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)


int main() {
  set<char> S;
  int n, k;
  cin >> n >> k;
  loop(i,0,k) {
    int a; cin >> a;
    S.insert((char)(a+'0'));
  }
  
  loop(x,n,100 * n) {
    string s = to_string(x);
    bool ok = true;
    for (auto &&c: s) ok &= S.count(c) == 0;
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    ll i = 0;
    while(true){
        if (ll(pow(k, i)) <= n) ans ++, i++;
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(age,fare);
    if(6<=age && age<13) fare /= 2;
    if(age<6) fare = 0;
    cout << fare << nn;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=10000000;
  for(int i=-100;i<=100;i++){
    int sum=0;
    for(int j=0;j<n;j++) sum+=pow(a[j]-i,2);
    ans=min(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, K;
char S[400011];

char get(char c, bool flip) {
    if (c == 'A') return flip? 'B': 'A';
    return flip? 'A': 'B';
}

void MAIN() {
    scanf("%d%d%s", &N, &K, S);

    int pos = 0;
    bool flip = false;
    while (pos < N && K) {
	char cur = get(S[pos], flip);

	if (cur == 'A') {
	    S[pos] = get(S[pos], true);
	    K--;
	} else {
	    K--;
	    S[pos+N] = get('B', flip);
	    pos++;
	    flip = !flip;
	}
    }
    REP (i, N) {
	S[i] = get(S[i+pos], flip);
    }
    S[N] = 0;
    if (K >= 3) {
	K = (K-3)%2 + 3;
    }
    REP (k, K) {
	pos = 0;
	int from = -1;
	while (0 <= pos && pos < N) {
	    if (S[pos] == 'A') {
		S[pos] = 'B';
		pos += from;
		from = -from;
	    } else {
		S[pos] = 'A';
		pos -= from;
	    }
	}
    }
    puts(S);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    string str;
    while(cin>>str)
    {
        if(str.length()==2)
        {
            cout<<str<<endl;
        }
        else if(str.length()==3)
        {
            reverse(str.begin(),str.end());
            cout<<str<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
int main(){
  std::string s,t;
  int i,j,a[26]={},b[26]={},f;
  std::cin>>s>>t;
  std::vector <char> x, y;
  for(i=0;i<s.size();++i)++a[s[i]-97];
  for(i=0;i<t.size();++i)++b[t[i]-97];
  for(i=0;i<26;++i)for(j=0;j<a[i];++j)x.push_back(i+97);
  for(i=25;i>=0;--i)for(j=0;j<b[i];++j)y.push_back(i+97);
  if(s.size()>=t.size()){
    f = 0;
    for(i=0;i<t.size();++i){
      if(x[i]>y[i]){break;}
      if(y[i]>x[i]){f=1;break;}
    }
  }
  else {
    f = 1;
    for(i=0;i<s.size();++i){
      if(y[i]>x[i]){break;}
      if(y[i]<x[i]){f=0;break;}
    }
  }
  std::cout<<(f?"Yes":"No")<<"\n";
}

Measured memory_bytes: 256
<?php
$n = (int)fgets(STDIN);
for($i = 0; $i < $n; $i++){
    $map[] = str_split(trim(fgets(STDIN)));
}
$count = 0;
for($i = 0; $i < $n; $i++){
    $flag = true;
    for($x = 0; $x < $n; ++$x){
        $X = ($x+$i) % $n;
        $mapX = $map[$X];
        for($y = $x + 1; $y < $n; ++$y){
            if($mapX[$y] != $map[($y+$i)%$n][$x])$flag = false;
        }
    }
    $count+=$flag;
}
echo $count*$n,"\n";


Measured memory_bytes: 12920
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    print("x"*len(s))

main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

const ULL M = 1000000007;

ULL powm(ULL a, ULL i) {
    if (!i) return 1;
    if (i & 1) return powm(a * a % M, i >> 1) * a % M;
    return powm(a * a % M, i >> 1);
}

ULL F[1001], I[1001], iF[1001];

ULL C(ULL n, ULL r) { return F[n] * iF[r] % M * iF[n - r] % M; }
ULL P(ULL n, ULL r) { return F[n] * iF[n - r] % M; }

struct Problem {

    void Solve() {
        F[0] = 1; for (UL i = 1; i <= 1000; i++) F[i] = F[i - 1] * i % M;
        I[1] = 1; for (UL i = 2; i <= 1000; i++) I[i] = M - M / i * I[M % i] % M;
        iF[0] = 1; for (UL i = 1; i <= 1000; i++) iF[i] = iF[i - 1] * I[i] % M;
        ULL N, K; cin >> N >> K;
        if (K < N) { cout << 0 << endl; return; }
        cout << P(K, N) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <cstdlib>

int main(){
  int n,k;
  std::cin >> n >> k;
  int sum = 0;
  for(int i = 0 ; i < n ; i++){
    int x;
    std::cin >> x;
    int t1 = abs(x - k);
    if(t1 < x) {
      sum += t1*2;
    }else{
      sum += x*2;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


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

int main()
{
    int n,x,z,y,sum;
    while(~scanf("%d%d%d%d",&n,&x,&z,&y))
    { sum=0;
        if(x<=n)
        {
            sum=x*z+(n-x)*y;
        }
        if(x>n)
        {
            sum=n*z;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ll n, ca, cb;
	cin >> n;
	cin >> ca >> cb;
	for (ll i = 1; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		if (a > ca && b > cb) {
			ca = a;
			cb = b;
		} else {
			ll x = (cb-1ll)/b; x++;
			ll tb = b*x;
			ll ta = a*x;

			if (tb < cb || ta < ca) {
				x = (ca-1ll)/a; x++;
				tb = b*x;
				ta = a*x;

				if (tb < cb || ta < ca) {

				} else {
					ca = ta;
					cb = tb;
				}
			} else {
				ca = ta;
				cb = tb;
			}
		}
	}
	cout << ca+cb << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<vector<int>> t(n);
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		t[a].push_back(b);
		t[b].push_back(a);
	}
	vector<int> b(n), w(n), vis(n);
	vis[0] = 1;
	queue<int> q;
	q.push(0);
	while(!q.empty()) {
		int now = q.front();
		q.pop();
		for(int i = 0; i < t[now].size(); i++) {
			int nxt = t[now][i];
			if(vis[nxt]) continue;
			vis[nxt] = 1;
			b[nxt] = b[now] + 1;
			q.push(nxt);
		}
	}
	fill(vis.begin(), vis.end(), 0);
	vis[n - 1] = 1;
	q.push(n - 1);
	while(!q.empty()) {
		int now = q.front();
		q.pop();
		for(int i = 0; i < t[now].size(); i++) {
			int nxt = t[now][i];
			if(vis[nxt]) continue;
			vis[nxt] = 1;
			w[nxt] = w[now] + 1;
			q.push(nxt);
		}
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
			if(b[i] <= w[i]) cnt++;
			else cnt--;
	}
	if(cnt > 0) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	
	return 0;	
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;

int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

	int n; cin >> n;
	cout << v[n-1] << '\n';

	return 0;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int num = 0;
    int ans = 0;
    if(n == 2){
        cout << a[1] - a[0] << endl;
        return 0;
    }
    else if(n % 2 == 0 && n >= 4){
        int i = 0;
        int num = 0;
        for(i=1; i<n/2; i++){
            num += 2;
            ans += num * (a[i] - a[i-1]);
        }
        num += 1;
        ans += num * (a[i] - a[i-1]);
        i++;

        num--;
        ans += num * (a[i] - a[i-1]);
        i++;

        for(; i<n; i++){
            num -= 2;
            ans += num * (a[i] - a[i-1]);
        }
    }
    else if(n == 3){
        cout << max(2*a[2]-a[1]-a[0], a[2]+a[1]-2*a[0]) << endl;
        return 0;
    }
    else{
        int ans1 = 0, ans2 = 0;
        int num1 = 0, num2 = 0;
        int i;
        
        for(i=1; i<=n/2; i++){
            num1 += 2;
            ans1 += num1 * (a[i] - a[i-1]);
        }
        num1--;
        ans1 += num1 * (a[i] - a[i-1]);
        i++;
        num1--;
        ans1 += num1 * (a[i] - a[i-1]);
        i++;
        for(; i<n; i++){
            num1 -= 2;
            ans1 += num1 * (a[i] - a[i-1]);
        }

        for(i=1; i<n/2; i++){
            num2 += 2;
            ans2 += num2 * (a[i]-a[i-1]);            
        }
        num2++;
        ans2 += num2 * (a[i] - a[i-1]);
        i++;
        num2++;
        ans2 += num2 * (a[i] - a[i-1]);
        i++;
        for(; i<n; i++){
            num2 -=2;
            ans2 += num2 * (a[i] - a[i-1]);
        }

        ans = max(ans1, ans2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4020
N, M, L = (int(i) for i in input().split())

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

graph = [[0]*N for i in range(N)]
for i in range(M):
    a, b, c = (int(i) for i in input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

graph = csr_matrix(graph)
d = floyd_warshall(csgraph=graph, directed=False)

new_graph = [[0]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            new_graph[i][j] = 1
            new_graph[j][i] = 1

graph = csr_matrix(new_graph)
d = floyd_warshall(csgraph=graph, directed=False)
Q = int(input())
for i in range(Q):
    s, t = (int(i) for i in input().split())
    if d[s-1][t-1] == float("inf"):
        print("-1")
    else:
        print(int(d[s-1][t-1]-1))

Measured memory_bytes: 20228
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n,m;
while(cin>>n){
vector<pair<int,int>> vec;
for(i=0;i<n;i++){
    cin>>j;
vec.push_back(make_pair(j,i));
}
sort(vec.begin(),vec.end());
for(i=0;i<n;i++) {

   cout<<vec[i].second+1<<" ";
}
cout<<endl;
} return 0;
}


Measured memory_bytes: 1780
#include <cstdio>
using namespace std;
const int MOD = 1e9 + 7; 
int main() {
    int m, n;
    scanf("%d%d", &m, &n);
    long long ans = 1, cur = m;
    for (int i = 0; (1 << i) <= n; i++) {
    	if (n & (1 << i)) ans = (ans * cur) % MOD;
    	cur = (cur * cur) % MOD;
	}
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2764