akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;



int main() {

	string s;
	int n, k;

	cin >> n >> k;
	cin >> s;

	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else {
		s[k - 1] = 'c';
	}
	
	cout << s << endl;

	return 0;


}

Measured memory_bytes: 3568
#include <stdio.h>

#define LOOP_INIT 0
#define SORT_CNT_INIT 0
#define TRUE 1
#define FALSE 0
#define PREV_ITEM( x ) x - 1
#define TESTCASE_ARRAY_MAX 100
#define EXIT_SUCCESS 0

int main( void )
{
	unsigned char ubW_Dtestcase[ TESTCASE_ARRAY_MAX ];
	unsigned char ubW_Dtc_cnt;
	unsigned char ubW_Dchange;
	unsigned short usW_Csort_cnt = SORT_CNT_INIT;
	unsigned char ubW_Ctc_loop_cnt;
	unsigned char ubW_Floop_flug = TRUE;

	scanf("%d", &ubW_Dtc_cnt);
	for( ubW_Ctc_loop_cnt = LOOP_INIT; ubW_Ctc_loop_cnt < ubW_Dtc_cnt; ubW_Ctc_loop_cnt++){
		scanf("%d", &ubW_Dtestcase[ ubW_Ctc_loop_cnt ] );
	}

	while( ubW_Floop_flug ){
		ubW_Floop_flug = FALSE;
		for( ubW_Ctc_loop_cnt = LOOP_INIT; ubW_Ctc_loop_cnt < ubW_Dtc_cnt; ubW_Ctc_loop_cnt++ ){
			if( ubW_Dtestcase[ ubW_Ctc_loop_cnt ] < ubW_Dtestcase[ PREV_ITEM( ubW_Ctc_loop_cnt ) ] ){
				ubW_Dchange = ubW_Dtestcase[ ubW_Ctc_loop_cnt ];
				ubW_Dtestcase[ ubW_Ctc_loop_cnt ] = ubW_Dtestcase[ PREV_ITEM( ubW_Ctc_loop_cnt ) ];
				ubW_Dtestcase[ PREV_ITEM( ubW_Ctc_loop_cnt ) ] = ubW_Dchange;
				ubW_Floop_flug = TRUE;
				usW_Csort_cnt++;
			}
			else{
				/* else?????????????????????????????\ */
			}
		}
	}

	for( ubW_Ctc_loop_cnt = LOOP_INIT; ubW_Ctc_loop_cnt < PREV_ITEM( ubW_Dtc_cnt ); ubW_Ctc_loop_cnt++){
		printf("%d ", ubW_Dtestcase[ ubW_Ctc_loop_cnt ] );
	}
	printf("%d\n", ubW_Dtestcase[ PREV_ITEM( ubW_Dtc_cnt ) ]);
	printf("%d\n", usW_Csort_cnt);
	return EXIT_SUCCESS;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=1e9+7;
using namespace std;
lli t,n,u,x,y,m;
const lli N = 100001;
int main(){
    fast
     t=1;
   // cin>>t;
    while(t--){
        cin>>n;
        cout<<(!n)<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int n,m;
pair<int,int> p[N];
struct bit{
	int a[N];
	void add(int p,int d){
		for (;p<=n;p+=p&-p) a[p]+=d;
	}
	int query(int p){
		int ans=0;
		for (;p;p-=p&-p) ans+=a[p];
		return ans;
	}
}T;
int main()
{
	scanf("%d%d",&m,&n);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&p[i].first,&p[i].second);
		p[i].first=p[i].second-p[i].first;
	}
	sort(p+1,p+m+1);
	for (int i=1,j=1;i<=n;i++){
		for (;j<=m&&p[j].first<i;T.add(p[j].second+1,-1),T.add(p[j].second-p[j].first,1),j++);
		int ans=m-j+1;
		for (int k=i;k<=n;k+=i) ans+=T.query(k);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());

		int c = a*b;
		int d = (a+b)*2;
		System.out.println( c + " " + d );

	}
}


Measured memory_bytes: 24164
from collections import deque
S = deque(list(input()))
Q = int(input())
Flag = True
for _ in range(Q):
    q = input().split()
    if len(q) == 1:
        Flag = False if Flag else True
    else:
        if Flag:
            if q[1] == '1':
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if q[1] == '1':
                S.append(q[2])
            else:
                S.appendleft(q[2])

if Flag:
    print(''.join(S))
else:
    print(''.join(reversed(S)))

Measured memory_bytes: 8420
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
Ans = 0
answer = 0
for i in range(n):
    for j in range(m):
        ans = B[j]*A[i][j]
        Ans += ans 
    Ans = Ans + c
    if Ans >0 :
        answer += 1
    Ans = 0
print(answer)


Measured memory_bytes: 3060
n,x =map(int,input().split())
a=list(map(int,input().split()))
a.sort()
i=0
#print(a)
while x > 0 and i < n:
    x -=a[i]
    i += 1
if i == n and x > 0:
    print(n-1)
elif x ==0:
    print(i)
else:
    print(i-1)

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

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1000000007;

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

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

  ll k1 = (((k+1) * k) / 2) % MOD;
  ll k2 = ((k * (k-1)) / 2) % MOD;

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    ll x = 0;
    for (ll j = 0; j < i; ++j) {
      if (a[i] > a[j]) x++;
    }
    ans = (ans + (x * k2) % MOD) % MOD;
    
    x = 0;
    for (ll j = i+1; j < n; ++j) {
      if (a[i] > a[j]) x++;
    }
    ans = (ans + (x * k1) % MOD) % MOD; 
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int n;
	cin >> n;
	cout << (n / 3) << endl;
	return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner

import scala.util.Random


object Main {

  def read() = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val v = IndexedSeq.fill(n)(sc.nextInt())
    (n, k, v)
  }

  def solve(n: Int, k: Int, v: IndexedSeq[Int]): Int = {

    (for (deqTimes <- 0 to math.min(k, n); deqRightTimes <- 0 to deqTimes) yield {
      // 右側から何回撮るか
      val deqLeftTimes = deqTimes - deqRightTimes
      // [0, l), [n-r, n)
      val deqLeft = (0 until deqLeftTimes).map(v)
      val deqRight = (n - deqRightTimes until n).map(v)
      val deq = IndexedSeq.concat(deqLeft, deqRight).sorted

      val enqTimes = k - deqTimes
      // 負のやつ捨てる
      val result = deq.zipWithIndex.map {
        case (v, i) => if (i < enqTimes && v < 0) 0 else v
      }.sum
      result
    }).max
  }

  def readRandom() = {
    val n = 50
    val k = 100
    val v = IndexedSeq.fill(n)(Random.nextInt(20000000) - 10000000)
    println(s"$n $k")
    println(v.mkString(" "))
    (n, k, v)
  }

  def main(args: Array[String]): Unit = {
    val (n, k, v) = read()
    println(solve(n, k, v))
  }
}

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

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

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

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

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

#define int long long

signed main()
{
    int n, q;
    while(cin>>n>>q, n) {
        int date[101] = {0};
        for(int i=0; i<n; ++i) {
            int m;
            cin >> m;
            for(int j=0; j<m; ++j) {
                int a;
                cin >> a;
                date[a]++;
            }
        }
        int ans = 0;
        int mx = -1;
        for(int i=0; i<101; ++i) {
            if(mx<date[i]) {
                mx = date[i];
                ans = i;
            }
        }
        int res = (mx>=q)?ans:0;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

int H, W;
string grid[300];

int memo[305][305];
int cost[305][305];

int calc(int w, int h1, int h2) {
  if (h1 == H and h2 == H) return 0;
  if (memo[h1][h2] != -1) return memo[h1][h2];
  int res = INF;
  int cst = cost[h1][h2];
  if (h1 < H) chmin(res, calc(w, h1 + 1, h2) + cst);
  if (h2 < H) chmin(res, calc(w, h1, h2 + 1) + cst);
  return memo[h1][h2] = res;
}

int main(void) {
  cin >> H >> W;
  REP(i, H) cin >> grid[i];
  int res = 0;
  REP(w, W - 1) {
    REP(i, H + 1) REP(j, H + 1) memo[i][j] = -1;
    for (int d = -H; d <= H; d++) {
      int di = -1, dj = -1;
      if (d >= 0) { di = 0; dj = d; }
      else { di = -d; dj = 0;}
      int cnt = 0;
      for (int k = max(di, dj); k < H; k++) {
	cnt += (grid[k - di][w] == grid[k - dj][w + 1]);
      }
      cost[di][dj] = cnt;
      for (int k = 0; k < H - max(di, dj); k++) {
	cnt -= (grid[H - di - 1 - k][w] == grid[H - dj - 1 - k][w + 1]);
	cost[di + k + 1][dj + k + 1] = cnt;
      }
    }
    res += calc(w, 0, 0);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;

const int N = 1e6+69;

ll n,x,y,k,m,a,b;

char c;
string s,t;

int A[N];

int main(){

	cin>>a>>b>>k;
	if(a>=k){
		a-=k;
		cout<<a<<" "<<b<<endl;
		return 0;
	}
	k-=a;
	a=0;
	if(b>=k){
		b-=k;
		cout<<a<<" "<<b<<endl;
		return 0;
	}
	b=0;
	cout<<a<<" "<<b<<endl;
}

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

using namespace std;

int prime[MAX_N];  // i番目の素数
bool is_prime[MAX_N + 1];  // is_prime[i]がtrueならiは素数

// n以下の素数の数を返す
int sieve(int n) {
  int p = 0;
  for(int i = 0; i <= n; i++) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for(int j = 2 * i; j <= n; j += i) {
	is_prime[j] = false;
      }
    }
  }
  return p;
}

int main(void) {
  int n = sieve(1001);
  int x;
  cin >> x;

  int mx = 1;
  for(int i = 2; i < x; i++) {
    int p = 0;
    int tmp = 1;
    while(tmp <= x) {
      tmp *= i;
      p++;
    }
    tmp /= i;
    p--;
    if(mx < tmp && 1 < p) {
      //      cout << "i: " << i << endl;
      mx = tmp;
    }
  }
  cout << mx << endl;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    FORS(i, 1, 9){
        FORS(j, 1, 9){
            if (N == i*j) {
                cout << "Yes" <<endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }
    val count = hashMapOf<Long,Int>()
    count[0] = 1

    var ans = 0L
    var sum = 0L
    a.map {
        sum += it
        ans += count.getOrDefault(sum, 0)
        count[sum] = count.getOrDefault(sum, 0) + 1
    }
    println(ans)
}

Measured memory_bytes: 80612
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long 
#define lli long long int
#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


int a[100005][4];
int n;
int dp[100005][4];
//int ar[200001];

int func(int day,int flag)
{
	if(day==n) return 0;

	if(dp[day][flag]!=-1) return dp[day][flag];
	int maxi=0;
	if(flag==0){
		maxi=max(maxi,a[day][1] + func(day+1,1));
		maxi=max(maxi,a[day][2] + func(day+1,2));
		maxi=max(maxi,a[day][3] + func(day+1,3));
	}
	else if(flag==1){
		maxi=max(maxi,a[day][2] + func(day+1,2));
		maxi=max(maxi,a[day][3] + func(day+1,3));
	}
	else if(flag==2){
		maxi=max(maxi,a[day][1] + func(day+1,1));
		maxi=max(maxi,a[day][3] + func(day+1,3));
	}
	else{
		maxi=max(maxi,a[day][1] + func(day+1,1));
		maxi=max(maxi,a[day][2] + func(day+1,2));
	}
	return dp[day][flag]=maxi;
}
int main()
{
	//c_p_c();
	
    //int n;
    cin>>n;
    //int ar[n];
    for(int i=0;i<n;i++)
    {
    	for(int j=1;j<=3;j++)
    	{
    		cin>>a[i][j];
    	}
    }
memset(dp,-1,sizeof dp);
    cout<<func(0,0);
  return 0;

}


Measured memory_bytes: 9600
pi = 3.1415926

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
s = input().strip()
t = input().strip()
if s == t[:-1]:
    print('Yes')
else:
    print('No')
#print('No')
#print()



Measured memory_bytes: 61696
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll x, y;
	cin >> x >> y;

	if (abs(x - y) <= 1) {
		cout << "Brown" << en;
	}
	else {
		cout << "Alice" << en;
	}
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int m, n, ice[93][93];
bool done[93][93];

int dfs (int i, int j, int dep)
{
    if (ice[i][j]==0 || i==0 || i==n+1 || j==0 || j==m+1) return dep-1;
    int a=0,b=0,c=0,d=0;
    done[i][j]=false;
    if (done[i-1][j]) a=dfs(i-1, j, dep+1);
    if (done[i+1][j]) b=dfs(i+1, j, dep+1);
    if (done[i][j-1]) c=dfs(i, j-1, dep+1);
    if (done[i][j+1]) d=dfs(i, j+1, dep+1);
    done[i][j]=true;
    return max(a,max(b,max(c,d)));
}

int main()
{
    while (1)
    {
        int ans=0;
        cin>>m>>n;
        if (m==0 && n==0) break;
        for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin>>ice[i][j];
        for (int i=1; i<=n; i++)
        {
            for (int j=1; j<=m; j++)
            {
                if (ice[i][j]==0) continue;
                memset(done, true, sizeof(done));
                ans=max(ans, dfs(i, j, 1));
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cmath>
#define N 4
#define N2 16
#define MAX 100
using namespace std;

int dx[N] = {0, -1, 0, 1};
int dy[N] = {1, 0, -1, 0};
char dc[N] = {'r', 'u', 'l', 'd'};
int puz[N2][N2];

struct puzzle{
  int f[N2];
  int space;
  int x;
};

puzzle state;
int lim;
int path[MAX];

int getAll(puzzle pzl){
  int sum = 0;

  for(int i = 0; i < N2; i++){
    if(pzl.f[i] == N2) continue;
    sum += puz[i][pzl.f[i]-1];
  }

  return sum;
  
}

bool Solv(){
  for(int i = 0; i < N2; i++){
    if(state.f[i] != (i+1)) return false;
  }
  
  return true;
  
}

bool dfs(int depth, int prev){
  if(state.x == 0) return true;
  if((depth + state.x) > lim) return false;

  int sx = state.space / N;
  int sy = state.space % N;

  puzzle dummy;

  for(int i = 0; i < N; i++){
    int tx = sx + dx[i];
    int ty = sy + dy[i];

    if(tx < 0 || ty < 0 || tx >= N || ty >=N) continue;
    if(max(prev, i) - min(prev, i) == 2) continue;

    dummy = state;

    state.x -= puz[tx*N + ty][state.f[tx*N + ty] - 1];
    state.x += puz[sx*N + sy][state.f[tx*N + ty] - 1];

    swap(state.f[tx*N + ty], state.f[sx*N + sy]);

    state.space = tx * N + ty;

    if(dfs(depth + 1, i)){
      path[depth] = i;

      return true;
      
    }

    state = dummy;
    
  }

  return false;
  
}

string iterative(puzzle in){
  in.x = getAll(in);

  for(lim = in.x; lim < MAX; lim++){
    state = in;

    if(dfs(0, -100)){
      string ans = "";

      for(int i = 0; i < lim; i++){
	ans += dc[path[i]];
      }

      return ans;
      
    }
  }

  return "unsolvable";
  
}

int main(){

  for(int i = 0; i < N2; i++){
    for(int j = 0; j < N2; j++){
      puz[i][j] = abs(i/N - j/N) + abs(i%N - j%N);
    }
  }

  puzzle in;

  for(int i = 0; i < N2; i++){
    cin >> in.f[i];

    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }

  string ans = iterative(in);

  cout << ans.size() << endl;

  return 0;
  
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool f = false;
  int ans;
  for(int i=0;i<47000;i++){
    ans=i*1.08;
    if(ans==n){
      f =true;
      ans = i;
      break;
    }
  }
  if(f)cout << ans << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


Measured memory_bytes: 3576
import itertools
n = int(input())
l = list(map(int,input().split()))
cnt = 0
for i in itertools.combinations(l,3):
  if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
    if (sum(i)-max(i)) > max(i):
      cnt += 1
print(cnt)

Measured memory_bytes: 9204
N,L = map(int,input().split())
NL = [int(i)+L-1 for i in range(1,N+1)]
SNL = sum(NL)
ate = 10**18
count = 0
for i in range(N):
  ate = min(ate,abs(NL[i]))
  if ate == abs(NL[i]):
    count = i
print(SNL-NL[count])

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  cout << (1 + N) * N / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val acgt = new Array[Boolean](26)
    Seq('A', 'C', 'G', 'T').foreach(c => acgt(c - 'A') = true)

    val S = sc.nextLine()
    val candidate = for {
      h <- 0 until S.length
      t <- h until S.length
      if (h to t).forall(i => acgt(S.charAt(i) - 'A'))
    } yield t - h + 1

    println(if (candidate.nonEmpty) candidate.max else 0)
  }

}


Measured memory_bytes: 55712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int S; cin>>S;
  int A=S/1000000000,B=1000000000;
  int C=A*B-S,D=1;
  if(A*B!=S){
    A++;
    C=A*B-S;
  }
  cout<<0<<" "<<0<<" "<<C<<" "<<A<<" "<<B<<" "<<D<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    int a,b,q;
    int s[114514],t[114514];
    cin>>a>>b>>q;
    for(int i=0;i<a;i++)cin>>s[i];
    for(int i=0;i<b;i++)cin>>t[i];
    for(int i=0;i<q;i++){
        int x;
        cin>>x;
        int a1,a2,b1,b2;
        a2=lower_bound(s, s+a, x)-s;
        if(s[a2]==x){
            a1=0;
            a2=0;
        }else if(a2==a){
            a1=x-s[a2-1];
            a2=114514191981;
        }else if(a2==0){
            a1=114514191981;
            a2=s[a2]-x;
        }else{
            a1=x-s[a2-1];
            a2=s[a2]-x;
        }
        
        b2=lower_bound(t, t+b, x)-t;
        if(t[b2]==x){
            b1=0;
            b2=0;
        }else if(b2==b){
            b1=x-t[b2-1];
            b2=114514191981;
        }else if(b2==0){
            b1=114514191981;
            b2=t[b2]-x;
        }else{
            b1=x-t[b2-1];
            b2=t[b2]-x;
        }
        cout<<min({max(a1,b1),max(a2,b2),a1*2+b2,a2*2+b1,b1*2+a2,b2*2+a1})<<endl;
    }
    return 0;
}



Measured memory_bytes: 2944
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
ma = max(c.items(), key=lambda x: x[1])[1]
ans = []
for _s, cnt in c.items():
    if ma == cnt:
        ans.append(_s)

for _ans in sorted(ans):
    print(_ans)


Measured memory_bytes: 35572
al = [chr(c) for c in range(ord('A'), ord('Z') + 1)] + [chr(c) for c in range(ord('a'), ord('z') + 1)] 

def f1(c):
    if 'A' <= c <= 'Z':
        return ord(c) - ord('A')
    return ord(c) - ord('a') + ord('Z') - ord('A') + 1
while True:
    if not int(input()):
        break
    k = list(map(int, input().split()))
    s = list(map(f1, input()))
    print(''.join([al[c - k[i % len(k)]]  for i, c in enumerate(s)]))

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll n;

	cin >> n;

	vector<ll> v(n, 0);
	vector<ll> dp(n, INF);

	REP(i, n) {
		cin >> v[i];
	}

	dp[0] = 0;
	dp[1] = abs(v[0] - v[1]);

	FOR(i, 2, n) {
		dp[i] = min(dp[i], dp[i - 1] + abs(v[i] - v[i - 1]));
		dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
	}

	cout << dp[n - 1] << endl;
}

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

typedef vector<int> vi;
typedef long long int ll;
#define clr(v, d)           memset(v, d, sizeof(v))
#define all(v)   (v.begin()),(v.end())
#define lp(i,n)     for(int i=0;i<n;i++)
#define sz(v)       v.size()
#define F           first
#define S           second
#define pb          push_back
#define MP          make_pair
#define pii         pair<int, int>

int main() {
    int n;
    cin>>n;
    string s;
    map<string,int> mp;
    lp(i,n){
        cin>>s;
        if(mp.count(s)==0){
            mp[s]=1;
        }
        else{
            mp[s]++;
        }
    }
    vector<int> v;
    for(auto iter = mp.begin(); iter != mp.end(); ++iter){
        v.push_back(iter->second);
    }
    sort(all(v));
    for(auto iter = mp.begin(); iter != mp.end(); ++iter){
        if(iter->second==v[sz(v)-1]){
            cout<<iter->first<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26104
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<random>
#include<deque>
#include<cstdio>
#include<fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2000100;
const int mod = (int)pow(10, 9) + 7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define ppp pair<pp,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define inp(s) cin>>s
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
ll n,dp[1100];
int main() {
	cin >> n;
	dp[0] = 1;
	rep(i, 100) {
		if (dp[i] != 0)dp[i + 4] = dp[i + 7] = 1;
	}
	cout << yn(dp[n] > 0) << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]
flag = [[-1 for _ in range(W)] for _ in range(H)]

now = 0
for i in range(H):
    for j in range(W):
        if flag[i][j] == -1:
            stack = deque([]) 
            stack.append([i, j])
            flag[i][j] = now
            while len(stack) > 0:
                y, x = stack.popleft()
                for nx, ny in ([1, 0], [0, 1], [-1, 0], [0, -1]):
                    if 0<= x + nx < W and 0 <= y + ny < H:
                        if S[y][x] != S[y+ny][x+nx] and flag[y+ny][x+nx] == -1:
                            stack.append([y+ny, x+nx])
                            flag[y+ny][x+nx] = now
            now += 1
    
Black = [0 for _ in range(now+1)]
White = [0 for _ in range(now+1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            Black[flag[i][j]] += 1
        else:
            White[flag[i][j]] += 1
   
res = 0
for i in range(now + 1):
    res += Black[i] * White[i]
    
print(res)

Measured memory_bytes: 11424
package main
import "fmt"
func main() {
  var n int
  var t,a,ti,ai,k int64
  fmt.Scan(&n)
  fmt.Scan(&t,&a)
  for i:=1;i<n;i++ {
    fmt.Scan(&ti,&ai)
    k = max(ceil(t,ti),ceil(a,ai))
    t = k*ti
    a = k*ai
  }
  fmt.Println(t+a)
}
func max(n int64,m int64) int64 {
  if n > m {
    return n
  } else {
    return m
  }
}
func ceil(n int64,m int64) int64 {
  if n%m == 0 {
    return n/m
  } else {
    return n/m+1
  }
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

a.sort()

now = 0

ans = []

for i in range(n-2):
    if a[i+1] > 0:
        ans.append([a[0], a[i+1]])
        a[0] = a[0] - a[i+1]
    else:
        ans.append([a[n-1], a[i+1]])
        a[n-1] = a[n-1] - a[i+1]

ans.append([a[n-1],a[0]])
print(a[n-1]-a[0])

for i in ans:
    print(i[0],i[1])

Measured memory_bytes: 22468
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
using namespace std;

char a[N];

int main(void)
{
    int i, j, o;

    scanf("%s", a);
    for(i = o = 0, j = 2; a[i]; i ++)
        if(j == 2)
        {
            o ++;
            j = 1;
        }
        else if(a[i] != a[i - 1])
            o ++;
        else if(a[i + 1])
        {
            o ++;
            i ++;
            j = 2;
        }
        else
            break;
    printf("%d\n", o);

    return 0;
}


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

struct data {
  string l;
  int p, a, b, c, d, e, f, s, m;
};

int n;
vector<data> v;

bool ch(data l, data r);
void solve();
double calc(data now);

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; ++i) {
      data now;
      cin >> now.l >> now.p >> now.a >> now.b >> now.c >>
          now.d >> now.e >> now.f >> now.s >> now.m;
      v.push_back(now);
    }
    solve();
    for(int i = 0; i < n; ++i) cout << v[i].l << endl;
    cout << "#" << endl;
    v.erase(v.begin(), v.end());
  }
  return 0;
}

bool ch(data l, data r) {
  double nowl = calc(l), nowr = calc(r);
  if(nowl != nowr) return nowl > nowr;
  return l.l < r.l;
}

void solve() { sort(v.begin(), v.end(), ch); }

double calc(data now) {
  double sumt =
      now.a + now.b + now.c + (now.d + now.e) * now.m;
  return (now.s * now.f * now.m - now.p) / sumt;
}


Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 1000  // Gの頂点数の最大値
#define INF 10000000

int G[MAX][MAX];
int d[MAX];
char color[MAX];
int n;

void initializeSingleSource(void);
void dijkstra(void);

int main(){

  int u,k,i,j,v,c;
  
  /* 入力 */
  scanf("%d",&n); //n:Gの頂点数

  for(i = 0; i < n;i++){ // 初期化
    for(j = 0;j < n;j++){
      G[i][j] = INF;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&k); // u:頂点の番号 , k:uの出次数
    for(j = 0;j < k;j++){
      scanf("%d %d",&v,&c); // v:uに隣接する頂点の番号, c: 重み
      G[u][v] = c; // G[u][v]にはuとvをつなぐ辺の重みを入れる
    }
  }

  dijkstra();
  
  return 0;
}

void initializeSingleSource(void)
{
  int v;

  for(v = 0;v < MAX;v++){
    d[v] = INF; // 始点からvまでの重みの合計
    color[v] = 'W';
  }
  d[0] = 0;
  color[0] = 'G';
}

void dijkstra(void)
{
  int mincost,i,u,v;

  initializeSingleSource(); // 初期化

  while(1){
    mincost = INF;
    for(i = 0;i < n;i++){
      if((color[i] != 'B') && (d[i] < mincost)){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INF) break;

    color[u] = 'B';

    for(v = 0;v < n;v++){
      if(color[v] != 'B' && G[u][v] != INF){	 
	if(d[v] > d[u] + G[u][v]){
	d[v] = d[u] + G[u][v];
	color[v] = 'G';
	}
      }
    }

  }

   /* 出力 */
  for(i = 0;i < n;i++){
    printf("%d %d\n",i,d[i]);
  }
}

Measured memory_bytes: 988
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int diff = Math.Abs(A - B);
        if (diff % 2 == 0) Console.WriteLine("Alice");
        else Console.WriteLine("Borys");
    }

}


class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 13140
W, H, x, y = map(int, input().split(' '))


multi_ans = 0

if ((x == 0 and y == 0) or (x == 0 and y == H) or (y == 0 and x == W) or (y == H and x == W)):
    multi_ans = 0
elif (W==H and not((x == W - x or y == H - y))):
    multi_ans == 1
elif (x != 0 and y != 0):
    if (W / x == H / y):
        if (x == W - x and y == H -y):
            multi_ans = 1
        else:
            multi_ans = 0

ans = W * H /2.0
print("{} {}".format(ans, multi_ans))



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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;

int a[NMAX];
int main(int argc, char const *argv[])
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(register int i = 1;i <= n;i++)	scanf("%d",a+i);
	sort(a+1,a+1+n);
	int ans = 0;
	for(register int i = 1;i <= k;i++)	ans += a[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3744
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
    String a = sc.next();
    String b = sc.next();
    // 条件分岐と出力
    if (a.equals("H") && b.equals("H")) {
      System.out.println("H");
    } else if (a.equals("H") && b.equals("D")) {
      System.out.println("D");
    } else if (a.equals("D") && b.equals("H")) {
      System.out.println("D");
    } else {
      System.out.println("H");
    }
  }
}

Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    string a;
    string b;
    cin >> a;
    cin >> b;
    vector<char> s1(a.size());
    vector<char> s2(b.size());
    
    rep(i, a.size()) s1[i] = a.at(i);
    
    rep(i, b.size()) s2[i] = b.at(i);

    vsort(s1);
    sort(s2.begin(), s2.end(), greater<char>());

    // rep(i, s1.size()) cout << s1[i];
    // cout << endl;
    // rep(i, s2.size()) cout << s2[i];
    // cout << endl;
    int s1leng = 0;
    int s2leng = 0;
    if(s1.size() < s2.size()){
        rep(i, s1.size()){
            s1leng += (int)s1[i];
            s2leng += (int)s2[i];
            // cout << s1leng << endl;
            // cout << s2leng << endl;
            if(s1leng < s2leng){
                yes;
                return 0;
            }else if(s1leng == s2leng){
                continue;
            }else{
                no;
                return 0;
            }
        }
    }else{
        rep(i, s2.size()){
            s1leng += (int)s1[i];
            s2leng += (int)s2[i];

            // cout << s1leng << endl;
            // cout << s2leng << endl;
            if(s1leng < s2leng){
                yes;
                return 0;
            }else if(s1leng == s2leng){
                continue;
            }else{
                no;
                return 0;
            }
        }
    }
    if(s1.size() < s2.size()){
        yes;
        return 0;
    }
    no;
    return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll n;
string s = "";
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    while(n > 0){
        n--;
        s += (char) ((n%26)+ 'a');
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    multiset<int> s;
    rep (i, 1 << n)
    {
        int temp;
        cin >> temp;
        s.insert(-temp);
    }

    // for (auto& x : s)
    // {
    //     cout << -x << " ";
    // }
    // cout << "\n";

    bool ans = true;
    vs32 t(1 << n);
    t[0] = -*s.begin();
    rep (i, n)
    {
        for (int j = 0; j < (1 << i); ++j)
        {
            auto it = s.upper_bound(-t[j]);
            if (it == s.end())
            {
                ans = false;
                break;
            }
            int temp = *it;
            t[(1 << i) + j] = -temp;
            s.erase(it);
        }
        if (!ans) break;
    }

    // sort(t.begin(), t.end());

    // rep (i, 1 << n) cout << t[i] << " ";
    // cout << "\n";

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}



Measured memory_bytes: 16672
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb  push_back
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define endl "\n"
#define inf 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
  	if(n&1) {
      cout<<"No";
      return;
    }
	//cout<<s<<endl;
	FOR(i, 0, n/2){
		if(s[i]!=s[(n/2)+i]){
		//	cout<<s[i]<<" "<<s[(n/2) + i]<<endl;
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

template<int_fast64_t m=MOD>
struct Mcomb{
  using i64=int_fast64_t;
  vector<i64>f;  //$B3,>h(B
  vector<i64>finv; //$B3,>h$N5U85(B
  vector<i64>inv;  //$B5U85(B

  Mcomb(i64 max){
    f.resize(max+1,0);
    finv.resize(max+1,0);
    inv.resize(max+1,0);
    f[0]=f[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(i64 i=2;i<=max;i++){
      f[i]=f[i-1]*i%m;
      inv[i]=m-inv[m%i]*(m/i)%m;
      finv[i]=finv[i-1]*inv[i]%m;
    }
  }

  //nCr=n!/r!(n-r)!
  i64 slove(i64 n,i64 r){
    if(n<r)return 0;
    if(n<0||r<0)return 0;
    return (f[n]*(finv[r]*finv[n-r]%m)%m)%m;
  }
};

template<uint_fast64_t m>
int_fast64_t mpow(int_fast64_t x,int_fast64_t n){
  using i64=int_fast64_t;
  if(n==0)return 1;
  if(n%2)return ((x%m)*(mpow<m>(x,n-1)%m))%m;
  else {
    i64 half=mpow<m>(x,n/2)%m;
    return (half*half)%m;
  }
}

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

  int N,M,K;
  cin>>N>>M>>K;
  int ans=0;
  Mcomb<MOD>c(N);
  for(int i=0;i<=K;i++)ans=(ans+((c.slove(N-1,i)*M)%MOD*mpow<MOD>(M-1,N-i-1))%MOD)%MOD;
  cout<<ans<<endl;

  return 0;
}


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

typedef long long ll;

const int M = (int)1e2;
const int N = (int)1e4;
const int inf = 0x3f3f3f3f;
const ll mod = (ll)1e9 + 7;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int a, b; scanf("%d %d", &a, &b);
    if(b >= a) printf("unsafe\n");
    else       printf("safe\n");
    return 0;
}


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


int main()
{
	string w;
	cin>>w;
	map<char,int> m;
	for(auto c : w)
	{
		m[c]++;
	}
	bool flag=true;
	for(auto p :m)
	{
		if(p.second%2!=0) flag=false;
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("avx,avx2,fma,sse,sse2")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define N 200007

typedef tree<int, null_type, less<int>,rb_tree_tag,
tree_order_statistics_node_update> new_data;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(ll)ceil(1.0*n/x)*t<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int ERAST_MAX = 55555;

vector<bool> erast(ERAST_MAX,true);

void erasttenesu(){
    erast[1]=false;
    erast[2]=true;
    for(int i=2;i<=ERAST_MAX;i++){
     if(erast[i]==true){
         for(int j=2;j*i<=ERAST_MAX;j++){
             erast[i*j]=false;
         }
     }
    }
}



int main() {
    erasttenesu();

    int n;
    cin>>n;
    vector<int> ans;
    int sum=2;
    ans.push_back(2);
    n--;
    for(int i=3;i<ERAST_MAX;i++){
        if(erast[i]==true){
           if(i%5==2) {
               ans.push_back(i);
               n--;
               if (n == 0)break;
           }
             }

        }



    rep(i,ans.size()){
        cout<<ans[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,y=0;
  cin >> N;
  int x=N;
  
for (int i = 0; i < 8; i++){

      
    y+=x%10;
  	x/=10;
 
  
      if(x==0) break;   
  
	}  
  
  if(N % y ==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
 }
  



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int main(void) {
	long n;
	scanf("%ld", &n);
	int* list = (int*)malloc(sizeof(int) * n-1); /*上司の社員番号*/
	int* res = (int*)malloc(sizeof(int) * n);   /*部下の人数*/
	for (int i = 0;i < n-1;i++) scanf("%d", &list[i]);
	for (int k = 0;k < n;k++) res[k] = 0;
	for (int j = 0;j < n-1;j++) res[list[j]] += 1;
	for (int i = 1;i < n;i++) printf("%d\n", res[i]);
	printf("%d", 0);
	return 0;
}

Measured memory_bytes: 3712