akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

const int N = 100005;


int main(){
  int v[3] = {0}, w[3] = {0}, n, maxi;

  cin >> n;
  f(i, n){
    f(j, 3)
      cin >> w[j];
    if ( i == 0 ){
      f(j, 3)
        v[j] = w[j];
    }
    else{
      f(j, 3){
        maxi = -1;
        f(z, 3)
          if ( z != j && v[z] > maxi )
            maxi = v[z];
        w[j] += maxi;
      }
    f( j, 3 )
      v[j] = w[j];
    }
  }

  maxi = -1;
  f( i , 3 )
    maxi = ( maxi < v[i] ? v[i] : maxi );

  cout << maxi;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int a[N];
int main()
{
    int mx = 0,cnt = 0,n;
    scanf("%d",&n);
    a[n+1] = 1e9+5;
    for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
    for(int i=n;i>=1;i--)
    {
        if(a[i]>=a[i+1])    ++cnt;
        else                cnt = 0;
        mx = max(mx,cnt);
    }
    printf("%d\n",mx);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// #include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    
    V<bool> c(n, false);
    for (int i = 0; i < n; i++) {
        int c1, c2; cin >> c1 >> c2;
        c[i] = c1 == c2;
    }

    bool ans = false;
    for (int i = 2; i < n; i++) {
        ans = ans || (c[i - 2] & c[i - 1] & c[i]);
    }
    if (ans) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

int card[255][14] = {{0}};

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        char c;
        int num;
        cin >> c >> num;
        card[(int)c][num] = 1;
    } 
    for (int i = 1; i <=13; i++){
        if (card[(int)'S'][i] == 0)
        cout << "S " << i << endl;
    }
    for (int i = 1; i <=13; i++){
        if (card[(int)'H'][i] == 0)
        cout << "H " << i << endl;
    }
    for (int i = 1; i <=13; i++){
        if (card[(int)'C'][i] == 0)
        cout << "C " << i << endl;
    }
    for (int i = 1; i <=13; i++){
        if (card[(int)'D'][i] == 0)
        cout << "D " << i << endl;
    }
}


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

using ll = long long;

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    vector<pair<ll, ll>> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        v[i] = make_pair(a[i], b[i]);
    }

    sort(rbegin(v), rend(v), [] (auto const& p1, auto const& p2) {
            return p1.first + p1.second < p2.first + p2.second;
        });

    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        if(i & 1) ans -= v[i].second;
        else      ans += v[i].first;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N;
  cin>>N;
  int ans=0;
  rep(i,0,4){
    if(N%10==2)
      ans++;
    N/=10;
  }
  cout<<ans;
  }


Measured memory_bytes: 256
import math
def count(n, r):
    return math.factorial(n) // math.factorial(n - r)
def main():
  N, M = map(int, input().split())
  if (N == 0 and M == 0) or (N == 1 and M == 1):
    ans = 0
  elif N == 0 or N == 1:
    y = count(M, 2)
    ans = y
  elif M == 0 or M == 1:
    x = count(N, 2)
    ans = x
  else:
    x = count(N, 2)
    y = count(M, 2)
    ans = x + y
  print(int(ans/2))

main()



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

int main()
{
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int vx = x2 - x1, vy = y2 - y1;
	int x3 = x2 - vy, y3 = y2 + vx;
	int x4 = x3 - vx, y4 = y3 - vy;
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (auto&& e : h) cin >> e;
  int ans = 0;
  int c = 0;
  for (int i = 0; i < n - 1; i++) {
    if (h[i] >= h[i + 1]) {
      c++;
    } else {
      ans = max(ans, c);
      c = 0;
    }
  }
  ans = max(ans, c);
  cout << ans << endl;
}


Measured memory_bytes: 768
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	switch {
	case a < 10 && b < 10:
		fmt.Println(a * b)
	default:
		fmt.Println(-1)
	}
}


Measured memory_bytes: 640
import sys
def input():
    return sys.stdin.readline()[:-1]


N = int(input())
cnt = 0
n = N//2+1
k = int(N**0.5)+1
b = 0
for i in range(k,1,-1):
    if N%i==0:
        b = N//i
        a = i
        print(a+b-2)
        exit()
else:
    print(N-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int n;
    cin>>n;
    vector<string> s(n+1,"zzzzzzzzzzzz");
    REP(i,n)cin>>s[i];
    sort(all(s));
    string f=s[0];
    vector<string> ans;
    int max=0,num=0;
    REP(i,n){
        num++;
        if(s[i+1]!=f) {
            f=s[i+1];
            if(max<num){
                max=num;
                ans.clear();
                ans.push_back(s[i]);
            }
            else if(max==num){
                ans.push_back(s[i]);
            }
            num=0;
        }
    }
    REP(i,ans.size()){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int k = s.size();
  int ans = 15 - k;
  for(int i = 0; i < k; i++){
    if(s.at(i) == 'o') ans++;
  }
  
  if(ans >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;

int main() {
    int x;

    // Main loop
    for (int i = 1; ; i++) {
        // input
        cin >> x;

        // process
        if (x == 0) break;

        // output
        cout << "Case " << i << ": " << x << endl;
    }

    return 0;
}



Measured memory_bytes: 3032
using System;

class Program
{
    static void Main(string[] args)
    {
        string n = Console.ReadLine();
        int sum = 0;
        for(int i = 0, l = n.Length; i < l; i++)
        {
            
            sum += int.Parse(n[i].ToString());
        }

        Console.WriteLine(sum % 9 == 0 ? "Yes" : "No");
    }


 
}




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

int main() {
	int h,m,s;
	cin >> s;
	h = s / 3600;
	m = (s % 3600) / 60;
	s = (s % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

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

int main(){
  string s;
  cin >>s;
  int cnt = 0;
  rep(i,s.size()){
    if(s[i]=='2') cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main( ) {
  int count = 0;
  string s("++++");
  cin >> s;
  
  for (int i = 0; i < 4; i++){
    if(s[i]=='+'){
      count++;
    }else{
      count--;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int j=i;
		int l=0;
		while(j){
			l++;
			j/=10;
		}
		if(l%2!=0) ans++;
	}
	cout<<ans;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

set<ll> a;

int main(void)
{
  ll n;
  cin >> n;
  REP(i, n) {
    ll t;
    cin >> t;
    if(a.find(t) == a.end()) {
      a.insert(t);
    } else {
      a.erase(a.find(t));
    }
  }
  cout << a.size() << endl;
}


Measured memory_bytes: 4864
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  cout<<((k*2<=n+1) ? "YES" : "NO");
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};
bool dp[MAX_N]={};

int main() {
	int n,m,q;
	cin>>n>>m>>q;
	rep(i,n)f[i]=(i+1+n)%n;
	rep(i,n)b[i]=(i-1+n)%n;
	int s=0;
	rep(i,m){
		int a1;
		cin>>a1;
		if(a1%2==0){
			rep(j,a1)s=f[s];
		}else{
			rep(j,a1)s=b[s];
		}
		dp[s]=true;
		b[f[s]]=b[s];
		f[b[s]]=f[s];
		s=f[s];
//		cout<<s<<endl;
	}
	rep(i,q){
		int q1;
		cin>>q1;
		if(dp[q1]){
			cout<<"0"<<endl;
		}else{
			cout<<"1"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4796
N,M = map(int,input().split())
A = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1
uf = UnionFind(N)

for x,y in XY:
    if uf.is_same(x,y): continue
    uf.unite(x,y)

re = N - uf.count
if re==1:
    print(0)
    exit()
v = (re-1)*2
if v > N:
    print('Impossible')
    exit()

for i in range(N):
    uf.root(i)
ans = 0
used = [0]*N
d = {}
for i in range(N):
    r = uf.root(i)
    if r in d:
        if d[r][0] > A[i]:
            d[r] = (A[i], i)
    else:
        d[r] = (A[i], i)

for a,b in d.values():
    ans += a
    used[b] = 1
rem = v-re
notused = []
for i in range(N):
    if used[i]: continue
    notused.append(A[i])
notused.sort()
ans += sum(notused[:rem])
print(ans)

Measured memory_bytes: 28232
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <cstring>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const LL maxn=1e5+10;
const long long mod=1e9+7;
LL even,odd;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    LL n;
    cin>>n;
    for(LL i=0;i<n;i++)
    {
        LL t;
        cin>>t;
        if(t%2==0)
            even++;
        else
            odd++;
    }
    if(odd%2!=0)
        cout<<"NO";
    else
    {

            cout<<"YES";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    string S;
    cin >>S;
    size_t size = S.length();
    int ans = 0;
    for (int i=0;i<size;i++){
        if (S[2*i]=='L'){
            ans = 1;
            break;
        }
        
        if (S[2*i+1]=='R'){
            ans = 1;
            break;
        }
        
        if (2*(i+1)>size)break;
    }
    if (ans ==1) cout <<"No";
    else cout <<"Yes";
    }

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

struct Pro{
    string name; int t;
};
Pro Q[100005]; int head, tail;

void enqueue(Pro x){
    Q[tail]=x;
    tail=(tail+1)%100005;
}
Pro dequeue(){
    Pro x=Q[head];
    head=(head+1)%100005;
    return x;
}

int main() {
    int n, q, time=0; cin >> n >> q;
    for(int i=1;i<=n;++i){
        cin >> Q[i].name >> Q[i].t;
    }
    head=1; tail=n+1;
    while(head!=tail){
        Pro x=dequeue();
        int c=min(q,x.t); x.t-=c; time+=c;
        if(x.t) enqueue(x);
        else cout<<x.name << " " <<  time <<endl;
    }
    return 0;
}

Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
int n,ans;
double d,x,y;
int main(void){
	scanf("%d%lf",&n,&d);
	while(n--)scanf("%lf%lf",&x,&y),ans+=(x*x+y*y<=d*d);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define ALL(v) v.begin(), v.end()

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)

int calc(int a, int b, char ope) {
    if (ope == '+') return a + b;
    if (ope == '-') return a - b;
    if (ope == '*') return a * b;
    return -1;
}

bool isten(string s) {
    int ans;
    if (s[1] == '(') {
        int a, b, c, d;
        a = s[2] - '0';
        b = s[6] - '0';
        c = s[11] - '0';
        d = s[16] - '0';
        ans = calc(calc(calc(a,b,s[4]), c, s[9]), d, s[14]);
    }else {
        int a, b, c, d;
        a = s[1] - '0';
        b = s[5] - '0';
        c = s[11] - '0';
        d = s[15] - '0';
        ans = calc(calc(a, b, s[3]), calc(c, d, s[13]), s[8]);
    }
    return ans == 10;
}

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)


vector<char> operands = {'+', '-', '*'};
random_device rd;

char getRandomOperand() {
    return operands[rd() % 3];
}

void solve41(int a, int b, int c, int d) {
    vector<int> nums;
    nums.push_back(a), nums.push_back(b), nums.push_back(c), nums.push_back(d);
    sort(ALL(nums));
    do {
        REP(i,50) {
            string eq1, eq2;
            eq1 = "((" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " " + to_string(nums[2]) +
            ") " + getRandomOperand() + " " + to_string(nums[3]);
            eq2 = "(" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " (" + to_string(nums[2]) +
            " " + getRandomOperand() + " " + to_string(nums[3]) + ")";
            if (isten(eq1)) {
                cout << eq1 << endl;
                return;
            }else if (isten(eq2)) {
                cout << eq2 << endl;
                return;
            }
        }
    }while (next_permutation(nums.begin(), nums.end()));
    cout << 0 << endl;
}

int main() {
    int a, b, c, d;
    while(cin >> a >> b >> c >> d, a + b + c + d) {
        solve41(a,b,c,d);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

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; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 15;

int N;
vector< tuple<int, int, int> > XYP; 

// すでにある先のパターンが i のとき Aj に一番近い線までの距離
int near_x[40000][MAX_N];
int near_y[40000][MAX_N];

// 集落ind に一番近い路線との距離を返す
// l_x の i bit 目が立っている　… Xi に線がある
static inline int near(int l_x, int l_y, int ind) {
    return min(near_x[l_x][ind], near_y[l_y][ind]);
}

// 現状の線での値
// l_x の i bit 目が立っている　… Xi に線がある
static inline int calc(int l_x, int l_y) {
    int ret = 0;
    REP(i, N) {
        int p = get<2>(XYP[i]);
        // 自分に一番近い線路を探す
        ret += near(l_x, l_y, i) * p;
    }
    return ret;
}

// i 番目を見ていて cur 本引いている
static inline int dfs(int i, int cur, int n, int l_x, int l_y) {
    if(i >= N) {
        if(n != cur) { return LLINF; }
        return calc(l_x, l_y);
    }
    int ret = LLINF;

    // 追加しない
    chmin(ret, dfs(i+1, cur, n, l_x, l_y));

    // x に追加
    if( ((l_x >> i) & 1) == 0) {
        chmin(ret, dfs(i+1, cur+1, n, l_x | (1 << i), l_y));
    }

    // y に追加
    if( ((l_y >> i) & 1) == 0) {
        chmin(ret, dfs(i+1, cur+1, n, l_x, l_y | (1 << i)));
    }

    return ret;
}

// 引ける線の数が n のときの最小
static inline int solve(int n) {
    if(n == 0) {
        return calc(0, 0);
    }

    return dfs(0, 0, n, 0, 0);
}

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

    cin >> N;
    REP(i, N) {
        int x, y, p;
        cin >> x >> y >> p;
        XYP.push_back(make_tuple(x, y, p));
    }

    // near_x, near_y の作成
    for(int i = 0; i < (1 << N); ++i) {
        for(int j = 0; j < N; ++j) {
            near_x[i][j] = abs(get<0>(XYP[j]));
            near_y[i][j] = abs(get<1>(XYP[j]));
            for(int k = 0; k < N; ++k) {
                if((i >> k) & 1) {
                    int dist = abs(get<0>(XYP[k]) - get<0>(XYP[j]));
                    chmin(near_x[i][j], dist);
                    dist = abs(get<1>(XYP[k]) - get<1>(XYP[j]));
                    chmin(near_y[i][j], dist);
                }
            }
        }
    }

    for(int i = 0; i <= N; ++i) {
        int ans = solve(i);
        printf("%lld\n", ans);
    }

    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        if (h >= k)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

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

int n;
vector<ll> h(100010,0);
vector<ll> dp(100010,INF);

int main(){
    int k;
    cin>>n>>k;
    rep(i,n) cin>>h[i];

    dp[0]=0;
    for(int i=1;i<=n;i++){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) {
            for(int j=2;j<=min(i,k);j++) chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 4696
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,a[maxn],dp[maxn];
int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n; ++i) scanf("%d",a+i);
    for(int i = 2;i <= n; ++i){
        dp[i] = dp[i-1]+abs(a[i]-a[i-1]);
        if(i-2 > 0) dp[i] = min(dp[i],dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    ll n ; 
    cin >> n ; 
    ll c = n/1000 ; 
    string ans = "ABC" ; 
    ans[2]+=c ; 
    cout << ans ; 




















return 0 ;
}


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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

/* -------------------------------- Library -------------------------------- */

struct Trie {
  static const int SIZE = 32;
  struct State {
    int index, next[SIZE];
    State(int index) : index(index) { memset(next, -1, sizeof(next)); }
  };

  vector<State> pma;
  vector<int> cnt;
  vector<int> acc;

  void dfs(int v) {
    int res = 0;
    REP(i,SIZE) {
      int nv = pma[v].next[i];
      if (nv != -1) {
        dfs(nv);
        res += cnt[nv];
      }
    }
    cnt[v] += res;
  }

  Trie(const vector<string> &str) {
    pma.clear();
    pma.push_back(State(0));
    cnt.clear();
    cnt.push_back(0);
    acc.clear();
    acc.push_back(0);

    REP(i,str.size()) {
      int t = 0;
      for (char cc : str[i]) {
        int c = cc - 'a';
        if (pma[t].next[c] == -1) {
          int m = pma.size();
          pma[t].next[c] = m;
          pma.push_back(State(m));
          cnt.push_back(0);
          acc.push_back(0);
        }
        t = pma[t].next[c];
      }
      ++cnt[t];
      ++acc[t];
    }
    dfs(0);
  }

  pair<vector<vector<int>>,int> query(const string &str) {
    vector<vector<int>> table(26, vector<int>(26, 0));
    int res = 1;
    int st = 0;
    REP(i,str.size()) {
      res += acc[st];
      REP(j,SIZE) {
        int nst = pma[st].next[j];
        if (nst != -1)
          table[str[i] - 'a'][j] += cnt[nst];
      }
      st = pma[st].next[str[i] - 'a'];
    }
    return make_pair(table, res);
  }
};

/* ---------------------------------- Main ---------------------------------- */

int main() {
  int N, Q;
  cin >> N;
  vector<string> strs(N);
  REP(i,N) cin >> strs[i];
  Trie trie(strs);

  vector<pair<vector<vector<int>>,int>> pre(N);
  REP(i,N) pre[i] = trie.query(strs[i]);

  cin >> Q;
  REP(i,Q) {
    int k; string ord;
    cin >> k >> ord; --k;
    int res = pre[k].second;
    REP(i,26) REP(j,i) {
      int from = ord[i] - 'a';
      int to   = ord[j] - 'a';
      res += pre[k].first[from][to];
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 372456
#include<cstdio>
#include<cstring>
using namespace std;
int n;
char a[105][13];
int main()
{
	scanf("%d",&n);
	scanf("%s",a[1]);
	for(int i=2;i<=n;++i) {
		scanf("%s",a[i]);
		for(int j=1;j<i;++j) if(strcmp(a[i],a[j])==0) {puts("No");return 0;}
		if(a[i][0]!=a[i-1][strlen(a[i-1])-1]) {puts("No");return 0;}
	}
	puts("Yes");
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(b == 1) cout << '0' << endl;
    else{
        int cnt = 1;
        b -= a;
        a -= 1;
        while(b >= 1){
            b -= a;
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  vi v(N); in(v);
  ll a = 1, b = 1;
  rep(i,N){
    a *= 3;
    b *= 1 + (v[i] % 2 == 0);
  }
  out(a - b);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

bool ask(ll n) {
    cout << "? " << n << endl;
    char ans;
    cin >> ans;
    return ans == 'Y';
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll t[19];

    t[0] = 1;
    rep(i, 18) t[i + 1] = t[i] * 10;

    if(ask(1e12)) {
        int ng = -1, ok = 9;
        while(ng + 1 < ok) {
            int mid = ok + ng >> 1;
            (ask(t[mid] * 2) ? ok : ng) = mid;
        }
        cout << "! " << t[ok] << endl;
    } else {
        int ok = 0, ng = 10;
        while(ok + 1 < ng) {
            int mid = ok + ng >> 1;
            (ask(t[mid]) ? ok : ng) = mid;
        }
        ll l = t[ok], r = t[ng];
        while(l + 1 < r) {
            ll mid = l + r >> 1;
            (ask(mid * 10) ? r : l) = mid;
        }
        cout << "! " << r << endl;
    }

    return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int n, k;
vector<int> w;

bool check(ll x) {
  int i = 0;
  rep (j, k) {
    ll weight = 0;
    while (w[i] + weight <= x) {
      weight += w[i++];
      if (i == n) return true;
    }
  }
  return false;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n >> k;
    w.resize(n);
    rep (i, n) cin >> w[i];
    ll left = -1, right = 100000 * 10000;
    while (right - left > 1) {
      ll mid = (left + right) / 2;
      if (check(mid)) right = mid;
      else left = mid;
    }
    cout << right << endl;
    
    return 0;
}




Measured memory_bytes: 3328
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        Scanner sc = new Scanner(System.in);
        String line=sc.nextLine();
int l=0;
        while(line!="0 0 0"){

            String[]s=line.split(" ",0);
            int n=Integer.parseInt(s[0]);
            int m=Integer.parseInt(s[1]);
            int p=Integer.parseInt(s[2]);
            if(n==0&&m==0&&p==0){
                break;
            }
            int ans=0;
            int []g=new int [n];
            for(int i=0;i<n;i++){
                line=sc.nextLine();
                g[i]=Integer.parseInt(line);
                ans+=Integer.parseInt(line);
            }
if(g[m-1]!=0)
            System.out.println((ans*(100-p))/g[m-1]);
            else
System.out.println(0);
            line=sc.nextLine();
        }
    }
}


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

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

  int N; cin >> N;
  vector<int> a;

  rep(i, N) {
    int A; cin >> A;
    auto p = lower_bound(a.rbegin(), a.rend(), A);
    if(p == a.rbegin()) {
      a.push_back(A);
    } else {
      --p;
      *p = A;
    }
  }

  cout << a.size() << endl;
}


Measured memory_bytes: 892
#
# ~oisín~ Python3 Template
#

import sys
import math
import statistics
import datetime
import collections

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    e = False
    for x in a:
        if ans > 1000000000000000000:
            print("-1")
            e = True
            break
        ans *= x
    if ans > 1000000000000000000 and e == False:
        print("-1")
    elif e == False:
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 94076
#include<iostream>
#include<vector>
#include<algorithm>
  
const int INF=1000000000;
  
using namespace std;
  
int main(void){
  
  int n,m,c,s,g,x,y,d,C;
  int p[21],q[21][51],r[21][51];
  int graph[21][101][101],G[101][101],cost[21][20001];
    
  while(cin >> n >> m >> c >> s >> g,n|m|c|s|g){
    
    fill(graph[0][0],graph[21][101],INF);
    fill(G[0],G[101],INF);
 
    for(int i=0;i<21;i++)
      for(int j=0;j<101;j++)graph[i][j][j]=0;
    
    for(int i=0;i<m;i++){
      cin >> x >> y >> d >> C;
      graph[C][x][y]=graph[C][y][x]=min(graph[C][x][y],d);
    }
    
    for(int i=1;i<=c;i++)cin >> p[i];
    
    for(int i=1;i<=c;i++){
      for(int j=1;j<p[i];j++)cin >> q[i][j];
      for(int j=1;j<=p[i];j++)cin >> r[i][j];
    }
    
    for(int l=1;l<=c;l++)
      for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	    graph[l][i][j]=min(graph[l][i][j],graph[l][i][k]+graph[l][k][j]);
    
    fill(cost[0],cost[21],0);
    
    for(int i=1;i<=c;i++){
      for(int j=1,k=0;j<20001;j++){
	if(k<p[i] && q[i][k]<j)k++;
	cost[i][j]=cost[i][j-1]+r[i][k];
      }
    }
    
    for(int l=1;l<=c;l++)
      for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	  if(graph[l][i][j]!=INF)
	    G[i][j]=min(G[i][j],cost[l][graph[l][i][j]]);

    for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	  G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
    
    if(G[s][g]==INF)cout << -1 << endl;
    else cout << G[s][g] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <iostream>
#include <math.h>

#define PI 3.1415926535897932

using namespace std;

int main() {
	int hosu;
	int kaku1 = 90;
	int kaku2;
	char a;
	double kita = 0.0;
	double higasi = 0.0;

	while(1) {
		cin >> hosu >> a >> kaku2;

		if(hosu == 0 && kaku2 == 0) {
			break;
		}

		kita += hosu * sin(PI * (double)kaku1 / 180.0);
		higasi += hosu * cos(PI * (double)kaku1 / 180.0);

		kaku1 += kaku2;
	}

	cout << -(int)higasi << endl << (int)kita << endl;

	return 0;
}

Measured memory_bytes: 1164
N=int(input())
A = list(int(i) for i in input().split())
B = list(int(i) for i in input().split())

check=0
max_c=0
c=0

for i in range(1,N):
  c+=(A[i]-B[i-1])
  if max_c<c:
    max_c=c
    check=i
ans=0
for j in range(check+1):
  ans+=A[j]
for k in range(check,N):
  ans+=B[k]
print(ans)

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

using namespace std;


int main() {
	int n, v;
	long sum;

	cin >> n;
	sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v;
		sum += v;
	}
	cout << sum / n << endl;

	return 0;
}


Measured memory_bytes: 3084
n, m = input().split()
fav_foods = {}
for i in range(0, int(n)):
    foods = input().split()
    for food in foods[1:]:
        if not food in fav_foods:
            fav_foods[food] = 1
        else:
            fav_foods[food] += 1

res = 0
for food in fav_foods.keys():
    if fav_foods[food] == int(n):
        res += 1
print(res)
    
        

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		out.println(instr().substring(0, 1) + instr().substring(0, 1) + instr().substring(0, 1));

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	vector<ll> A(9);
	REP(i, 9) cin >> A[i];
	ll N;
	cin >> N;
	vector<ll> b(N);
	REP(i, N) cin >> b[i];

	REP(i, N) {
		REP(j, 9) {
			if (A[j] == b[i]) A[j] = -1;
		}
	}

	bool can = false;
	if (A[0]==-1 && A[1]==-1 && A[2]==-1) can = true;
	if (A[3]==-1 && A[4]==-1 && A[5]==-1) can = true;
	if (A[6]==-1 && A[7]==-1 && A[8]==-1) can = true;
	if (A[0]==-1 && A[3]==-1 && A[6]==-1) can = true;
	if (A[1]==-1 && A[4]==-1 && A[7]==-1) can = true;
	if (A[2]==-1 && A[5]==-1 && A[8]==-1) can = true;
	if (A[0]==-1 && A[4]==-1 && A[8]==-1) can = true;
	if (A[2]==-1 && A[4]==-1 && A[6]==-1) can = true;

	if (can) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
ll N,M;
typedef struct{
    ll to;
    ll cap;
    ll rev;
} edge;
vector<edge> G[1010];
bool used[1010];

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,0,M){
        ll u,v,c;
        cin >> u >> v >> c;
        G[u].push_back((edge){v, c, G[v].size()});
        G[v].push_back((edge){u, 0, G[u].size() - 1});
    }
    ll ans = 0;
    while(1){
        memset(used, 0, sizeof(used));
        ll f = dfs(0, N-1, INF);
        if(f == 0) break;
        ans += f;
    }
    print(ans);

    
}


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

using namespace std;

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

    int n, ans = 0;
    cin >> n;
    int arr[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i], ans = __gcd(ans, arr[i]);

    cout << ans << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
 
    void solve(){
        string s;
        cin>>s;
        int maxi=0;
        s.push_back('S');
        int total=0;
        for(int i=0;i<s.size();i++){
            if(s[i]=='R')
                total++;
            else{
                maxi=max(maxi,total);
                total=0;
            }
        }
        cout<<maxi;
        return;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3652
def main():
    from itertools import product

    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]
    S_T = [[int(s[w]) for s in S] for w in range(W)]
    sumS = sum(map(sum, S_T))
    ans = (H - 1) * (W - 1)

    if sumS <= K:
        print(0)
    else:
        for i in product([True, False], repeat=H-1):
            cnt = sum(i)
            if cnt >= ans:
                continue
            M = [[0]]
            for j, k in enumerate(i):
                if k:
                    M.append([])
                M[-1].append(j+1)
            A = [0] * len(M)
            for s_t in S_T:
                for l, m in enumerate(M):
                    A[l] += sum(s_t[i] for i in m)
                if any(a > K for a in A):
                    cnt += 1
                    if cnt >= ans:
                        break
                    A = [sum(s_t[i] for i in m) for m in M]
                    if any(a > K for a in A):
                        cnt = ans + 1
                        break
            ans = min(cnt, ans)
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
// https://atcoder.jp/contests/abc061/tasks/abc061_b
//  B - Counting Roads
//

#include <stdio.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(int argc, const char * argv[]) {
    int i, n, m, a, b;
    int x[50] = {0};
    
    n = get_num();
    m = get_num();
    
    for (int i = 0; i < m; i++) {
        a = get_num();
        b = get_num();
        x[a-1] += 1;
        x[b-1] += 1;
    }
    
    for (int i = 0; i < n; i++) {
        printf("%d\n", x[i]);
    }
    
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a,b,c;
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		
		if(a==b && b==c)
		{
			System.out.println("No");
			System.exit(0);
		}
		
		else if(a==b)
		{
			System.out.println("Yes");
		}
		else if(c==b)
		{
			System.out.println("Yes");
		}
		else if(a==c)
		{
			System.out.println("Yes");
		}
		
		else
		{
			System.out.println("No");
		}
	}
}

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

int main()
{
	int a, b;
	
	scanf("%d%d", &a, &b);
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		puts("Possible");
	} else {
		puts("Impossible");
	}
}

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

int main() {
  int64_t n;
  cin>>n;
  vector<int64_t> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int64_t S=0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int count=0;
  int64_t x=0,y=0;
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      if(count==0){
        count++;
        x=a.at(i);
        i++;
        continue;
      }
      if(count==1){
        count++;
        y=a.at(i);
        continue;
      }
      if(count==2){
        break;
      }
    }
  }
  S=x*y;
  cout<<S<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <list>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int N, A[100010];
int deg[100010];
int cyc[100010];

map <int, int> OC;

int p[100010], z[100010];
int Find(int x){return p[x] == x ? x : p[x] = Find(p[x]); }
int chk[100010];

const int MOD = 1e9 + 7;
ll D[100010];
int d[100010];

int get(int X){
	int res = 1;
	vector <int> v; v.pb(d[X]);
	int t = A[X];
	while(t != X){
		v.pb(d[t]);
		t = A[t];
	}
	int L = sz(v);
	for(int S=0;S<L;S++)if(v[S] != 1){
		for(int j=0;j<L;){
			int t = v[(S-j+L)%L];
			if(t == 0){j++; continue; }
			for(int k=1;k<t;k++){
				if(v[(S-j-k+L+L)%L] > 0)return 0;
			}
			if(v[(S-j-t+L+L)%L] > 0){
				j += t;
			}
			else{
				j += t + 1;
				res = res * 2 % MOD;
			}
		}
		break;
	}
	return res;
}
void solve(){
	scanf("%d", &N);
	for(int i=1;i<=N;i++)scanf("%d", A+i);
	for(int i=1;i<=N;i++)deg[A[i]]++;
	queue <int> que;
	for(int i=1;i<=N;i++)if(deg[i] == 0)que.push(i);
	while(!que.empty()){
		int t = que.front(); que.pop();
		deg[A[t]]--;
		d[A[t]] = d[t] + 1;
		if(deg[A[t]] == 0){
			que.push(A[t]);
		}
	}
	for(int i=1;i<=N;i++)cyc[i] = deg[i], deg[i] = 0;
	for(int i=1;i<=N;i++)deg[A[i]]++;
	for(int i=1;i<=N;i++){
		if(deg[i] > 2 || (deg[i] == 2 && cyc[i] == 0)){
			printf("0");
			return;
		}
	}
	for(int i=1;i<=N;i++)p[i] = i, z[i] = 1;
	for(int i=1;i<=N;i++){
		int x = Find(i), y = Find(A[i]);
		if(x != y)p[x] = y, z[y] += z[x];
	}
	for(int i=1;i<=N;i++)if(deg[i] == 2)chk[Find(i)] = 1;
	for(int i=1;i<=N;i++)if(Find(i) == i && chk[i] == 0)OC[z[i]]++;
	ll ans = 1;
	for(auto e : OC){
		D[0] = 1;
		int t = ((e.Fi % 2 == 1 && e.Fi > 1) ? 2 : 1);
		for(int i=1;i<=e.Se;i++){
			D[i] = t * D[i-1] + (i > 1 ? ((ll)(i-1) * e.Fi % MOD) * D[i-2] : 0);
			D[i] %= MOD;
		}
		ans = ans * D[e.Se] % MOD;
	}
	for(int i=1;i<=N;i++)if(Find(i) == i && chk[i] == 1){
		ans = ans * get(i) % MOD;
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3232
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split(" ");
    tmp = tmp.map(Number);
    M = Math.max.apply(null,tmp);
    max_key = tmp.indexOf(M);
    tmp = tmp.filter(n => n !==M);

    answer = tmp[0]*tmp[1]*0.5;
    
    console.log(answer);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main{
         public static void main(String[] args) {
		int i = 1;
                Scanner sc = new Scanner(System.in);
                while (true) {
			int num = sc.nextInt();
			if (num == 0) break;
			System.out.printf("Case %d: %d\n", i, num);
			i ++;
		}
	}
}

Measured memory_bytes: 62720