akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int q;
    cin >> q;
    Vi ans;
    while(q--){
        ll a,b;
        cin >> a >> b;
        ll lim=a*b-1;
        ll mid, ok = 0, ng = min(lim,1000000000ll);
        while(abs(ok-ng)>1){
            mid = (ok+ng)/2;
            if(mid*(mid+1)<=lim)ok = mid;
            else ng = mid;
        }//midではなくokを使わないとバグる!
        if(a==b)ans.pb(ok+lim/(ok+1));
        else ans.pb(ok-1+lim/(ok+1));
    }
    for(auto l:ans){
        print(l);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
N,C = map(int,input().split())
D = [[int(i) for i in input().split()] for j in range(C)]
c = [[int(i) for i in input().split()] for j in range(N)]

c_sum = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        c_sum[(i+j)%3][c[i][j]-1] += 1

D_sum = [[0]*C for _ in range(3)]
for i in range(C):
    for j in range(C):
        for k in range(3):
            D_sum[k][j] += D[i][j] * c_sum[k][i]

ans = 1000*500*500
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            else:
                ans = min(ans, D_sum[0][i]+D_sum[1][j]+D_sum[2][k])
print(ans)

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int k,n;
int a[N];
int main() {
	int i,ans;
	scanf("%d%d",&k,&n);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	ans=a[n]-a[1];
	for (i=2;i<=n;i++)
		ans=min(ans,k-a[i]+a[i-1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>

#define M 1046257
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;

}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if (strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 17044
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N , M;
  cin >> N >> M;
  int k = M;
  long long int broken[100002] , dp[100002] = {0};
  for(int i = 0 ; i < M ; i++)  cin >> broken[i];
  dp[N] = 1;
  for(int i = N - 1; 0 <= i ; i--){
    if(0 <= k - 1 && broken[k - 1] == i){
      dp[i] = 0;
      k--;
    }else{
      dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
    }
  }
  cout << dp[0] << endl;  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (i; i <= n; i++)

int main() {
  int A, B,C;
  cin>>A>>B;
  C=A;
  int n=0;
  rep(A,B){
    if(C%10==(C-C%10000)/10000 %10 && (C-C%10)/10 %10 == (C-C%1000)/1000 %10){
      n++;
    }
    C++;
  }
  cout<<n<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
 
	//入力の読み込み処理
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
 
    //Nの各桁数だけ取り出す
		int a = N % 10;  //1の位
		int b = N / 100;  //100の位
		int c = (N - a - b*100) / 10;  //10の位
 
	//各桁数の確認
		//System.out.println(a);
		//System.out.println(b);
		//System.out.println(c);
 
	//if文で処理を決める
		if(a == 7 || b == 7 || c == 7) {
			System.out.println("Yes");
		}
		else {
		    System.out.println("No");
		}
	}
}

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

string s;
ll ans=0;

void cal(int i,ll sum,ll kari){
	if(s.size()==i){
		ans+=sum+kari;
		return;
	}
	cal(i+1,sum,kari*10+(s[i]-'0'));
	cal(i+1,sum+kari,s[i]-'0');
}

int main() {
	cin>>s;
	cal(0,0,0);
	cout <<ans/2;
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  if(N%10==3) cout<<"bon"<<endl;
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

bool is_same_number(i32 a[3]) {
  return a[0] == a[1] && a[1] == a[2];
}

bool is_sequence(i32 a[3]) {
  return a[0] + 2 == a[1] + 1 && a[1] + 1 == a[2];
}

bool is_good_set(i32 a[3]) {
  return is_same_number(a) || is_sequence(a);
}

bool is_all_good_set(i32 hand[9]) {
  return is_good_set(hand) && is_good_set(hand + 3) && is_good_set(hand + 6);
}

i32 solve() {
  i32 hand[9];
  REP(i, 9) cin >> hand[i];
  REP(i, 9) {
    string color;
    cin >> color;
    if (color == "G") hand[i] += 10;
    else if (color == "B") hand[i] += 20;
  }
  sort(hand, hand + 9);
  do {
    if (is_all_good_set(hand)) return 1;
  } while (next_permutation(hand, hand + 9));
  return 0;
}

signed main() {
  i32 T;
  cin >> T;
  REP(_, T) {
    cout << solve() << endl;
  }
}



Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll A;
    ld B;
    cin >> A >> B;
    ll C = A*B;
    cout << C << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,k;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {cout<<"OK";
        return 0;}
    }
    cout<<"NG";
    return 0;
}

Measured memory_bytes: 3572
import sys

numChar = 26
ordA = ord('a')

Ss = input().rstrip()
Ts = input().rstrip()

setS, setT = set(Ss), set(Ts)
for T in setT:
    if T not in setS:
        print(-1)
        sys.exit()

def getDistNextss(As, numChar):
    lenA = len(As)
    poss = [-1] * numChar
    for i, A in enumerate(As):
        if poss[A] == -1:
            poss[A] = i + lenA
    distNextss = [[0]*(numChar) for _ in range(lenA)]
    for i in reversed(range(lenA)):
        poss[As[i]] = i
        distNextss[i] = [pos-i for pos in poss]
    return distNextss

As = [ord(S)-ordA for S in Ss]
distNextss = getDistNextss(As, numChar)

lenS = len(Ss)
i = 0
for T in Ts:
    T = ord(T) - ordA
    i += distNextss[i%lenS][T]
    i += 1

print(i)


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

vector<int> lol = {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 N;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  cout << lol[N - 1] << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var LR = new long[N][];
        for (int i = 0; i < N; i++)
        {
            var r = ReadLine().Split().Select(long.Parse).ToArray();
            LR[i] = new long[2] { r[0] - r[1], r[0] + r[1] };
        }
        Array.Sort(LR, (_a, _b) => _a[1].CompareTo(_b[1]));

        int ans = 1;
        long last = LR[0][1];
        for (int i = 1; i < N; i++)
        {
            if (last <= LR[i][0])
            {
                last = LR[i][1];
                ans++;
            }
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 50120
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, A, B;
    cin >> N >> A >> B;
    if(A * B >= N && A + B - 1 <= N){
        if(A == 1){
            vector<ll> ret(N);
            rep(i, N) ret[i] = N - i;
            voutput(ret);
            return 0;
        }
        vector<ll> AA(A, 1);
        AA[0] = B;
        ll r = N - (A + B - 1);
        ll p = r / (A - 1);
        ll q = r % (A - 1);
        rep(i, 1, A) AA[i] += p;
        rep(i, 1, q + 1) AA[i]++;
//        voutput(AA);
        vector<ll> ret;
        ll now = 0;
        for(auto a: AA) {
            now += a;
            for(ll i = now; i > now - a; i--) ret.pb(i);
        }
        voutput(ret);
    }
    else {
        output(-1);
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 8176
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        int n= scn.nextInt();
        int[] ar = new int[n];
        int max=0;
        int semiMax=0;
        for(int i=0;i<n;i++){
            ar[i]=scn.nextInt();
            if(max<ar[i]){
                max=ar[i];
                continue;
            }
            if(semiMax<ar[i]){
                semiMax=ar[i];
            }
        }
        for(int i=0;i<n;i++){
            if(max==ar[i]){
                System.out.println(semiMax);
            }else{
                System.out.println(max);
            }
        }
    }
}

Measured memory_bytes: 83360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int n,k;
    cin>>n>>k;
    ll p[n];
    FOR(i,0,n) cin>>p[i];
    sort(p,p+n);
    ll s=0;
    FOR(i,0,k) s+=p[i];
    
    cout<<s;
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;

constexpr int inf = 1ll<<61;
constexpr int mod = 1e9+7;
ll ext_gcd(ll a, ll b, ll &x, ll &y){ // ax+by=gcd(a,b)なるx,y,gcdを返す
  if(b == 0){
    x = 1; y = 0; return a;
  }
  ll q = a / b;
  ll g = ext_gcd(b, a-q*b, x, y);
  ll z = x - q * y;
  x = y; y = z;
  return g;
}
ll lcm(ll a, ll b){
  ll x, y;
  return a * b / ext_gcd(a,b,x,y);
}

main(){
  int n,m; cin >> n >> m;
  string s,t; cin >> s >> t;
  int l = lcm(n,m);
  int a = l/n, b = l/m;
  dump(l,a,b);
  bool f = true;
  rep(i,l/(a*b)){
    if(s[i*b] != t[i*a]) f = false;
  }
  if(f) cout << l << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265
int main()
{
    ll n, m;
    cin >> n >> m;
    ll nm = n * m;
    if(n == 1 || m == 1)
    {
        cout << "1" << endl;
        return 0;
    }
    cout << (nm+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int way[110][110];
bool used[110];
int main() {
	int n,m;
	while(n=in()){
		m=in();
		int i,j;
		for(i=0;i<110;i++){
			for(j=0;j<110;j++){
				way[i][j]=1000000000;
			}
			way[i][i]=0;
		}
		for(i=0;i<m;i++){
			int a,b,d;
			scanf("%d,%d,%d",&a,&b,&d);
			chmin(way[a][b],d/100-1);
			chmin(way[b][a],d/100-1);
		}
		/*for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				cout<<way[i][j]<<" ";
			}
			cout<<endl;
		}
		*/
		for(i=0;i<110;i++){
			used[i]=false;
		}
		priority_queue<pint,vector<pint>,greater<pint> > que;
		int res=0;
		que.push(pint(0,0));
		while(!que.empty()){
			pint p=que.top();
			que.pop();
			int v=p.second;
			if(used[v])continue;
			res+=p.first;
			used[v]=true;
//cout<<"v:"<<v<<endl;
			for(i=0;i<n;i++){
				if(way[v][i]!=1000000000&&v!=i&&!used[i]){
					que.push(pint(way[v][i],i));
//cout<<"i:"<<i<<endl;
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

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

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

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;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int main()
{
    int N, K;
    int A, B;

    scanf("%d%d%d", &K,&A,&B);

    for (int i = A; i <= B; i++)
    {
        if (i%K == 0)
        {
            printf("OK");
            return 0;
        }
    }
    printf("NG");
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <bitset>
#include <chrono>
#include <iomanip>
using namespace std;

/////------------------------TYPEDEF--------------------------/////
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
#define prq priority_queue<ll>;

/////------------------------CONSTANTS--------------------------/////
ll MOD=1000000007;
#define PI 3.1415926535897932384626433832795

/////------------------------GENERAL--------------------------/////
#define forx(i,j,n) for(int i=j;i<n;i++)
#define fory(i,j,n) for(int i=j;i>=n;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false)
#define testcase int t; cin>>t
#define MEM(xx,yy) memset(xx,yy,sizeof(xx))
#define vbs(xx,x) binary_search(all(xx),x)
#define vlb(xx,x) lower_bound(all(xx),x)
#define vub(xx,x) upper_bound(all(xx),x)

/////------------------------IO--------------------------/////
#define inpi(xx) scanf("%d",&xx)
#define inpl(xx) scanf("%lld",&xx)
#define inpc(xx) scanf("%c",&xx)
#define inps(xx) scanf("%s",&xx)
#define pri(xx) printf("%d",xx)
#define prl(xx) printf("%lld",xx)
#define prls(xx) printf("%lld ",xx)
#define prle(xx) printf("%lld\n",xx)
#define prc(xx) printf("%c",xx)
#define prs printf(" ");
#define pre printf("\n")
ll n,W;
ll w[100005],v[100005];
ll ans[100005][102];

ll fun(ll W, ll n){  
   // cout<<n;
   if(ans[W][n]!=-1) return ans[W][n];
if (n==0||W==0) return 0;  
if (w[n]>W) return fun(W,n-1);  
else ans[W][n]= max(v[n]+fun(W-w[n],n-1),fun(W,n-1));  
return ans[W][n];
}

int main() {
	int t=1;
	while(t--){
	    cin>>n>>W;
	    forx(i,0,n) cin>>w[i+1]>>v[i+1];
	    MEM(ans,-1);
	    cout<<fun(W,n);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
  	cin >> H[i];
  }
  int count = 0;
  int result = 0;
  for (int i = 0; i < N - 1; i++) {
  	if (H[i] >= H[i + 1]) {
    	count++;
    } else {
      	result = max(result, count);
    	count = 0;
    }
  }
  result = max(result, count);
  cout << result << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

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

    int ans  = 0;
    for (size_t i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3424
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextLong();
        }
        //Arrays.sort(a);
        int ans=0;
        //int[][][] vis = new int[101][101][101];
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                for(int k=j+1;k<n;k++){
                    int pa=0;
                    if(a[i]==a[j]||a[i]==a[k]||a[k]==a[j])
                        continue;
                    if(a[i]+a[j]>a[k]){
                        pa++;
                    }
                    if(a[k]+a[j]>a[i]){
                        pa++;
                    }
                    if(a[i]+a[k]>a[j]){
                        pa++;
                    }
                    if(pa==3){
                        ans++;
                    }
                    //System.out.println(a[i]+" "+a[j]+" "+a[k]);
                }
            }
        }
        str.append(ans);
        
        
        
        
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 34220
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b < 0) {
            int count = - a + b + 1;
            if (count % 2 == 0) {
                System.out.println("Positive");
            } else {
                System.out.println("Negative");
            }
        } else if (a > 0) {
            System.out.println("Positive");
        } else {
            System.out.println("Zero");
        }
    }
}

Measured memory_bytes: 21076
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	char s[100010];
	cin >> s;
	rep(i, strlen(s)) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
def candy_distribution(N: int, M: int, A: list)->int:
    S = 0
    remainders = {}
    remainders[0] = 1
    for a in A:
        S = (S + a) % M
        if S not in remainders:
            remainders[S] = 0
        remainders[S] += 1

    count = sum(r*(r-1)//2 for r in remainders.values())
    # for l in range(1, N+1):
    #     for r in range(l, N+1):
    #         if (S[r] - S[l-1]) % M == 0:
    #             # print('S({}, {}) = {}'.format(l, r, S[r] - S[l-1]))
    #             count += 1

    return count


if __name__ == "__main__":
    N, M = map(int, input().split())
    A = [int(s) for s in input().split()]
    ans = candy_distribution(N, M, A)
    print(ans)


Measured memory_bytes: 14252
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows!* * * * * * */
#include      <bits/stdc++.h>
using namespace std;
#define IOS       ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC      cout.precision (10); cout << fixed
#ifdef CONVICTION
#include "/home/convict/Dropbox/myfiles/sport_coding/cplib/snippets/debug.h"
#else
#define debug(x...)
#endif
//Don’t practice until you get it right. Practice until you can’t get it wrong

const int Mod = (int)1e9 + 7;
// const int Mod = 998244353;
#warning is it 998244353?
#define M(x) ((int)((x) % Mod))

inline int add (int x, int y) { return M(1ll*M(x) + M(y) + (Mod << 1)); }
inline int sub (int x, int y) { return M(1ll*M(x) - M(y) + (Mod << 1)); }
inline int mul (int x, int y) { return (int) M(1ll*(M(x) + Mod) * (M(y) + Mod)); }
inline int pow (int x, long long y) {
  int res = 1;
  while (y) {
    if (y & 1ll) res = mul(res, x);
    x = mul(x, x), y >>= 1ll;
  }
  return res;
}
inline int inv (int x) { return pow(x, 1ll*Mod - 2); }
inline int dv (int x, int y) { return mul(x, inv(y)); }

const int MAXFAC = (int)2e6 + 10;
int fac[MAXFAC];
#warning call_init_fac
void init_fac (int maxn) {
  fac[0] = 1;
  for (int i = 1; i < maxn; ++i) fac[i] = mul(fac[i - 1], i);
}
inline int C(int n, int r) {
  return dv(fac[n], mul(fac[n-r], fac[r]));
}
void preproc()
{
   init_fac(MAXFAC);
}

void solve()
{
   int H, W, A, B;
   cin >> H >> W >> A >> B;

   int res = 0;
   // part I -> height -> H - A, width -> i
   // part II -> height -> A, width -> W - i + 1
   for (int i = B+1; i <= W; ++i) {
      int inc = mul(C(H - A + i - 2, i - 1), C(A + W - i - 1, A - 1));
      res = add(res, inc);
   }
   cout << res << '\n';
}

signed main()
{
  IOS; PREC;
  preproc();

  int tc = 1;
  // cin >> tc;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    // cout << "Case #" << Tt << ": ";
    solve();
  }
  return EXIT_SUCCESS;
}


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

int main(){

int D;
cin >> D;

if(D == 22) cout << "Christmas Eve Eve Eve" << endl; 
else if(D == 23) cout << "Christmas Eve Eve" << endl; 
else if(D == 24) cout << "Christmas Eve" << endl; 
else if(D == 25) cout << "Christmas" << endl; 

}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    text = input().rstrip()
    n = int(input().rstrip())
    for i in range(n):
        s = input().split()
        if s[0] == "print":
            print(text[int(s[1]):int(s[2])+1])
        elif s[0] == "replace":
            new_text = ""
            new_text += text[:int(s[1])]
            new_text += s[3]
            new_text += text[int(s[2])+1:]
            text = new_text
        elif s[0] == "reverse":
            new_text = ""
            new_text += text[:int(s[1])]
            for i in range(int(s[2])-int(s[1]) + 1):
                new_text += text[int(s[2]) - i]
            new_text += text[int(s[2])+1:]
            text = new_text
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 5624
N = int(input())
P = []
for _ in range(N):
    x, y, h = map(int, input().split())
    P.append((x, y, h))

found = False
for i in range(len(P)):
    x, y, h = P[i]
    for cy in range(101):
        for cx in range(101):
            H = h + abs(x - cx) + abs(y - cy)
            if all(h == max(H - abs(x - cx) - abs(y - cy), 0) for x, y, h in P):
                print(cx, cy, H)
                found = True
                break
        if found:
            break
    if found:
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool cmp(ll a, ll b)
{
    return a > b;
}
int main()
{
    int n;
    while (cin >> n)
    {
        ll b[n];
        map<int, int> a;
        for (int i = 0; i < n; i++)
            cin >> b[i];
        sort(b, b + n, cmp);
        ll x[3];
        int cnt = 0;
        int tmp = -1;
        for (int i = 0; i < n; i++)
        {
            a[b[i]]++;
            if (a[b[i]] == 2)
            {
                x[cnt++] = b[i];
                tmp = b[i];
            }
            else if (a[b[i]] == 4 && b[i] == tmp)

            {
                x[cnt++] = b[i];
            }
            if (cnt == 2)
                break;
        }
        if (cnt != 2)
        {
            cout << "0" << endl;
            continue;
        }
        ll ans = x[0] * x[1];
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  long m,k;
  cin >> m>>k;
  if(k==0){
    rep(i,1<<(m+1)){
      cout<<i/2<<" ";
    }
  }
  else{
    if(m==1||k>=(1<<m)){
      cout<<-1<<endl;
    }
    else{
      long n=1<<(m+1);
      vector<long>a(n);
      a[0]=k;
      a[n/2]=k;
      rep2(i,1,n/2){
        if(i<k){
          a[i]=i%(n/2);
        }
        else{
          a[i]=(i+1)%(n/2);
        }
      }
      rep2(i,1,n/2){
        a[n/2+i]=a[n/2-i];
      }
      rep(i,n){
        cout<<a[i]<<" ";
      }
    }
  }
}

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

const int INF = 1e9;

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

  sort(a, a + n);
  int cnt;
  int idx;
  if (n % 2 == 0) {
    cnt = 1;
    idx = 0;
  } else {
    if (a[0] != 0) {
      cout<<0<<endl;
      return 0;
    }
    cnt = 2;
    idx = 1;
  }
  while (idx < n) {
      if (a[idx] != cnt || a[idx+1] != cnt) {
        cout<<0<<endl;
        return 0;
      }
    cnt += 2;
    idx += 2;
  }
  long long ans = 1;
  for (int i=0; i<n/2; i++) {
    ans = 2 * ans;
    ans = ans % (long long)(1e9 + 7);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
from heapq import heappush, heappop, heapify

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
nodes = [[] for _ in range(n)]
costs = [n+1 for i in range(n)]
costs[0] = 0
oyas = [None for _ in range(n)]

for tmp in ab:
    nodes[tmp[0]-1].append(tmp[1]-1)
    nodes[tmp[1]-1].append(tmp[0]-1)
#print(nodes)
## (cost, node, oya)
op_l = [(costs[0]+1, no, 0) for no in nodes[0]]
heapify(op_l)

while True:
    if len(op_l) == 0:
        break
    cost, node, oya = heappop(op_l)
    if oyas[node] is not None:
        continue
    else:
        costs[node] = cost
        oyas[node] = oya
        for ko in nodes[node]:
            if ko == 0 or oyas[ko] is not None:
                continue
            else:
                tmp = (costs[node]+1, ko, node)
                heappush(op_l, tmp)
#print(oyas)
for i in range(n):
    if i == 0:
        print("Yes")
    else:
        print(oyas[i]+1)

Measured memory_bytes: 76728
#include <iostream>

using namespace std;

int main() {
    int n, q;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cin >> q;
    int m[q];
    bool mm[q];
    for (int i = 0; i < q; ++i) {
        mm[i] = 0;
    }
    for (int j = 0; j < q; ++j) {
        cin >> m[j];
    }
    for (int i = 0; i < (1 << n); ++i) {
        /*for (int k = 0; k < q; ++k) {
            cout << mm[k] << " ";
        }*/
        //cout << endl;
        int s = 0;
        for (int j = 0; j < n; ++j) {
            if(i & (1<<j)){
                s += a[j];
            }
        }
        //cout << s << endl;
        for (int j = 0; j < q; ++j) {
            if(s == m[j]){
                //cout << s << " " << m[j] << endl;
                mm[j] = true;
            }
        }
    }
    for (int i = 0; i < q; ++i) {
        if(mm[i]){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
int N ;
int main ()
{
scanf ("%d " ,&N );
int res = N ;
for ( int i =0; i <= N ; i ++)
{
int cc =0;
int t = i ;
while (t >0) cc += t %6 , t /=6;
t=N - i ;
while (t >0) cc += t %9 , t /=9;
if ( res > cc ) res = cc ;
}
printf ("%d\n" , res );
}


Measured memory_bytes: 128
R=range(9)
Z=[0]*9
def f(M):
  global F
  def f1(i):
    if A.count(A[i])>=2: F[y][x]="*"
    return
  for y in R:
    A=M[y]
    for x in R: f1(x)
  for x in R:
    A=[M[y][x] for y in R]
    for y in R: f1(y)
  for i in R:
    x0=i%3*3
    y0=i/3*3
    A=[]
    for j in [0,1,2]: A+=M[y0+j][x0:x0+3]
    for j in R:
      y=y0+j/3
      x=x0+j%3
      f1(j)
  return

n=input()
while n:
  M=[]
  F=[[" " for _ in Z] for _ in Z]
  M=[map(int,raw_input().split()) for _ in Z]
  f(M)
  for i in R:
    s=zip(F[i],map(str,M[i]))
    print "".join([a+b for a,b in s])
  if n>1: print
  n-=1

Measured memory_bytes: 4300
#include<iostream>
#include<cstdio>
using namespace std;
int n,now,ans;
int a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]<=a[i-1]) now++;
		else {
			ans=max(ans,now);
			now=0;
		}
	}
	ans=max(ans,now); 
	printf("%d",ans);
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL N, C;
    cin >> N >> C;
    vector<LP> v(N), rv(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].F >> v[i].S;

    }

    for(int i = 0; i < N; ++i) {
        rv[i] = MP(C - v[N - i - 1].F, v[N - i - 1].S);

    }

    LL max_value[SIZE];
    LL s, d, res;
    s = d = res = 0;
    LL mvalue = 0;
    LL ns = 0;
    for(int i = 0; i < N; ++i) {
        ns += v[i].S;
        mvalue = max(mvalue, ns - v[i].F);
        max_value[i] = mvalue;

    }

    for(int i = 0; i < N; ++i) {
        res = max(res, s + max_value[N - i - 1] - d);
        s += rv[i].S;
        LL dd;
        if(i != 0) dd = rv[i].F - rv[i - 1].F;
        else dd = rv[i].F;
        s -= dd;
        d += dd;
        res = max(res, s);
    }

    for(int i = N - 1; i > 0; --i) {
        v[i].F -= v[i - 1].F;

    }

    ns = mvalue = 0;
    for(int i = 0; i < N; ++i) {
        max_value[i] = 0;
        ns += rv[i].S;
        mvalue = max(mvalue, ns - rv[i].F);
        max_value[i] = mvalue;

    }

    d = 0;
    s = 0;
    for(int i = 0; i < N; ++i) {
        LL mx = s + max_value[N - i - 1] - d;
        res = max(res, mx);
        s += v[i].S - v[i].F;
        d += v[i].F;
        res = max(res, s);

    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4224
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 黒のマスを表す文字 */
	private static final char BLACK = '#';
	/** 空のマスを表す文字 */
	private static final char EMPTY = 0;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			char[][] a = new char[h][];
			IntStream.range(0, h).forEach(i -> a[i] = scanner.next().toCharArray());
			boolean[] hasBlack = new boolean[h];
			Arrays.fill(hasBlack, false);
			// 行を確認する
			IntStream.range(0, h).forEach(i -> {
				for (int j = 0; j < w; j++) {
					if (BLACK == a[i][j]) {
						hasBlack[i] = true;
						break;
					}
				}
				if (!hasBlack[i]) {
					Arrays.fill(a[i], EMPTY);
				}
			});
			IntStream.range(0, w).forEach(j -> {
				boolean hasBlackj = false;
				for (int i = 0; i < h; i++) {
					if (BLACK == a[i][j]) {
						hasBlackj = true;
						break;
					}
				}
				if (!hasBlackj) {
					IntStream.range(0, h).forEach(i -> a[i][j] = EMPTY);
				}
			});
			IntStream.range(0, h).filter(i -> hasBlack[i]).forEach(i -> {
				IntStream.range(0, w).filter(j -> EMPTY != a[i][j]).forEach(j -> System.out.print(a[i][j]));
				System.out.println();
			});
		}
	}
}


Measured memory_bytes: 40360
program main
      implicit none
      integer(4) :: q, i, j, length, frlen, enlen
      character(10000000) :: s
      character(5) ::inp(2*10**5)
      character(2*10**5) :: fr, en, buff
      logical :: flag = .true.

      read *, s
      read *, q
      do i = 1, q
        read '(a5)', inp(i)
      end do
      length = len(trim(s))

      frlen = 0
      enlen = 0
      do i = 1, q
        if ( inp(i)(1:1) == '1' ) then
          if ( flag ) then
            flag = .false.
          else
            flag = .true.
          end if
        else if ( inp(i)(1:1) == '2' ) then
          if ( inp(i)(3:3) == '1' ) then
            if ( flag ) then
               frlen = frlen + 1
               fr(frlen:frlen) = inp(i)(5:5)
            else
               enlen = enlen + 1
               en(enlen:enlen) = inp(i)(5:5)
            end if
          else
            if ( flag ) then
               enlen = enlen + 1
               en(enlen:enlen) = inp(i)(5:5)
            else
               frlen = frlen + 1
               fr(frlen:frlen) = inp(i)(5:5)
            end if
          end if
        end if
      end do

      if ( flag ) then
        buff = fr
        do i = 1, frlen
          fr(frlen-i+1:frlen-i+1) = buff(i:i) 
        end do
        print *, fr(1:frlen)//s(1:length)//en(1:enlen)
      else
        buff = en
        do i = 1, enlen
          en(enlen-i+1:enlen-i+1) = buff(i:i) 
        end do
        buff = s
        do i = 1, length
          s(length-i+1:length-i+1) = buff(i:i) 
        end do
        print *, en(1:enlen)//s(1:length)//fr(1:frlen)
      end if

end program main



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

const int maxn = 55;
int n;
double val[maxn];
double ans = 0;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",&val[i]);
	}
	std::sort(val+1,val+n+1);
	ans = val[1];
	for(int i=2;i<=n;i++){
		ans = (ans + val[i]) / 2;
	}
	printf("%lf",ans);
	return 0;
}

Measured memory_bytes: 256
j = 0
i = 0
count = 0
max_count = 0
b = input()

b = b.replace('A','*')
b = b.replace('T','*')
b = b.replace('G','*')
b = b.replace('C','*')

while i < len(b):
    if b[i] == "*":
        while i + j < len(b):
            if b[i+j] == "*":
                count += 1
                j += 1
            else:
                i = i + j
                j = 0
                break
        if count >= max_count:
            max_count = count
            count = 0
    i += 1
    
print(max_count)

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

int a[100100], t[100100], mx[100100];
int n;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        t[i] = a[i];
    }
    for (int i = 0; i < n; i++) {
        if (i > 0) mx[i] = max(mx[i - 1], a[i - 1]);
    }
    sort(t, t + n);
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (mx[i] >= a[i]) cout << "0\n";
        else {
            long long sm = 0;
            while (cur < n && t[cur] <= a[i]) {
                sm += t[cur] - mx[i];
                cur++;
            }
            sm += 1ll * (n - cur) * (a[i] - mx[i]);
            cout << sm << '\n';
        }
    }
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
char a[200010];
int p,g,ans;
int main() {
	cin>>a;
	for(int i=0;i<strlen(a);++i) {
		if(g==p) {
			g++;
			if(a[i]=='p')
				ans--;
		}
		else {
			p++;
			if(a[i]=='g')
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
map<char,ll>m;
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    ll n=s.size(),ans=0;
    for(int i=0;i<n;i++){
        ans+=i;
        ans-=m[s[i]];
        m[s[i]]++;
    }
    cout<<ans+1;
	exit(0);
}


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

int main() {
    long long n, k, result = 0;
    cin >> n >> k;
    if (k == 0) {
        result += n * n;
    } else {
        for (long long j = k + 1; j <= n; j++) {
            result += (n + 1) / j * (j - k);
            if (n % j >= k && (n + 1) % j != 0) {
                result += n % j - k + 1;
            }
        }
    }
    cout << result;
    return 0;
}


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



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

    int N;
    cin >> N;

    vector<long long> A(N), B(N), C(N), dpA(N), dpB(N), dpC(N);

    for(int i=0;i<N;i++) cin >> A[i] >> B[i] >> C[i];

    dpA[0] = A[0];
    dpB[0] = B[0];
    dpC[0] = C[0];

    for(int i=1;i<N;i++) {
        dpA[i] = max(dpB[i-1],dpC[i-1]) + A[i];
        dpB[i] = max(dpC[i-1],dpA[i-1]) + B[i];
        dpC[i] = max(dpA[i-1],dpB[i-1]) + C[i];

    }

    cout << max(max(dpA[N-1],dpB[N-1]),dpC[N-1]) << endl;

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	n %= 10;
	if(n == 3) puts("bon");
	else if(n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
	else puts("hon");
	return 0;
}



Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

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

	double s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
int main() {
	int n, k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n+1][k+1];
	dp[0][0] = 1;
	for(int i=1;i<=k;i++){
	    dp[0][i] = 0;
	}
	for(int i=1;i<=n;i++){
	    for(int j=0;j<=k;j++){
	        if(j == 0){
	            dp[i][j] = dp[i-1][j];
	        }else{
	            dp[i][j] = ((dp[i-1][j] + dp[i][j-1])%MOD - ((j-1-arr[i-1] >= 0) ? dp[i-1][j-1-arr[i-1]] : 0) + MOD)%MOD;
	        }
	    }
	}
	cout<<dp[n][k];
	return 0;
}

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

int main(){
    ll n;
    cin>>n;
    ll a[5];
    rep(i,5)cin>>a[i];
    ll aa[5];
    rep(i,4){
        if(a[i+1]>a[i]){
            a[i+1]=a[i];
        }
    }
    aa[0]=(n+a[0]-1)/a[0];
    aa[1]=(n+a[1]-1)/a[1]+1;
    aa[2]=(n+a[2]-1)/a[2]+2;
    aa[3]=(n+a[1]-1)/a[3]+3;
    aa[4]=(n+a[4]-1)/a[4]+4;
    ll min=aa[0];
    rep(i,5){
        if(min<aa[i]){
            min=aa[i];
        }
    }
    cout<<aa[4]<<endl;
    return 0;
}

Measured memory_bytes: 256