akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int low_digit = 0;
	int high_digit = 0;
	int log10 = 1;

	int perm[6] = { 0, 2, 22, 222, 2222, 22222 };
	int ans[200003] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, };

	for(int i = 10; i <= 200000; ++i)
	{
		if      (i >= 100000) log10 = 5;
		else if (i >= 10000)  log10 = 4;
		else if (i >= 1000)   log10 = 3;
		else if (i >= 100)    log10 = 2;
		else                  log10 = 1;
		
		low_digit = i % 10;
		high_digit = i / (int)(pow(10, log10));

		if (low_digit == 0)
		{
			ans[i] = 0;
			continue;
		}
		if (high_digit > low_digit)
		{
			ans[i] = perm[log10];
		}
		else if (high_digit < low_digit)
		{
			ans[i] = perm[log10 - 1];
		}
		else // low_digit == high_digit
		{
			ans[i] = perm[log10 - 1] + ((i / 10) % (int)(pow(10, log10 - 1))) * 2  + 3;
		}
	}

	int n;
	cin >> n;

	for(int i = 0; i < n; ++i)
	{
		ans[i + 1] = ans[i] + ans[i + 1];
	}

	cout << ans[n];


}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 1024
//Created by Aminul on 8/29/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int mod = (int) 1e9 + 7;
        int n = in.nextInt();
        int[] arr = new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
            sum += arr[i];
            sum %= mod;
        }

        long res = 0;
        for (int i : arr) {
            sum -= i;
            sum = (sum + mod) % mod;
            res += (i * sum) % mod;
            res %= mod;
        }

        pw.println(res);


        pw.close();
    }

    static long burte(int n, int[] arr) {
        int mod = (int) 1e9 + 7;
        long res = 0;
        for (int i = 0; i < n; i++) {
            long tmp = 0;
            for(int j = i + 1; j < n; j++) {
                tmp += (arr[i] * 1l * arr[j]) % mod;
                tmp %= mod;
            }
            res = (res + tmp) % mod;
            debug(i, tmp, res);
        }
        return res;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 50092
def func(n: int) -> int:
    return n // 2 if n % 2 == 0 else n * 3 + 1


def answer(s: int) -> int:
    sequence_a = [s]
    while True:
        num = func(sequence_a[-1])
        if num in sequence_a:
            return len(sequence_a) + 1
        sequence_a.append(num)


def main():
    s = int(input())
    print(answer(s))


if __name__ == '__main__':
    main()


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

int main(){
	int n,t,l,b;
	cin >> n >> t >> l >> b;
	while(n>0){
		int map[n+1];
		for (int i=0;i<n+1;i++){
			map[i]=0;
		}
		for (int i=0;i<l;i++){
			int temp;
			cin >> temp;
			map[temp]=1;
		}	
		for (int i=0;i<b;i++){
			int temp;
			cin >> temp;
			map[temp]=2;
		}
		
		double prob[t+2][n+1];
		double sixth=1.0/6.0;
		for (int i=0;i<t+2;i++){
			for(int j=0;j<n+1;j++){
				prob[i][j]=0.0;
			}
		}

		prob[0][0]=1.0;	
		for (int i=0;i<t;i++){
			prob[i+1][n]+=prob[i][n];
			for (int j=0;j<n;j++){
				for (int k=0;k<6;k++){
					int nsq=j+k+1;
					if(n<nsq){
						nsq=n*2-nsq;
					}
					if(map[nsq]==0){
						prob[i+1][nsq]+=prob[i][j]*sixth;
					}else if(map[nsq]==1){
						prob[i+2][nsq]+=prob[i][j]*sixth;
					}else if(map[nsq]==2){
						prob[i+1][0]+=prob[i][j]*sixth;
					}
				}
			}
		}

		cout << fixed << setprecision(6) << prob[t][n] << endl;
		cin >> n >> t >> l >> b;
	}
	return 0;
}


Measured memory_bytes: 1312
//#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int n,t=1;
int main(){
    string w;
    cin>>w;
    if(w[2]==w[3]&&w[4]==w[5])
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    int n,i,k;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
    	if((s[i]-'A'+1+n)%26==0){
    		k=26;
		}
    	else{
    		k=(s[i]-'A'+1+n)%26;
		}
		cout<<char((64+k));
	}
    return 0;
}


Measured memory_bytes: 256
z = input()
cs = [ int(x) for x in input().split() ]
ar = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
up = 0
mn = 0
mx = 0

for x in cs :
  if x < 400 :
    ar[0] = 1
  elif x < 800 :
    ar[1] = 1
  elif x < 1200 :
    ar[2] = 1
  elif x < 1600 :
    ar[3] = 1
  elif x < 2000 :
    ar[4] = 1
  elif x < 2400 :
    ar[5] = 1
  elif x < 2800 :
    ar[6] = 1
  elif x < 3200 :
    ar[7] = 1
  else :
    up = up + 1

if sum(ar) == 0 :
  mn = 1
  mx = up
else :
  mn = sum(ar)
  mx = sum(ar) + up

print(str(mn) + " " + str(mx))

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

MOD = 10 ** 9 + 7

n, k = map(int, input().split())
a = list(map(int, input().split()))

a_single = 0
a_multi = 0

for i, ai in enumerate(a):
    for j, aj in enumerate(a):
        if ai > aj:
            a_multi += 1
            if j > i:
                a_single += 1

ans = 0
ans = (a_single * k % MOD + ans) % MOD
ans = (k * (k - 1) // 2 % MOD * a_multi % MOD + ans) % MOD

print(ans)


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


/*
int solve(int i){
	if(i == 0) return 0;
	if(i == 1) return 0;
	if(memo[i] != -1) return memo[i];
	int m = INT_MAX;
	for(int d = 1; d <= k; d++){
		if(i - d < 0) break;
		m = min(solve(i-d, k)+abs(h[i]-h[i-d]), m);
	}
	return memo[i] = m;
}
*/

int main(){


	string s, t;
	cin >> s >> t;

	vector<array<pair<pair<int, int>, int>, 3000>> dp(3000);
	dp[0][0] = make_pair(make_pair(0,0), (s[0] == t[0] ? 1 : 0));
	for(int i = 1; i < s.size(); i++){
		int same = (s[i] == t[0] ? 1 : 0);
		dp[i][0] = make_pair(make_pair(i-1,0), max(dp[i-1][0].second, same));
	}
	for(int i = 1; i < t.size(); i++){
		int same = (s[0] == t[i] ? 1 : 0);
		dp[0][i] = make_pair(make_pair(0,i-1), max(dp[0][i-1].second, same));
	}
	
	for(int i = 1; i < s.size(); i++){
		for(int j = 1; j < t.size(); j++){
			bool same = s[i] == t[j];
			if(same){
				dp[i][j] = make_pair(make_pair(i-1,j-1), dp[i-1][j-1].second + 1);
			}
			else{
				if(dp[i-1][j].second >= dp[i][j-1].second){
					dp[i][j] = make_pair(make_pair(i-1,j), dp[i-1][j].second);
				}
				else{
					dp[i][j] = make_pair(make_pair(i,j-1), dp[i][j-1].second);
				}
			}
		}
	}

	string buf;
	pair<int, int> o = make_pair(0, 0);
	pair<pair<int, int>, int> p = dp[s.size() - 1][t.size() - 1];
	pair<int, int> ppos = make_pair(s.size() - 1, t.size() - 1);
	int l = p.second;

	while(ppos != o){
		if(l - 1 == dp[p.first.first][p.first.second].second){
			l--;
			buf.push_back(s[ppos.first]);
		}
		ppos = make_pair(p.first.first, p.first.second);
		p = dp[p.first.first][p.first.second];
	}
	if(l == 1) buf += s[0];

	reverse(buf.begin(), buf.end());

	cout << buf << endl;

    return 0;
}


Measured memory_bytes: 105728
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

int a,b,k;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> a >> b >> k;
    fort (i,k)
    {
        if (i%2==1)
        {
            if (a%2==1) --a;
            a/=2, b+=a;
        }
        else
        {
            if (b%2==1) --b;
            b/=2, a+=b;
        }
    }
    cout << a << ' ' << b;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long a, b, c, d, ans;
int main(){
	cin >> a >> b >> c >> d;
	ans=max(a*c,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	string s;
	string t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<3;++i)
	{
	    if(s[i]==t[i])cnt++;
	}
	cout<<cnt;
	return 0;
}
 

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

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

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll X, Y;
    cin >> X >> Y;
    if (abs(X - Y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,W;
  cin>>N>>W;
  vector<vector<int>> A(N+1,vector<int>(W+1,0));
  for(int i=1;i<=N;i++){
    int a,b;
    cin>>a>>b;
    for(int j=0;j<=W;j++){
      if(j<a)
        A[i][j]=A[i-1][j];
      else
        A[i][j]=max(A[i-1][j],A[i-1][j-a]+b);
    }
  }
  int ans=0;
  for(int i=0;i<=W;i++)
    ans=max(ans,A[N][W]);
  cout<<ans<<endl;
}

Measured memory_bytes: 82996
# map(int,input().split())
a = [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]
K = int(input())
print(a[K-1])

Measured memory_bytes: 3060
/**
 *COYG, 14 FA Cups we are back baby
 */
#include <bits/stdc++.h>
using namespace std;
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
#define plll pair<ll,pll >
const ll mod=1000000007;
string s;ll d;ll n;
ll dp[10001][100][2];
ll getans(ll index,ll rem,ll maxval)
{
    if(index>=n){if(rem==0)return 1;else return 0;}
    if(dp[index][rem][maxval]!=-1)return dp[index][rem][maxval];
    ll ans=0;
    if(maxval)
    {
        forn(i,10)
        {
            ll temp=rem-i;
            if(temp<0)temp+=100*d;
            temp%=d;
            ans=(ans+getans(index+1,temp,1))%mod;
        }
    }
    else
    {
        ll val=char2Int(s[index]);
        forn(i,val)
        {
            ll temp=rem-i;
            temp=(temp+d)%d;
            ans=(ans+getans(index+1,temp,1))%mod;
        }
        ll nxt=rem-val;nxt=(nxt+d)%d;
        ans=(ans+getans(index+1,nxt,0))%mod;
    }
    dp[index][rem][maxval]=ans;
    return ans;
}
void solve()
{
    //dp[index][D][maxval(0/1)]
    cin>>s;cin>>d;n=(ll)s.size();
    forn(i,n)forn(j,d){dp[i][j][0]=-1;dp[i][j][1]=-1;}
    ll ret=getans(0,0,0);--ret;
    if(ret==-1)ret=mod-1;
    cout<<ret<<endl;
}
int main()
{
    IOS;cin.tie(NULL);
    ll zz;zz=1;
    //cin>>zz;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 20056
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int m,n,a,b;
char c[1005][1005];
int main()
{
	scanf("%d%d%d%d",&m,&n,&a,&b);
	int i,j;
	for (i=1;i<=m;i++)for(j=1;j<=n;j++)c[i][j]='.';
	if(n&1){for(i=1;i<m&&b;i+=2){c[i][n]='^';c[i+1][n]='v';b--;}}
	if((b&1)&&(m&1)){if(n>2&&m>1){c[m-1][n-2]='^';c[m][n-2]='v';b--;}}
	for(i=1;i<m;i++)for (j=1;j<=n-(n&1)&&b;j++)if(c[i][j]=='.'&&c[i+1][j]=='.'){c[i][j]='^';c[i+1][j]='v';b--;}
	if(b){puts("NO");return 0;}
	for(i=1;i<=m;i++)for(j=1;j<n&&a;j++)if(c[i][j]=='.'&&c[i][j+1]=='.'){c[i][j]='<';c[i][j+1]='>';a--;}
	if(a){puts("NO");return 0;}
	puts("YES");
	for(i=1;i<=m;i++)printf("%s\n",c[i]+1);
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void)
{
	char str[20];
	int a, b, c;
	
	scanf("%s", str);
	a = 0;
	
	while (str[a] != '\0') {
		a++;
	}
	
	a -= 1;
	for (b = a; b >= 0; b--) {
		printf("%c", str[b]);
	}
	printf("\n");
	
	return (0);
}	

Measured memory_bytes: 524
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int solve(int n) {
	int result = 0;
	RANGE(i, 1, n) { result += (n - 1) / i; }
	return result;
}

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

	cout << solve(n) << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i, j, n, b;
  long long ans=2000000, sum;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  for(b=-100; b<101; b++){
    sum=0;
    for(i=0; i<n; i++)
      sum+=(b-a[i])*(b-a[i]);
    if(sum<ans) ans=sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int N;
  scanf ("%d",&N);
  if (N%10==3){printf ("bon");}
  else if (N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){printf ("hon");}
  else if (N%10==0||N%10==1||N%10==6||N%10==8){printf ("pon");}// Your code here!
}


Measured memory_bytes: 1712
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=1e5+10;
int n,a[N],b[N];

bool cmp( int x, int y ) {
    return a[x]<a[y];
}

int main() {
    R(n);
    REP(i,n) R(a[i]);
    REP(i,n) b[i]=i;
    sort(b,b+n,cmp);
    int ans=0;
    REP(i,n) if ( i%2!=b[i]%2 ) ans++;
    assert(ans%2==0);
    W(ans/2);
    return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll n, x, d;
	cin >> n >> x >> d;

	if (d == 0)
	{
		if (x == 0) cout << "1\n";
		else cout << n+1 << "\n";
		return 0;
	}

	if (d < 0)
		d *= -1, x *= -1;

	map<ll, vector<pair<ll, ll>>> a;
	a[0].push_back({ 0, 0 });
	for (ll k = 1; k <= n; ++k)
	{
		ll r = (k*x % d + d) % d;
		a[r].push_back({ k*x + (k-1)*k/2 * d, k*x + (n-k + n-1)*(n-1-(n-k)+1)/2 * d });
	}

	ll ans = 0;
	for (auto &z : a)
	{
		auto &i = z.S;
		sort(i.begin(), i.end());
		if (!i.empty())
		{
			ll l = i[0].F, r = i[0].S;
			for (auto j : i)
			{
				if (j.F <= r)
					r = max(r, j.S);
				else
				{
					ans += 1 + (r - l) / d;
					l = j.F, r = j.S;
				}
			}
			ans += 1 + (r - l) / d;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
  if(b>a){
  for(int i=0;i<b;i++){
  cout<<a;
  }
   
  }
  else{
  for(int i=0;i<a;i++){
  cout<<b;
  }
   
  }
cout<<endl;
  }
 


Measured memory_bytes: 256
def main():
    n,q = map(int,input().split())
    tree = [1 for _ in range(n+1)]
    for _ in range(n-1):
        a,b = map(int,input().split())
        tree[b]=a

    ls_q = [[int(x) for x in input().split()] for _ in range(q)]

    ans = [0 for _ in range(n+1)]
    for i,j in ls_q:
        ans[i] += j

    for i in range(2,n+1):
        ans[i] += ans[tree[i]]

    
    
    for i in range(1,n+1):
        print(ans[i],end=" ")

if __name__ =="__main__":
    main()

Measured memory_bytes: 105164
#include <iostream>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;++i)
using namespace std;
typedef long long ll;
int main(){
    int D,G;
    cin >> D >> G;
    vector<int> P(D);
    vector<int> C(D);
    REP(i,D) cin >> P[i] >> C[i];

    int mi=1e9;
    for(int p=0; p<(1<<D); p++){
        int all_solve_score=0, x=0;
        for(int problem=0; problem<=D-1; problem++)
            if(p >> problem & 1) {
                all_solve_score += 100*(problem+1) * P[problem] + C[problem];
                x += P[problem];
            }
        for(int problem=D-1; -1<=problem; problem--){
            if(p >> problem & 1) continue;
            for(int solve_num=0; solve_num<=P[problem]-1; solve_num++){
                int total_score = all_solve_score + 100*(problem+1) * solve_num;
                int last_x = x+solve_num;
                if(total_score >= G) mi = min(mi, last_x);
            }
        }
        if(p==(1<<D)-1) mi = min(mi,x);
    }
    cout << mi << endl;
    return 0;
}

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

int main()
{
    int a,b,c;
   while(cin>>a>>b>>c)
   {
   if((c>b)&&(b>a))
        cout<<"Yes\n";
    else
        cout<<"No\n";
   }
    return 0;
}



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

int main(){
    long long n, k;
    cin >> n >> k;
    
    map<int, long long> mp;
    
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        
        mp[a] += b;
    }
    
    long long count = 0;
    int ans;
    for (auto p : mp){
        count += p.second;
        
        if (count >= k){
            ans = p.first;
            break;
        } 
    }
    cout << ans << endl;
}

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


int main() {
    char s;
    cin >> s;
    if(s=='A') cout<<'T'<<endl;
    else if(s=='T') cout<<'A'<<endl;
    else if(s=='C') cout<<'G'<<endl;
    else if(s=='G') cout<<'C'<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int N,R = 0,c,B;
char s[101];

scanf("%d",&N);
scanf("%s",&s);

for(c = 0;c < N;c++){
if(s[c] == 'R'){
R+=1;
}
}
if(R>N-R)
printf("Yes\n");
else
printf("No\n");


return 0;
}

Measured memory_bytes: 128
pos_latest = []

surface = input()

total = []
total_x = []
y = 0
x = 0
total_tmp = 0
for i in range(len(surface)):
    if surface[i] == "\\":
        pos_latest.append(x)
    if surface[i] == "/":
        if pos_latest:
            pos = pos_latest.pop()
            total.append(x-pos)
            total_x.append([pos, x, x-pos])
    x += 1

if sum(total) > 0:
    sorted_total_x = sorted(total_x)
    t_base = sorted_total_x[0][1]
    tmp = sorted_total_x[0][2]
    res = []
    
    for f, t, v in sorted_total_x[1:]:
        if t <= t_base:
            tmp += v
        else:
            res.append(int(tmp))
            tmp = v
            t_base = t
        if sum(res)>=sum(total):
            break
    res.append(int(tmp))

    print(sum(res))
    print(len(res), *res, sep=" ")
    
else:
    print(sum(total))
    print(0)



Measured memory_bytes: 7444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC118_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);

            int ans = 0;

            if (b % a == 0)
            {
                ans = a + b;    
            }
            else
            {
                ans = b - a;
            }

            Console.WriteLine("{0}", ans);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
#include<algorithm>
using std::max;
int a[92][92];
int F(int x,int y)
{
	if(!a[y][x])return 0;
	a[y][x]=0;
	int r=max(max(F(x+1,y),F(x-1,y)),max(F(x,y+1),F(x,y-1)))+1;
	a[y][x]=1;
	return r;
}
int main()
{
	int w,h,x,y;
	while(scanf("%d%d",&w,&h),w)
	{
		memset(a,0,sizeof(a));
		for(y=1;y<=h;++y)for(x=1;x<=w;++x)scanf("%d",&a[y][x]);
		int r=0;
		for(y=1;y<=h;++y)for(x=1;x<=w;++x)r=max(r,F(x,y));
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    ans = len(S)
    for i in range(len(S)):
        tmp = 0
        ma = 0
        for j in range(i + 1):
            if S[i] == S[j]:
                ma = max(ma, tmp)
                tmp = 0
            else:
                tmp += 1
        ans = min(ans, max(ma, len(S) - i - 1))

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<numeric>
#include<algorithm>
using namespace std;

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<int> p(M);
    vector<string> S(M);
    for (int i = 0; i < M; i++)
        cin >> p[i] >> S[i];

    for (int i = 0; i < M; i++)
        p[i]--;

    vector<vector<int>> ac(N), wa(N);
    for (int i = 0; i < M; i++) {
        int index = p[i];
        string state = S[i];

        if (state == "AC")
            ac[index].push_back(i);
        else
            wa[index].push_back(i);
    }

    int cntAC = 0;
    for (int i = 0; i < N; i++)
        if (ac[i].size() > 0)
            cntAC++;

    int cntPenalty = 0;
    for (int i = 0; i < N; i++) {
        if (ac[i].size() == 0)
            continue;

        int penalty = lower_bound(wa[i].begin(), wa[i].end(), ac[i][0]) - wa[i].begin();
        cntPenalty += penalty;
    }

    cout << cntAC << " " << cntPenalty << endl;

    return 0;
}


Measured memory_bytes: 13952
import math

N=int(input())
x=math.sqrt(N)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors
  
if x.is_integer():
  a=len(make_divisors(N))
  b=sorted((make_divisors(N)))[a//2]
  print(2*b-2)
  
else:  
  c=len(make_divisors(N))
  d=sorted((make_divisors(N)))[c//2]
  e=sorted((make_divisors(N)))[(c//2)-1]
  print(d+e-2)

Measured memory_bytes: 3288
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n=sc.nextInt();
                if(n ==0){
                    break;
                }
                int[] scores =new int [n];
                for(int i=0;i<scores.length;i++){
                    scores[i]=sc.nextInt();
                }
                double ave=0,var=0,sum=0;
                for(int i=0;i<scores.length;i++){
                    sum=sum+scores[i];
                }
                ave = sum/n;
                for(int i=0;i<scores.length;i++){
                    var=var+((scores[i]-ave)*(scores[i]-ave))/n;
                }
                System.out.println(Math.sqrt(var));
                
            }
        }
    }
}


Measured memory_bytes: 31908
MOD = 10**9+7
n, k = map(int, input().split())
n += 1

def cumsum(s):
    n = len(s)
    cs = [0] * (n+1)
    for i in range(n):
        cs[i+1] = cs[i] + s[i]
    return cs

s = list(range(n))
cs = cumsum(s)
ans = 0

for i in range(k, n+1):
    ans += (cs[n] - cs[n-i]) - cs[i] + 1
    ans %= MOD

print(ans)


Measured memory_bytes: 26964
M=998244353
N,*A=map(int,open(0))
d=[0]*90001
d[0]=1
e=[0]*90001
e[0]=1
z=1
s=0
for a in A:
	i=s;s+=a;z=z*3%M
	while i>=0:
		d[i+a]+=d[i]%M
		d[i]*=2
		e[i+a]+=e[i]%M
		i-=1
for i in range(s+1>>1,s+1):z=(z-d[i]*3)%M
print([(z+e[s//2]*3)%M,z][s%2])

Measured memory_bytes: 141980
-- 1_5_B
main =  do  cs <- getLine
            case cs of
                "0 0"   -> return ()
                cs      ->  do  putStrLn $ unlines $ make_a_frame $ map (\x -> read x::Int) $ words cs
                                main
 
make_a_frame :: [Int] -> [String]
make_a_frame [h, w] = [replicate w '#'] ++ replicate (h - 2) ("#" ++ replicate (w - 2) '.' ++ "#") ++ [replicate w '#']

Measured memory_bytes: 3916
n=int(input())
A=list(map(int,input().split()))
s=0
m=10**9+7
for i in A:
    s+=i
    s%=m
ans=0
for i in range(n-1):
    s-=A[i]
    if s<0:
        s+=m
    ans+=(A[i]%m)*s
    ans%=m
print(int(ans))

Measured memory_bytes: 31568
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin >> s
#define pr(r) cout << r << endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout << a[j] << " "
#define wh(t) ll t; cin >> t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define arr(a,n) vl a(n, 0); fab(i, 0, n) cin >> a[i]
#define prs(u) cout << u << " "
#define fab(i,a,b) for(ll i = a; i < b; i++)
#define fba(i,b,a) for(ll i = b; i >= a; i--)
#define fa(i, x) for(auto i: x)
#define mem(s, j) memset(s, j, sizeof(s))
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pl>
#define pl pair<ll, ll>
#define pll pair<ll, pl>
#define vvl vector<vl>
#define vvpl vector<vpl>
#define mxe(x, n) *max_element(x, n)
#define mne(x, n) *min_element(x, n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N = (ll)3e5;
const ll inf = (ll)1e18 + 7;
const ll mod = (ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.second > b.second);}
bool sort2(const pair<ll, ll> &a,const pair<ll, ll> &b){ return (a.second < b.second);}

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}

ll sm(vl a) {
    ll sum = 0;
    for(auto i: a)
        sum += i;
    return sum;
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}


int main()
{
	sup;
    
    ll n, a, b;
    cin >> n >> a >> b;
    cout << ((n / (a + b)) * a + min(n % (a + b) ,a));
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;


class Node {
public:
    int total = 0;
    int count[26];
    int chidx[26];
    bool exist = false;
    Node() {
        fill(count, count+26, 0);
        fill(chidx, chidx+26, -1);
    }
    int child(char c) {
        return chidx[c - 'a'];
    }
    int getcount(char c) {
        return count[c - 'a'];
    }
};

vector<Node> pool(1);

void add(string &s) {
    int idx = 0;
    for (char c : s) {
        int nxt = pool[idx].child(c);
        if (nxt == -1) {
            nxt = pool.size();
            pool[idx].chidx[c - 'a'] = nxt;
            pool.push_back(Node());
        }
        idx = nxt;
    }
    pool[idx].exist = true;
}

void calc(int i) {
    for (int j = 0; j < 26; j++) {
        int k = pool[i].chidx[j];
        if (k >= 0) {
            calc(k);
            for (int jj = 0; jj < 26; jj++) {
                if (j == jj)
                    pool[i].count[jj] += pool[k].total;
                else
                    pool[i].count[jj] += pool[k].count[jj];
            }
            pool[i].total += pool[k].total;
        }
    }
    if (pool[i].exist) pool[i].total++;
}

void dump() {
    for (Node &n : pool) {
        cerr << n.total << " " << int(n.exist) << endl;
        for (int i = 0; i < 26; i++) cerr << n.count[i] << ' '; cerr << endl;
        for (int i = 0; i < 26; i++) cerr << n.chidx[i] << ' '; cerr << endl;
    }
}

int main() {
    int n; cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
        add(s[i]);
    }
    // dump();
    calc(0);
    // cerr << endl; dump();
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int idx = 0;
        for (int j = 0; j < s[i].size() - 1; j++)
            idx = pool[idx].child(s[i][j]);
        ans += pool[idx].getcount(s[i].back());
        // cerr << ans << endl;
    }
    cout << ans - n << endl;
}


Measured memory_bytes: 259028
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  double a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (abs(a - b) / (v - w) <= t && v > w)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int a, b; cin >> a >> b;
	long long ans = 1LL*a*b/__gcd(a, b);
	cout << ans << endl;	
	return 0;
}


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

int main(){
	vector<int> v(3);
	cin >> v.at(0) >> v.at(1) >> v.at(2);
	sort(v.begin(),v.end());
	cout << v.at(2)*10+v.at(1)+v.at(0) << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int c=0,a=0;
    for(int i=0;i<n;++i){
      string s; cin>>s;
      if(s=="lu" || s=="ru"){
        if(c==1) a++, c=0;
        else c=1;
      }else if(s=="ld" || s=="rd"){
        if(c==-1) a++, c=0;
        else c=-1;
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long N,A,B;
  cin >> N >> A >> B;

  if(A==0){
  cout << "0" << endl;
  return 0;
  }
  if(B==0){
  cout << N << endl;
  return 0;
  }
  
  if(N%(A+B)<A){
    cout << ((N/(A+B))*A)+N%(A+B) << endl;
  }
  else{
    cout << ((N/(A+B))*A)+A << endl;
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, h, ma = 0, res = 0;
	cin >> n;
	REP(i, n) {
		cin >> h;
		if (h >= ma) ++res;
		ma = max(ma, h);
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int pow(int a, int n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return a;
    }
    int ans = pow(a, n / 2);
    ans *= ans;
    ans %= mod;
    if (n % 2)
    {
        ans *= a;
        ans %= mod;
    }
    return ans;
}

const int MAXN = 1e5 + 7;

int sum[MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i >= 1; --i)
    {
        int cur = pow(k / i, n);
        for (int j = 2 * i; j <= k; j += i)
        {
            cur -= sum[j];
        }
        ans += i * cur;
        ans %= mod;
        sum[i] = cur;

    }
    cout << (ans + mod) % mod << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a.at(i);
  int score = 0;
  
  for (int i = 0; i < (N+1)/2; i++){
    int Alice = 0;
    int Amax = 0;
    for (int j = 0; j < N; j++){
      if (Alice < a.at(j)){
        Alice = a.at(j);
        Amax = j;
      }
    }
    score += Alice;
    a.at(Amax) = 0;
    
    int Bob = 0;
    int Bmax = 0;
    for (int j = 0; j < N; j++){
      if (Bob < a.at(j)){
        Bob = a.at(j);
        Bmax = j;
      }
    }
    score -= Bob;
    a.at(Bmax) = 0;
  }
  cout << score << endl;
}


Measured memory_bytes: 256
function Main(input) {
    	tmp = input.split(" ");
    	// convert string from integer using "parseInt"
    	var a = parseInt(tmp[0], 10);
    	var b = parseInt(tmp[1], 10);

      var num1 = a + (a - 1);
      var num2 = a + b;
      var num3 = b + (b - 1);

      //output
      console.log('%d', Math.max(num1, num2, num3));
    }

    // Don't edit this line!
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 2020202;
ll fac[N];
ll finv[N];
ll inv[N];
void modinv(int max) {
	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;
	}
}
ll comb(int n, int r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
ll modpow(ll a, ll b, ll M) {
	ll res = 1;
	for (; b > 0; b >>= 1) {
		if (b & 1) res = (res * a) % M;
		a = a * a % M;
	}
	return res;
}
ll calc(ll a, ll b, ll c) {
	ll res = a;
	res *= b; res %= MOD;
	res *= c; res %= MOD;
	return res;
}
int main() { // dpの考えを捨てたのは正解だけど、もしdpができたら？を考えるとやりやすかった
	modinv(N);
	int k; string s;
	cin >> k >> s;
	int n = s.size();
	// 出来上がる文字列の長さS+kに注目する
	// 最後の文字の出現位置を決め打つと、「sが出来上がる前でありうる文字列の数は？」と「はみ出した部分で出来上がる文字列の数は？」となる
	// 前者は重複を許さない置き方かつ文字の出現位置の通りを掛け合わせて25^i*k+S-i-1CS-1通り
	// 後者は何でも選べて26^j通り
	ll ans = 0;
	rep(i, k + 1) {
		ll j = k - i; // はみ出した文字列の長さ
		ans += calc(modpow(25, i, MOD), comb(k + n - j - 1, n - 1), modpow(26, j, MOD));
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string S,T;
    cin>>S;
    cin>>T;
    int count=0;
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i])
            count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3464
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val r = sc.nextLong()
  val g = sc.nextLong()
  val b = sc.nextLong()
  val n = sc.nextLong()

  var count = 0L
  for (ri in 0L..n/r) {
    for (gi in 0L..n/g) {
      val tmp = r * ri + g * gi
      val last = n - tmp
      if (last < 0L) {
        continue
      }
      if (last == 0L) {
        count++
        continue
      }
      if (last % b == 0L) {
        count++
      }
    }
  }


  println(count)
}


Measured memory_bytes: 36392
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <map>
#include <math.h>
#include <time.h>
#include <vector>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

#define ll long long

using namespace std;

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

  if (k==1) {
    cout<<0<<endl;
    return 0;
  }

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

    a[i]--;
    a[i] += a[i-1];
    a[i] %= k;
  }

  map<ll, ll> count;
  ll ans = 0;

  for (ll i=0; i<=n; i++) {
    ans += count[a[i]];
    count[a[i]]++;

    if (i-(k-1) >= 0) count[a[i-(k-1)]]--;
  }

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



Measured memory_bytes: 14336
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
	public static void main(String[] args) {
	  Scanner input = new Scanner(System.in);
      int N = input.nextInt();
      int[] A = new int[N];int[] B = new int[N]; int[] C = new int[N];
	  for(int i = 0; i < N; ++i) A[i] = input.nextInt();
	  for(int i = 0; i < N; ++i) B[i] = input.nextInt();
	  for(int i = 0; i < N; ++i) C[i] = input.nextInt();
	  Arrays.sort(A); Arrays.sort(B); Arrays.sort(C);
	  long[] comBC = new long[N];   
      for(int i = 0 , j = 0; i < N; i++){
		while(j < N && C[j] <= B[i]){
          j++;
        }
        comBC[i] = N - j;
      }
      for(int i = N - 1; i > 0; i--){
        comBC[i - 1] += comBC[i];
      }
      long ans = 0;
      for(int i = 0, j = 0; i < N; i++){
        while(j < N && B[j] <= A[i]){
          j++;
        }	
        if(j < N){
          ans += comBC[j];
        }
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 91780
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 1 -> a, 26 -> z
fn num_to_alphabet(n: u8) -> char {
    (b'a' + n) as char
}

fn main() {
    let mut n: u64 = read();
    let alp: u64 = 26;
    let mut ans = String::new();
    while n!= 0 {
        n -= 1;
        ans.push(num_to_alphabet((n % alp) as u8));
        n /= alp;
    }
    print!("{}", ans.chars().rev().collect::<String>())
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<string> d={"SAT","FRI","THU","WED","TUE","MON","SUN"};
  string S;cin >> S;
  for (int i=1;i<8;i++) {
    if (d[i-1]==S) cout << i << endl;
  }
}

Measured memory_bytes: 256
H, W, d = gets.split.map(&:to_i)
ans = Array.new(H){Array.new(W)}
colors = [['R', 'G'], ['B', 'Y']]
H.times do |i|
    W.times do |j|
        x = (i - j) / d % 2
        y = (i + j) / d % 2
        ans[i][j] = colors[x][y]
    end
end

H.times do |i|
    puts ans[i].join
end

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;

    LL mn = 1e14, mx = 0;
    for(LL i = 1; i <= n; i++){
        LL a;
        cin >> a;

        mx = max(mx, a);
        mn = min(mn, a);
    }

    cout << mx - mn << '\n';
    return 0;
}



Measured memory_bytes: 256
bmi w h        = w / (h * h)
bmi' [s, w, h] = (floor s, bmi w h)
bmiOver25      = map fst . filter ((>= 25) . snd) . map bmi'

main = do
  s <- getContents
  putStr . unlines . map show
         . bmiOver25
         . map (map read . words . map commaToSpace) . lines $ s

commaToSpace ',' = ' '
commaToSpace  c  =  c

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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << "\t|";
    __f(comma + 1, args...);
}


#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}


int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    vector<int> heights(n);
    for (int i = 0; i < n; i++)
        cin >> heights[i];
    
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        // frog will reach i from i - 1 to i - k
        for (int j = 1; j <= k; j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]));
            }
        }
    }
    cout << dp.back();
    return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, A, B;
  cin >> N >> A >> B;

  std::vector<int> P(N);
  int p1 = 0, p2 = 0, p3 = 0;
  for (auto& v : P)
  {
    cin >> v;
    if (v <= A) ++p1;
    else if (v > B) ++p3;
    else ++p2;
  }

  cout << std::min(p1, std::min(p2, p3)) << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else
        cout << c << " " << b << " " << a << endl;
}



Measured memory_bytes: 3096