akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

const ll INF = 1e15;

int main()
{
    string S;
    cin >> S;
    bool tmp = false;
    int idx[2]={0,0};
    for(int i = 2;i<=S.length()-2;i++){
        if(S[i]=='C'){
            tmp=true;
            idx[1]=i;
            break;
        }
    }
    REP(i,S.length()){
        if(idx[0] == i or idx[1]==i) continue;
        if(S[i]<'a' || S[i] >'z'){
            tmp=false;
        }
    }

    bool ans = tmp;
    ans = ans && S[0]=='A';
    if(ans){
        cout << "AC" <<endl;
    }else{
        cout << "WA" <<endl;
    }
}

Measured memory_bytes: 256
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 = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;

        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j < n ; j++) {
                ans = Math.max(ans, Math.abs(a[i] - a[j]));
            }

        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21204
#include <cstdio>

int check(int ABCD[], int ops)
{
  int ans = ABCD[0];
  for (int i = 0; i < 3; i++) {
    if (ops % 2 == 0) ans += ABCD[i + 1];
    else ans -= ABCD[i + 1];
    ops /= 2;
  }
  if (ans == 7) return 1;
  else return 0;
}

void print_answer(int ABCD[], int ops)
{
  printf("%d", ABCD[0]);
  for (int i = 0; i < 3; i++) {
    printf("%c%d", ops % 2 == 0 ? '+' : '-', ABCD[i + 1]);
    ops /= 2;
  }
  printf("=7\n");
}

int main()
{
  int X;
  int ABCD[4];
  if (scanf("%d", &X) < 1) return 1;
  for (int i = 0; i < 4; i++) {
    ABCD[3 - i] = X % 10;
    X /= 10;
  }
  int ops = 0;
  for (; ops < 8; ops++) {
    if (check(ABCD, ops)) break;
  }
  print_answer(ABCD, ops);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[10002], b[10002];
    ll s = 0, t = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++){
        if(b[i] < a[i]) s += a[i] - b[i];
        else t += (b[i] - a[i]) / 2;
    }
    if(t >= s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	
	string S;
	cin >> S;

	bool flag = true;

	if (S[0] != 'A') { flag = false; }

	int n = S.find('C');

	if (n<2 || n>S.size()-2) { flag = false; }

	if (n > 0) {
		S[n] = 'a';
	}
	for (int i = 1; i < S.size(); i++) {
		if (S[i] < 'a') {
			flag = false;
		}
	}
	
	if (flag == true) {
		cout << "AC";
	}
	else {
		cout << "WA";
	}

	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

struct Game {
    int i, j, date;
    Game(int i, int j, int date) : i(i), j(j), date(date) {}
};

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

    int n;
    cin >> n;

    vvi a(n, vi(n - 1));
    rep(i, 0, n) {
        rep(j, 0, n - 1) {
            int x;
            cin >> x;
            a[i][j] = x - 1;
        }
    }

    // 初日に出来る試合をキューにプッシュ．
    queue<Game> q;
    rep(i, 0, n) {
        if (i < a[i][0] && a[a[i][0]][0] == i) { q.emplace(i, a[i][0], 1); }
    }

    // 全試合数，日数．
    int cnt = 0, date = 0;

    // 各プレイヤーの終了した試合数．
    vi done(n, 0);

    while (!q.empty()) {
        Game g = q.front();
        q.pop();

        ++cnt;
        ++done[g.i];
        ++done[g.j];
        date = max(date, g.date);

        // g.iが翌日に試合出来るかどうか．
        if (done[g.i] != n - 1) {
            int j = a[g.i][done[g.i]];
            if (a[j][done[j]] == g.i) { q.emplace(g.i, j, g.date + 1); }
        }

        // g.jが翌日に試合出来るかどうか．
        if (done[g.j] != n - 1) {
            int i = a[g.j][done[g.j]];
            if (a[i][done[i]] == g.j) { q.emplace(i, g.j, g.date + 1); }
        }
    }

    if (cnt != n * (n - 1) / 2) {
        cout << -1 << endl;
    } else {
        cout << date << endl;
    }

    return 0;
}

Measured memory_bytes: 4224
N = int(input())


if 63 < N :
  print (64)
elif 31 < N:
  print (32)
elif 15 < N:
  print (16)
elif 7 < N:
  print (8)
elif 3 < N:
  print (4)
elif 1 < N:
  print (2)
else :
  print (1)


Measured memory_bytes: 2940
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

struct t
{
    bool operator () (pii const &a, pii const &b)
    {
        return min(a.F, a.S) < min(b.F, b.S);
    }
};

int main()
{
    fast();
    int n; cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        v.pb(a);
    }

    sort(v.rbegin(), v.rend());
    priority_queue<pii, vector<pii>, t> pq;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == 0)
        {
            pq.push(make_pair(v[i], v[i]));
            continue;
        }

        int val = v[i];
        auto t = pq.top();
        pq.pop();

        ans += min(t.F, t.S);
        pii t1 = make_pair(max(t.F, val), min(t.F, val));
        pii t2 = make_pair(max(t.S, val), min(t.S, val));
        pq.push(t1);
        pq.push(t2);
    }
    cout << ans << endl;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N, K;
  cin >> N >> K;
  vi p(N, 0);
  vector<double> E(N, 0);
  vector<double> cumsum(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    E[i] = (1 + p[i]) / 2.0;
  }
  cumsum[0] = E[0];
  for (int i = 1; i < N; i++) {
    cumsum[i] = cumsum[i - 1] + E[i];
  }
  double ans = cumsum[K - 1];
  for (int i = K; i < N; i++) {
    ans = max(ans, cumsum[i] - cumsum[i - K]);
  }
  printf("%.12f\n", ans);
}

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

  solve();

  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        int n;
        scanf("%d", &n);
        vector<pii> d1, d2;
        long long ans = 0;
        for(int i=0;i<n;i++){
            int l, r, k;
            scanf("%d%d%d", &k, &l, &r);
            if(l >= r){
                d1.emplace_back(make_pair(l-r, k));
                ans += r;
            }
            else{
                d2.emplace_back(make_pair(r-l, k));
                ans += l;
            }
        }
        sort(d1.begin(), d1.end());
        reverse(d1.begin(), d1.end());

        sort(d2.begin(), d2.end());
        reverse(d2.begin(), d2.end());

        set<int> vis;
        for(int i=1;i<=n;i++) vis.insert(i);
        for(int i=0;i<d1.size();i++){
            int sum = d1[i].first, k = d1[i].second;
            auto it = vis.upper_bound(k);
            if(it != vis.begin()){
                it--;
                vis.erase(it);
                ans += sum;
            }
        }
        int cnt = 0;
        for(auto it:vis) cnt++;
        vis.clear();
        for(int i=n-cnt+1;i<=n;i++) vis.insert(i);

        for(int i=0;i<d2.size();i++){
            int sum = d2[i].first, k = d2[i].second+1;
            auto it = vis.lower_bound(k);
            if(it != vis.end()){
                vis.erase(it);
                ans += sum;
            }
        }
        printf("%lld\n", ans);
    }
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    string s;
    cin >> s;
    set<char> st;
    REP(i, 4) st.insert(s[i]);
    if((st.size()) == 2) cout << "Yes";
    else cout << "No";
    return 0;
}

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

/*int getDigit(int16_t n) {
    int digit = 0;
    while (n > 0) {
        n /= 10;
        digit++;
    }
    return digit;
}*/

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

    int sqrtN = sqrt(N);
    int min = 10000;
    for (int64_t a=1; a<=sqrtN; a++) {
        if (N % a != 0) continue;
        
        int64_t b = N / a;
        int digit = max (log10(a),log10(b));
        if (min > digit) min = digit;
    }
    cout << min+1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    int count=0;
    cin>>s>>t;
    for(int i=0; i<s.size(); i++){
            if(s[i] != t[i]){
                    count++;
            }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3936
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) print("Possible");
  else print("Impossible");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
 vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT", "SUN"};
 string t;
 cin>>t;
 for(int i=0;i<s.size();i++){
   if(t==s[i]){
     for(int j=i+1;j<s.size();j++){
       if(s[j]=="SUN"){
         cout<<j-i<<endl;
         return 0;
       }
     }
   }
 }
  return 0;
}

Measured memory_bytes: 256
from inspect import currentframe


def debug_print(s):
    # print(s)
    return


def debug_key(*args):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    debug_print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))


def solve(M, T, P, R, m, t, p, j):
    debug_print("\n-----solve-----")
    AC_COUNT = 0
    TEAM_NUMBER = 2
    SUM_TIME = 1
    QUE_NUMBER = 3


    record = [[0, 0, i + 1] + [0] * P for i in range(T)]
    debug_print(record)

    for i in range(R):
        if j[i] == 0:
            record[t[i] - 1][AC_COUNT] += 1
            record[t[i] - 1][SUM_TIME] -= m[i] + record[t[i] - 1][QUE_NUMBER + p[i] - 1] * 20
        else:
            record[t[i] - 1][QUE_NUMBER + p[i] - 1] += 1

    record.sort()
    record.reverse()
    debug_print(record)

    ans = str(record[0][TEAM_NUMBER])

    for i in range(1, T):
        if record[i][SUM_TIME] == record[i-1][SUM_TIME] and record[i][AC_COUNT] == record[i-1][AC_COUNT]:
            ans += "=" + str(record[i][TEAM_NUMBER])
        else:
            ans += "," + str(record[i][TEAM_NUMBER])

    print(ans)


    return


if __name__ == '__main__':

    while True:
        M_input, T_imput, P_imput, R_imput = map(int, input().split())
        if M_input == T_imput == P_imput == R_imput == 0:
            break
        m_input = [0 for _ in range(R_imput)]
        t_input = [0 for _ in range(R_imput)]
        p_input = [0 for _ in range(R_imput)]
        j_input = [0 for _ in range(R_imput)]

        for i in range(R_imput):
            m_input[i], t_input[i], p_input[i], j_input[i] = map(int, input().split())

        solve(M_input, T_imput, P_imput, R_imput, m_input, t_input, p_input, j_input)




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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//..##
int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<int> w(N + 1,0), b(N + 1,0);
	for (int i = 0; i < N; i++) {
		if (S[i] == '.') {
			w[i + 1] = w[i] + 1;
			b[i + 1] = b[i];
		}
		else {
			w[i + 1] = w[i];
			b[i + 1] = b[i] + 1;
		}
	}
	int ans = INF;
	ans = min(b[0] + w[N], ans);
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		tmp += b[i+1];
		tmp += w[N] - w[i+1];
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B, long long C){
    LL ans = min(B / A, C);
    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int n = SIZE(s);
    LL x,y;cin>>x>>y;

    VVL move(2);
    int tmp_d = 0;
    int tmp_m = 0;
    REP(i,n){
        if(s[i] == 'F'){
            tmp_m++;
        }
        else{
            move[tmp_d].PB(tmp_m);
            tmp_m=0;
            tmp_d = (tmp_d+1)%2;
        }
    }
    move[tmp_d].PB(tmp_m);

    /*
    REP(i,2){
        for(auto a : move[i]){
            cerr<<a<<" ";
        }
        cerr<<endl;
    }
    */
    

    int nx = SIZE(move[0]);
    vector<set<LL>> dpx(nx+1);
    dpx[0].insert(0);
    REP(i,nx){
        //cerr<<i<<":"<<endl;
        for(auto t : dpx[i]){
            //cerr<<" "<<t<<" "<<move[0][i]<<endl;
            dpx[i+1].insert(t + move[0][i]);
            if(i!=0){
                dpx[i+1].insert(t - move[0][i]);
            }
        }
    }

    if(dpx[nx].count(x) == 0){
        cout<<"No"<<endl;
        return;
    }

    int ny = SIZE(move[1]);
    vector<set<LL>> dpy(ny+1);
    dpy[0].insert(0);
    REP(i,ny){
        for(auto t : dpy[i]){
            dpy[i+1].insert(t + move[1][i]);
            dpy[i+1].insert(t - move[1][i]);
        }
    }

    if(dpy[ny].count(y) == 0){
        cout<<"No"<<endl;
        return;
    }

    cout<<"Yes"<<endl;

    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

void rotate(int*, int, int, int, int);

class Dice {
	public:
	int face[6];
	Dice (int* f) {
		for (int i=0; i<6; i++) face[i] = f[i];
	}
	void roll_x(bool d) {
		if (d) rotate(0, 4, 5, 1);
		else rotate(1, 5, 4, 0);
	}
	void roll_y(bool d) {
		if (d) rotate(0, 2, 5, 3);
		else rotate(3, 5, 2, 0);
	}
	void roll_z(bool d) {
		if (d) rotate(1, 3, 4, 2);
		else rotate(2, 4, 3, 1);
	}
	void rotate(int a, int b, int c, int d) {
	  int t;
	  t = face[d];
	  face[d] = face[c];
	  face[c] = face[b];
	  face[b] = face[a];
	  face[a] = t;
	}
	void print() {
		cout << face[0] << endl;
	}
};

int getRight(Dice d, int u, int f) {
	for (int i=0; i<6; i++) {
		for (int j=0; j<4; j++) {
			if (d.face[0]==u && d.face[1]==f) return d.face[2];
			d.roll_z(true);
		}
		if (i%2==0) d.roll_x(true);
		else d.roll_y(true);
	}
	return -1;
}

int main()
{
	int f[6];
	for (int i=0; i<6; i++) cin >> f[i];
	Dice d(f);
	int n;
	cin >> n;
	for (int k=0; k<n; k++) {
		int uf, ff;
		cin >> uf >> ff;
		cout << getRight(d, uf, ff) << endl;
	}
	return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int graph[105][105];

void WarshallFloyd(int SIZE) {
    for( int k = 1; k <= SIZE; ++k ) {
        for( int i = 1; i <= SIZE; ++i ) {
            for( int j = 1; j <= SIZE; ++j ) {
                if( graph[i][k] == INF || graph[k][j] == INF ) {
                    continue;

                }
                graph[i][j] = min( graph[i][j], 
                                    graph[i][k] + graph[k][j] );

            }
        }
    }
    return;

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

    int N, M;
    cin >> N >> M;
    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j <= N; ++j) {
            if(i == j) graph[i][j] = 0;
            else graph[i][j] = INF;
        }
    }

    vector<P> g[105];
    while(M--) {
        int a, b, c;
        cin >> a >> b >> c;
        graph[a][b] = graph[b][a] = c;
        g[a].pb(MP(b, c));
    }

    WarshallFloyd(N);

    int c = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 0; j < g[i].size(); ++j) {
            P p = g[i][j];
            if(graph[i][p.F] != p.S) ++c;
        }
    }
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
prod = 1
f = 0
if 0 in a:
    print(0)
    exit(0)
for i in a:
    prod*=i
    if prod>10**18:
        f = 1
        break
if f==1:
    print(-1)
else:
    print(prod)

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

int main(){
  long long n,k;
  cin >> n >> k;
  vector<long long> t(n);
  long long ans = 0;
  for(int i = 0; i < n; i++){
    cin >> t[i];
  }
  sort(t.begin(),t.end(),greater<long long>());
  for(int i = k; i < n; i++){
    ans += t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4828
import java.util.*;

public class Main {
    private static class Point {
        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (o == this) {
                return true;
            }

            if (!(o instanceof Point)) {
                return false;
            }

            Point p = (Point) o;
            return this.x == p.x && this.y == p.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }
    }

    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        Map<Point, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            for (int j = a - 2; j <= a; j++) {
                if (j <= 0 || j > h - 2) {
                    continue;
                }
                for (int k = b - 2; k <= b; k++) {
                    if (k <= 0 || k > w - 2) {
                        continue;
                    }
                    map.compute(new Point(k, j), (p, v) -> (v == null) ? 1 : v + 1);
                }
            }
        }

        System.out.println(((long) h - 2) * ((long) w - 2) - map.size());
        long ans[] = new long[9];
        map.values().forEach(v -> ans[v - 1]++);
        for (int i = 1; i <= 9; i++) {
            System.out.println(ans[i - 1]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0, now;
	for (int i = 1; i <= n; ++i)
	{
		now = 0;
		int t = i;
		for (int j = 0; j < 5; ++j)
		{
			now += t % 10;
			t /= 10;
		}
		ans += (a <= now && now <= b?i:0);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<vector<char>> data(1010, vector<char>(1010));
vector<vector<ll>> dp(1010, vector<ll>(1010,0));

int main(){  
  int h,w;
  cin >> h >> w;
  rep(i,h){ rep(j,w){
    cin >> data[i][j];
  } }
  dp[0][0]=1;

  rep(i,h){ rep(j,w){
    dp[i][j] %= mod;
    if(data[i][j]=='#'){ continue; }
    dp[i+1][j] += dp[i][j];
    dp[i][j+1] += dp[i][j];
  } }
  
  ll ans=dp[h-1][w-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9344
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] L = new long[n];
        for (int i = 0; i < n; i++) {
            L[i] = sc.nextLong();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if(L[i] == L[j])continue;
                long longer = Math.max(L[i], L[j]);
                long rest1 = Math.min(L[i], L[j]);
                for (int k = j+1; k < n; k++) {
                    if(L[i] == L[k] || L[j] == L[k])continue;
                    long longest = Math.max(longer, L[k]);
                    long rest2 = Math.min(longer, L[k]);
                    if(rest1 + rest2 > longest) ans++;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 36380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1 << 10;
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll t = n % k;
	cout << min(t, k - t);
    return (0);
}

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

using namespace std;

const int SIZE_LIMIT = 3e5+5;
int sumH[SIZE_LIMIT], sumW[SIZE_LIMIT];
int indexH[SIZE_LIMIT], indexW[SIZE_LIMIT];

struct PairHash
{
  size_t operator()(const pair<int, int>& p) const {
    return p.first * 31 + p.second;
  }
};


bool cmpH(int i, int j) {
  return sumH[i] < sumH[j];
}

bool cmpW(int i, int j) {
  return sumW[i] < sumW[j];
}

unordered_set<pair<int, int>, PairHash> points;

int main() {
  memset(sumH, 0, sizeof(sumH)), memset(sumW, 0, sizeof(sumW));

  int h, w, m;
  scanf("%d%d%d", &h, &w, &m);

  for (int i = 0; i < SIZE_LIMIT; ++i) {
    indexW[i] = i, indexH[i] = i;
  }

  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    
    points.insert({x, y});
    sumH[x]++, sumW[y]++;
  }

  sort(indexH, indexH+h+1, cmpH);
  sort(indexW, indexW+w+1, cmpW);

  int maxh = sumH[indexH[h]], maxw = sumW[indexW[w]];
  for (int i = h; i > 0 && sumH[indexH[i]] == maxh; --i) {
    for (int j = w; j > 0 && sumW[indexW[j]] == maxw; --j) {
      if (points.find({indexH[i], indexW[j]}) == points.end()) {
        printf("%d\n", maxh+maxw);
        return 0;
      }
    }
  }
  printf("%d\n", maxh+maxw-1);
  return 0;
}

Measured memory_bytes: 21976
#include <iostream>
using namespace std;
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    int tmp;
    for (int i=0;i<k;i++){
        tmp=a/2+a%2;
        a-=tmp;
        b+=a;
        tmp=a;a=b;b=tmp;
    }
    if (k%2){
        tmp=a;a=b;b=tmp;
    }
    cout<<a<<' '<<b;
};


Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
int main()
{   int n;
    scanf("%d",&n);
    char s[n][11];
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
        }
        int flag=0;
    for(int i=0;i<n-1;i++){
        if(s[i][strlen(s[i])-1]!=s[i+1][0]){
            printf("No");
            return 0;
        }
        for(int j=i+1;j<n;j++){
            if(strcmp(s[i],s[j])==0){
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
bool visit[100005];
vector<int> g[100005];
void dfs(int u){
	visit[u] = true;
	for(int i=0;i<g[u].size();i++){
		if(!visit[g[u][i]]){
			dfs(g[u][i]);
		}
		dp[u] = max(dp[u],1+dp[g[u][i]]);
	}
}
int main(){
	int n,m,a,b;
		cin>>n>>m;
		for(int i=0;i<=n;i++){
			visit[i] = false;
			dp[i]=0;
		}
		for(int i=0;i<m;i++){
			cin>>a>>b;
			g[a].push_back(b);
		}
		for(int i=1;i<=n;i++){
			if(!visit[i]){
				dfs(i);
			}
		}
		int ans = 0;
		for(int i=1;i<=n;i++){
			ans = max(dp[i],ans);
		}
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=805,M=N*N;
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
int n,m,k,i,j,a[N][N],h,t,qx[M],qy[M],ans;
char s[N];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for (i=1;i<=n;i++){
		scanf("%s",s+1);
		for (j=1;j<=m;j++){
			if (s[j]=='S') qx[1]=i,qy[1]=j;
			if (s[j]=='#') a[i][j]=1;
		}
	}
	for (i=1;i<=n;i++) a[i][0]=a[i][m+1]=1;
	for (i=1;i<=m;i++) a[0][i]=a[n+1][i]=1;
	t=1;a[qx[1]][qy[1]]=1;ans=1e9;
	for (;h!=t;){
		h++;int x=qx[h],y=qy[h];
		ans=min(ans,min(min(x-1,n-x),min(y-1,m-y)));
		if (a[x][y]==k+1) continue;
		for (i=0;i<4;i++){
			int tx=x+dx[i],ty=y+dy[i];
			if (!a[tx][ty]){
				a[tx][ty]=a[x][y]+1;
				t++;qx[t]=tx;qy[t]=ty;
			}
		}
	}
	printf("%d",1+(ans+k-1)/k);
}

Measured memory_bytes: 7808
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

long long int n, k;
long long int p[3000000];
long long int val_max = 0;
double ans;

int main(){
	p[0] = 0;
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> p[i];
		p[i] += p[i - 1];
	}
	for(int i = 0; i < n - k + 1; i++){
		int val = p[i + k] - p[i];
		if(val >= val_max){
			val_max = val;
		}
	}
	ans = ((double)val_max + (double)k)/2.0;
	printf("%.10f\n", ans);
	return 0;
}

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

int main()
{
	string s;
	int a, b;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = s.size() - 1; i >= 0; i--)
	{
		if (s[i] == 'Z') {
			b = i;
			break;
		}
	}
	cout << b - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int main(){
  ll X;
  cin >> X;

  for(int a = -118; a < 120; a++){
    for(int b = -119; b < 119; b++){
      if(pow(a,5) - pow(b,5) == X){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;


int main(void){
	string s;
	cin >> s;
	vector<int> a(30,0);
	vector<int> b(11,0);
	for(int i = 0; i < s.length(); ++i){
		if(s[i] - 'a' >= 0 && 'z' - s[i] >= 0){
			a[s[i]-'a']++;
		}else{
			b[s[i]-'0']++;
		}
	}
/*
	for(int j = 0; j < 26; ++j){
		cout << a[j] << " ";
	}
	cout << endl;
*/
	int ans = s.length();
	while(true){
		int st = -1;
		int count = 0;
		int bans = ans;
		for(int i = 0; i < 27; ++i){
			if(st == -1 && a[i]>=1){
				st = i;
				count = 1;
				//cout << i << " ";
			}else if(st != -1){
				if(a[i] >= 1){
					count++;
				}else{
					if(count>3){
						ans -= count-3;
						for(int j = st; j < i; ++j){
							a[j]--;
							//cout << a[j] << " ";
						}
					}
					count = 0;
					st = -1;
				}
			}
		}
		if(bans == ans) break;
	}
	while(true){
		int st = -1;
		int count = 0;
		int bans = ans;
		for(int i = 0; i < 11; ++i){
			if(st == -1 && b[i]>=1){
				st = i;
				count = 1;
				//cout << i << " ";
			}else if(st != -1){
				if(b[i] >= 1){
					count++;
				}else{
					if(count>3){
						ans -= count-3;
						for(int j = st; j < i; ++j){
							b[j]--;
							//cout << a[j] << " ";
						}
					}
					count = 0;
					st = -1;
				}
			}
		}
		if(bans == ans) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3224
/**
 *      purpose : KEYENCE Programming Contest 2019 A
 *      author  : kyomukyomupurin
 *      created : 2019-01-13 21:00:12
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a[4];
    rep(i, 4) cin >> a[i];
    sort(a, a + 4);
    if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) print("YES");
    else print("NO");
    
    
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	int n;cin >> n;
	string str;cin >> str;

	if(n % 2){
		cout << "No" << endl;
		return 0;
	}

	n /= 2;
	REP(i, n){
		if(str[i] != str[i+n]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

int main(){
    //input
    long long q;
    cin >> q;
    long long i,j,k, m, n;
    string S, T;
    const char *s = NULL, *t = NULL;
    for(k = 1; k <= q; k++){
        cin >> S;
        m = S.length();
        s = S.c_str();
        cin >> T;
        n = T.length();
        t = T.c_str();
        long long dp[m+1][n+1];
        for(i = 0; i<= m; i++){
            dp[i][0] = 0;
        }
        for(j = 0; j <= n; j++){
            dp[0][j] = 0;
        }
        for(i = 1; i <= m; i++){
            for(j = 1; j <= n; j++){
                dp[i][j] = max({dp[i-1][j-1] + (s[i-1]==t[j-1]) , dp[i-1][j], dp[i][j-1]});
            }
        }
        cout<< dp[m][n] << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int a[50], b[50], c[50], d[50];
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++)
		cin >> c[i] >> d[i];
	for (int i = 0; i < n; i++)
	{
		int ans = 0, far = 1e9;
		for (int j = 0; j < m; j++)
			if (far > abs(a[i] - c[j]) + abs(b[i] - d[j]))
			{
				far = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j;
			}
		cout << ans + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

#define int long long
//typedef long long ll;
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int N, Ma, Mb;
int a[45], b[45], c[45];
const int inf = 1000000;
int dp[45][450][450];

int rec(int i, int sa, int sb)
{
    if (dp[i][sa][sb] != -1) return dp[i][sa][sb];

    if (sa != 0 && sb != 0 && sa * Mb == sb * Ma) return dp[i][sa][sb] = 0;
    if (i == N) return dp[i][sa][sb] = inf;

    return dp[i][sa][sb] = min(rec(i + 1, sa + a[i], sb + b[i]) + c[i], rec(i + 1, sa, sb));
}

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> Ma >> Mb;
    rep(i,N) {
        cin >> a[i] >> b[i] >> c[i];
    }

    rep(i,45) rep(j,450) rep(k,450) dp[i][j][k] = -1;

    int ans = rec(0, 0, 0);
    if (ans >= inf) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 71424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=305*305;

pair<int,int>point[maxn];
int dist[maxn];

int main(int argc, char const *argv[])
{
	int h,w,d;
	ios::sync_with_stdio(false);
	while(cin>>h>>w>>d){
		int temp;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>temp;
				point[temp].first=i;
				point[temp].second=j;
			}
		}
		memset(dist,0,sizeof(dist));
		for(int i=d;i<=w*h;i++){
			dist[i]=dist[i-d]+abs(point[i].first-point[i-d].first)+abs(point[i].second-point[i-d].second);
		}
		int q,l,r;
		cin>>q;
		while(q--){
			cin>>l>>r;
			cout<<dist[r]-dist[l]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;

//***********************************Functions and macros begin*************************************//

#define pi pair<int,int>
#define pii pair<pi,int>
#define pb push_back
#define fast ios_base::sync_with_stdio
#define fast1 cin.tie(NULL)
#define mod1 1000005187
#define mp make_pair
#define SORT(x) sort(x.begin(),x.end())
#define PI 3.14159265
#define R3 1.7320508
#define R5 2.2360679
typedef long long int  ll;
const ll mod=1e9+7;
int phi(int n) //No of coprimes
{int result=n;for(int i=2;i*i<=n;i++)if(n%i==0){while(n%i==0) n=n/i;result-=result/i;}if(n>1) result-=result/n; return result;}

ll mod_pow(ll base,ll e) 
{ ll ans=1; while(e){if(e&1) ans=(ans*base)%mod;base=(base*base)%mod;e>>=1;}return ans;}

int gcd(int a,int b) //Greatest common divisior
{return b ? gcd(b,a%b) : a;}


//*********************************** Fucntions and macros end  *************************************// 

int main()
{
	int n;
	cin>>n;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,temp;
	scanf("%d %d",&a,&b);
	
	while(!(a==0 && b==0)){
		if(a>=b){
			temp=a;
			a=b;
			b=temp;
		printf("%d %d\n",a,b);
		}
			else{
				printf("%d %d\n",a,b);
			}
		
		scanf("%d %d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 1028
#
# 7a
#

def main():
    while True:
        m, f, r = map(int, input().split())
        if m == f == r == -1:
            break
        elif (m == -1 or f == -1) or m+f < 30:
            print("F")
        elif m+f >= 80:
            print("A")
        elif m+f >= 65:
            print("B")
        elif m+f >= 50 or r >= 50:
            print("C")
        elif m+f >= 30:
            print("D")


if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
#define ull unsigned  long long
using namespace std;
const int INF =1e9+10;
const int N = 5e2 + 10;
signed main() {
    string s;
    cin>>s;
    int ma=0,cnt=0;
    for(auto i:s){
        if(i=='R'){
            cnt++;
        }else{
            ma=max(ma,cnt);
            cnt=0;
        }
    }
    if(cnt){
        ma=max(ma,cnt);
    }
    cout<<ma;
    return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int M,D;
    cin >> M >> D;
    int ans = 0;
    for(int k = 1;k <= M;k++)
    {
    for(int i = 2;i < D/10+1;i++)
    {
        for(int j = 2;j < min(10,D);j++)
        {
            if(i * 10 + j > D) continue;
            if(i * j == k)
            {
                ans++;
            }
        }
    }
    }
    cout << ans << endl;
}


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


int main() {
  int K ,X ;
  cin >> K >> X ;
  
  for(int i = 0 ; i < 2*K - 1 ; i++ ){
  cout << X - K + i  + 1 << " " ; 
  
  }
  cout << endl ;
}

Measured memory_bytes: 3620
<?php
$n = trim(fgets(STDIN));
$arr = explode(" ",trim(fgets(STDIN)));

$count = 0;
for($i=0; $i<$n; $i++){
    if($arr[$i] != $i+1){
        $count++;
    }
}

if($count == 2 || $count ==0){
    echo "YES";
}else{
    echo "NO";
}
?>

Measured memory_bytes: 3576
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long a, b;
  scanln(a, b);

  string x = a.to!string.repeat(b).array.join.to!string;
  string y = b.to!string.repeat(a).array.join.to!string;

  if (x < y) {
    x.writeln;
  } else {
    y.writeln;
  }
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<list>
#include<set>


using namespace std;

#define N 100001
#define MOD 10007

struct Node{
  int id;
  int con[2];
  int cost[2];
  Node():id(-1){}
  Node(int id,int con1, int cost1, int con2, int cost2):id(id){
    con[0]=con1;con[1]=con2;
    cost[0]=cost1;cost[1]=cost2;
  }
};

typedef vector<Node> Graph;
typedef list< pair<Graph,set<int> > > Forest;

void bfs(int st, bool vis[N], const Graph &G, Forest &F){
  queue<int> qi;
  Graph ret;
  set<int> g;
  qi.push(st);
  vis[st]=true;
  ret.push_back( G[st] );
  while(!qi.empty()){
    int now = qi.front();
    qi.pop();
    
    
    g.insert( now );
    
    for(int i = 0; i < 2; ++i){
      for(int j = 0; j < 2; ++j){
	if( G[ G[now].con[i] ].con[j] == now &&
	    !vis[ G[now].con[i] ] ){
	  ret.push_back( G[ G[now].con[i] ] );
	  qi.push( G[now].con[i] );
	  vis[ G[now].con[i] ] = true;
	}
      }
    }
  }
  F.push_back( make_pair( ret, g ) );
}

int main()
{
  while(true){
    int answer = 1;
    int n;
    bool vis[N]={false,};
    Graph G;
    Forest F;
    cin >> n;
    if( n == 0 )break;
    for(int i = 0; i < n; ++i){
      int con1,cost1,con2,cost2;
      cin >> con1 >> cost1 >> con2 >> cost2;
      G.push_back( Node(i,con1,cost1,con2,cost2) );
    }
    for(int i = 0; i < n; ++i){
      if( !vis[i] ){
	bfs(i,vis,G,F);
      }
    }
    for(Forest::iterator itg = F.begin(); itg != F.end(); ++itg){
      int max_w = -1;
      int cnt = 0;

      /*
      cout << itg->first.size() << endl;
      for(int i = 0; i < itg->first.size(); ++i){
	cout << itg->first[i].id << " : ";
	for(int j = 0; j < 2; ++j){
	  cout << itg->first[i].con[j] << ' ' << itg->first[i].cost[j] << "  ";
	}
	cout << endl;
      }
      */

      if( itg->first.size() == 1 ) continue;
      for(int i = 0; i < itg->first.size(); ++i){
	for(int j = 0; j < 2; ++j){
	  if( itg->second.find( itg->first[i].con[j] ) !=
	      itg->second.end() ){
	    max_w = max( max_w, itg->first[i].cost[j] );
	  }
	}
      }
      for(int i = 0; i < itg->first.size(); ++i){
	for(int j = 0; j < 2; ++j){
	  if( itg->second.find( itg->first[i].con[j] ) !=
	      itg->second.end() ){
	    if( max_w == itg->first[i].cost[j] ){
	      ++cnt;
	    }
	  }
	}
      }

      cnt/=2;
      answer *= cnt;
      answer %= MOD;
    }
    
    cout << answer << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<P> v;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v.emplace_back(b,a);
    }
    sort(v.begin(),v.end());
    ll now = 0;
    rep(i,n){
        now += v.at(i).second;
        if(now > v.at(i).first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
    
}

Measured memory_bytes: 5304
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

from collections import deque
def bfs(maze):
    ans = 0
    d = [[-1] * w for _ in range(h)]
    que = deque([])
    for i in range(h):
        for j in range(w):
            if maze[i][j] == '#':
                que.append([i, j])
                d[i][j] = 0
    #que = deque([[sy, sx]])
    #d[sy][sx] = 0
    while que:
        y, x = que.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ny, nx = y + j, x + k
            if 0 <= nx < w  and 0 <= ny < h  and d[ny][nx] == -1 and maze[ny][nx] != "#":
                d[ny][nx] = d[y][x] + 1
                ans = max(ans, d[ny][nx])
                que.append([ny, nx])
                
    return ans

print(bfs(maze))


Measured memory_bytes: 176732