akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 3e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, s, a[N], dp[N][N], ans;
void add(int &a, int b) {
  a += b;
  if (a < mod2) a += mod2;
  a %= mod2;
}
main() {
  file("threesum");
  ios;
  cin >> n >> s;
  fo(i, 1, n, 1) cin >> a[i];
  fo(i, 1, n, 1) {
    memcpy(dp[i], dp[i - 1], sizeof(dp[0]));
    add(dp[i][a[i]], i);
    foo(j, s - a[i], 0, 1) add(dp[i][j + a[i]], dp[i - 1][j]);
    add(ans, dp[i][s]);
  }
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 35584
// ProblemURL : https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_a
// ---------------------------------------------
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(strings.TrimSuffix(s, "FESTIVAL"))
}


Measured memory_bytes: 640
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int m = 0, a = 0, r = 0, c = 0, h = 0, N;
    cin >> N;
    string S;
    for (Int i = 0; i < N; i++) {
        cin >> S;
        switch (S[0]) {
        case 'M':
            m++;
            break;
        case 'A':
            a++;
            break;
        case 'R':
            r++;
            break;
        case 'C':
            c++;
            break;
        case 'H':
            h++;
            break;

        default:
            break;
        }
    }

    Int ans = 0;
    vector<Int> march{m, a, r, c, h};
    Int ro = 5;
    for (Int i = 0; i < ro; i++) {
        for (Int j = i + 1; j < ro; j++) {
            for (Int k = j + 1; k < ro; k++) {
                ans += march[i] * march[j] * march[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=20,maxm=20;
const int mod=1e9+7;
int a[maxm];
long long pw[1<<maxn],iv[1<<maxn];
long long dp[maxm][1<<maxn];
int read(){
    int x=0,y=1;
    char ch=getchar();
    while(ch<48||ch>57){if(ch==45)y=-1;ch=getchar();}
    while(ch>=48&&ch<=57)x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*y;
}
long long power(long long x,long long b){
	long long ans=1;
	while(b){
		if(b&1)ans=ans*x%mod;
		x=x*x%mod;
		b>>=1;
	}
	return ans;
}
long long C(int n,int m){
	return pw[n]*iv[m]%mod*iv[n-m]%mod;
}
int main(){
//    freopen("AT3981.in","r",stdin);
//    freopen("AT3981.out","w",stdout);
   	int n,m;
	n=read();m=read();
	for(int i=1;i<=m;i++)a[m-i+1]=read();
	int num=(1<<n);
	pw[0]=iv[0]=1;
	for(int i=1;i<=num;i++){pw[i]=pw[i-1]*i%mod;iv[i]=iv[i-1]*power(i,mod-2)%mod;}
	dp[0][0]=1;
	for(int i=0;i<m;i++){
		for(int s=0;s<(1<<n);s++){
			if(!dp[i][s])continue;
			(dp[i+1][s]+=dp[i][s])%=mod;
			for(int j=0;j<n;j++){
				if(s&(1<<j))continue;
				(dp[i+1][s|(1<<j)]+=dp[i][s]*C(num-s-a[i+1],(1<<j)-1)%mod*pw[(1<<j)]%mod)%=mod;
			}
		}
	}
	long long ans=0;
	for(int s=0;s<(1<<n);s++){
		if(!dp[m][s])continue;
		int x=s,c=0;
		while(x){
			if(x&1)c++;
			x>>=1;
		}
		int op=(c&1?-1:1);
		ans=(ans+op*dp[m][s]*pw[num-s-1]%mod)%mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans*num%mod);
    return 0;
}


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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] abc = str.split(" ", 0);
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);

		if (a <= b && b <= c) {
			System.out.println(a + " " + b + " " + c);
		} else if (a <= c && c < b) {
			System.out.println(a + " " + c + " " + b);
		} else if (b <= a && a < c) {
			System.out.println(b + " " + a + " " + c);
		} else if (b <= c && c < a) {
			System.out.println(b + " " + c + " " + a);
		} else if (c <= a && a < b) {
			System.out.println(c + " " + a + " " + b);
		} else if (c <= b && b < a) {
			System.out.println(c + " " + b + " " + a);
		}
	}
}

Measured memory_bytes: 24204
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long ;
using ld=long double;
 
 
int main(){
    int n,m;
    cin>>n>>m;
    int v[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {cin>>v[i];
    sum+=v[i];}
    double d=(float)1/(m*4)*sum;
    
    //cout<<d<<" ";
    
    sort(v,v+n);
    int k=n-m;
    for(int i=n-1;i>=k;i--){
        if(d>v[i]){
            cout<<"No";
            return 0;
        }
    }
    
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    if(n %2 == 0) cout << n << endl;
    else cout << 2 * n << endl;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

int main(){
    int r, D, x_first;
    std::cin >> r >> D >> x_first;
    
    int x_start = x_first;
    for (int i = 0; i < 10; ++i)
    {
        x_start = r*x_start - D;
        std::cout << x_start << "\n";
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private int MAX = 1000000000;
    private int MAXA = (int)Math.sqrt(MAX+1);
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        boolean[] primes = new boolean[MAXA];
        Arrays.fill(primes, true);
        for (int i = 2; i < MAXA; i++) {
            if (primes[i]) {
                for (int j = i * 2; j < MAXA; j += i) {
                    primes[j] = false;
                }
            }
        }
        int[] xs = new int[input.nextInt()];
        for (int i = 0; i < xs.length; i++) {
            xs[i] = input.nextInt();
        }
        int count = 0;
        for (int x : xs) {
            boolean flag = true;
            for (int i = 2; i * i <= x; i++) {
                if (primes[i] && x % i == 0) {
                    flag = false;
                }
            }
            if (flag) {
                count++;
            }
        }
        System.out.println(count);
    }
    
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
}

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

using namespace std;

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

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

    double ans = 0;
    for (int i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            ans += x;
        } else {
            ans += 380000.0 * x;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()

	if a > 0 && b > 0 {
		fmt.Println("Positive")
		return
	}
	if a <= 0 && b >= 0 {
		fmt.Println("Zero")
		return
	}

	if (b-a)%2 == 0 {
		fmt.Println("Negative")
		return
	}
	fmt.Println("Positive")
	return
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
//解説実装

#include <iostream>

using namespace std;

int N;
int A[100005];

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

int solve() {

  /*
   * L[i]: A1, A2, ..., Ai-1までのgcd
   * R[i]: Ai, Ai+1, ..., ANまでのgcd 
  */
  int L[100005], R[100005];

  /*
   * L[i] = gcd(L[i - 1], A[i - 1])
   * R[i] = gcd(R[i + 1], R[i])
   * 但し，L[0] = R[N + 1] = 0
   * gcd(X, 0) = gcd(0, X) = X
  */
  L[1] = A[1];
  R[N] = A[N];

  for (int i = 2; i <= N; i++) {
    L[i] = gcd(L[i - 1], A[i - 1]);
  }
    
  for (int i = N - 1; i >= 1; i--) {
    R[i] = gcd(R[i + 1], A[i]);
  }



  /* A1又はANを消した場合のgcd */
  int m = max(R[2], L[N]);

  /* 2〜N -1のいずれかを消した場合のgcd*/
  for (int i = 2; i <= N - 1; i++) {
    m = max(m, gcd(L[i], R[i + 1]));
  }

  return m;
    
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  
  int ans = solve();
  
  printf("%d\n", ans);
  
  

}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#include<vector>
#include<queue>
#include<limits>
template<typename T>
vector<T>dijkstra(int s,const vector<vector<pair<int,T> > >&G,T INF=numeric_limits<T>::max())
{
	int n=G.size();
	vector<T>d(n,INF);
	vector<int>parent(n,-1);
	priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > >P;
	d[s]=0;
	P.push(make_pair(d[s],s));
	while(!P.empty())
	{
		pair<T,int>p=P.top();P.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(const pair<int,T>&e:G[v])
		{
			int u=e.first;
			T cost=d[v]+e.second;
			if(d[u]>cost)
			{
				d[u]=cost;
				parent[u]=v;
				P.push(make_pair(d[u],u));
			}
		}
	}
	return d;
}
int N,M,S,T;
long mod=1e9+7;
vector<pair<pair<int,int>,int> >edge;
main()
{
	cin>>N>>M>>S>>T;
	S--,T--;
	vector<vector<pair<int,long> > >G(N);
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		edge.push_back({{a,b},c});
		G[a].push_back({b,c});
		G[b].push_back({a,c});
	}
	vector<long>d1=dijkstra(S,G);
	vector<long>d2=dijkstra(T,G);
	vector<long>dp1(N,0),dp2(N,0);
	vector<bool>u1(N,false),u2(N,false);
	dp1[S]=1;
	u1[S]=1;
	priority_queue<pair<long,int> >P;
	P.push({0,S});
	while(!P.empty())
	{
		int u=P.top().second;P.pop();
		for(int i=0;i<G[u].size();i++)
		{
			if(d1[G[u][i].first]!=d1[u]+G[u][i].second)continue;
			int v=G[u][i].first;
			long d=G[u][i].second;
			(dp1[v]+=dp1[u])%=mod;
			if(!u1[v])
			{
				P.push({-d1[v],v});
				u1[v]=1;
			}
		}
	}
	dp2[T]=1;
	u2[T]=1;
	P.push({0,T});
	while(!P.empty())
	{
		int u=P.top().second;P.pop();
		for(int i=0;i<G[u].size();i++)
		{
			if(d2[G[u][i].first]!=d2[u]+G[u][i].second)continue;
			int v=G[u][i].first;
			long d=G[u][i].second;
			(dp2[v]+=dp2[u])%=mod;
			if(!u2[v])
			{
				P.push({-d2[v],v});
				u2[v]=1;
			}
		}
	}
	vector<pair<long,long> >E;
	long sa=0,sb=0;
	vector<bool>pu(N,false);
	long ans=dp1[T]*dp1[T]%mod;
	for(int i=0;i<N;i++)
	{
		if(d1[i]==d2[i]&&d1[i]+d2[i]==d1[T])
		{
			pu[i]=1;
			ans=(ans-dp1[i]*dp2[i]%mod*dp1[i]%mod*dp2[i]%mod+mod)%mod;
		}
	}
	for(int i=0;i<edge.size();i++)
	{
		int u=edge[i].first.first,v=edge[i].first.second;
		if(d1[u]>d1[v])swap(u,v);
		if(d1[u]+d2[v]+edge[i].second!=d1[T])continue;
		if(pu[u]||pu[v])continue;
		if(abs(d1[u]-d1[v])<=edge[i].second)
		{
			if(d1[u]<d2[u]&&d1[v]>d2[v])
			{
				ans=(ans-dp1[u]*dp2[v]%mod*dp1[u]%mod*dp2[v]%mod+mod)%mod;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 21128
#include<bits/stdc++.h> 
using namespace std; 
bool ch[2][105]={0};  
char a[105][105];
int h,w;
int main(){ 
  	int i,j;
  	cin>>h>>w;
  	for(i=0;i<h;i++) 
    for(j=0;j<w;j++){   
        cin>>a[i][j];
      	if(a[i][j]=='#'){
		  	ch[0][i]=1;ch[1][j]=1;    
		} 
    }
  	for(i=0;i<h;i++){   
    	for(j=0;j<w;j++)  
      if(ch[0][i]&&ch[1][j]) cout<<a[i][j]; 
      
    cout<<endl;
  	}
  	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> ans(n, 0);
	rep(i, n-1){
		int in;
		cin >> in;
		in--;
		ans.at(in)++;
	}
	rep(i, n){
		cout << ans.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 4056
# -*- coding: utf-8 -*-

N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

ans = 0
for k in range(N):
    res = 0
    for x in range(N):
        if x < k:
            res += A[0][x]
        elif x==k:
            res += A[0][x]+A[1][x]
        else:
            res += A[1][x]

    ans = max(ans,res)

print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL<<60;
int main() {
  int A,B,C,K,ans=0; cin>>A>>B>>C>>K;
  while(A>=B){
    B*=2;
    ans++;
  }
  while(B>=C){
    C*=2;
    ans++;
  }
  if(ans<=K) cout<<"Yes";
  else cout<<"No";

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
	//freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	int a[n + 5];

	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	int prev = a[0];
	long long ans = 0LL;
	for (int i = 1; i < n; ++i){
		if(a[i] < prev)
			ans += (prev - a[i]);
		prev = max(a[i], prev);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4316
def find(i)
  if $parent[i]
    return find($parent[i])
  else
    return i
  end
end

n, m = gets.split.map(&:to_i)

bridges = m.times.map { gets.split.map(&:to_i) }
$parent = [nil] + Array.new(n, nil)
rank = [nil] + Array.new(n, 1)

ans = []
inconv = (n - 1) * n / 2
bridges.reverse_each do |x, y|
  ans << inconv
  xset = find(x)
  yset = find(y)
  if xset != yset
    inconv -= rank[xset] * rank[yset]

    if xset > yset
      xset, yset = yset, xset
    end
    $parent[xset] = yset
    rank[yset] += rank[xset]
  end
end

puts ans.reverse


Measured memory_bytes: 14772
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

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

	for (int i = 0;i * 7 <= n;i++) {
		if ((n - (7 * i)) % 4 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>
#include<queue>
#include<cmath>
#include<numeric>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<iomanip>
#include<functional>
#include<bitset>

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

using namespace std;
typedef long long ll;

int n;
int t[100010],x[100010],y[100010];

bool move(int place){
    int xdist = abs(x[place+1] - x[place]),ydist = abs(y[place+1] - y[place]);
    int dist = xdist + ydist;
    int time = t[place+1] - t[place];
    if(dist > time) return 0;
    else{
        if(dist%2 == time%2) return 1;
        else return 0;
    }
}

int main(){
    t[0] = 0;x[0]=0;y[0]=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
    bool flag;
    rep(i,n){
        flag = move(i);
        if(!flag) break;
    }
    cout<<(flag? "Yes":"No")<<endl;

    return 0;
}

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

int main() {
    int n;
    string ans;
    cin >> n;
    switch(n%7) {
        case 0:
            ans = "thu";
            break;
        case 1:
            ans = "fri";
            break;
        case 2:
            ans = "sat";
            break;
        case 3:
            ans = "sun";
            break;
        case 4:
            ans = "mon";
            break;
        case 5:
            ans = "tue";
            break;
        case 6:
            ans = "wed";
            break;
        default:
            ans = "";
            break;
    }
    cout << ans << endl;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==5&&b==7&&c==5) cout << "YES";
  else if(a==5&&b==5&&c==7) cout << "YES";
  else if(a==7&&b==5&&c==5) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){   
    int n,x,i,j,k,v;   
    while(1){       
        cin >> n;       
        cin >> x;
        v=0;
        if(n==0&&x==0)break;       
        for(i=1;i<=n-2;i++){           
            for(j=i+1;j<=n-1;j++){               
                for(k=j+1;k<=n;k++){                   
                    if(i+j+k==x){                       
                        v=v+1;                   
                    }               
                    
                }           
                
            }       
            
        }       
        cout << v << endl;   
        }
    }


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

void startup()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


int main()
{
	startup();
				
				  		string s;
				  		cin>>s;
				  		int i=0;
				  		int ans=INT_MIN;

				  		while(i<s.size())
				  		{
				  			if(s[i]=='R')
				  			{
				  				int sum=0;
				  				while(s[i]=='R' && i<s.size())
				  				{
				  					++sum;
				  					++i;
				  				}
				  				ans=max(ans,sum);
				  			}
				  			else
				  			{
				  				++i;
				  			}
				  		}
				  		if(ans==INT_MIN)
				  			cout<<"0";
				  		else
				  			cout<<ans;

	
	return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>
#define MAX 101

void dfs();
void reVisit(int);

int Adj[MAX][MAX];
int D[MAX];
int F[MAX];
int n, time;

int main()
{
  int i, j;
  int u, v, k;

  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      for(j = 1; j <= n; j++)
	{
	  Adj[i][j] = 0;
	}
    }
  for(i = 1; i <= n; i++)
    {
      scanf("%d %d", &u, &k);
      for(j = 1; j <= k; j++)
	{
	  scanf("%d", &v);
	  Adj[u][v] = 1;
	}
    }

  dfs();

  for(i = 1; i <= n; i++)
    {
      printf("%d %d %d\n", i, D[i], F[i]);
    }

 return 0;
}

void dfs()
{
  int i;

  time = 0;

  for(i = 0; i < n; i++)
    {
      D[i] = 0;
      F[i] = 0;
    }

  for(i = 1; i <= n; i++)
    {
      if(D[i] == 0)
	reVisit(i);
    }
}

void reVisit(int u)
{
  int i, j;

  D[u] = ++time;


  for(i = 1; i <= n; i++)
    {
      if(Adj[u][i] == 1 && D[i] == 0)
	{
	  reVisit(i);
	}
    }

  F[u] = ++time;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

int main(){
	int c1, c2, c3;
	while(cin >> c1 >> c2 >> c3){
		if(cin.eof()) break;
		int odd = 20-(c1+c2);
		double count = 0.0;
		for(int i = 1; i <= 10; i++){
			if(i==c1||i==c2||i==c3)continue;
			if(odd>=i) count++;
		}
		double ans = count/7.0;
		if(ans >= 0.5) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b&&b<c)
	{
	printf("Yes\n");
	}
	else
	{
	printf("No\n");
	}
	return 0;
}



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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  string S;
  cin>>S;
  vector<int> g(3);
  for(auto x:S) {
    int t = x - 'a';
    g[t]++;
  }
  bool ok = true;
  if(max(max(abs(g[0]-g[1]),abs(g[1]-g[2])),abs(g[2]-g[0]))>1) ok =false;
  if(ok) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3692
n,m = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
area=0
mod=10**9+7

x=0

for i in range(n):
  x += -(n-i-1)*X[i]+i*X[i]

y = 0

for i in range(m):
  y += -(m-i-1)*Y[i]+i*Y[i]

print(x*y%mod)

Measured memory_bytes: 18624
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
template <usize N, class T, class... Args, std::enable_if_t<N==0, int> = 0>
auto mkvec(Args... args) {
    return T(args...);
}
template <usize N, class T, class... Args, std::enable_if_t<N!=0, int> = 0>
auto mkvec(usize sz, Args... args) {
    using value_type = std::decay_t<decltype(mkvec<N-1, T>(args...))>;
    return vec<value_type>(sz, mkvec<N-1, T>(args...));
}
auto cmn = [](auto& x, auto y){ if (x>y) { x=y; return true; } return false; };
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize max = 400;
    u32 inf = numr<u32>::max();

    usize n, a, b;
    std::cin >> n >> a >> b;
    auto dp = mkvec<2, u32>(max+1, max+1, inf);
    dp.at(0).at(0) = 0;
    while (n--) {
        usize u, v, c;
        std::cin >> u >> v >> c;
        for (usize i=max-u; i!=numr<usize>::max(); i--) {
        for (usize j=max-v; j!=numr<usize>::max(); j--) {
            cmn(dp.at(i+u).at(j+v), dp.at(i).at(j) + c);
        }}
    }

    u32 ans = inf;
    for (usize i=1; i*a<=max && i*b<=max; i++) {
        cmn(ans, dp.at(i*a).at(i*b));
    }
    std::cout << (ans == inf ? -1 : i32(ans)) << '\n';
}


Measured memory_bytes: 896
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll INF = 1e18;
const ll N = 2e5 + 10;
ll n;
ll tree[N * 8];

void update(ll idx , ll l , ll r , ll x , ll val) {
  if (r < x || l > x) return;
  if (l == x && r == x) {
    tree[idx] = val;
    return;
  }
  ll mid = (l + r) / 2;
  update(idx * 2 , l , mid , x , val);
  update(idx * 2 + 1 , mid + 1 , r , x , val);
  tree[idx] = min(tree[idx * 2] , tree[idx * 2 + 1]);
  return;
}

ll rangeMin(ll idx , ll l , ll r , ll a , ll b) {
  if (r < a || l > b) return INF;
  if (a <= l && r <= b) return tree[idx];
  ll mid = (l + r) / 2;
  return min(
    rangeMin(idx * 2 , l , mid , a , b),
    rangeMin(idx * 2 + 1 , mid + 1 , r , a , b)
  );
}

int main() {
  
  in(n);
  vector <ii> v(n + 1), kpy(n + 1);
  for (ll i = 1 ; i <= n ; i++) {
    in(v[i].fi); in(v[i].se);
  }

  sort(v.begin() , v.end());
  for (ll i = 1 ; i <= n ; i++) {
    kpy[i] = {v[i].se , i};
    update(1 , 1 , n , i , INF);
  }
  sort(kpy.begin() , kpy.end());

  ll ans = 0;
  for (ll i = 1 ; i <= n ; i++) {
    ll idx = kpy[i].se;
    ll cur = rangeMin(1 , 1 , n , 1 , idx - 1);
    if (cur < INF) {
      ans = max(ans , v[idx].fi + v[idx].se - cur);
    }
    update(1 , 1 , n , idx , v[idx].fi + v[idx].se);
  }
  for (int i = 1 ; i <= n ; i++) {
    update(1 , 1 , n , i , INF);
  }

  kpy[0] = {INF , INF};
  for (int i = 1 ; i <= n ; i++) {
    kpy[i].se = -kpy[i].se;
  }
  sort(kpy.rbegin() , kpy.rend());
  for (int i = 1 ; i <= n ; i++) {
    int idx = -kpy[i].se;
    ll cur = rangeMin(1 , 1 , n , 1 , idx - 1);
    if (cur < INF) {
      ans = max(ans , v[idx].fi - v[idx].se - cur);
    }
    update(1 , 1 , n , idx , v[idx].fi - v[idx].se);
  }

  printf("%lld\n" , ans);
  return 0;
}

void in(ll &x){
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 13480
# include "cstdio"

int N,A,B;

int main(){
	scanf("%d",&N);
	switch(N){
		case 1:
			printf("Hello World");
			break;
		case 2:
			scanf("%d%d",&A,&B);
			printf("%d",A+B);
			break;
	}
	return 0; 
}

Measured memory_bytes: 128
#include <stdio.h>

typedef struct STRUCT00 {
  int MEMBER00 ;
  int MEMBER01 ;
  int MEMBER02 ;
  int MEMBER03 ;
  int MEMBER04 ;
  int MEMBER05 ;
} STRUCT00 ;

STRUCT00 * FUNC00 ( STRUCT00 * ARG00 , char ARG01 ) {
  int VAR00 ;

  if ( ARG01 == 'N' ) {
    VAR00 = ARG00 -> MEMBER01 ;
    ARG00 -> MEMBER01 = ARG00 -> MEMBER05 ;
    ARG00 -> MEMBER05 = ARG00 -> MEMBER04 ;
    ARG00 -> MEMBER04 = ARG00 -> MEMBER00 ;
    ARG00 -> MEMBER00 = VAR00 ;
  } else if ( ARG01 == 'S' ) {
    VAR00 = ARG00 -> MEMBER04 ;
    ARG00 -> MEMBER04 = ARG00 -> MEMBER05 ;
    ARG00 -> MEMBER05 = ARG00 -> MEMBER01 ;
    ARG00 -> MEMBER01 = ARG00 -> MEMBER00 ;
    ARG00 -> MEMBER00 = VAR00 ;
  } else if ( ARG01 == 'E' ) {
    VAR00 = ARG00 -> MEMBER03 ;
    ARG00 -> MEMBER03 = ARG00 -> MEMBER05 ;
    ARG00 -> MEMBER05 = ARG00 -> MEMBER02 ;
    ARG00 -> MEMBER02 = ARG00 -> MEMBER00 ;
    ARG00 -> MEMBER00 = VAR00 ;
  } else if ( ARG01 == 'W' ) {
    VAR00 = ARG00 -> MEMBER02 ;
    ARG00 -> MEMBER02 = ARG00 -> MEMBER05 ;
    ARG00 -> MEMBER05 = ARG00 -> MEMBER03 ;
    ARG00 -> MEMBER03 = ARG00 -> MEMBER00 ;
    ARG00 -> MEMBER00 = VAR00 ;
  }

  return ARG00 ;
}

int main ( void ) {
  STRUCT00 VAR01 ;
  STRUCT00 * VAR02 ;
  char VAR03 ;
  int VAR04 , VAR05 , VAR06 , VAR07 , VAR08 ;

  VAR02 = & VAR01 ;
  scanf ( "%d%d%d%d%d%d" , & VAR01 . MEMBER00 , & VAR01 . MEMBER01 , & VAR01 . MEMBER02 , & VAR01 . MEMBER03 , & VAR01 . MEMBER04 , & VAR01 . MEMBER05 ) ;
  scanf ( "%d" , & VAR06 ) ;
  for ( VAR05 = 0 ; VAR05 < VAR06 ; VAR05 ++ ) {
    scanf ( "%d%d" , & VAR07 , & VAR08 ) ;
    if ( VAR07 == VAR01 . MEMBER00 ) ;
    else if ( VAR07 == VAR01 . MEMBER01 ) VAR02 = FUNC00 ( VAR02 , 'N' ) ;
    else if ( VAR07 == VAR01 . MEMBER02 ) VAR02 = FUNC00 ( VAR02 , 'W' ) ;
    else if ( VAR07 == VAR01 . MEMBER03 ) VAR02 = FUNC00 ( VAR02 , 'E' ) ;
    else if ( VAR07 == VAR01 . MEMBER04 ) VAR02 = FUNC00 ( VAR02 , 'S' ) ;
    else if ( VAR07 == VAR01 . MEMBER05 ) {
      VAR02 = FUNC00 ( VAR02 , 'N' ) ; VAR02 = FUNC00 ( VAR02 , 'N' ) ;
    }

    if ( VAR08 == VAR01 . MEMBER01 ) printf ( "%d\n" , VAR01 . MEMBER02 ) ;
    else if ( VAR08 == VAR01 . MEMBER02 ) printf ( "%d\n" , VAR01 . MEMBER04 ) ;
    else if ( VAR08 == VAR01 . MEMBER03 ) printf ( "%d\n" , VAR01 . MEMBER01 ) ;
    else if ( VAR08 == VAR01 . MEMBER04 ) printf ( "%d\n" , VAR01 . MEMBER03 ) ;
  }

  return 0 ;
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

int mv[3] = {0,-1,1};

void dfs(int x,int y){
  if(dp[x][y] == -1)return;
  dp[x][y] = -1;
  rep(i,0,3){
    rep(j,0,3){
      if(mv[i] == 0 && mv[j] == 0)continue;
      if(dp[x+mv[i]][y+mv[j]] == 1)dfs(x + mv[i],y + mv[j]);
    }
  }
}

int main(){
  while(1){
    cin >> m >> n;
    if(!n && !m)break;
    clr(dp,-1);
    lep(i,1,n){
      lep(j,1,m){
        cin >> dp[i][j];
      }
    }
    ll ans = 0;
    lep(i,1,n){
      lep(j,1,m){
        if(dp[i][j] == 1){
          ans++;
          dfs(i,j);
        }
      }
    }
    print(ans);
  }
  return 0;
}


Measured memory_bytes: 7104
# ABC135C - City Savers
# greedy algorithm
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    B = tuple(map(int, input().rstrip().split()))
    ans, a1 = 0, A[0]
    for a2, b in zip(A[1:], B):
        cnt1 = min(a1, b)
        cnt2 = min(a2, b - cnt1)
        ans += cnt1 + cnt2
        a1 = a2 - cnt2  # a2 becomes a1 in next turn
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 19648
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

template <typename T>
class SlideMaximum
{
    // (位置, 値)
    std::deque<std::pair<int, T>> deq;
    int pos, window;

  public:
    SlideMaximum(int _w) : pos(0), window(_w) {}
    T query(T val)
    {
        while (!deq.empty() && deq.front().first <= pos - window)
            deq.pop_front();
        while (!deq.empty() && deq.back().second <= val)
            deq.pop_back();
        deq.push_back(std::make_pair(pos++, val));
        return deq.front().second;
    }
};

ll N, M, K;
vector<ll> A(100010);

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

    cin >> N >> M >> K;
    vector<vector<ll>> dp(K+1,vector<ll>(N+1,0));
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        dp[1][i] = A[i];
    }
    for (ll i = 2; i <= K; i++)
    {
        SlideMaximum<ll> sm(M);
        ll ma = 0;
        for(int j=max(1LL, i-M);j<=i-2;j++)
        {
            ma = sm.query(dp[i-1][j]);
        }
        for (ll j = i; j <= N; j++)
        {
            ma = sm.query(dp[i-1][j-1]);
            ll v = i * A[j] + ma;
            dp[i][j] = v;
        }
    }
    ll ret = 0;
    for(int i=K;i<=N;i++) ret = max(ret, dp[K][i]);
    cout << ret << endl;
}


Measured memory_bytes: 237824
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

correct = [0 for i in range(N)]
for i in range(Q):
    correct[A[i]-1] += 1

for i in range(N):
    if Q - correct[i] < K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8716
from collections import Counter

mod = (10 ** 9 + 7) ** 5
MAX = 2 * 10 ** 5 + 1 # これは変動するので注意

def com_init(MAX, mod):
    fac = [0] * MAX
    finv = [0] * MAX
    inv = [0] * MAX
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv

fac, finv = com_init(MAX, mod)

def nCr(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

n = int(input())
A = list(map(int, input().split()))

counter = Counter(A)

mapping = {}
for k, v in counter.items():
    mapping[k] = nCr(v, 2)

all_sum = 0
for v in mapping.values():
    all_sum += v

memo = {}
for i in range(n):
    num = A[i]
    if num in memo:
        print(memo[num])
    else:
        t = counter[num]
        ans = all_sum - nCr(t, 2) + nCr(t - 1, 2)
        print(ans)
        memo[num] = ans



Measured memory_bytes: 127548
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<int> a(n+1,0);
    for(int i=0;i<n;i++)cin>>a[i+1];
    a.push_back(0);
    int cost=0;
    for(int i=1;i<n+2;i++){
        cost+=abs(a[i]-a[i-1]);
    }
    for(int i=1;i<n+1;i++){
        int d = abs(a[i-1]-a[i+1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1]);
        if((a[i-1]<=a[i]&&a[i]<=a[i+1])||(a[i-1]>=a[i]&&a[i]>=a[i+1]))cout<<cost<<endl;
        else cout<<cost+d<<endl;
    }
}

Measured memory_bytes: 1656
#include <iostream>
using namespace std;
 
int main() {
	int a, b;
	char op;
	while(1){
		cin >> a >> op >> b;
		if(op == '?')break;
 
		if(op == '+')cout << a + b << endl;
		if(op == '-')cout << a - b << endl;
		if(op == '*')cout << a * b << endl;
		if(op == '/')cout << a / b << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();
		int[][] table = new int[r + 1][c + 1];
		int sum = 0;

		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				int n = scan.nextInt();
				table[i][j] = n;
				table[i][c] += n;
				table[r][j] += n;
				sum += n;
			}
		}
		table[r][c] = sum;

		for(int i = 0; i < r + 1; i++){
			for(int j = 0; j < c + 1; j++){
				System.out.printf((j != c) ? "%d " : "%d\n", table[i][j]);
			}
		}
	}
}

Measured memory_bytes: 50268
N=int(input())
A=list(map(int,input().split()))
H=list(range(1,N+1))
c=0
ans=0
for i in range(N):
  if A[i]==H[c]:
    c+=1
  else:
    ans+=1
if ans==N:
  print("-1")
else:
  print(ans)

Measured memory_bytes: 32284
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]

import networkx as nx
G = nx.Graph()
G.add_edges_from(a)
nx.connected_components(G)

max_size = 1

for component in nx.connected_components(G):
    if len(component) > max_size:
        max_cluster = component
        max_size = len(max_cluster)
print(max_size)

Measured memory_bytes: 278620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;

int main(){
  int H,W;cin>>H>>W;
  vector<vector<int>> data(H,vector<int>(W,1));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>data[i][j];
    }
  }
  int count=0;
  vector<pair < pair<int,int>,pair<int,int> > > ans;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j]%2==0){
        continue;
      }else{
        data[i][j]--;
        if(j!=W-1){
          ans.push_back({{i,j},{i,j+1}});
          data[i][j+1]++;
          count++;
        }else{
          if(i!=H-1){
            ans.push_back({{i,j},{i+1,j}});
            data[i+1][j]++;
            count++;
          }else{

          }
        }
      }
    }
  }
  cout<<count<<endl;
  for(int i=0;i<count;i++){
    cout<<ans[i].first.first+1<<" "<<ans[i].first.second+1<<" "<<ans[i].second.first+1<<" "<<ans[i].second.second+1<<endl;
  }
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    bool f = true;

    rep(i, h) rep(j, w) {
        if (s[i][j] == '#') {
            bool f2 = false;
            rep(k, 4) {
                int ty = i + dy[k];
                int tx = j + dx[k];
                if (ty >= 0 && ty < h && tx >= 0 && tx < w) {
                    if (s[ty][tx] == '#') f2 = true;
                }
            }
            if (!f2) f = false;
        }
    }

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int work(int n,int m)
{
	int ans=2100000000;
	for (int i=1;i<n;i++)
	{
		long long mx=max((long long)i*m,(long long)(m+1)/2*(n-i));
		long long minn=min((long long)i*m,(long long)m/2*(n-i));
		ans=min((long long)ans,mx-minn);
	}
	return ans;
}
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	if ((n%3==0)||(m%3==0)) printf("0\n");
	else
	{
		int ans=min(n,m);
		ans=min(ans,work(n,m));
		ans=min(ans,work(m,n));
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 384
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N-1):
        if A[i] > A[i+1]:
            ans += A[i]-A[i+1]
            A[i+1] = A[i]
    print(ans)
resolve()

Measured memory_bytes: 32060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            while ((s = Console.ReadLine()) != "-1")
            {
                Solve(int.Parse(s));
            }
        }

        static void Solve(int n)
        {
            List<int> answer = new List<int>();

            for (int i = 0;; i++)
            {
                answer.Add(n % 4);
                if (n / 4 == 0)
                    break;
                n /= 4;
            }

            answer.Reverse();
            foreach (int i in answer)
            {
                Console.Write(i);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5848
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;


main()
{
     long long N;

    cin >> N;

     long long ans = 1e18;
    for( long long i = 1; i * i <=  N; i++)
    { if(N % i == 0)
    {
        long long j = N / i;
        ans = min(ans,i + j - 2);
    }


    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

tmp = [0]*N

for i in range(1,N):
    if A[i] <= A[i-1]+tmp[i-1]:
        tmp[i] =  A[i-1] + tmp[i-1] - A[i] 

ans = sum(tmp)

print(ans)


Measured memory_bytes: 32332
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long n, sum = 1; cin >> n;
	int j = 2;//1, 2, 3
	long long k;
	for (long i = 0; i < n; i++){
		long long a; cin >> a;
		if (i == 0);
		else if (j == 2) {
			if (k > a)j = 1;
			else if (k < a)j = 3;
		}
		else if (k < a&&j == 1) { j = 2; sum++; }
		else if (k > a&&j == 3) { j = 2; sum++; }
		k = a;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] str=sc.next().toCharArray();
		sc.close();
		int first=0,l=0;
		char oc=str[0],nc;
		StringBuilder ans = new StringBuilder();
		StringBuilder temp=new StringBuilder();
		for(int i=1;i<str.length;i++) {
			nc=str[i];
			if(oc=='R'&&nc=='L') {
				l=i;
			}else if(oc=='L'&&nc=='R'){
				int rNum=l-first,lNum=i-l;
				int rVal=lNum/2,lVal=rNum/2;
				rNum-=lVal;
				lVal+=lNum-rVal;
				rVal+=rNum;
				ans.append(" ");
				ans.append(rVal);
				ans.append(" ");
				ans.append(lVal);
				ans.append(temp.toString());
				temp=new StringBuilder();
				first=i;
			}else if(oc=='R'&&nc=='R') {
				ans.append(" 0");
			}else {//LL
				temp.append(" 0");
			}
			oc=nc;
		}
		int rNum=l-first,lNum=str.length-l;
		int rVal=lNum/2,lVal=rNum/2;
		rNum-=lVal;
		lVal+=lNum-rVal;
		rVal+=rNum;
		ans.append(" ");
		ans.append(rVal);
		ans.append(" ");
		ans.append(lVal);
		ans.append(temp.toString());
		System.out.println(ans.substring(1));
	}

}


Measured memory_bytes: 30604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int sum=0;
  for(int i=A;i<=B;i++){
    if((i/10000==i%10)&&((i/1000-(i/10000)*10)==((i%100)-i%10)/10)){
      sum++;
    }
  }
       cout<<sum<<endl;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

struct UnionFind {
    int n;
    vector<int> dat;
    UnionFind(int size): n(size), dat(size, -1) { }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (dat[y] < dat[x]) swap(x, y);
            dat[x] += dat[y];
            dat[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return dat[x] < 0 ? x : dat[x] = root(dat[x]);
    }
    int size(int x){
        return -dat[root(x)];
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,m; cin >> n >> m;
    auto uf = UnionFind(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans = 1;
    rep(i,n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a,b,h;
int main(){
	scanf("%d%d%d",&a,&b,&h);
	printf("%d\n",(a+b)*h/2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ' ';  } return os;  }


class SegTree {
public:
  SegTree(vector<ll> vec) {
    int size = vec.size();
    n = 1;
    while (n<size) n*=2;

    node.resize(2*n-1, IDENT);
    lazy.resize(2*n-1, INF);

    loop(i,0,size) node[i+n-1] = vec[i];
    for (int i=n-2; i>=0; i--) node[i] = f(node[c1(i)], node[c2(i)]);
  }

  void update(int l, int r, ll v) {
    updateRec(l,r,v,0,0,n);
  }

  ll get(int l, int r) {
    return getRec(l,r,0,0,n);
  }

  void debug() {
    cout << "node: " << node << endl;
    cout << "lazy: " << lazy << endl;
  }

private:
  int n;
  vector<ll> node, lazy;
  const ll INF = 1000000000000000000;
  const ll IDENT = 0;

  ll f(ll a, ll b) {
    return max(a, b);
  }

  void f_lazy(ll &a, ll b) {
    a = b;
  }

  inline int p(int i) { return (i-1)/2; }
  inline int c1(int i) { return i*2+1; }
  inline int c2(int i) { return i*2+2; }

  void eval(int k, int l, int r) {
    if (lazy[k] == INF) return;
    f_lazy(node[k], lazy[k]);

    if (r-l>1) {
      f_lazy(lazy[c1(k)], lazy[k] / 2);
      f_lazy(lazy[c2(k)], lazy[k] / 2);
    }

    lazy[k] = INF;
  }

  void updateRec(int l, int r, ll v, int k, int selfL, int selfR) {
    eval(k, l, r);
    if (r <= selfL or selfR <= l) return;
    if (l <= selfL and selfR <= r) {
      lazy[k] = (r-l)*v;
      eval(k, l, r);
      return;
    }

    updateRec(l, r, v, c1(k), selfL, (selfL+selfR)/2);
    updateRec(l, r, v, c2(k), (selfL+selfR)/2, selfR);
    node[k] = f(node[c1(k)], node[c2(k)]);
  }

  ll getRec(int l, int r, int k, int selfL, int selfR) {
    if (r <= selfL or selfR <= l) return IDENT;
    eval(k, l, r);
    if (l <= selfL and selfR <= r) {
      eval(k, l, r);
      return node[k];
    }

    return f(
      getRec(l, r, c1(k), selfL, (selfL+selfR)/2),
      getRec(l, r, c2(k), (selfL+selfR)/2, selfR)
    );
  }
};


int main() {
  int n,k; cin >> n >> k;
  vector<ll> A(n, 0);
  loop(i,0,n) cin >> A[i];
  SegTree seg(vector<ll>(600100, 0));

  loop(i,0,n) {
    ll a = A[i];
    ll ma = seg.get(max(a-k, 0LL), a+k+1);
    seg.update(a, a+1, ma+1);
    // seg.debug();
  }

  ll ans = 0;
  loop(i,0,300000) {
    ans = max(ans, seg.get(i,i+1));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 43132