akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
main(){
  char c[100];
  int n,p,i,j,k=0;
  while(scanf("%s",c)!=EOF){
    p=1;
    i=0;
    n=strlen(c);
    j=n-1;
    while(i<j && p==1){
      if(c[i]!=c[j]){
	p=0;
      }
      j--;
      i++;
    }
    if(p==1){
      k++;
    }
  }
  printf("%d\n",k);
  return 0;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod = 1e9 + 7;
int main(){
	int n; sd(n);
	vector<int> a(n), b(n);
	vector<pii> P;
	for(int i = 0; i < n; i++){
		sd(a[i]);
		P.push_back({a[i], -1});
	}

	for(int i = 0; i < n; i++){
		sd(a[i]);
		P.push_back({a[i], 1});
	}

	sort(all(P));
	int xygrr = 0;
	int ans = 1;
	int diff = 0;
	for(auto it : P){
		int col = it.S;
		if(col * diff < 0){
			ans = (ans * 1ll * abs(diff)) % mod;
		}
		diff += col;
	}
	printf("%d\n", ans);
}

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

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

    int h[n+1];
    h[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    int dp[n+5];
    for(int i=0;i<=n+5;i++)
    {
        dp[i]=0;
    }
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 5124
#include <algorithm>
#include <iostream>

using namespace std;
int n;
int a[100000 + 5];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (a[a[i]] == i) cnt++;
    }
    cout << cnt / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int n;
	double x;
	string u;
	double sum = 0.0;

	cin >> n;

	for(int i = 0; i < n; ++i)
	{
		cin >> x >> u;
		if(u == "JPY")
		{
			sum += x;
		}
		else
		{
			sum += x * 380000.0;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
<?php
$s = trim(fgets(STDIN));
$flag = true;
if($s[0] != "A")$flag = false;
$countC = 0;
for($i = 2; $i < strlen($s) - 1; $i++){
if($s[$i] == "C"){$countC++;$s[$i] = "c";}
}
if($countC != 1)$flag = false;
$s[0] = "a";
if(strtolower($s) != $s)$flag = false;
echo $flag ? "AC" : "WA";

Measured memory_bytes: 3700
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		ou.print(Math.PI * 2.0 * n + "\n");
		ou.flush();
    }
}

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

typedef long long ll;

int main() {
  int N;
  cin >> N;
  ll a[N+1];
  a[0] = 0;
  ll sum = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> a[i];
    sum += a[i];
  }

  // 累積和をとる
  for (int i = 1; i < N + 1; i++) a[i] += a[i-1];

  ll mini = 1e18;
  for (int i = 1; i < N; i++) {
    mini = min(mini, abs(a[i] - (sum - a[i])));
  }

  // 解答
  cout << mini << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  
  vector<int> vec(n + 1);
  vec[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> vec[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if(vec[i + 1] > vec[i]) {
      cnt += vec[i + 1] - vec[i];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
ls = [0] * 50505
for i in range(len(ls)):
	ls[i] = int(i * 1.08)
for i in range(N, 0, -1):
	if ls[i] == N:
		print(i)
		sys.exit()
print(':(')

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int n,c;
vpii ch [35];
int pd[100010],sum[100010],mx;
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>c;
    for(int i=1;i<=n;i++){
        int l,r,s;
        cin>>l>>r>>s;
        ch[s].pb(mp(l,r));
    }

    for(int i=1;i<=c;i++){
        sort(ch[i].begin(),ch[i].end());
        for(int j=0; j<ch[i].size();j++){
            int l = ch[i][j].fi;
            int r = ch[i][j].se;
            if(j>0) {
                if(l == ch[i][j-1].se){l++;}
            }
            pd[l]++; pd[r+1]--;
        }
    }

    for(int i=1;i<=1e5+5;i++){
        sum[i] = sum[i-1] + pd[i];
        mx = max(mx,sum[i]);
    }
    cout<<mx<<newl;

}


Measured memory_bytes: 2304
n = int(input())

chars = [
    'a',
    'b',
    'c',
    'd',
    'e',
    'f',
    'g',
    'h',
    'i',
    'j']

def f(i):
    if i == 1:
        return [chars[i - 1]]
    else:
        temp = f(i - 1)
        e = []
        for j in temp:
            w = min([len(set(j)) + 1, i - 1])
            for c in range(w):
                e.append(j + chars[c])
        e.append(''.join(chars[0:i]))
        return e

    
result = f(n)
result = sorted(result)
for i in result:
    print(i)
    


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

using namespace std;

#define mod 1000000007
#define int int64_t
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)


void solve()
{
    string s;
    cin>>s;
    int n=s.size(),sum=0;
    for(int i=0;i<n;i++)
        sum+=s[i]-'0';
    cout<<(sum%9==0 ? "Yes":"No")<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 3660
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var abcd = Sarray();
            WriteLine(Max(abcd[0] * abcd[1], abcd[2] * abcd[3]));
        }
    }
}

Measured memory_bytes: 27916
#include<stdio.h>
int main(void)
{
	int n,a[8],i,j,x,h,h2,l;
	scanf("%d",&n);
	for(i=0;i<8;i++)	a[i]=0;
	l=0;
	for(i=0;i<n;i++){
		scanf("%d",&x);
		if(x>3199){
			l++;
		}
		else{
			h=400;	h2=1;
			for(j=0;j<8;j++){
//			printf("h2=%d h=%d\n",h2,h);
				if(h2<=x && x<h){
					a[j]=1;
					break;
				}
				h2=h;
				h=h+400;
			}
		}
	}
	x=0;
	for(i=0;i<8;i++){
		if(a[i]==1)	 x++;
	}
	l=x+l;
	if(x==0)	x=1;
//	if(l>8)	l=8;
	printf("%d %d\n",x,l);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int i = 1; i <= N; i++) {
			String n = Integer.toString(i);
			int t = 0;
			for(int j = 0; j < n.length(); j++) {
				t += n.charAt(j) - '0';
			}
			if(t >= A && t <= B) {
				cnt += i;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
/*
for (int i = 0; i < N; ++i){}
 
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
 
int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}
 
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
 
 
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;

int main() {
	// 入力
    int N;
    cin >> N;
    long long L[N], R[N];
    for (int i = 0; i < N; ++i) cin >> L[i] >>R[i];
 
 
    sort(L, L + N, greater<long long>());  // a[0:N] を大きい順にソート
    sort(R, R + N);  // a[0:N] を大きい順にソート
    int i = 0;
    long long place = 0;
    long long distance = 0;
    long long zero = 0;
    //cout << "=> " << place << " dis " << distance << endl; 
    while (true){
    	if (L[i]<=place && R[i]>=place){
    		distance += abs(zero - place);
    		place = zero;
    		// cout << "=> " << place << " dis1 " << distance << endl; 
    		break;		
    	}
    	else if (L[i]<=place){
    		// distance += 0 - place;
    		// place = 0;
    		// cout << "=> " << place << " dis " << distance << endl; 
    		// break;	
    	} 
    	else{
    		// cout << "L[" << i << "]: " << L[i] << endl;
    		distance += abs(L[i] - place);
    		place = L[i];
    		// cout << "=> " << place << " dis2 " << distance << endl; 
    	}
    	if (R[i]>=place){
    		distance += abs(place);
    		place = zero;
    		// cout << "=> " << place << " dis3 " << distance << endl; 
    		break;	
    	} 
    	else{
    		distance += abs(place - R[i]);
    		place = R[i];
    		// cout << "=> " << place << " dis4 " << distance << endl; 
    	}
    	++i;
    }
     i = 0;
     place = 0;
    long long distance2 = 0;
    
    //cout << "=> " << place << " dis " << distance2 << endl; 
    while (true){
    	if (L[i]<=place && R[i]>=place){
    		distance2 += abs(zero - place);
    		place = zero;
    		// cout << "=> " << place << " dis1 " << distance2 << endl; 
    		break;		
    	}
    	else if (R[i]>=place){
    		distance2 += abs(place);
    		place = zero;
    		// cout << "=> " << place << " dis3 " << distance2 << endl; 
    		break;	
    	} 
    	else{
    		distance2 += abs(place - R[i]);
    		place = R[i];
    		// cout << "=> " << place << " dis4 " << distance2 << endl; 
    	}
    	if (L[i]<=place){
    		// distance += 0 - place;
    		// place = 0;
    		// cout << "=> " << place << " dis " << distance2 << endl; 
    		// break;	
    	} 
    	else{
    		// cout << "L[" << i << "]: " << L[i] << endl;
    		distance2 += abs(L[i] - place);
    		place = L[i];
    		// cout << "=> " << place << " dis2 " << distance2 << endl; 
    	}

    	++i;
    }

	//出力
    cout << max(distance, distance2) << endl;

}
 
 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=100000000;


int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> e(n+1,vector<int>(0));
    int re,rec;
    rep(i,m){
        cin >> re >> rec;
        e.at(re).push_back(rec);
    }
    vector<vector<int>> d(n+1,vector<int>(3));
    rep(i,n+1){
        rep(j,3) d.at(i).at(j)=inf;
    }
    queue<pp> q;
    pp v;
    int s,t;
    cin >> s >> t;
    d.at(s).at(0)=0;
    v.first=s;v.second=0;
    q.push(v);
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        q.pop();
        int yy=y+1;
        if (yy==3) yy=0;
        for (int i=0;i<e.at(x).size();i++){
        if (d.at(e.at(x).at(i)).at(yy)>d.at(x).at(y)+1){
            d.at(e.at(x).at(i)).at(yy)=d.at(x).at(y)+1;
            v.first=e.at(x).at(i);
            v.second=yy;
            q.push(v);
        }
        }
    }
    if (d.at(t).at(0)==inf) cout << -1 << endl;
    else cout << d.at(t).at(0)/3 << endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 10000
int sumA=0,sumB=0;
int a[4],b[4];
using namespace std;
int main() {
  rep(i,4) cin >> a[i];
  rep(i,4) cin >> b[i];
  rep(i,4) sumA += a[i];
  rep(i,4) sumB += b[i];
  if(sumB>sumA){
    cout << sumB << endl;
  }else{
    cout << sumA << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	ll n,k;
	cin>>n>>k;
	umap<ll,ll> m;
	while(k--)
	{
		ll x,d;
		cin>>d;
		while(d--)
		{
			cin>>x;
			m[x]++;
		}
	}
	cout<<n-m.size();
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    vector<int> next(n);
    vector<int> order;
    order.push_back(0);
    for (int i=0; i<n; ++i) {
        int a; cin >> a;
        a--;
        next[i] = a;
    }
    int now = 0;
    set<int> seen;
    seen.insert(0);
    int memo = -1;
    for (int i=0; i<n; ++i) {
        int ne = next[now];
        if (seen.count(ne)) {
            memo = ne;
            break;
        }
        order.push_back(ne);
        seen.insert(ne);
        now = ne;
    }
    for (int i=0; i<(int)order.size(); ++i) {
        if (memo == order[i]) {
            memo = i;
            break;
        }
    }
    int ans;
    if (k < memo) ans = order[k] +1;
    else ans = order[(k-memo)%(order.size()-memo) + memo] +1;
    cout << ans << endl;
}

Measured memory_bytes: 13824
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    double f; cin >> f;
    cout.precision(6);
    cout << fixed;
    cout << f * f * M_PI << " " << 2 * f * M_PI << "\n";

    return 0;
}

Measured memory_bytes: 1304
from networkx import *
h,w=map(int,input().split());r=range(10);G=DiGraph();G.add_nodes_from(r);C=[[*map(int,input().split())]for _ in r];G.add_weighted_edges_from([(i,j,C[i][j])for i in r for j in r]);S=[single_source_dijkstra_path_length(G,i)[1]for i in r];A=[[*map(int,input().split())]for _ in "_"*h];print(sum(S[abs(x)] for a in A for x in a))

Measured memory_bytes: 53440
//template---{{{
#include <bits/stdc++.h>

using namespace std;

//DEFINE---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); 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--)
//end.DEFINE---}}}

//end.template ---}}}

int main() {
  int N;

  cin >> N;

  if (N % 2 == 0) {
    cout << N << endl;
  }
  else {
    cout << N * 2 << endl;
  }

  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string s; cin>>s;
    vector<int> box(s.size(),0);
    int rcnt=0;
    int lcnt=0;
    rep(i,0,s.size()){
        if(s[i]=='R'){
            rcnt++;
            if(i!=0&&s[i-1]!='R'){
                if(lcnt%2==0){
                    box[i-lcnt]+=lcnt/2;
                    box[i-lcnt-1]+=lcnt/2;
                }else{
                    box[i-lcnt]+=(lcnt/2+1);
                    box[i-lcnt-1]+=lcnt/2;
                }
                lcnt=0;
            }
        }else{
            lcnt++;
            if(i!=0&&s[i-1]!='L'){
                if(rcnt%2==0){
                    box[i]+=rcnt/2;
                    box[i-1]+=rcnt/2;
                }else{
                    box[i]+=rcnt/2;
                    box[i-1]+=(rcnt/2+1);
                }
                rcnt=0;
            }
        }
    }
    if(lcnt%2==0){
        box[s.size()-lcnt]+=lcnt/2;
        box[s.size()-lcnt-1]+=lcnt/2;
    }else{
        box[s.size()-lcnt]+=(lcnt/2+1);
        box[s.size()-lcnt-1]+=lcnt/2;
    }
  
    rep(i,0,s.size()-1){
        cout<<box[i]<<" ";
    }
    cout<<box[s.size()-1]<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;
 
 
int main() {
	double n;
	cin >> n;
    n =2*n*M_PI;
	cout << n;   
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
  ll a, b;
  cin >> a >> b;
  ll smaller = a < b ? a : b;
  ll answer = 1;
  ll i;
  for (i = 2; i * i <= smaller; ++i) {
    if (a % i == 0 && b % i == 0) {
      answer++;
    }
    while (a % i == 0) {
      a /= i;
    }
    while (b % i == 0) {
      b /= i;
    }
  }
  if (a > i && b > i) {
    if (a % b == 0 || b % a == 0) {
      answer++;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int sosuu(int);
int main(){
  int a,b,c,count1=0;
  scanf("%d",&a);
  for(int i=0;i<a;i++){
    scanf("%d",&b);
    c=sosuu(b);
    if(c==1)count1++;
  }
  printf("%d\n",count1);
  return 0;
}
int sosuu(int x){
  int i,c;
  double d=sqrt(x);
  if(x==2)return c=1;
  if(x <2 ||x%2==0)return c=0;
  i=3;
  while(i<=d){
    if(x%i==0)return c=0;
    i=i+2;
  }
  return c=1;
}


Measured memory_bytes: 2052
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 1005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,m,s1,s2,e1,e2,vis[maxn][maxn];
string adj[maxn];
int X[]={1,-1,0,0};
int Y[]={0,0,1,-1};
bool check(int x,int y)
{
	if(x >=0  and x < n and y >= 0 and y < m)
	return true;
	return false;
}
void dfs(int x,int y,queue<pp> &q,int cnt)
{
	vis[x][y]=cnt;
	q.push({x,y});
	for(int i=0;i<4;i++)
	{
		int x1 = x+X[i];
		int y1 = y+Y[i];
		if(check(x1,y1) and adj[x1][y1]=='.' and vis[x1][y1]==-1)
			dfs(x1,y1,q,cnt);
	}
}
void solve()
{
	memset(vis,-1,sizeof(vis));
	cin >> n >> m;
	cin >> s1 >> s2 >> e1 >> e2;
	s1--,s2--,e1--,e2--;
	for(int i=0;i<n;i++)
	cin >> adj[i];
	queue<pp> q;
	dfs(s1,s2,q,0);
	while(q.size())
	{
		pp p = q.front();
		q.pop();
		int x=p.ff;
		int y=p.ss;
		for(int i=x-2;i<=x+2;i++)
			for(int j=y-2;j<=y+2;j++)
			if(check(i,j) and adj[i][j]=='.' and vis[i][j]==-1)
				dfs(i,j,q,vis[x][y]+1);
	}
	cout << vis[e1][e2];
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

long long N, M, V, P;
vector<long long> A;

bool is_ok(int x){
  if(P + (x - 1) >= V){
    if(A[x] + M >= A[N - P + 1]){
      return true;
    }else{
      return false;
    }
  }else{
    long long resid = 0;
    for(int i = x + 1; i <= N - P + 1; i++){
      resid += M - (A[i] - A[x]);
      if(M - (A[i] - A[x]) < 0){
	return false;
      }
    }
    if(resid >= M * (V - P - x + 1)){
      return true;
    }else{
      return false;
    }
  }
}



int main(){
  cin >> N >> M >> V >> P;

  A.push_back(-1e12); // banpei
  for(int i = 1; i <= N; i++){
    long long tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  sort(A.begin(), A.end());

  int ok = N - P + 1, ng = 0;
  while(ok - ng > 1){
    int mid = (ok + ng) / 2;
    if(is_ok(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }

  cout << (N - ok + 1) << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int X, Y;
	cin >> X >> Y;
	
	int total = 0;
	if (X == 1 && Y == 1) {
		total = 300000 * 2 + 400000;
		cout << total << endl;
		return 0;
	}

	if (X == 1) {
		total += 300000;
	}
	else if (X == 2) {
		total += 200000;
	}
	else if (X == 3) {
		total += 100000;
	}

	if (Y == 1) {
		total += 300000;
	}
	else if (Y == 2) {
		total += 200000;
	}
	else if (Y == 3) {
		total += 100000;
	}

	cout << total << endl;

}






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


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

    vector<int> a(100110),b(100110),c(100110);
    vector<int> amax(100110), bmax(100110), cmax(100110);
    int n;
    cin >> n;
    rep(i, n) cin >> a[i + 1] >> b[i + 1] >> c[i + 1];
    
    forx(i,1,n+1){
        amax[i] = a[i] + max(bmax[i - 1], cmax[i - 1]);
        bmax[i] = b[i] + max(amax[i - 1], cmax[i - 1]);
        cmax[i] = c[i] + max(bmax[i - 1], amax[i - 1]);
    }
    cout << max({amax[n], bmax[n], cmax[n]}) << endl;


    return 0;
    }


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int n;
int dp[100010];

int abs(int x) {
	if (x < 0) return x * -1;
	else return x;
}

int main() {
	int h;
	cin >> n;
	vector<int> hv;
	rep(i,n) {
		cin >> h;
		hv.pb(h);
	}
	dp[0] = 0;
	dp[1] = abs(hv[1]-hv[0]);
	for(int i=2; i<n; i++) {
		dp[i] = min(dp[i-2] + abs(hv[i] - hv[i-2]), dp[i-1] + abs(hv[i] - hv[i-1]));
	}
	cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
int n;
cin>>n;
ll x =  0 ; 
vector<int> v(n);
for(int   i = 0  ; i<n ; i++) cin>>v[i],x^=v[i];
for(int i = 0 ; i<n; i++) cout<<(x^v[i])<<" ";
cout<<endl;
}

Measured memory_bytes: 3980
from functools import cmp_to_key
n, m = map(int, input().split())
a = [int(e) for e in input().split()]
bc = [[int(e) for e in input().split()] for _ in range(m)]
bc.sort(key = cmp_to_key(lambda x, y: y[1] - x[1]))
t = 0
for b, c in bc:
  a.extend([c] * b)
  t += b
  if t > n:
    break
a.sort(reverse = True)
print(sum(a[:n]))


Measured memory_bytes: 30664
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 200001
#define INF (int)1e9
#define mod (int)(1e9+7)
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;

inline int Min(int a,int b,int c){
	return min(a,min(b,c));
}

int mp[inf][3];
int p[inf],pos[inf],ck[inf];
int n;

int main(){
	rd(n)
	for (int i=1;i<=3;i++){
		for (int j=1;j<=n;j++){
			rd(mp[j][i])
		}
	}
	for (int i=1;i<=n;i++){
		if (mp[i][3]-mp[i][2]==mp[i][2]-mp[i][1] && mp[i][3]-mp[i][2]==1){
			p[i]=0;
		}
		else if (mp[i][2]-mp[i][3]==mp[i][1]-mp[i][2] && mp[i][2]-mp[i][3]==1){
			p[i]=1;
		}
		else{
			puts("No");
			return 0;
		}
		int minv=Min(mp[i][1],mp[i][2],mp[i][3]);
		int dis=abs(i-minv/3-1);
		if (dis&1){
			puts("No");
			return 0;
		}
		pos[minv/3+1]=i;
	}
	int cnt[2]={0,0};
	for (int i=1;i<=n;i++){
		cnt[i&1]+=p[i];
	}
	for (int i=1;i<=n;i++){
		if (!ck[i]){
			ck[i]=1;
			int len=0,now=pos[i];
			while (!ck[now]){
				ck[now]=1;
				now=pos[now];
				len++;
			}
			cnt[!(i&1)]+=len;
		}
	}
	if ((cnt[0]&1) || (cnt[1]&1)){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);

	vector< int > sm(n + 1, 0);
	REP(i, n) {
		sm[i + 1] = sm[i] + a[i];
	}

	int ans = LINF;
	FOR(i, 1, n) {
		ans = min(ans, abs(sm.back() - sm[i] - sm[i]));
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && b==c && c==a) || (a!=b && b!=c && c!=a)){
		cout<<"No";
	}else if((a==b && b!=c && c!=a) || (a==c && c!=b && b!=a) || (b==c && c!=a && a!=b)){
		cout<<"Yes";
	}
return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	int n;
	ll ans=-1;
	cin>>n;
	for(int i=0;i<n+1;i++)
	{
		if((int)(i*1.08)==n)
		{
			ans=i;
			break;
		}
	}
	if(ans!=-1)
		cout<<ans<<endl;
	else
		cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    string s,t;
    ll i,ans=0;
    cin>>s>>t;
    for(i=0;s[i];i++)
    {
        if(s[i]!=t[i]) ans++;
    }

        cout<<ans<<'\n';


    return 0;
}




Measured memory_bytes: 3792
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int n;
ll vs[300000+10];
ll memo1[300000+10];
ll memo2[300000+10];

void calcMemo1(void) {
  memo1[0] = 0;
  priority_queue<ll> q; // negate
  ll sum = 0;
  REP(i, n*2) {
    q.push(-vs[i]);
    sum += vs[i];
    if(q.size() > n) {
      sum += q.top(); q.pop();
    }
    memo1[i+1] = sum;
  }
}

void calcMemo2(void) {
  memo2[3*n] = 0;
  priority_queue<ll> q;
  ll sum = 0;
  REP(i, n*2) {
    q.push(vs[3*n-1-i]);
    sum += vs[3*n-1-i];
    if(q.size() > n) {
      sum -= q.top(); q.pop();
    }
    memo2[3*n-1-i] = sum;
  }
}

int main(void) {
  scanf("%d", &n);
  REP(i, 3*n) {
    scanf("%lld", &vs[i]);
  }
  calcMemo1();
  calcMemo2();
  ll res = -1e18;
  for(int i = n; i <= 2*n; ++i) {
    res = max(res, memo1[i] - memo2[i]);
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 8308
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
dp = [0 for i in range(H + 10**4 + 1)]

hm = list(list(map(int, input().split())) for i in range(N))

for i in range(1, H+1):
    dp[i] = min(list(dp[i - h] + m for h, m in hm))
print(dp[H])

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

using namespace std;

using ll = long long;

int num[] = {6,2,5,5,4,5,6,3,7,6};

int dp[10][10005], dp2[10][10005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    sort(a.begin(), a.end());

    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            if (j >= num[a[i]]) {
                if (dp[i+1][j-num[a[i]]] >= 0) {
                    dp[i + 1][j] = dp[i+1][j-num[a[i]]]+1;
                    dp2[i + 1][j] = i+1;
                }
                
                /*
                if (dp[i][j-num[a[i]]]>=0 && dp[i+1][j] <= dp[i][j-num[a[i]]]) {
                    dp[i + 1][j] = dp[i][j-num[a[i]]]+1;
                    dp2[i + 1][j] = i+1;                    
                }*/
            }

            if (dp[i][j]>=0 && dp[i+1][j]<dp[i][j]) {
                dp[i+1][j] = dp[i][j];
                dp2[i+1][j] = dp2[i][j];
            }
        }
    }
    //cerr << dp[m][n] << endl;

    int cur = m;
    int rest = n;
    while (cur >= 0 && rest >= 0 && rest <= n && dp2[cur][rest] > 0) {
        cout << a[dp2[cur][rest]-1];
        rest -= num[a[dp2[cur][rest]-1]];
        cur = dp2[cur][rest];
    }
    cout << endl;
    return 0;
}

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

void extGCD(int a, int b, int &x, int &y){
    if (b == 0){
        x = 1;
        y = 0;
        return;
    }
    else {
        extGCD(b, a % b, y, x);
        y -= (a / b) * x;
        return;
    }
}

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b; cin >> a >> b;
    int x, y;
    extGCD(a, b, x, y);
    cout << x << " " << y << endl;

    return 0;
}


Measured memory_bytes: 3208
import bisect
H,N = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [[10**18]*(H+1) for _ in range(N+1)]
dp[0][0]=0
mi=10**9
for i in range(N):
  for w in range(H+1):
    dp[i+1][w]=min(dp[i+1][w],dp[i][w])
    dp[i+1][min(w+AB[i][0],H)]=min(dp[i+1][min(w+AB[i][0],H)],dp[i+1][w]+AB[i][1])
print(dp[N][H])


Measured memory_bytes: 120668
#include <stdio.h>

int main ( )
{
	int total ;
	int sum ;
	int tmp ;
	while ( scanf ( "%d" , &total ) == 1 && total ) {
		sum = 0 ;
		for ( int i = 0 ; i < 9 ; i++ ) {
			scanf ( "%d" , &tmp ) ;
			sum += tmp ;
		}
		printf ( "%d\n" , total - sum ) ;
	}
	return 0 ;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;
const int MAX_V=105;
const int INF=1<<25;
struct edge{int to,cap,rev;};
vector<edge>G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap)
{
	edge ins={to,cap,G[to].size()};
	G[from].push_back(ins);
	ins.to=from;ins.cap=0;ins.rev=G[from].size()-1;
	G[to].push_back(ins);
}

int dfs(int v,int t,int f)
{
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0)
		{
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0)
			{
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t)
{
	int flow=0;
	for(;;)
	{
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
	}
}

int main()
{
	int N,M,f,t,c;
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++)
	{
		scanf("%d%d%d",&f,&t,&c);
		add_edge(f,t,c);
	}
	printf("%d\n",max_flow(0,N-1));
}

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

bool prime(int n) {
	if (n < 2) return false;
	for (int x = 2; x*x <= n; ++x) {
		if (n%x == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x;
	cin >> x;
	while (!prime(x)) ++x;
	cout << x << '\n';
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try( BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      while(true){
        String line = br.readLine();
        if(line.equals("0")) break;

        int sum = 0;
        char[] ch   = line.toCharArray();
        
        for( int i = 0; i < line.length(); i++ )  {
          sum += Character.getNumericValue(ch[i]);
        }

        System.out.println(sum);
      }
    }
  }
}


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

int main(){
  int n;
  cin >> n;
  int a[n],max=0,max2=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    
    if(a[i]>=a[max]){
      max2 = max;
      max = i;
    }else if(a[i]>=a[max2]){
       max2 = i;
    }
    if(i==1){
      if(a[0]>=a[1]){
        max=0;
        max2=1;
      }else{
        max=1;
        max2=0;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i==max) cout << a[max2] << endl;
    else cout << a[max] << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
using System;

namespace ABC134
{
    class Program
    {
        static int Main(string[] args)
        {
            problemC();
            return 0;
        }

        static void problemC()
        {
            string input = Console.ReadLine();

            int n = int.Parse(input);

            int[] A = new int[n];

            for(int i = 0; i<n; i++)
            {
                string inputA = Console.ReadLine();
                A[i] = int.Parse(inputA);
            }

            int[] maxL = new int[n];
            int[] maxR = new int[n];

            maxL[0] = 0;
            maxR[n-1] = 0;
            int L = 0;
            int R = 0;

            for (int i = 0; i < n; i++)
            {
                if (i > 0)
                {
                    if (L < A[i - 1])
                    {
                        L = A[i - 1];
                    }

                    maxL[i] = L;

                    if (R < A[n - i])
                    {
                        R = A[n - i];
                    }

                    maxR[n - i-1] = R;
                }
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(Math.Max(maxL[i], maxR[i]));
            }
        }
    }
}


Measured memory_bytes: 18772
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def lowmod(a, b, mod):
    a -= b
    if a >= mod:
        a -= mod
    return a

def solve():
    n = int(input())
    s = input()
    c = collections.Counter(s)
    mod = 10**9+7
    ans = 1
    for i in c:
        ans *= (c[i]+1)
        ans %= mod
    ans = lowmod(ans, 1, mod)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10484
n=int(input())
a=sorted(list(map(int,input().split())))
i=a[1]
while i > 0:
  flg=0
  for j in a:
    if j%i!=0:
      flg+=1
      if flg>1:
        break
  if flg<=1:
    print(i)
    break
  else:
    i-=1

Measured memory_bytes: 14076
a,b,c,d = map(int, input().split())
m = a*c
n = a*d
o = b*c
p = b*d
if(m>n and m>o and m>p):
    print(m)
elif (n>m and n>o and n>p):
    print(n)
elif (o> m and o>n and o>p):
    print(o)
else:
    print(p)

Measured memory_bytes: 9196
class Node
  attr_reader :id, :left, :right
  attr_writer :parent
 
  def initialize(id)
    @id = id
    @parent = nil
    @left = @right = nil
  end
 
  def left=(child)
    @left = child
    child.parent = self
  end

  def right=(child)
    @right = child
    child.parent = self
  end
 
  def type
    return 'root' if @parent.nil?
    return 'leaf' if @left.nil? && @right.nil?
    'internal node'
  end
 
  def parent_id
    return -1 if @parent.nil?
    @parent.id
  end
 
  def depth
    return 0 if @parent.nil?
    1 + @parent.depth
  end

  def degree
    deg = 0
    deg += 1 unless @left.nil?
    deg += 1 unless @right.nil?
    deg
  end

  def sibling_id
    return -1 if @parent.nil?
    s = (@parent.left == self ? @parent.right : @parent.left)
    s.nil? ? -1 : s.id
  end

  def height
    return 0 if @left.nil? && @right.nil?
    hl = @left.nil? ? 0 : @left.height
    hr = @right.nil? ? 0 : @right.height
    1 + [hl, hr].max
  end
end
 
n = gets.to_i
nodes = n.times.map{|id| Node.new(id) }
 
n.times do
  id, left_id, right_id = gets.split.map(&:to_i)
  node = nodes[id]
  node.left = nodes[left_id] unless left_id == -1
  node.right = nodes[right_id] unless right_id == -1
end
 
nodes.each do |n|
  puts "node #{n.id}: parent = #{n.parent_id}, sibling = #{n.sibling_id}, degree = #{n.degree}, depth = #{n.depth}, height = #{n.height}, #{n.type}"
end

Measured memory_bytes: 8752
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            String T = sc.next();
            System.out.println(T.substring(0, T.length() - 1).equals(S) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 26924
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int n, m;
	long int h[100000];
	long int a[100000];
	long int b[100000];
	long int count[100000] = {0};
	long int work;
	long int flg = 0;
	long int ans = 0;
	
	scanf("%ld %ld", &n, &m);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &h[i]);
	}
	
	for(i = 0; i < m; i++) {
		scanf("%ld %ld", &a[i], &b[i]);
		if(h[a[i] - 1] <= h[b[i] - 1]) {
			count[a[i] - 1]++;
		}
		if(h[a[i] - 1] >= h[b[i] - 1]) {
			count[b[i] - 1]++;
		}
	}
	
	for(i = 0; i < n; i++) {
		if(count[i] == 0) {
			ans++;
		}
	}
	
	printf("%ld\n", ans);
	
	return 0;
}


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

int main()
{
  int n,m;
  cin >> n >> m;
  int s[2*n];
  for(int i=0;i<2*n;i++)
    s[i]=i+1;
  int a[m];
  for(int i=0;i<m;i++)
    cin >> a[i];
  for(int i=0;i<m;i++){
    if(a[i]==0){
      int v1[n]={},v2[n]={};
      for(int x=0;x<n;x++){
        v1[x]=s[x];
        v2[x]=s[n+x];
      }
      for(int x=0;x<n;x++){
        s[2*x]=v1[x];
        s[2*x+1]=v2[x];
      }
    }
    else{
      int v1[a[i]]={},v2[2*n-a[i]]={};
      for(int x=0;x<a[i];x++)
        v1[x]=s[x];
      for(int x=0;x<2*n-a[i];x++)
        v2[x]=s[a[i]+x];
      for(int x=0;x<2*n-a[i];x++)
        s[x]=v2[x];
      for(int x=0;x<a[i];x++)
        s[2*n-a[i]+x]=v1[x];
    }
  }
  for(int i=0;i<2*n;i++)
    cout << s[i] << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
int main(void){
    int r,d,x,i,y=0;
    
    scanf("%d%d%d",&r,&d,&x);
    
    for(i=0; i<10; i++){
        y=r*x-d;
        printf("%d\n",y);
        x=y;
    }
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int check[26];
int main(){
	string s; cin >>s;
	for(int i=0;i<s.size();i++){
		check[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(check[i]>=2){
			cout <<"no"<< endl;
			return 0;
		}
	}
	cout << "yes"<< endl;
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll H, W;
    cin >> H >> W;
    if (H > W) swap(H, W);
    if (H == 1) {
        cout << 1 << endl;
        return;
    }
    cout << (H * W + 1) / 2 << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i,n){
		cin >> a[i];
	}
	for(int i=k; i<n; ++i){
		if(a[i-k] < a[i]) cout << "Yes\n";
		else cout << "No\n";
		
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 4836
n = int(input())
ans = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(n):
  if i != n-1 and a[i] == a[i+1] - 1:
        ans += c[a[i]-1]
print(ans + sum(b))
  

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

int main(int argc, const char * argv[]) {
    
    int N = 0;
    ll sum = 0;
    
    cin >> N;
 
    rep(i, N){
        if(i % 3 == 0 || i % 5 == 0){
        }else{
            sum += i;
        }
    }
        
    cout << sum;
    
    return 0;

    
}

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

using namespace std;

int a[100010],l[100010],r[100010];

int gcd(int a, int b)
{
    if(a<b) swap(a,b);
    return 0 == b ? a : gcd(b, a%b);
}

int main()
{
    int n,i,ans=1;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    l[0] = a[0];
    for (i=1; i<n; i++)
    {
        l[i]=gcd(l[i - 1], a[i]);
    }
    r[n - 1] = a[n - 1];
    for (i=n-2; ~i; i--)
    {
        r[i] = gcd(r[i + 1], a[i]);
    }
    for (i=1; i<n-1; i++)
    {
        ans = max(gcd(l[i - 1],r[i + 1]),ans);
    }
    cout << max(ans,max(r[1],l[n-2])) << endl;
}

Measured memory_bytes: 1408
n = int(input())
arr = list(map(int,input().split()))
left = []
l = arr[0]
right = []
r = arr[-1]
ans = 0
left = [0 for _ in range(n)]
right =  [0 for _ in range(n)]

def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x
for i in range(n):
    l = gcd(l,arr[i])
    left[i]= l
    r = gcd(r,arr[-(i+1)])
    right[-(i+1)] = r
for i in range(n):
    if i-1 <0:
        a = arr[-1]
    else:
        a = left[i-1]
    if i+1>n-1:
        b = arr[0]
    else:
        b = right[i+1]
    # print('remove:',i,'Left:',a,'Right:',b)
    ans = max(gcd(a,b),ans)
# print(left)
# print(right)
if n == 2:
    print(max(arr))
else:
    print(ans)


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

int main(){
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  for (int i=0 ; i<2 ; i++){
    if (a > b){
      ans += a;
      a--;
    }
    else{
      ans += b;
      b--;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

struct Node {int parent, left, right;};


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

	int n;
	cin >> n;
	map<string, int> ma;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		ma[s] += 1;
	}
	cout << "AC x " << ma["AC"] << endl;
	cout << "WA x " << ma["WA"] << endl;
	cout << "TLE x " << ma["TLE"] << endl;
	cout << "RE x " << ma["RE"] << endl;
}

Measured memory_bytes: 3676