akhauriyash/Code-Regression huggingface dataset:
fun main(args :Array<String>) {
    val (h, w) = readIntegerList()
    val map = arrayListOf<CharArray>()
    map.add(CharArray(w + 2) { '#' })
    for (i in 0 until h) {
        val row = readLine()!!
        map.add(('#' + row + '#').toCharArray())
    }
    map.add(CharArray(w + 2) { '#' })

    val countTop = Array<IntArray>(h + 2) { IntArray(w + 2) { 0 } }
    val countBottom = Array<IntArray>(h + 2) { IntArray(w + 2) { 0 } }
    for (i in 1..h) {
        for (j in 1..w) {
            countTop[i][j] = if (map[i][j] == '.') countTop[i - 1][j] + 1 else 0
            countBottom[h - i + 1][j] = if (map[h - i + 1][j] == '.') countBottom[h - i + 1 + 1][j] + 1 else 0
        }
    }

    val countLeft = Array<IntArray>(h + 2) { IntArray(w + 2) { 0 } }
    val countRight = Array<IntArray>(h + 2) { IntArray(w + 2) { 0 } }
    for (j in 1..w) {
        for (i in 1..h) {
            countLeft[i][j] = if (map[i][j] == '.') countLeft[i][j - 1] + 1 else 0
            countRight[i][w - j + 1] = if (map[i][w - j + 1] == '.') countRight[i][w - j + 1 + 1] + 1 else 0
        }
    }
    var ans = 0
    for (i in 1..h) {
        for (j in 1..w) {
            val sum = countTop[i][j] +
                countRight[i][j] +
                countBottom[i][j] +
                countLeft[i][j] -
                3
            ans = Math.max(ans, sum)
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 153908
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
using namespace std;

const int MOD = pow(10, 9) + 7;

int main()
{
   int nb_maris;
   cin >> nb_maris;
   bool possible[22][22];
   int dp[1<<(nb_maris)];
   for (int i=0;i<nb_maris;++i)
        for (int j=0;j<nb_maris;++j)
            cin >> possible[i][j];
    
    for (int i=0;i<(1<<(nb_maris));++i)dp[i] = 0;
  //  cout << dp[1<<nb_maris-1]<<endl;
    bool okay[22];
    dp[0] = 1;
    for (int bin_rep = 0; bin_rep < (1<<(nb_maris)); ++ bin_rep)
    {
      //  cout << dp[bin_rep] << endl;
        if (dp[bin_rep] >= 0)
        {
           dp[bin_rep] = dp[bin_rep]%MOD;
           int id_men = __builtin_popcount(bin_rep);
           int tem = bin_rep;
           for (int i=0;i<nb_maris;++i)
           {
               okay[i] = 1 - tem%2;
               tem /= 2;
           }
           for (int id_woman = 0; id_woman < nb_maris; ++ id_woman)
           {
               if (possible[id_men][id_woman] && okay[id_woman])
               {
           //     cout <<bin_rep << " " << bin_rep + (1<<id_woman)<< endl;
                   bool pos = dp[bin_rep + (1<<id_woman)]>=0;
                   int tamp = dp[bin_rep + (1 << id_woman)];
                   dp[bin_rep + (1 << id_woman)] += dp[bin_rep];
                   if (pos && dp[bin_rep + (1 << id_woman)] < 0) cout << bin_rep << " " << dp[bin_rep]<<" " << tamp<<endl;
                   dp[bin_rep + (1 << id_woman)] %= MOD;
               }
           }
        }
       // else  cout << bin_rep<<" " << dp[bin_rep] << endl;
    }
    //cout << dp[1] << " ";
    cout << dp[(1<<nb_maris)-1] << endl;
   return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <map>
using namespace std;

int main(){
    int n; cin >> n;
    pair<pair<string,int>,int> rest[n];
    for ( int i = 0 ; i < n ; i++ ){
        string city; int value , num = i+1;
        cin >> city >> value;
        rest[i] = make_pair(make_pair(city,-value),num);
   }

   sort(rest,rest+n);
   for ( int i = 0 ; i < n ; i++ ){
       cout << rest[i].second << endl;
   }
}

Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    ld = len(s)-len(t)
    ans = 9999999999
    for i in range(ld+1):
        v = sum([0 if a==b else 1 for (a,b) in zip(list(s[i:]),list(t))])
        ans = min(ans, v)
    print(ans)

main()

Measured memory_bytes: 9160
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int h = tmp[0], w = tmp[1], n = tmp[2];
	tmp = ReadIntArray();
	int sr = tmp[0], sc = tmp[1];
	string s = ReadLine();
	string t = ReadLine();

	int r1, c1; // Senario 1: Takahashi will try to move U and R
	int r2, c2; // Senario 2:                            L and D

	r1 = r2 = sr;
	c1 = c2 = sc;

	bool onBoard = true;
	for (int i = 0; i < n; i++)
	{
	    char m1 = s[i], m2 = t[i];
	    // Senario 1, Takahashi's move
	    if (m1 == 'U')
		if (--r1 < 1){ onBoard = false; break; }
	    if (m1 == 'R')
		if (++c1 > w){ onBoard = false; break; }
	    // Senario 1, Aoki's move
	    if (m2 == 'D' && r1 < h) r1++;
	    if (m2 == 'L' && c1 > 1) c1--;

	    // Senario 2, Takahashi's move
	    if (m1 == 'D')
		if (++r2 > h){ onBoard = false; break; }
	    if (m1 == 'L')
		if (--c2 < 1){ onBoard = false; break; }
	    // Senario 2, Aoki's move
	    if (m2 == 'U' && r2 > 1) r2--;
	    if (m2 == 'R' && c2 < w) c2++;
	}

	WriteLine(onBoard ? "YES" : "NO");
    }
}


Measured memory_bytes: 14688
#include<stdio.h>

int main(){


	int i,j,key,k;
	int a;
	int A[100000];

	scanf("%d",&a);
	

	for(i=0;i<a;i++)scanf("%d",&A[i]);
	for(k=0;k<a;k++){printf("%d",A[k]);
	if(k!=a-1)printf(" ");
	
	}
	printf("\n");


	for(i = 1;i<a;i++){
    key = A[i];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1;
	while (j >= 0 && A[j] > key){
        A[j+1] = A[j];
        j--;
    A[j+1] = key;

	}

	for(k=0;k<a;k++){printf("%d",A[k]);
	if(k!=a-1)printf(" ");
	
	}
	printf("\n");
}



	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
/*
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
*/

#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> S(n);

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

	int q;
	cin >> q;

	int t;
	int count = 0;
	for(i = 0; i < q; i++){
		cin >> t;
		int left = 0;
        int right = n-1;
        while(left <= right){
            int mid = (left + right) / 2;
            if(S[mid] < t){
                left = mid + 1;
            }else if(S[mid] > t){
                right = mid - 1;
            }else{
                count++;
                break;
            }
        }
	}

	cout << count << endl;
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111


	void solve(){

		ini(n);
		ini(n1);
		FOR(i,n1-n+1,n1+n){cout<<i<<" ";}
		out();











	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	while (true)
	{
		int x, h;
		scanf("%d\n%d\n", &x, &h);
		if (x == 0 && h ==0)
			break;

		printf("%.6f\n", x*x + 2*x*sqrt(x*x/4.0+h*h));
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

//const ll INF=1e18;

const ll max_E=100000;
const ll max_V=100000;
const ll INF=1e18;

struct edge{ll from,to,cost;};

edge es[max_E];
ll dist[max_V];
ll N,M;
ll pr[max_V];//経路復元
bool negative[max_V];

void shortest_path(ll s){
    for(int i=0;i<N;i++) dist[i]=INF;//INFを作る
    dist[s]=0;
    for(int loop=0;loop<N-1;loop++){
        for(int i=0;i<M;i++){
            edge e=es[i];
            if(dist[e.from]==INF) continue;
            if(dist[e.from]!=INF&&dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;
                pr[e.to]=e.from;
            }
        }
    }
}

void find_negative_loop(){
    fill(negative,negative+N,0);
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            edge e=es[j];
            if(dist[e.from]==INF) continue;
            if(dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;
                negative[e.to]=1;
            }
            if(negative[e.from]) negative[e.to]=1;
        }
    }
}

//頂点tへの最短路
vector<ll> get_path(ll t){
    vector<ll> path;
    for(;t!=-1;t=pr[t]) path.push_back(t);//tがsになるまでprev[t]をたどっていく
    reverse(all(path));
    return path;
}

signed main(){
    ll p;
    cin>>N>>M>>p;
    rep(i,M){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        es[i].from=a;
        es[i].to=b;
        es[i].cost=-c+p;
    }
    shortest_path(0LL);
    find_negative_loop();
    if(negative[N-1]) cout<<-1<<endl;
    else{
        cout<<max(0LL,-dist[N-1])<<endl;
    }
}

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

#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
#define pk push_back
#define N 100005
typedef std::pair<int,int> pii;
int s,t;
int cnt=1,head[N],to[N],flow[N],cost[N],nxt[N];
inline void add(int u,int v,int w,int c){
	to[++cnt]=v,flow[cnt]=w,cost[cnt]=c,nxt[cnt]=head[u],head[u]=cnt;
	to[++cnt]=u,flow[cnt]=0,cost[cnt]=-c,nxt[cnt]=head[v],head[v]=cnt;
}
bool vis[N]; int pre[N],dep[N];
inline bool spfa(int s,int t){
	memset(vis,0,sizeof(vis));
	memset(pre,-1,sizeof(pre));
	memset(dep,128,sizeof(dep));
	std::queue<int> q;
	q.push(s),dep[s]=0,vis[s]=1;
	int inf=dep[0];
	while(!q.empty()){
		int u=q.front(); q.pop();
		vis[u]=0;
		for(int i=head[u];i;i=nxt[i]){
			if(flow[i]&&dep[to[i]]<dep[u]+cost[i]){
				dep[to[i]]=dep[u]+cost[i],pre[to[i]]=i;
				if(!vis[to[i]]) vis[to[i]]=1,q.push(to[i]);
			}
		}
	}
	return dep[t]!=inf;
}
inline std::pair<int,int> mcmf(int s,int t){
	std::pair<int,int> ret(0,0);
	while(spfa(s,t)){
		int mi=2e9;
		for(int i=t;i!=s;i=to[pre[i]^1]) mi=std::min(mi,flow[pre[i]]);
		for(int i=t;i!=s;i=to[pre[i]^1]) flow[pre[i]]-=mi,flow[pre[i]^1]+=mi;
		ret.first+=mi,ret.second+=dep[t]*mi;
	}
	return ret;
}
int n,m;
char S[105][105];
inline int id(int x,int y){
	return (x-1)*m+y;
}
int main(){
	std::ios::sync_with_stdio(0),std::cin.tie(0),std::cout.tie(0);
	std::cin>>n>>m,s=n*m+1,t=s+1;
	rep(i,1,n) std::cin>>S[i]+1;
	rep(i,1,n) rep(j,1,m) if(S[i][j]!='#'){
		if(S[i][j]=='o') add(s,id(i,j),1,0);
		if(i<n&&S[i+1][j]!='#') add(id(i,j),id(i+1,j),2e9,1);
		if(j<m&&S[i][j+1]!='#') add(id(i,j),id(i,j+1),2e9,1);
		add(id(i,j),t,1,0);
	}
	std::cout<<mcmf(s,t).second<<'\n';
	return 0;
}

Measured memory_bytes: 4720
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<set>
//#include <bits/stdc++.h>

using namespace std;

int n;
int main()
{
	cin >> n;
	set<string> sets;
	string s;
	string ls;
	bool flag = true;
	cin >> s;
	ls = s;
	sets.emplace(s);
	for (int i = 1; i < n; i++)
	{
		cin >> s;
		if (sets.count(s) && flag)
		{
			flag = false;
		}
		if(flag)sets.emplace(s);
		if (ls[ls.size() - 1] != s[0] && flag)
		{
			flag = false;
		}
		if(flag)ls = s;
	}
	if (flag)cout << "Yes" << endl;
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int unsigned long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;

    vector<int> a(n);
    int prod = 1;
    bool ok = true;
    rep(i,0,a.size())
    {
        cin>>a[i];
    }
    sort(all(a),greater<int>());

    if ( a[a.size()-1] == 0 )
    {
        cout<<"0"<<endl;
    }
    else
    {
        int prev = 1000000000000000000;
        int prod = 1;
        rep(i,0,a.size())
        {
            prod *= a[i];
            if ( prev < a[i] )
            {
                cout<<"-1"<<endl;
                return;
                // break;
            }
            else
            {
                prev = prev/a[i];
            }
            
            if ( prod > 1000000000000000000 )
            {
                cout<<"-1"<<endl;
                return;
            }
        }

        cout<<prod<<endl;
    }
    

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3992
#include <iostream>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <climits>
#include <stdlib.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
typedef long double ld;
using namespace std;




vector<ll> sieve(ll n)
{
	vector<ll> a(n+1,0);
	for(ll i=3;i<=n;i+=2)
	a[i]=1;
	for(ll i=3;i<=n;i+=2)
	{
       if(a[i]==1)
	   {
		   for(ll j=i*2;j<=n;j+=i)
		   a[j]=0;
	   }
	}
	a[2]=1;
	a[1]=a[0]=0;
	return a;
}
ll reverse(ll n)
{
	ll s=0;
	while(n>0)
	{
       ll t=n%10;
	   s=s*10+t;
	   n/=10;
	}
	return s;
}
int count_setbits(int N)

{ int cnt=0;

while(N>0)

{

cnt+=(N&1);

N=N>>1;

}

return cnt;

}
ll power(ll x, ll y)  
{  
    int res = 1;     // Initialize result  
  
    x = x % mod; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % mod;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % mod;  
    }  
    return res;  
}  

void BellmanFord(vector< vector<ll> > &graph, int V, int E, int src) 
{ 
    // Initialize distance of all vertices as infinite. 
    int dis[V]; 
    for (int i = 0; i < V; i++) 
        dis[i] = INT_MAX; 
  
    // initialize distance of source as 0 
    dis[src] = 0; 
  
    // Relax all edges |V| - 1 times. A simple 
    // shortest path from src to any other 
    // vertex can have at-most |V| - 1 edges 
    for (int i = 0; i < V - 1; i++) { 
  
        for (int j = 0; j < E; j++) { 
            if (dis[graph[j][0]] + graph[j][2] < 
                               dis[graph[j][1]]) 
                dis[graph[j][1]] =  
                  dis[graph[j][0]] + graph[j][2]; 
        } 
    } 
  
    // check for negative-weight cycles. 
    // The above step guarantees shortest 
    // distances if graph doesn't contain 
    // negative weight cycle.  If we get a 
    // shorter path, then there is a cycle. 
    for (int i = 0; i < E; i++) { 
        int x = graph[i][0]; 
        int y = graph[i][1]; 
        int weight = graph[i][2]; 
        if (dis[x] != INT_MAX && 
                   dis[x] + weight < dis[y]) 
            cout << "Graph contains negative"
                    " weight cycle"
                 << endl; 
    } 
  
    
} 
int main()
{
    ull n;
    cin>>n;
   unordered_map<ull,ull> mp;
   while(n%2==0)
   {
       mp[2]++;n/=2;
   }
    for (ull i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if(n>2)
    mp[n]++;
   /* for(auto i:mp)
    cout<<i.first<<" "<<i.second<<"\n";*/
    ull res=0;
    
    for(auto j:mp)
    {
        ull i=1;
    while((i*(i+1)/2)<=j.second)
    {
        i++;
    }
    i--;res+=i;
    }
    cout<<res<<"\n";
    return 0;

}

Measured memory_bytes: 3676
@fact = []
def set_fact(max_n, mod = 10 ** 9 + 7)
  @fact[0] = 1
  (1..(max_n - 1)).each do |i|
    @fact[i] = @fact[i - 1] * i % mod
  end
end

# def choose2(n, r, mod = 10 ** 9 + 7)
#   r = n - r if r > n - r
#   ((n - r + 1)..n).inject(1){|sum, item|(sum * item) % mod} \
#     * modpow((1..r).inject(1){|sum, item|(sum * item) % mod}, mod - 2, mod) \
#     % mod
# end

# (n-r+1)~n間の階乗は!n / !(n-r)
def choose(n, r, mod = 10 ** 9 + 7)
  r = n - r if r > n - r
  @fact[n] * modpow(@fact[n - r], mod - 2, mod) % mod \
    * modpow(@fact[r], mod - 2, mod) \
    % mod
end

# 繰り返し二乗法を使用
def modpow(n, p, mod = 10 ** 9 + 7)
  res = 1
  while p > 0
    if p & 1 == 1
      res = (res * n) % mod
    end
    n = (n ** 2) % mod
    p >>= 1
  end
  res
end

N, M = gets.split.map(&:to_i)
set_fact(1000)
if N >= 2 && M >= 2
puts choose(N, 2) + choose(M, 2)
elsif N < 2 && M < 2
  puts 0
elsif N < 2
  puts choose(M, 2)
elsif M < 2
  puts choose(N, 2)
end


Measured memory_bytes: 1788
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

ll a[100005];

int main(){
    //freopen("b2.in", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll remain = 0; // 0 or 1
    ll pair = 0;
    for (int i = 0; i < n; ++i) {
        if (remain > 0) {
            ll can_pair = min(remain, a[i]);
            pair += can_pair;
            a[i] -= can_pair;
        }
        pair += a[i] / 2;
        remain = a[i] % 2;
    }
    cout << pair << endl;

    return 0;
}


Measured memory_bytes: 1024
L = input()
MOD = 10 ** 9 + 7

N = len(L)
dp = [[None, None] for _ in range(N+1)]
SMALL, POSBL = 1, 0
dp[0][POSBL] = 1
dp[0][SMALL] = 0

for i in range(1, N+1):
    pp, ps, ss = (2, 1, 3) if L[i-1] == '1' else (1, 0, 3)
    dp[i][POSBL] = (dp[i-1][POSBL] * pp) % MOD
    dp[i][SMALL] = (dp[i-1][SMALL] * ss + dp[i-1][POSBL] * ps) % MOD

print(sum(dp[-1]) % MOD)


Measured memory_bytes: 19628
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int a[][] = new int[H][W];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				a[i][j] = Integer.parseInt(sc.next()) % 2;
			}
		}
		Queue<Integer> ans_y1 = new ArrayDeque<Integer>();
		Queue<Integer> ans_x1 = new ArrayDeque<Integer>();
		Queue<Integer> ans_y2 = new ArrayDeque<Integer>();
		Queue<Integer> ans_x2 = new ArrayDeque<Integer>();
		for(int h = 0; h < H; h++) {
			if(h % 2 == 0) {
				for(int w = 0; w < W; w++) {
					if(a[h][w] == 1) {
						if(w == W - 1) {
							if(h != H - 1) {
								a[h][w]--;
								ans_y1.add(h);
								ans_x1.add(w);
								a[h + 1][w]++;
								ans_y2.add(h + 1);
								ans_x2.add(w);
							}
						} else {
							a[h][w]--;
							ans_y1.add(h);
							ans_x1.add(w);
							a[h][w + 1]++;
							ans_y2.add(h);
							ans_x2.add(w + 1);
						}

					}
				}
			} else {
				for(int w = W - 1; w >= 0; w--) {
					if(a[h][w] == 1) {
						if(w == 0) {
							if(h != H - 1) {
								a[h][w]--;
								ans_y1.add(h);
								ans_x1.add(w);
								a[h + 1][w]++;
								ans_y2.add(h + 1);
								ans_x2.add(w);
							}
						} else {
							a[h][w]--;
							ans_y1.add(h);
							ans_x1.add(w);
							a[h][w - 1]++;
							ans_y2.add(h);
							ans_x2.add(w - 1);
						}
					}
				}
			}
		}
		int ans_cnt = ans_y1.size();
		System.out.println(ans_cnt);
		for(int i = 0; i < ans_cnt; i++) {
			System.out.print(ans_y1.poll() + 1 + " ");
			System.out.print(ans_x1.poll() + 1 + " ");
			System.out.print(ans_y2.poll() + 1 + " ");
			System.out.println(ans_x2.poll() + 1);
		}
	}
}


Measured memory_bytes: 98396
<?php

fscanf(STDIN, "%d %d", $a, $b);

const K_MAX = 45;

function mxor($a) {
    if ($a <= 0) return 0;

    ++$a;

    $ans = 0;
    for ($i = 0; $i < K_MAX; ++$i) {
        $loop = 1<<($i + 1);
        $cnt = intdiv($a, $loop) * ($loop / 2);

        $cnt += max(0, $a % $loop - $loop / 2);

        if ($cnt % 2 === 1) {
            $ans += 1<<$i;
        }
    }
    return $ans;
}

echo mxor($b) ^ mxor($a - 1), PHP_EOL;


Measured memory_bytes: 4856
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const M: usize = 1_000_000_007;

fn solve(cur: usize, par: Option<usize>, graph: &Vec<Vec<usize>>, dp: &mut Vec<Vec<usize>>) {
    dp[cur][0] = 1;
    dp[cur][1] = 1;
    for &to in &graph[cur] {
        if par.is_some() && par.unwrap() == to {
            continue;
        }
        solve(to, Some(cur), graph, dp);
        dp[cur][0] *= dp[to][1];
        dp[cur][1] *= (dp[to][1] + dp[to][0]) % M;
        dp[cur][0] %= M;
        dp[cur][1] %= M;
    }
}

fn main() {
    input! {
        n: usize,
        edges: [(usize1, usize1); n - 1],
    }
    let mut graph = vec![vec![]; n];
    for &(f, t) in &edges {
        graph[f].push(t);
        graph[t].push(f);
    }
    let mut dp: Vec<Vec<usize>> = vec![vec![0; 2]; n];

    solve(0, None, &graph, &mut dp);
    println!("{}", (dp[0][0] + dp[0][1]) % M);
}


Measured memory_bytes: 28412
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			String S = scan.next();
			char[] c = new char[S.length()];
			c = S.toCharArray();
			int count = 0;
			int c0 = 0;
			int c1 = 0;
			
			for(int i = 0;i<S.length();i++) {
				if(c[i]=='0')c0++;
				if(c[i]=='1')c1++;
			}
			
			
			System.out.println(2*Math.min(c0, c1));
			
			
		}	
	}
}


Measured memory_bytes: 28300
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    String s = stdIn.next();
    String[] str = s.split("");
    int n = s.length();
    int count = 0;

    for (int i = 0; i < n / 2; i++) {
      if (!str[i].equals(str[n - i - 1])) {
        count++;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 22740
#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);

  string S, T, R;
  cin >> S >> T >> R;
  char W = 'a';
  while(true){
    if(W == 'a'){
      if(S.empty()){
        cout << 'A' << endl;
        return 0;
      }
      W = S[0];
      S.erase(0,1);
    }
    else if(W == 'b'){
      if(T.empty()){
        cout << 'B' << endl;
        return 0;
      }
      W = T[0];
      T.erase(0,1);
    }
    else if(W == 'c'){
      if(R.empty()){
        cout << 'C' << endl;
        return 0;
      }
      W = R[0];
      R.erase(0,1);
    }
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

bool OK[MAX];
LL dp[MAX];
int main()
{
    dp[0] = dp[1] = 1;
    int n, m;
    cin >> n >> m;
    mset(OK, 1);
    for(int i = 1; i <= m; i++){
        int x;
        cin >> x;
        OK[x] = 0;
    }
    for(int i = 2; i <= n; i++){
        dp[i] = (dp[i-1] * OK[i-1] + dp[i-2] * OK[i-2]) % Mod;
    }
    cout << dp[n] << endl;
    return 0;
}

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

int n,k;
int a[105],dp[100005];

int main(){
scanf("%d%d",&n,&k);
for (int i=0;i<n;i++){
scanf("%d",&a[i]);
}

for (int i=0;i<=k;i++){
  for (int j=0;j<n;j++){
    if (a[j]>i) {
      break;
    } else {
      dp[i]=dp[i]||(!dp[i-a[j]]);
    }
  }
}

if (dp[k]){
  printf("First\n");
} else {
  printf("Second\n");
}
return 0;
}


Measured memory_bytes: 640
#y,m,d=map(int,input().split())
#a,b=map(int,input().split())
#n=int(input())
#a=int(input())
#b=int(input())
#s=list(input())
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#b=list(map(int,input().split()))
#b=list(map(int,input().split()))
#a=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#a=[list(input().split())for _ in range(n)]
#a=[int(input())for _ in range(n)]
a=list(map(int,input().split()))
total=sum(a)
if 22<=total:
    print('bust')
else:
    print('win')

Measured memory_bytes: 2940
amount_of_employees = gets.chomp!.to_i
number_of_employees = gets.split(" ").map(&:to_i)
array = []
amount_of_employees.times{
	array << 0
}

number_of_employees.each do |x|
  array[x-1] += 1
end

array.each do |n|
    puts n
end

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

int main(){
	string s;
	cin>>s;
	
	vector<char> v;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='0')v.push_back('0');
		else if(s[i]=='1')v.push_back('1');
		else if(s[i]=='B' && v.size()!=0)v.pop_back();
	}
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       ll n,i,j=0,a,b;
       std::cin >> n>>a;
       if(n<a)
       cout<<"0\n";
       else
       cout<<"10\n";
   }
}

Measured memory_bytes: 3616
def main():
    s = input()
    most_753_number = -1

    for i,_ in enumerate(s[0:-2]):
        temp_number = int(s[i] + s[i+1] + s[i+2])
        if abs(temp_number - 753) <= abs(most_753_number - 753):
            most_753_number = temp_number
    print(abs(753 - most_753_number))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int a[100010], b[100010], c[100010];
int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	for (int i = 0; i < A; i++) cin >> a[i];
	for (int i = 0; i < B; i++) cin >> b[i];
	for (int i = 0; i < C; i++) cin >> c[i];
	sort(a, a + A,greater<int>());
	sort(b, b + B,greater<int>());
	vector<int> V;
	for (int i = 0; i < X; i++) V.push_back(a[i]);
	for (int i = 0; i < Y; i++) V.push_back(b[i]);
	for (int i = 0; i < C; i++) V.push_back(c[i]);
	sort(V.rbegin(), V.rend());
	ll ans = 0;
	for (int i = 0; i < X + Y; i++) {
		ans += V[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 6536
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 10;
int a[MAXN], b[MAXN];
int n, mx = 0;
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t) && t != '-') t = getchar(); 
	if (t == '-')
	{
		_read(x);
		x *= -1;
		return ;
	}
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
int main()
{
	_read(n);
	for (int i = 1; i <= n; ++i) _read(a[i]), mx = max(mx, a[i]), ++b[a[i]];
	if(mx & 1)
	{
		for(int i = mx; i >= (mx + 1) / 2; --i)
			if(b[i] < 2)
			{
				puts("Impossible");
				return 0;
			}
		for(int i = 1; i < (mx + 1) / 2; ++i)
			if(b[i])
			{
				puts("Impossible");
				return 0;
			}
		if(b[(mx + 1) / 2] > 2)
		{
			puts("Impossible");
			return 0;
		}
	}
	else
	{
		for(int i = mx; i > mx / 2; --i)
			if(b[i] < 2)
			{
				puts("Impossible");
				return 0;
			}
		for(int i = 1; i < mx / 2; ++i)
			if(b[i])
			{
				puts("Impossible");
				return 0;
			}
		if(b[mx / 2] != 1)
		{
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second

#include<iostream>

using namespace std;
int main()
{
  string r = "";
  // 入力
  string a;
  cin >> a;
  
  REP(i, a.size()) {
    switch(a[i]) {
      case 'B': 
        if(r.size() != 0) r.pop_back();
        break;
      default:
        r += a[i];
        break;
    }
  }
  OUT(r);
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    for(int i = 0;i < N;i++){
        cout << S[i] << T[i];
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
    };
    let mut res: Vec<usize> = vec![0; n];

    (0..k).for_each(|_| {
        input! {
            d: usize,
            a: [usize; d],
        };

        a.iter().for_each(|i| {
            res[i-1] += 1;
        });
    });

    println!("{}", res.iter().filter(|&&x| x == 0).count());
}



Measured memory_bytes: 2196
<?php

$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));

if ($n === 2)
{
	echo abs($a[0] - $a[1]);
}
else
{
	$total = array_sum($a);
	$ans = abs($total - $a[0] * 2);
	$x = 0;
	for ($i = 0; $i < $n-1; $i++)
	{
		$x += $a[$i];
		$total -= $a[$i];
		$ans = min($ans, abs($total - $x));
	}
	echo $ans;
}

Measured memory_bytes: 40436
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	if (a - b == b - c) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

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

    ll n;
    cin >> n;
    ll lim = sqrtl(n);
    vector<pair<ll, ll>> prime;
    vector<bool> vis(lim, false);
    for (ll i = 2; i * i <= n; i++)
    {
        if (!vis[i])
        {
            for (ll j = i * i; j <= lim; j += i)
            {
                vis[j] = true;
            }
        }
    }

    ll fact = 0, tmp = n;
    for (ll i = 2; i <= lim; i++)
    {
        if (!vis[i] and n % i == 0)
        {
            fact = 0;
            while (tmp % i == 0 and tmp > 0)
            {
                tmp /= i;
                fact++;
            }
            if (fact > 0)
                prime.push_back({i, fact});
        }
    }
    if (tmp > lim)
    {
        prime.push_back({tmp, 1});
    }

    ll ans = 0;
    for (auto pr : prime)
    {
        tmp = pr.second;
        for (ll t = 1;; t++)
        {
            if (tmp >= t)
            {
                ans++;
                tmp -= t;
            }
            else
                break;
        }
    }
    cout << ans << endl;
}

// 100000001

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

using namespace std;

int main()
{
    int w,a,b;
    cin >> w >> a >> b;
    if(a>b+w)
    {
        cout << a-b-w << endl;
    }
    else if(b>a+w)
    {
        cout << b-a-w << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)
void out()
{
	puts("Impossible");
	exit(0);
}
const int N=100+5;
int cnt[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,1,n)
	{
		int a;
		cin>>a;
		++cnt[a];
	}
	int mx=n;
	while(!cnt[mx])--mx;
	rep(i,0,mx)
	{
		int d=max(i,mx-i);
		if(!cnt[d])out();
		--cnt[d];
	}
	rep(i,1,(mx+1)/2)
	if(cnt[i])out();
	puts("Possible");
}

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

pub 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")
}
use std::collections::HashSet;

fn divisors(n: i64) -> HashSet<i64> {
    let mut ds = vec![];
    let mut d = 1;
    while d * d <= n {
        if n % d == 0 {
            ds.push(d);
            ds.push(n / d);
        }
        d += 1;
    }
    let uniq: HashSet<i64> = ds.into_iter().collect();
    uniq
}

fn main() {
    let n: i64 = read();
    let m: i64 = read();

    let d = divisors(m);
    let mut ans = 0;

    for i in d {
        if (m / i) >= n {
            if i > ans {
                ans = i;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main(){
    long long N,a;
    cin >> N;
    a = sqrt(N);
    for(long long i = a; i>0; i--){
        if(N%i ==0){
            cout << (N/i)+i-2 <<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []c = sc.next().toCharArray();
		
		int n = c.length;
		int []sum = new int [n];
		

		int count = 0;
		
		for(int i = 0 ; i < n ;i++) {
			if(c[i] == 'R') {
				count++;
			}
			else {
				sum[i] += Math.floorDiv(count, 2);
				sum[i-1] += Math.floorDiv(count, 2) + count % 2;
				count = 0;
			}
		}
		
		count = 0;
		
		for(int j = n-1 ; j >= 0 ; j--) {
			if(c[j] == 'L') {
				count++;
			}
			else {
				sum[j] += Math.floorDiv(count, 2);
				sum[j+1] += Math.floorDiv(count, 2) + count % 2;
				count = 0;
			}
		}
		
		for(int i = 0; i < n ;i++) {
			System.out.print(sum[i] +" ");
		}
		System.out.println("");
		
		

	}

}


Measured memory_bytes: 43272
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
    Scanner scanner = new Scanner (System.in);
    
    int N = scanner.nextInt();
    
    double goukei = 0;
    for (int index=0; index<N; index++){
      double money = scanner.nextDouble();
      String type= scanner.next();
      if (type.equals("JPY")){
        goukei+=money;
      } else {
        goukei+=money*380000.0;
      }
    }
    System.out.println(goukei);
  }
}

Measured memory_bytes: 23124
n = int(input())
p = list(map(int, input().split(' ')))
q = p[:]
q.sort()

diff = 0
for _p, _q in zip(p, q):
    if _p != _q:
        diff += 1

    if diff > 2:
        break

print('YES' if diff <= 2 else 'NO')

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }

    vector<int> lis(n + 1);
    fill(lis.begin(), lis.end(), 0);

    rep(i, n)
    {
        lis[p[i]] = lis[p[i] - 1] + 1;
    }

    int k = 0;
    rep(i, lis.size())
    {
        k = max(k, lis[i]);
    }
    cout << n - k << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

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

  ll mx = a.back();
  auto mid_iter = upper_bound(a.begin(), a.end(), mx / 2);
  if (mid_iter == a.begin())
  {
    cout << mx << " " << *mid_iter;
    return;
  }

  ll midr = *mid_iter;
  mid_iter--;
  ll midl = *mid_iter;

  // cout << midl << " " << midr << endl;

  cout << mx << " " << (mx - midl * 2 <= midr * 2 - mx ? midl : midr);
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct SegTree {
	int n;
	std::vector<int> data;
	SegTree () = default;
	SegTree (int n_) {
		for (n = 1; n < n_; n <<= 1);
		data.resize(n << 1);
	}
	int max(int l, int r) {
		int res = 0;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (r & 1) res = std::max(res, data[--r]);
			if (l & 1) res = std::max(res, data[l++]);
		}
		return res;
	}
	int operator [] (int i) { return data[i + n]; }
	void assign(int i, int val) {
		for (data[i += n] = val; i >>= 1; ) data[i] = std::max(data[i << 1], data[i << 1 | 1]);
	}
};

std::vector<int> a;
std::vector<std::vector<int> > hen;
std::vector<int> res;
SegTree tree;
void dfs(int i, int prev) {
	int cur = tree.max(0, a[i]) + 1;
	int old = tree[a[i]];
	tree.assign(a[i], std::max(old, cur));
	res[i] = tree.max(0, tree.n);
	for (auto j : hen[i]) if (j != prev) dfs(j, i);
	tree.assign(a[i], old);
}

int main() {
	int n = ri();
	a.resize(n);
	for (auto &i : a) i = ri();
	auto b = a;
	std::sort(b.begin(), b.end());
	for (auto &i : a) i = std::lower_bound(b.begin(), b.end(), i) - b.begin();
	hen.resize(n);
	for (int i = 1; i < n; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		hen[a].push_back(b);
		hen[b].push_back(a);
	}
	res.resize(n);
	tree = SegTree(n);
	dfs(0, -1);
	for (auto i : res) printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 32924
#include<stdio.h>
const int M=1<<18;
bool p[M];

int main(){
	int n,i,j;
	for(i=0;i<M;i++)
		p[i]=(i<=1)?0:1;
	for(i=2;i*i<=M;i++)
		if(p[i])
			for(j=i*2;j<M;j+=i)
				p[j]=0;

	for( ; j=0,scanf("%d",&n),n ; printf("%d\n",j) )
		for(i=n+1;i<=2*n;i++)
        	p[i]?j++:0;
}

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

using namespace std;

typedef long long ll;

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

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

    ll M = A + B;
    cout << (N / M) * A + min(A, (N % M)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ld A, w, h;
bool fn(ld ang){
    ld l, b, a, c, g, tmp, a1, md=h*cos(ang);
    l=h;
    b=md*tan(ang);
    a=w*cos(ang);
    c=w*sin(ang);
    g=(md-c)*tan(ang);
    a1=md/tan(ang);
    if(md<=c){
        tmp=(a1+b)*md/2.0;
    }
    else{
        tmp=(a+b)*md-b*md/2.0-a*c/2.0-(md-c)*g/2.0;
    }
    return(tmp<=A);
}
int main(){
    int n, t;
        ll ans=0;
        int h1, w1, A1;
        cin>>w1>>h1>>A1;
        h=h1;w=w1;A=A1/(ld)w;
        ld st=0, nd=acos(0), md, tmp1, tmp;
        int tt=100;
        while(tt--){
            md=(st+nd)/2.0;
            if(fn(md)){
                nd=md;
            }
            else{
                st=md;
            }
        }
        ld pi=3.1415926536;
        st=st*180.0/pi;
        cout<<fixed<<setprecision(9)<<st<<endl;
  return 0;
}




Measured memory_bytes: 384
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			char[] a = sc.next().toCharArray();
			if(a[0]=='x' && a[a.length-1]=='x') System.out.println('x');
			else System.out.println('o');
		}	
	}	
}

Measured memory_bytes: 17308
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

X, Y = rl()

for i in range(X+1):
	if i*2+(X-i)*4 == Y:
		print('Yes')
		exit()
print('No')


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

int main() {
  ll N,M;
  cin>>N>>M;
  ll ans[N];
  for(ll &x:ans){
    x=0;
  }
  for(int i=0;i<M;i++){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    ans[a]++;ans[b]++;
  }
  ll c=1;
  for(int i=0;i<N;i++){
    if(ans[i]%2){
      c=0;break;
    }
  }
  if(c){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}

Measured memory_bytes: 1024
K = int(input())

i = 7%K
se = set([i])
cnt = 1
while True:
  if i == 0:
    print(cnt)
    break
  cnt += 1
  i = (i*10 + 7)%K
  if i in se:
    print(-1)
    break
  else:
    se.add(i)
  

Measured memory_bytes: 77940
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
#MOD = 10**9+7
MOD = 10**9+7
import math
N,K = map(int,input().split())
ans = [0]*K
for i in range(K):
    p = K-i
    a = pow(math.floor(K/p),N,MOD)
    x = 1
    while p*(x+1) <= K:
        a -= ans[p*(x+1)-1]
        x = x+1
    ans[p-1] = a%MOD
s = 0
for i in range(K):
    s += (i+1)*ans[i]
    s = s%MOD
print(s)

Measured memory_bytes: 69224
#include<cstdio>
#include<algorithm>
long long int gcd(long long int a,long long int b){
	if(a%b==0)return b;
	else return gcd(b,a%b);
}
int main(){
	long long int a,b;
	scanf("%lld%lld",&a,&b);
	long long int ans=gcd(a,b);
	a=a/ans;
	b=b/ans;
	ans=ans*(a-1)*3;
	printf("%lld\n",ans);
	return 0;
}
	

Measured memory_bytes: 128
#include <stdio.h>

int main () {
	int a;
	int a1, a2, a3;
	scanf("%d", &a);
	a1 = a/100;
	a2 = (a%100)/10;
	a3= a%10;
	if(a1==7 || a2==7 || a3==7) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int s;
  bool ok=false;
  for(int i=0;i<=n;i++){
    if(floor(i*1.08)==n){
      ok=true;
      s=i;
      break;
    }
  }
  if(ok)
    cout << s << endl;
  else
    cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3592