akhauriyash/Code-Regression huggingface dataset:
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    s = list(read_str())
    n = len(s)
    ans = [1] * n
    for i in range(n-2):
        if s[i] == 'R' and s[i + 1] == 'R':
            ans[i + 2] += ans[i]
            ans[i] = 0
    for i in range(n - 1, 1, -1):
        if s[i] == 'L' and s[i - 1] == 'L':
            ans[i - 2] += ans[i]
            ans[i] = 0
    print(*ans)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 11580
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

int main(){

    ll k,a,b;
    cin>>k>>a>>b;

    if(b-a <= 1)
      cout<<k+1<<endl;
    else{

       if(k<=a ) cout<<k+1<<endl;
      else {
      k -= (a-1);
      if(k%2) cout<<a+(b-a) * (k/2)+1<<endl;
      else cout<<a+(b-a)*(k/2)<<endl;
    }

    }

return 0;
}

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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define pi              acos(-1.0)
#define NUM             1000005

typedef long long ll;


int main()
{
    FastRead

    ll n,x=0,y=0,ans=0;

    cin>>n;

    map<ll,ll>mp;

    for(ll i=1;i<=n;i++)
    {
        ll temp;
        cin>>temp;

        mp[temp] = i;
    }

    for(auto it:mp)
        cout<<it.second<<" ";
}


Measured memory_bytes: 9824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const int NMAX = 1e5+7;

int n, q;
vector<ll> A(NMAX, 0), esum(NMAX, 0), osum(NMAX, 0), sum(NMAX, 0);

bool check(int x, int a, int b){
    // t <= 1
    if(a == b) return true;
    ll d1 = abs(x - A[a]);
    ll d2 = abs(x - A[b]);
    if(d1 <= d2) return true;
    else return false;
}

ll calc(int l, int r, int d){
    if(l > r) return 0; 
    if(d == 0){
        return esum[r] - esum[l-1];
    }
    else if(d == 1){
        return osum[r] - osum[l-1];
    }
    else{
        return sum[r] - sum[l-1];
    }
}


ll query(ll x){
    ll left = 0, right = n+1;
    ll mid;
    while(left+1 < right){
        mid = (left+right)/2;
        int a = (mid+1)/2;
        int b = mid/2;

        int r = n+1-a;
        int l = n+1-mid;
        if(check(x, l, r)) left = mid;
        else right = mid;
    }

    int t = left;
    int a = (t+1)/2;
    int d = n%2;
    ll ans = calc(1, n-t, d) + calc(n+1-a, n, -1);
    return ans;
}

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

    cin >> n >> q;
    for(int i=1; i<=n; ++i) cin >> A[i];

    for(int i=1; i<=n; ++i){
        sum[i] += sum[i-1] + A[i];
        esum[i] += esum[i-1] + (i%2 == 0? A[i]:0);
        osum[i] += osum[i-1] + (i%2 == 1? A[i]:0);
    }

    for(int i=0; i<q; ++i){
        int x; cin >> x;
        ll ans = query(x);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4864
def longestRepeatedSubstring(str): 
  
    n = len(str) 
    LCSRe = [[0 for x in range(n + 1)]  
                for y in range(n + 1)] 
  
    res = "" # To store result 
    res_length = 0 # To store length of result 
  
    # building table in bottom-up manner 
    index = 0
    for i in range(1, n + 1): 
        for j in range(i + 1, n + 1): 
              
            # (j-i) > LCSRe[i-1][j-1] to remove 
            # overlapping 
            if (str[i - 1] == str[j - 1] and
                LCSRe[i - 1][j - 1] < (j - i)): 
                LCSRe[i][j] = LCSRe[i - 1][j - 1] + 1
  
                # updating maximum length of the 
                # substring and updating the finishing 
                # index of the suffix 
                if (LCSRe[i][j] > res_length): 
                    res_length = LCSRe[i][j] 
                    index = max(i, index) 
                  
            else: 
                LCSRe[i][j] = 0
  
    # If we have non-empty result, then insert  
    # all characters from first character to  
    # last character of string 
    if (res_length > 0): 
        for i in range(index - res_length + 1, 
                                    index + 1): 
            res = res + str[i - 1] 
  
    return res 
  
# Driver Code 
if __name__ == "__main__": 
  n=int(input())
  str=input()
  print(len(longestRepeatedSubstring(str)))

Measured memory_bytes: 247432
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    int ans=0;
    cin>>n;
    forsn(i,1,n+1){
        cin>>x;
        if(i&1 && x&1) ans++;
    }
    cout<<ans<<ln;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
// typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A+3);
  if(A[0] == A[2]){
    cout << "No" << endl;
  }
  else if(A[0] == A[1] || A[1] == A[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    for(int i = 0; i < k; i++) {
        cout << "ACL";
    }
    cout << endl;

    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    int nn=0;
    if(n==0){
        nn=9;
    }

    vector <int> s;
    int h=1;
    if(n<0){
        h=-1;
        n*=-1;
    }
    
    while(n!=0){
        s.push_back(n%2);
        n/=2;
    }
    int l2;
    l2=s.size();
    //rep(i,l2){
    //    cout << s[i] << endl;
    //}

    int l;
    s.push_back(0);
    s.push_back(0);
    s.push_back(0);
    s.push_back(0);
    l=s.size();
    vector <int> ans(l);
    ans=s;
    if(h==1){
    rep(i,l-2){
        //cout << i << endl;
        if(i%2==0){
            if(ans[i]==2){
                ++ans[i+1];
                ++ans[i+2];
                ans[i]=0;
            }
        }
        if(i%2==1){
            if(s[i]==1){
                ++ans[i+1];
            }
            if(ans[i]==2){
                --ans[i+1];
                ans[i]=0;
            }
        }
    }
    }
    else{
        rep(i,l-2){
        if(i%2==1){
            if(ans[i]==2){
                ++ans[i+1];
                ++ans[i+2];
                ans[i]=0;
            }
        }
        if(i%2==0){
            if(s[i]==1){
                ++ans[i+1];
            }
            if(ans[i]==2){
                --ans[i+1];
                ans[i]=0;
            }
        }
    }
    }
    

    int kk=0;
    if(nn==9){
        cout << 0 << endl;
    }
    else{
    rep(i,l){
        if(ans[l-i-1]==0 and kk==0){
            continue;
        }
        else{
            kk=1;
        cout << ans[l-i-1];
    }
    }
    }
    


    

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main() {
	int n,r;
	cin >> n >> r;
	if(n>=10) cout << r << endl;
	else cout << r+100*(10-n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int x[5];
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			cout << i + 1;
			return 0;
		}
	}
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
	int N;
	int i;
	int count;
	scanf("%d",&N);
	if(N<10){
		count = N;
	}
	else if(N<100){
		count = 9;
	}
	else if(N<1000){
		count = N-90;
	}
	else if(N<10000){
		count = 909;
	}
	else if(N<100000){
		count = N-9090;
	}
	else if(N==100000){
		count = 90909;
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
long long ans=0;
int n,head[MN+5],cnt=0,size[MN+5],flag=0,mn=1e9,s[MN+5],nl[MN+5],nr[MN+5],dn,p[MN+5];
struct edge{int to,next,w;}e[MN*2+5];
inline void ins(int f,int t,int w)
{
	e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
	e[++cnt]=(edge){f,head[t],w};head[t]=cnt;
}
void dfs(int x,int f)
{
	size[x]=1;nl[x]=++dn;p[dn]=x;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=f)
		{
			dfs(e[i].to,x);
			size[x]+=size[e[i].to];
			if(size[e[i].to]*2==n) ans+=(2LL*size[e[i].to]-1)*e[i].w,flag=1;
			else 
			{
				ans+=2LL*min(size[e[i].to],n-size[e[i].to])*e[i].w;
				if(size[e[i].to]>n-size[e[i].to]) ++s[nl[e[i].to]],--s[nr[e[i].to]+1];
				else ++s[1],--s[nl[e[i].to]],++s[nr[e[i].to]+1];
			}
		}
	nr[x]=dn;
}
int main()
{
	n=read();
	for(int i=1,j,k;i<n;++i) j=read(),k=read(),ins(j,k,read());
	dfs(1,0);
	if(!flag)
		for(int i=1;i<=n;++i) 
		{
			s[i]+=s[i-1];
			if(s[i]==n-1) for(int j=head[p[i]];j;j=e[j].next) mn=min(mn,e[j].w);
		}
	printf("%lld\n",flag?ans:ans-mn);
	return 0;
}



Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string n;
  cin >> n;
  int k=n.size();
  vector<vector<int>> r(9,vector<int>(9,0));
  int q=stoi(n);
  rep(i,q){
    int y=i+1;
    int b=y%10;
    if(b==0) continue;
    while(y>=10){
      y/=10;
    }
    r[y-1][b-1]++;
  }
  int ans=0;
  rep(i,9){
    rep(j,9){
      ans+=r[i][j]*r[j][i];
    }
  }
  cout << ans << endl;
}
                     


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

using namespace std;


int d[]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{




int m1,d1,m2,d2;
cin >> m1 >> d1 >> m2 >> d2;
if ( d[m1-1]==d1     ) cout << "1"; else cout << "0";





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long A[200000],ans=0;
int n,a,k,cnt;
int main(){
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>a;
    if(A[a-1]==0)cnt++;
    A[a-1]+=1;
}
sort(A,A+n);
for(int i=0;i<n,cnt-k>0;i++){
 if(A[i]>0){
     ans+=A[i];
     cnt--;
 }
}
cout<<ans<<endl;
}

Measured memory_bytes: 1792
s = gets.chomp
l = s.size
(l - 1).times{|i|
    if s[i] == s[i + 1]
        puts "#{i + 1} #{i + 2}"
        exit
    end
    }
(l - 2).times{|i|
    if s[i] == s[i + 2]
        puts "#{i + 1} #{i + 3}"
        exit
    end
    }
puts "-1 -1"

Measured memory_bytes: 1916
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll k;
string s;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>k>>s;
	if(k>=s.size())
	cout<<s;
	else
	{
	    s=s.substr(0,k);
	    cout<<s<<"...";
	}
	return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int prime[1000000],p[30],N,P,n[900];
bool isprime[1000001];

int sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++)isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=0;i<=n;i++){
		if(isprime[i]){
			prime[p++]=i;
			for(int j=i*2;j<=n;j+=i)isprime[j]=false;
		}
	}
	return p;
}

int main(){
	sieve(200000);
	while(cin>>N>>P&&N>-1){
		int cur=0;
		while(cur<30){
			N++;
			if(isprime[N])p[cur++]=N;
		}
		cur=0;
		rep(i,30)for(int j=i;j<30;j++)n[cur++]=p[i]+p[j];
		sort(n,n+cur);
		cout<<n[P-1]<<endl;
	}
}

Measured memory_bytes: 0
def func():
    pass


def main():
    a, b, c = map(int, input().split())
    l = []
    i = 1
    while True:
        x = a * i
        left = x % b
        if left == c:
            print("YES")
            return
        if left in l:
            print("NO")
            return
        l.append(left)
        i += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ins insert
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define sz(a) (ll)((a).size())
#define matrix vector<vector<ll>>
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
#define tr(container,it) for(typeof(container.begin())it=container.begin();it!=container.end();it++)
#define set_bits(n) __builtin_popcount (n)
const ll MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9;
const ll dx[4] = {0, 1, 0, -1};
const ll dy[4] = {1, 0, -1, 0};


int main()
{
    ll n,d;cin>>n>>d;
    cout<<ceil(n*1.0/(2*d+1)*1.0)<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n),v(n);
	for(int i=0; i<n; i++)
		cin>>w[i]>>v[i];
	vector<ll> dp(W+1,INT_MIN);
	dp[0] = 0;
	for(int item=0; item<n; item++)
	{
		for(int j=W; j>=0; j--)
		{
			if(dp[j]>=0)
			{
				if(j+w[item]<=W)
					dp[j+w[item]] = max(dp[j+w[item]],dp[j] + v[item]);
			}
		}
	}
	ll maxi = INT_MIN;
	//traceloop(W+1,dp);
	for(int i=W; i>=0; i--)
		maxi = max(maxi,dp[i]);
	cout<<maxi;
	return 0;
}
	

Measured memory_bytes: 1024
// Beginner162.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

bool has7(int n)
{
	while (n > 0)
	{
		int c = n % 10;
		if (c == 7) return true;
		n /= 10;
	}
	return false;
}

int gcd(int a, int b)
{
	while (b != 0)
	{
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int main()
{
	//A
	/*int n;
	cin >> n;
	bool has = has7(n);
	cout << (has ? "Yes" : "No");*/

	//B
	/*int n;
	cin >> n;

	ll result = 0;
	for (int i = 1; i <=n; ++i)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			result += i;
		}
	}
	cout << result;*/
	
	//C
	/*int k;
	cin >> k;

	ll result = 0;
	vector<vector<int>> v(k + 1, vector<int>(k + 1, 0));
	for (int i = 1; i <= k; ++i)
	{
		for (int j = i; j <= k; ++j)
		{
			int g = gcd(i, j);
			v[i][j] = g;
			v[j][i] = g;
		}
	}
	
	for (int i = 1; i <=k; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			int ij = v[i][j];
			
			for (int l = 1; l <= k; ++l)
			{
				int ijl = v[ij][l];
				result += ijl;
			}
		}
	}
	
	cout << result;*/

	//D
	int n;
	string s;
	cin >> n >> s;

	ll result = 0;

	vector<vector<int>> count(n, vector<int>(3, 0));
	for (int i = n-1; i >=0; --i)
	{
		if (s[i] == 'R') count[i][0]++;
		else if (s[i] == 'G') count[i][1]++;
		else count[i][2]++;

		if (i < n-1)
		{
			for (int j = 0; j < 3; ++j)
			{
				count[i][j] += count[i + 1][j];
			}
		}
	}

	for (int i = 0; i < n-2; ++i)
	{
		for (int j = i+1; j < n-1; ++j)
		{
			if (s[i] == s[j]) continue;

			int charIndex;
			if (s[i] != 'R' && s[j] != 'R') charIndex = 0;
			else if (s[i] != 'G' && s[j] != 'G') charIndex = 1;
			else charIndex = 2;

			result += count[j + 1][charIndex];
			int checkIndex = j + j - i;
			if (checkIndex < n && s[checkIndex] != s[i] && s[checkIndex] != s[j])
			{
				result--;
			}
		}
	}
	
	cout << result;
	//E

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

	//ll maxSum = INT_MIN;
	//if (n % 2 == 0)
	//{
	//	ll oddSum = 0;
	//	ll evenSum = 0;
	//	for (int i = 0; i < n; ++i)
	//	{
	//		if (i % 2 == 0) evenSum += a[i];
	//		else oddSum += a[i];
	//	}
	//	maxSum = max(oddSum, evenSum);
	//}
	//else
	//{
	//	vector<vector<int>> dp(n, vector<int>(n, 0));
	//	for (int i = 0; i < n; ++i)
	//	{
	//		for (int j = i; j < n; ++j)
	//		{
	//			if (j == i || j == i + 1)
	//				dp[i][j] = a[j];
	//			else
	//				dp[i][j] = dp[i][j - 2] + a[j];
	//		}
	//	}

	//	//twoSpaces == 0
	//	maxSum = dp[2][n - 1];
	//	//twoSpaces == n-2
	//	maxSum = max(maxSum, static_cast<ll>(dp[0][n - 3]));
	//	
	//	for (int twoSpaces = 1; twoSpaces <= n-6; twoSpaces += 2)
	//	{
	//		int sum = INT_MIN;
	//		int leftSum = dp[0][twoSpaces - 1];
	//		for (int j = twoSpaces + 3; j < n-2; j += 2)
	//		{
	//			int midSum = dp[twoSpaces + 2][j-1];
	//			int endSum = dp[j + 2][n - 1];
	//			sum = max(sum, leftSum + midSum + endSum);
	//		}

	//		if (sum > maxSum)
	//		{
	//			maxSum = sum;
	//		}
	//	}
	//}

	//cout << maxSum;
	
}



Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int ans = INF;
    for(char t = 'a'; t <= 'z'; t++) {
        int tot = 0, cnt = 0;
        rep(i, s.size()) {
            if(s[i] == t) {
                tot = max(tot, cnt);
                cnt = 0;
            } else if(i == s.size() - 1) {
                tot = max(tot, cnt + 1);
            } else {
                cnt++;
            }
        }
        ans = min(ans, tot);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a[26]={};
  char text[1200]={};
  int i=0,j;
  
  while(scanf("%c",&text[i])!=EOF){
    i++;
  }
  text[i] = 0;
  
  i=0;
  while(text[i]!=0){
    for(j='A';j<='z';j++){
      if(text[i]==j||text[i]==j+'a'-'A'){
	if(text[i]>='A'&&text[i]<='Z'){
	  a[j-'A']++;
	}
	else{
	  a[j-'a']++;
	}
      }
    }
    i++;
  }
  
  for(i='a',j=0;i<='z';i++,j++){
    printf("%c : %d\n",i,a[j]);
  }
  return(0);
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<double> P(N);
    for(int i = 0; i < N; i++) {
        int p; cin >> p;
        P[i] = (p+1) / 2.0;
    }
    vector<double> ans(N-K+1);
    double x = 0;
    for (int i = 0; i < K; i++) {
        x += P[i];
    }
    ans[0] = x;
    for (int i = 1; i < N-K+1; i++) {
        ans[i] = ans[i-1] - P[i-1] + P[i+K-1];
    }
    double a = 0;
    for (int i = 0; i <= N-K+1; i++) {
        a = max(a, ans[i]);
    }
    cout << setprecision(10) <<  a << endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();

        sc.close();

        System.out.println(A1 + A2 + A3 >= 22 ? "bust" : "win");

    }

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;


main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int res=0;
    for(int i=1;i<=n;i++) if(i%3&&i%5) res+=i;
    cout<<res;
}


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

using namespace std;

const int MAXN = 1<<18;

pair<int, int> arr[MAXN];
pair<int, int> mx[MAXN][2];

void fix(int i, pair<int, int> x)
{
	if (x == mx[i][0] || x == mx[i][1])
		return;
	if (x > mx[i][0])
	{
		mx[i][1] = mx[i][0];
		mx[i][0] = x;
	}
	else if (x > mx[i][1])
	{
		mx[i][1] = x;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, N, i, j;
	int sol = 0;
	
	cin>>n;
	
	N = 1<<n;
	
	for (i = 0; i < N; ++i)
	{
		cin>>arr[i].first;
		arr[i].second = i;
	}
	
	mx[0][0] = arr[0];
	for (i = 1; i < N; ++i)
	{
		fix(i, arr[i]);
		for (j = 0; j < n; ++j) if (i & (1<<j))
		{
			fix(i, mx[i ^ (1<<j)][1]);
			fix(i, mx[i ^ (1<<j)][0]);
		}
		
		sol = max(sol, mx[i][0].first + mx[i][1].first);
		cout<<sol<<'\n';
	}
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,m;
	cin>>n>>m;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	sort(a.begin(),a.end());
	vector<pair<lli,lli>> v;
	REP(i,0,m){
		lli b,c;
		cin>>b>>c;
		v.push_back(mp(c,b));
	}

	sort(v.rbegin(),v.rend());


	lli now=0;
	REP(i,0,m){
		if(now>=n)break;
		REP(j,0,v[i].second){
			if(now>=n)break;
			if(DEBUG)cout<<"now="<<now<<" aN="<<a[now]<<" vI="<<v[i].first<<endl;
			if(a[now]>=v[i].first){
				j--;
				now++;
				continue;
			}
			a[now]=v[i].first;
			now++;
		}
		if(now>=n)break;
	}

	lli sum=0;
	REP(i,0,n){
		if(DEBUG)cout<<"a[i}="<<a[i]<<endl;
		sum+=a[i];
	}
	cout<<sum<<endl;


	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000
#define P pair<ll,ll>

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<P> b(n);
  for (int i = 0; i < n; i++){
    b[i] = P(abs(a[i]), a[i]);
  }
  sort(b.begin(), b.end());
  
  vector<ll> pos(0), neg(0);
  ll p = 0;
  for (int i = 0; i < n; i++){
    if (a[i] >= 0)
      p++;
  }



  for (int i = 0; i < k; i++){
    if (b[n-1-i].second >= 0){
      pos.emplace_back(b[n-1-i].second);
    }
    else
      neg.emplace_back(b[n-1-i].second);
  }



  if (n == k){
    ll ans = 1;
    for (int i = 0; i < n; i++){
      ans = ans * a[i] % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
  }
  else if (neg.size() % 2 == 0){
    ll ans = 1;
    for (int i = 0; i < k; i++){
      ans = ans * b[n-1-i].first % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
  }
  else if (pos.size() == 0 && p == 0){
    ll ans = 1;
    for (int i = 0; i < k; i++){
      ans = ans * b[i].second % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
  }
  else if (pos.size() == 0){
    ll ans = 1;
    for (int i = 0; i < k-1; i++){
      ans = ans * b[n-1-i].second % MOD;
    }
    for (int i = k-1; i < n; i++){
      if (b[n-1-i].second >= 0){
        ans = ans * b[n-1-i].second % MOD;
        break;
      }
    }
 
    cout << (ans + MOD) % MOD << endl;
  }
  else {

    ll next_p = -1, next_n = 1;
    for (int i = n-k-1; i >= 0; i--){
      if (b[i].second < 0 && next_n == 1){
        next_n = b[i].second;
      }
      if (b[i].second > 0 && next_p == -1){
        next_p = b[i].second;
      }
    }


    if (next_p == -1 && next_n == 1){
      pos.emplace_back(0);
    }
    else if (next_p == -1 || next_n * neg[neg.size()-1] > next_p * pos[pos.size() - 1]){
      neg.emplace_back(next_n);
      pos.pop_back();
    }
    else {
      pos.emplace_back(next_p);
      neg.pop_back();
    }

    ll ans = 1;
    for (ll i : pos){
      ans = ans * abs(i) % MOD;
    }
    for (ll i : neg){
      ans = ans * abs(i) % MOD;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 10204
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};


int main(){
  int N;
  long long A, B, C, D;
  std::cin >> N >> A >> B >> C >> D;
  bool ok = false;
  for (int i=0; i<N; i++) {
    int pc = i;
    int mc = N-1-i;
    long long max = i*D-mc*C;
    long long min = i*C-mc*D;
    if (B-A>=min && B-A<=max) {
      ok = true;
      break;
    }
  }
  printf("%s\n", ok?"YES":"NO");
  return 0;
}

Measured memory_bytes: 3080
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion


	
static int a[100001];
	int main(void) {
		int n, i;

		scanf("%d\n", &n);
		for (i = 0; i < n; i++)
			scanf("%d", &a[i]);

		qsort(a, n, sizeof(int), i_asort);

		int c = 0;
		for (i = 0; i < n;i++) {
			if (a[i] == a[i + 1]) i++;
			else c++;
		}
	printf("%d\n",c);
	return 0;

}




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

using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  
  int ans = 0;
  if(S[0] == T[0]) ans++;
  if(S[1] == T[1]) ans++;
  if(S[2] == T[2]) ans++;
  
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using std::cin;
using std::cout;
using std::endl;

int main(){
	int a,b,c,d,e;
	int k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a>k)cout<<":("<<endl;
	else cout<<"Yay!"<<endl;

	return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    s=input()
    if s.isupper():
        print("A")
    else:
        print("a")


if __name__ == "__main__":
    main()

Measured memory_bytes: 72776
PROGRAM DiceAndCoin
      IMPLICIT NONE
      integer(16) :: n,k
      integer(16) :: score,counter,i
      real(16) :: ans
      !simulation!
      read*,n,k
      
      ans = 0
      do i = 1,n
        score = i
        counter = 0
        do while( score<=k-1 )
          score = score * 2
          counter = counter + 1
        end do
        
        
        ans = ans + 1_16 / real(2**counter)
        
      end do
      
      ans = ans / real(n)
      
      print*,ans
      
      
      
      do while(.false.)
        print*,'piyo'
      end do
      
      END PROGRAM

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main();
	}

	int w, h;
	int[][] c;

	Main() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();

			if (w == 0 && h == 0)
				break;

			c = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					c[i][j] = sc.nextInt();
				}
			}

			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (f(j, i))
						ans++;
				}
			}
			System.out.println(ans);
		}
	}

	boolean f(int x, int y) {
		try {
			if (c[y][x] == 0) {
				return false;
			}
		} catch (Exception e) {
			return false;
		}

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

		c[y][x] = 0;

		for (int i = 0; i < 8; i++) {
			f(x + dx[i], y + dy[i]);
		}
		return true;
	}
}

Measured memory_bytes: 43160
n = int(input())
n_list = list(map(int, input().split()))

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  int N = S.length(), sum = 0;
  for (int i = 0; i < N; i++){
    sum += S[i] - '0';
    sum %= 9;
  }
  if (sum == 0) Yes();
  else No();

  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	string n;

	cin >> n;

	REP(i, n.size())
	{
		if (n[i] == '1')
		{
			n[i] = '9';
		}
		else if (n[i] == '9')
		{
			n[i] = '1';
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($A,$B,$C,$X,$Y) = explode(" ",trim(fgets(STDIN)));
//$X  = explode(" ",trim(fgets(STDIN)));
$a[] = $A*$X+$B*$Y;
$a[] = max($X,$Y)*$C*2;
if ($X > $Y) {
  $a[]=$Y*$C*2+($X-$Y)*$A;
}
else {
  $a[]=$X*$C*2+($Y-$X)*$B;
}
printf("%d\n",min($a));


Measured memory_bytes: 3576
#include <iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<unordered_set>
#include<stack>
#include<queue>
#include<unordered_map>
using namespace std;
typedef long long int ll;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
void DSUinit(vector<ll>&a,vector<ll>&size,ll n)
{
    FOR(i,0,n)
    {
        a[i]=i;
        size[i]=1;
    }
    return;
}
ll root(vector<ll>&a,ll i)
{
    return (i==a[i])?i:a[i]=root(a,a[i]);
}
bool DSUfind(vector<ll>a,ll x,ll y)
{
    if(root(a,x)==root(a,y))
    {
        return true;
    }
    return false;
}
void DSUunion(vector<ll>&a,vector<ll>&size, ll x,ll y)
{
    x=root(a,x);
    y=root(a,y);
    if(x==y)
    {
        return;
    }
    if(size[x]<size[y]) swap(x,y);
    a[y]=x;
    size[x]+=size[y];
}
void dfs(vector<vector<ll> >&graph,vector<bool>&visited,ll start)
{
    visited[start]=true;
    FOR(i,0,graph[start].size())
    {
        if(!(visited[graph[start][i]]))
        {
            dfs(graph,visited,graph[start][i]);
        }
    }
    return;
}
bool isPrime(int n) 
{
    if (n <= 1)  return false; 
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
          return false;
    return true; 
}
ll power(ll x,ll y,ll p)
{
    ll ans=1;
    x = x%p;
    if(x==0) return 0;
    while(y)
    {
        if(y&1) ans=(ans*x)%p;
        y>>=1;
        x=(x*x)%p;
    }
    return ans;
}
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>v(n,0);
    FOR(i,0,n)
    {
        cin>>v[i];
    }
    vector<ll>dp(n,0);
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    FOR(i,2,n)
    {
        dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c; cin>>a>>b>>c;
    cout<<char(a[0]+'A'-'a')<<char(b[0]+'A'-'a')<<char(c[0]+'A'-'a')<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (i % c == 0) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35596
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

ll calc(ll n){
    switch(n%4){
        case 0: return n;
        case 1: return 1;
        case 2: return n+1;
        case 3: return 0;
    }
}

int main(void)
{
    ll a,b;
    cin >> a >> b;
    if(a > 0) pr(calc(b)^calc(a-1));
    else pr(calc(b));
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <list>
#include <utility>
using namespace std;

typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int n, k;
	cin >> n;
  vector<int> d;
  rep(i,n) {
    cin >> k;
    // 例外
    if ((i == 0 && k != 0) || (i != 0 && k == 0)) {
      cout << 0 << endl;
      return 0;
    }
    d.push_back(k);
  }
  sor(d);

  int depth_counter = 1;
  ll ans = 1;
  int countn_the_depth = 0;
  int countn_before_depth = 1;

  for (int i = 1; i < n; ++i) {
    if (d.at(i) == depth_counter + 1) {
      ll tmp = myPow(countn_before_depth, countn_the_depth, 998244353);
      ans *= tmp;
      ans %= 998244353;
      countn_before_depth = countn_the_depth;
      countn_the_depth = 1;
      depth_counter++;
    } else if (d.at(i) != depth_counter) {
      cout << 0 << endl;
      return 0;
    } else {
      countn_the_depth++;
    }
  }
  ll tmp = myPow(countn_before_depth, countn_the_depth, 998244353);
  ans *= tmp;
  ans %= 998244353;
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int N, D;
  int S[15][15];
  double t;
  int i, j, k;
  int count = 0; 
  scanf("%d", &N);
  scanf("%d", &D);

  for(i=0; i<N; i++){
    for(j=0; j<D; j++){
      scanf("%d", &S[i][j]);
    }
  }
  
  for(k=0; k<N; k++){
   for(i=k+1; i<N; i++){
     for(j=0; j<D; j++){
       t += pow(S[k][j] - S[i][j], 2);
     }
     t = sqrt(t);
     if(fmod(t, 1.00) == 0){
       count++;
     }
     t = 0;
   }
  }

  printf("%d", count);

  return 0;

}

Measured memory_bytes: 128
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int f(int a, int b) {
  return min(a - b, b);
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int>a(n);
  for(auto &e:a) cin >> e;
  sort(rbegin(a), rend(a));
  tuple<double, int, int> best(-1, 0, 0);
  int head = 0;
  for(int i = 0; i < n; i++) {
    while(head + 1 < n && (i >= head || f(a[i], a[head]) < f(a[i], a[head + 1]))) head++;
    auto d = make_tuple(lgamma(a[i] + 1) - lgamma(a[head] + 1) - lgamma(a[i] - a[head] + 1), a[i], a[head]);
    best = max(best, d);
  }
  cout << get<1>(best) << " " << get<2>(best) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int l, a, b, c, d;
	scanf("%d %d %d %d %d", &l, &a, &b, &c, &d);
	printf("%d\n", l - max((a + c - 1) / c, (b + d - 1) / d));

	return 0;
}

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

using namespace std;
int popcount64(uint64_t x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) + (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) + (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) + (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) + (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) + (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) + (x & 0x00000000ffffffffUL);
  return x;
}

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

  int n;
  cin >> n;
  for (int i = n; 0 <= i; --i) {
    if (popcount64(i) == 1) {
      cout << i << "\n";
      break;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  long long int m,h=0;
  cin >> m;
  while(m >= 500)
  {
    m -= 500;
    h += 1000;
  }
  while(m >= 5)
  {
     m -= 5;
    h += 5;
  }
  cout << h;
  return 0;
} 


Measured memory_bytes: 256