akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <set>
#define LL long long
#define MAXN 200010
using namespace std;

int n,m;
LL ti[MAXN],L,d[MAXN],sd[MAXN];
int p[MAXN][2],nump;
int pre[MAXN][21];
set< pair<LL,int> > S1,S2;

int getp(LL v,LL delta){
	int t1=n+1,t2=n+1;
	set< pair<LL,int> >::iterator it=S1.lower_bound(make_pair(delta-v,0));
	if(it!=S1.begin()) t1=(--it)->second;
	it=S2.lower_bound(make_pair(L+delta-v+1,0));
	if(it!=S2.end()) t2=it->second;
	if(t1==n+1 && t2==n+1) return nump+1;
	if(t1<t2) return p[t1][0];
	else return p[t2][1];
}

void pre_gao(int x){
	while(!S1.empty() && (--S1.end())->first>=sd[x]) S1.erase(--S1.end());
	S1.insert(make_pair(sd[x],x));
	while(!S2.empty() && S2.begin()->first<=sd[x]) S2.erase(S2.begin());
	S2.insert(make_pair(sd[x],x));
	pre[p[x][0]][0]=getp(0,sd[x]);
	pre[p[x][1]][0]=getp(L,sd[x]);
}

LL calc(LL delta,LL v,LL t){
	int l=0,r=n;
	while(l<r){
		int mid=(l+r+1)>>1;
		if(ti[mid]<=t) l=mid;
		else r=mid-1;
	}
	LL res=v+sd[l]-delta;
	if(l&1) res+=t-ti[l];
	else res-=t-ti[l];
	if(res<0) res=0;
	if(res>L) res=L;
	return res;
}

LL query(LL t,LL v){
	int temp=getp(v,0);
	if(!temp || ti[temp]>t) return calc(0,v,t);
	for(int i=20;i>=0;i--)
		if(ti[pre[temp][i]]<=t)
			temp=pre[temp][i];
	return calc(sd[(temp-1)%n+1],(temp>n)?L:0,t);
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%lld%d",&L,&n);
	n++;
	for(int i=1;i<=n;i++){
		if(i<n) scanf("%lld",ti+i);
		else ti[i]=ti[i-1]+L;
		d[i]=ti[i]-ti[i-1];
		if(i&1) d[i]=-d[i];
		sd[i]=sd[i-1]+d[i];
	}
	for(int i=1;i<=n;i++) p[i][0]=++nump;
	for(int i=1;i<=n;i++) ti[p[i][1]=++nump]=ti[i];
	ti[nump+1]=1LL<<60;
	for(int i=n;i>=1;i--) pre_gao(i);
	for(int j=0;j<=20;j++) pre[nump+1][j]=nump+1;
	for(int i=n;i>=1;i--){
		for(int j=1;j<=20;j++) pre[p[i][0]][j]=pre[pre[p[i][0]][j-1]][j-1];
		for(int j=1;j<=20;j++) pre[p[i][1]][j]=pre[pre[p[i][1]][j-1]][j-1];
	}
	scanf("%d",&m);
	while(m--){
		LL t,v;
		scanf("%lld%lld",&t,&v);
		if(t>ti[n]) t=ti[n];
		printf("%lld\n",query(t,v));
	}
	return 0;
}


Measured memory_bytes: 23936
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial
mod = 1000000007
x,y = [int(x) for x in stdin.readline().rstrip().split()]

if (x+y)%3 != 0:
    print(0)
    exit()

a = (2*x-y)//3
b = (2*y-x)//3

if a < 0 or b < 0:
    print(0)
    exit()

def combination(n,r,mod=10**9+7):
    r=min(r,n-r)
    up,down=1,1
    for i in range(r):
        up=up*(n-i)%mod
        down=down*(i+1)%mod
    return up*pow(down,mod-2,mod)%mod

print(combination(a+b,a))

Measured memory_bytes: 13212
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k;
     cin>>n>>k;
   int a[n],sum=0;


   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   sort(a,a+n);
  // reverse(a,a+n);
    for(int i=0;i<k;i++)
   {
       sum=sum+a[i];
   }
   cout<<sum<<endl;
   return 0;


}


Measured memory_bytes: 3632
//7-12-19
#include<bits/stdc++.h>

#define Pi acos(-1.0)
#define ll long long
#define uu first
#define vv second
#define scl(n) scanf("%d",&n)
#define scll(n) scanf("%lld",&n)

//Vector Macros
#define pb push_back
#define eb emplace_back
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c),0)

//Loop Macros
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define For(i,n) for(int i=0;i<n;i++)

//Debug Macros
#define deb(a) cout << #a << " : " << a << " ";
#define debln(a) cout<< #a <<" : " << a << endl;
#define open  freopen("input.txt","r",stdin);
#define close freopen ("output.txt","w",stdout);

#define fastio ios::sync_with_stdio(false);cin.tie(nullptr);

//Print Macros
#define print(v)  for(auto x : v) {  cout<<x<<" ";   }  cout<<endl;
#define PRINT(v)  for(auto x : v) { cout<<x.uu<<" "<<x.vv<<endl; }

using namespace std;



int main()
{
    //open
    //close
    //fastio
    
    string s;
    cin>>s;
    
    int sz=s.size();
    int cnt_o=0;
    int cnt_O=0;
    for(int i=0,j=sz-1;i<sz/2 ;i++,j--){
        
        if(s[i]!=s[j])
        cnt_o++;
        
    }
   for(int i=0,j=sz/2;j<sz;i++,j++){
       
       if(s[i]!=s[j])
       cnt_O++;
       
   }
    //cout<<cnt_o<<" "<<cnt_O<<endl;
    cout<<cnt_o<<endl;
    
    return 0;
}




Measured memory_bytes: 256
N,M=map(int,input().split())
MOD=(10**9)+7
a=[0 for i in range(N+1)]
for _ in range(M):
  A=int(input())
  a[A]=-1
a[0]=1

for i in range(N):
  if a[i]==-1:
    continue
  if a[i+1]!=-1:
    a[i+1]+=a[i]
    a[i+1]%=MOD
  if i+2<=N and a[i+2]!=-1:
    a[i+2]+=a[i]
    a[i+2]%=MOD
print(max(0,a[N]))

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


typedef long long ll;

const int maxn=3010;

int a[maxn][maxn];
bool vis[maxn];
ll dp[3005][3005][4];

int main() 
{
    int n,m,k;
    cin>>n>>m>>k;
    
    for( int i=1;i<=k;i++ )
    {
    	int x,y,w;
    	cin>>x>>y>>w;
    	a[x][y]=w;
    }
    
    dp[1][1][1]=a[1][1];
    for( int i=1;i<=n;i++ )
    {
    	for( int j=1;j<=m;j++ )
    	{
    		if( i==1 && j==1 ) continue;
    		
    		ll maxup=max(dp[i-1][j][3],max(dp[i-1][j][2],max(dp[i-1][j][1],dp[i-1][j][0])));
    		dp[i][j][0]=max(maxup,dp[i-1][j][0]);
    		for( int k=1;k<=3;k++ )
    		{
    			dp[i][j][k]=max(dp[i][j-1][k-1]+a[i][j],dp[i][j-1][k]);
    		}
    		dp[i][j][1]=max(maxup+a[i][j],dp[i][j][1]);
    	}
    }
    ll ans=max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])));
    cout<<ans<<endl;
}

Measured memory_bytes: 320540
N = int(input())
S = []
for i in range(0, N):
    A, B = list(map(int, input().split()))
    S.append((B, A))
S.sort(reverse=True)
T_all = 0
for i in range(0, N):
    T_all += S[i][1]
for i in range(0, N):
    if (T_all > S[i][0]):
        print("No")
        break
    else:
        T_all -= S[i][1]
else:
    print("Yes")

Measured memory_bytes: 67288
#include <iostream>

signed main() {

  std::ios_base::sync_with_stdio(false);

  int k, x;
  std::cin >> k >> x;

  for(int i = std::max(-1000000, x - k + 1); i <= x; ++i) {
    std::cout << i << ' ';
  }
  for(int i = x + 1; i <= std::min(1000000, x + k - 1); ++i) {
    std::cout << i << ' ';
  }
  
  std::cout << std::endl;

  return 0;
}

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

using namespace std;

int main() {
    
    int n;
    string s;
    cin >> n >> s;
    
    char last = '#';
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] != last) ans++;
        last = s[i];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define range(i,a) for(ll i=(0);i<(a);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define bug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define bugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)

using namespace std;
using ll=long long;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int n,k; cin>>n>>k;
  double p=0.0;
  rep(i, 1, n) {
    ll need = (k+(i-1)) / i;
    auto p1 = 1.0/n; ll f = 1; 
    while(f < need) {f = f << 1; p1/=2;}
    p+=p1;
  }
  cout << setprecision(20) << p << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
K = []
for i in range (N):
    K.append(list(map(int,input().split())))
ans = 0
yobi = 0

for i in range(1,M+1):
    for j in range (N):
        for k in range(1,K[j][0]+1):
            if K[j][k]  == i:
                yobi += 1
        
    if yobi == N:
        ans += 1
        yobi = 0
    
    else:
        yobi = 0

print(ans)    
        

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;

ll ans=0,N;

ll dfs(ll num,bool ans3,bool ans5,bool ans7) {
  if (ans3 && ans5 && ans7) ans+=1;
 
  if (num*10+3<=N) dfs(num*10+3,true,ans5,ans7);
  if (num*10+5<=N) dfs(num*10+5,ans3,true,ans7);
  if (num*10+7<=N) dfs(num*10+7,ans3,ans5,true);
}
 
int main() {
  cin >> N;
  dfs(0,0,0,0);
  cout << ans << endl;
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#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 print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    int d[100];
    cin >> n;
    rep(i, n) cin >> d[i];

    int ans = 0;
    for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) ans += d[i] * d[j];

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  char C;
  cin>>C;
  cout<<char(C+1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;

struct Node{
	int key;
	Node *p, *l, *r;
};

Node *root, *NIL;

void insert(int key){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = key;
	z->l = NIL;
	z->r = NIL;

	while(x != NIL){
		y = x;
		if(z->key < x->key)	
			x = x->l;
		else
			x = x->r;
	}

	z->p = y;
	if(y == NIL)
		root = z;
	else{
		if(z->key < y->key)
			y->l = z;
		else
			y->r = z;
	}
}

void preParse(Node *u){
	if(u == NIL)
		return;
	cout << " " << u->key;
	preParse(u->l);
	preParse(u->r);
}

void inParse(Node *u){
	if(u == NIL)
		return;
	inParse(u->l);
	cout << " " << u->key;
	inParse(u->r);
}

Node * find(Node *u, int key){
	while(u != NIL && key != u->key){
		if(key < u->key)	
			u = u->l;
		else
			u = u->r;
	}
	return u;
}

Node * treeMinimum(Node *u){
	while(u->l != NIL)
		u = u->l;
	return u;
}

Node * treeSuccessor(Node *u) {
	if(u->r != NIL)
		return treeMinimum(u->r);
	Node *y = u->p;
	while(y != NIL && u == y->r){
		u = y;
		y = y->p;
	}
	return y;
}

void treeDelete(Node *z){
	Node *y;
	Node *x;
	if(z->l == NIL || z->r == NIL)
		y = z;
	else	
		y = treeSuccessor(z);

	if(y->l != NIL)
		x = y->l;
	else
		x = y->r;

	if(x != NIL)
		x->p = y->p;
	
	if(y->p == NIL)
		root = x;
	else{
		if(y == y->p->l)
			y->p->l = x;
		else
			y->p->r = x;
	}
	if(y != z){
		z->key = y->key;
	}
	free(y);
}

int main(){
	int n, temp;
	char s[10];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s;
		if(s[0] == 'i'){
			cin >> temp;
			insert(temp);
		}
		else if(s[0] == 'f'){
			cin >> temp;
			Node *flag = find(root, temp);
			if(flag != NIL)	cout << "yes" << endl;
			else	cout << "no" << endl;
		}
		else if(s[0] == 'd'){
			cin >> temp;
			treeDelete(find(root, temp));
		}
		else{
			inParse(root);
			cout << endl;
			preParse(root);
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 21736
package main

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

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	matrix := make([]int, N)
	for i := 0; i < M; i++ {
		A, B := sc.NextInt(), sc.NextInt()
		A--
		B--
		matrix[A]++
		matrix[B]++
	}
	for i := 0; i < N; i++ {
		fmt.Println(matrix[i])
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll g[3];
    bool odd = true;
    rep(i, 3) {
        cin >> g[i];
        if(!(g[i]&1)) odd = false;
    }
    if(!odd) {
        cout << 0 << endl;
    } else {
        cout << min({g[0]*g[1], g[1]*g[2], g[0]*g[2]}) << endl;
    }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

const int MAXN = 2010;
int n, K, e, Begin[MAXN], ans;
int to[MAXN<<1], Next[MAXN<<1];
int fa[MAXN];

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

inline void Add(int u, int v) {
	to[++e] = v, Next[e] = Begin[u];
	Begin[u] = e;
}

int dfs(int u, int K) {
	if(K == 0) return 1;
	int i, res = 1;
	for(i = Begin[u]; i; i = Next[i]) {
		if(to[i] == fa[u]) continue;
		fa[to[i]] = u;
		res += dfs(to[i], K-1);
	}
	return res;
}

int main() {
	int i;
	n = read(), K = read();
	for(i = 1; i < n; i++) {
		int u = read(), v = read();
		Add(u, v), Add(v, u);
	}
	ans = n;
	if(K & 1) {
		for(i = 1; i < n; i++) {
			int x = to[(i<<1)-1], y = to[i<<1];
			fa[x] = y, fa[y] = x;
			ans = min(ans, n-dfs(x, K>>1)-dfs(y, K>>1));
		}
	}
	else {
		for(i = 1; i <= n; i++) {
			fa[i] = 0;
			ans = min(ans, n-dfs(i, K>>1));
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var X = cin.next[0];
        var Y = cin.next[0];
        if (X < Y)
        {
            WriteLine("<");
        }
        else if (Y < X)
        {
            WriteLine(">");
        }
        else
        {
            WriteLine("=");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092
n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
mod=pow(10,9)+7
dp=[0]*(1<<n)
dp[0]=1
for i in range(1<<n):
    cnt=0
    v=[]
    #　bitが何個たつか調べる
    for j in range(n):
        if (i>>j)&1:
            cnt+=1
            v.append(j)
    for j in v:
        dp[i] += dp[i ^ (1 << j)] * a[j][cnt-1]

print(dp[-1]%mod)

Measured memory_bytes: 102108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(),vecto.end()
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a%2!=0&&b%2!=0){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int R = cin.nextInt();
        if (R >= 2800)
        {
            Console.WriteLine("AGC");
        }
        else if (R >= 1200)
        {
            Console.WriteLine("ARC");
        }
        else
        {
            Console.WriteLine("ABC");
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

vector <ll> Prime;
bool prime(int num){
  if (num == 1) return false;
  for (int i = 2; i * i <= num; i++){
    if (num % i == 0) return false; 
  }
  return true;
}

ll DP[int(1e7 + 5)];
bool visited[int(1e7 + 5)];
int Count(ll Before, int Index){

  for (int i = Index; i < Prime.size(); i++){
    ll cnt = 1, Now = Before * Prime[i];
    if (Now > 1e7) break;

    while (Now <= 1e7){
      DP[Now] = DP[Before] * (cnt + 1);
      Count(Now, i + 1);
      Now *= Prime[i]; cnt++;
    }
  }
  return 0;
}

int main(){
  Prime.push_back(2);
  for (int i = 3; i <= 5e6; i+=2){
    if (prime(i)) Prime.push_back(i);
  }

  DP[1] = 1; Count(1, 0);

  int N; cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i++){
    if (DP[i] == 0) ans += i * 2;
    else ans += i * DP[i];
  }
  cout << ans << endl;

  return 0;
}



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

int n,q;
int tree[10000];
void init(){
  for(int i=0;i<n;i++){
    tree[i]=i;
  }
}
int root(int x){
  if(tree[x]==x) return x;
  return tree[x]=root(tree[x]);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  tree[x]=y;
}
int same(int x,int y){
  return root(x)==root(y);
}
int main(){
  cin>>n>>q;
  init();
  int com,x,y;
  for(int i=0;i<q;i++){
    cin>>com>>x>>y;
    if(com==0) unite(x,y);
    else cout<<same(x,y)<<"\n";
  }
}



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

int main()
{
  int n,l;
  cin >> n >> l;
  
  int a[n];
  int all = 0;
  for(int i = 1; i <= n; i++){
    a[i] = l + i - 1;
    all += a[i];
  }
  
  int minu = 0,maxmin = 2000000;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(j != i){
        minu += a[j];
      }//if
    }//for
    if(abs(minu - all) < abs(maxmin - all)){
      maxmin = minu;
    }
    minu = 0;
  }
  
  cout << maxmin << endl;
    
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, D;

    cin >> N >> D;
    ll count = 0;
    REP(i, N){ 
        ll X, Y;
        cin >> X >> Y;
        if( sqrt(X*X + Y*Y) <= (double)D){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int X, A, B;
            cin >> X >> A >> B;
                if(B <= A){
                    cout << "delicious" << endl;
                }else if(A < B && B <= A + X){
                    cout << "safe" << endl;
                }else if(A + X + 1 <= B){
                    cout << "dangerous" << endl;
                }else{}
    return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define endl '\n'
using namespace std;
const int MOD = 1000000007, MAX = 2000000007, MAXN = 100005;
vector<int> l;

void solve(int n)
{
    
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,x;
    cin>>n>>x;
    l.push_back(0);
    for(int i=0; i<n; i++)
    {
        int ele;
        cin>>ele;
        l.push_back(l.back()+ele);
    }
    int low = lower_bound(l.begin(),l.end(),x)-l.begin();
    if(l[low] == x)
        cout<<low+1;
    else
    {
        cout<<low;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 1e9+7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

int c[N];
int mat[13][13];
int temp[13];

void solve () {
    int n,m,x;cin>>n>>m>>x;
    for (int i=0;i<n;i++) {
        cin>>c[i];
        for (int j=0;j<m;j++) {
            cin>>mat[i][j];
            // cout<<mat[i][j]<<" ";
        }
        // cout<<endl;
    }
    int ans = INF;
    // Understaning of all m is greater than x.
    for (int msk=1;msk<(1<<n);msk++) {
        for (int i=0;i<=m;i++) temp[i] = 0;
        int cc = 0;
        for (int j=0;j<n;j++) {
            // Should Take This.
            if (msk & (1<<j)) {
                cc += c[j];
                for (int k=0;k<m;k++) temp[k] += mat[j][k];
            }
        }
        bool ok = true;
        for (int k=0;k<m;k++) {
            if (temp[k] < x) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = min(ans,cc);
        }
    }
    if (ans == INF) ans = -1;
    cout<<ans<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

public class Main{
    public static void main(String[] args){
        PrintWriter out=new PrintWriter(System.out);
        Scanner ir=new Scanner(System.in);
        for(;;){
            int n=ir.nextInt();
            long m=ir.nextLong();
            long k=ir.nextLong();
            if(n==0&&m==0&&k==0){
                break;
            }
            long[] pos=new long[n+1];
            pos[n]=m;
            for(int i=n-1;i>=0;i--){
                if(pos[i+1]<=1L<<i){
                    pos[i]=(1L<<i)+1-pos[i+1];
                }
                else{
                    pos[i]=pos[i+1]-(1L<<i);
                }
            }
            StringBuilder sb=new StringBuilder();
            long cur=k;
            for(int i=0;i<n;i++){
                if(cur<=1L<<(n-i-1)){
                    if(pos[i+1]<=1L<<i){
                        cur=calcleft(cur, i+1, n);
                        sb.append("L");
                    }
                    else{
                        cur=calcright(cur, i+1, n);
                        sb.append("R");
                    }
                }
                else{
                    if(pos[i+1]<=1L<<i){
                        cur=calcright(cur, i+1, n);
                        sb.append("R");
                    }
                    else{
                        cur=calcleft(cur, i+1, n);
                        sb.append("L");
                    }
                }
                //out.println(cur+" "+i+" "+pos[i]);
            }
            out.println(sb);
        }
        out.flush();
    }

    static long calcleft(long cur, int t,int n){
        if(cur>1L<<(n-t)){
            return cur-(1L<<(n-t));
        }
        return (1L<<(n-t))+1-cur;
    }

    static long calcright(long cur, int t,int n){
        if(cur<=1L<<(n-t)){
            return cur;
        }
        return (1L<<(n-t+1))-cur+1;
    }
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()
#define fst first
#define sec	second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<long,long> P;

const int mod = 1e9 + 7;


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

	int n;
	cin >> n;
	vi h(n);
	rep(i, n){
		cin >> h[i];
	}

	bool fl = true;
	int sum,ans=0;
	rep(i, n-1){
		sum=0;
		rept(j, i, n-1){

			if(h[j] >= h[j+1]){
				sum++;
			}else{
				break;
			}
		}
		ans = max(ans, sum);
		if(ans >= n/2)break;
	}

	cout << ans << endl;
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int n; cin >> n;
    vector<int> v(n);
    vector<pair<int, int>> odd(100001), even(100001);
    ll sum = n;
    for(int i = 0; i < 100001; i++) {
        odd[i].second = i;
        even[i].second = i;
    }
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        if(i % 2 == 0) odd[v[i]].first++;
        else even[v[i]].first++;
    }
    sort(odd.begin(), odd.end());
    sort(even.begin(), even.end());
    ll O = odd[100000].second, E = even[100000].second;
    if(O == E) {
        if(odd[100000].first == even[100000].first) {
            if(odd[99999].first > even[99999].first) sum -= odd[99999].first + even[100000].first;
            else sum -= odd[100000].first + even[99999].first;
        }
        else if(odd[100000].first > even[100000].first) sum -= odd[100000].first + even[99999].first;
        else sum -= odd[99999].first + even[100000].first;
    }
    else {
        sum -= (odd[100000].first + even[100000].first);
    }
    cout << sum << endl;
}

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

const long long mod = 1000000007;

long long f(long long n)
{
	long long ans;

	ans = 1;
	for (long long i = n; i > 0; i--)
	{
		ans *= i;
		ans %= mod;
	}
	return ans;
}

signed main(void)
{
	long long n, m;
	cin >> n >> m;
	if (m == n)
		cout << 2 * f(m) * f(n) % mod << endl;
	else if (abs(m - n) == 1)
		cout << f(m) * f(n) % mod << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int people;
    
    scanf("%d", &people);

    long long height[people];

    scanf("%lld", &height[0]);

    long long sum=0;

    for(int i=1;i<people;i++){

        scanf("%lld", &height[i]);
        
        if(height[i-1]>height[i]){
            sum+=(height[i-1]-height[i]);
            height[i]=height[i-1];
        }
    }

    printf("%lld\n", sum);

    return 0;
}

Measured memory_bytes: 3656
N,M = map(int, input().split())
AC=[0]*N
WA=[0]*N
pena = 0
for _ in range(M):
    a,S = input().split()
    if S=='AC':
        AC[int(a)-1] = 1
    elif S=='WA' and AC[int(a)-1]==0:
        WA[int(a)-1] += 1
for i in range(N):
    if AC[i]:
        pena += WA[i]
print(sum(AC),pena)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 3 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fast;
    ll k;
    cin >> k;
    ll ans = 0;
    fore(i, 1, k + 1)
        fore(j, 1, k + 1)
            fore(l, 1, k + 1)
                ans += __gcd(i,__gcd(j,l));
    cout << ans << '\n';

    return 0;
}   

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
ll N,M,V,P;
vector<ll> A;

bool judge(ll key){
    ll L = key;
    ll K = A[key];
    if (K + M < A[N-P]) return false;
    if (key >= N - P) return true;
    ll canvote = M*L+(P-1)*M;
    ll limit = K + M;
    for (size_t i = key + 1; i <= N - P ; i++) {
        canvote += min(limit - A[i],M);
    }

    return canvote >= M * (V-1);

}

int binary_search(){
	// lower_bound (a-1,b] (ans = [a,b])
	// <= left never satisfy
	// right <= always satisfy

	int left = -1; 
	int right = N; // index of size + 1;

	while(right - left > 1){
			int mid = left + (right - left) / 2;

			if (judge(mid)) right = mid;
			else left = mid;
	}

	// left is the maximum that don't satisfy the condition.
	// right is the minimum that satisfies the condtion.
	
	return right; 

}

int main() {
    cin >> N >> M >> V >> P;
    REP(i,N){
        ll a; cin >> a;
        A.push_back(a);
    }

    sort(ALL(A));

    cout << N - binary_search() << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include <assert.h>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge { int to, cost; };
#define VMAX 100000

int K;
ll N, ans = 0;
ll X[100010], Y[100010];
ll W_[3010][3010], B_[3010][3010];
auto W = W_ + 3;
std::string C[100010];
//yxyx
ll imos(int a, int b, int c, int d, int mode) {
	assert(c < 2 * K || d < 2*K);
	if (mode == 0) return W[c][d] - W[c][b - 1] - W[a - 1][d] + W[a - 1][b - 1];
	//else        return B[c][d] - B[c][b - 1] - B[a - 1][d] + B[a - 1][b - 1];
	return 0;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin >> N >> K;
	REP(i, N) {
		cin >> X[i] >> Y[i] >> C[i];
		X[i] %= 2 * K, Y[i] %= 2 * K;
		if (C[i] == "W")W[Y[i]][X[i]] += 1;
		else W[Y[i]][(X[i] + K) % (2 * K)] += 1;
	}
	REP(i, 2 * K)REP(j, 2 * K) {
		W[i][j + 1] += W[i][j];
		//B[i][j + 1] += B[i][j];
	}
	REP(i, 2 * K)REP(j, 2 * K) {
		W[i + 1][j] += W[i][j];
		//B[i + 1][j] += B[i][j];
	}

	//for (size_t i = 0; i < 2 * K; i++)
	//{
	//	for (size_t j = 0; j < 2 * K; j++)
	//	{
	//		cout << W[i][j] << ' ';
	//	}
	//	cout << endl;
	//}

	REP(i, K)REP(j, K)REP(k, 2) {
		ll tans = 0;
		tans += imos(0    ,     0,     i - 1,     j - 1, 0);
		tans += imos(0    , j + K,     i - 1, 2 * K - 1, 0);
		tans += imos(i    ,     j, i + K - 1, j + K - 1, 0);
		tans += imos(K + i,     0, 2 * K - 1,     j - 1, 0);
		tans += imos(K + i, j + K, 2 * K - 1, 2 * K - 1, 0);
		ans = max(tans, ans);
		ans = max(W[2*K-1][2*K-1] - tans, ans);
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int cnt=0;
    int flag=0,maxx=0;
    for(int i=0;i<s.size();i++)
    {
        if(flag)
        {
            if(s[i]=='R')
                cnt++;
            else
                flag=0;
        }
        else
        {
            if(s[i]=='R')
                {flag=1;cnt=1;}
        }
        maxx=max(cnt,maxx);
    }
    cout<<maxx<<endl;
    return 0;
}


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

int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  bool f=false;
  if((W==x*2)&&(H==y*2)){
    f=true;
  }
  cout << fixed << setprecision(10) << W*H/2 << " " << f << endl;
}
      


Measured memory_bytes: 256
l=list(input())
for i in range(len(l)):
            del l[-1]
            if len(l)%2!=0:
                        del l[-1]
                        #print('1',l)
            if len(l)%2==0:
                        if l[:len(l)//2]==l[len(l)//2:]:
                                    print(len(l))
                                    exit()
                        else:
                                    del l[-1]
                                    #print('3',l)
                                    


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, K, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    for(int i=0;i<K;i++) {
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

int c_h[300300], c_w[300300];

signed main() {

    int h, w, m;

    cin >> h >> w >> m;

    map<pii, int> mp;

    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> y >> x;
        mp[{x - 1, y - 1}] = 1;
        c_h[y-1]++;
        c_w[x-1]++;
    }

    int m_h = 0, m_w = 0;
    int ih = 0, iw = 0;
    for(int i = 0; i < h; i++) {
        if(chmax(m_h, c_h[i])) ih = i;
    }

    for(int i = 0; i < w; i++) {
        if(chmax(m_w, c_w[i])) iw = i;
    }

    vector<int> mhs, mws;

    for(int i = 0; i < h; i++) {
        if(m_h == c_h[i]) mhs.bash(i);
    }

    for(int i = 0; i < w; i++) {
        if(m_w == c_w[i]) mws.bash(i);
    }

    for(auto&&y:mhs) {
        for(auto&&x:mws) {
            if(mp[{x, y}] == 0) {
                cout << m_h + m_w << endl;
                return 0;
            }
        }
    }

    cout << m_h + m_w - 1 << endl;
    return 0;
}

Measured memory_bytes: 28436
# N, M = 10, 3
# ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
# BRR = [
#     [3, 10],
#     [4, 30],
#     [1, 4]
# ]


N,M = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = []
for i in range(M):
    BRR.append(list(map(int,input().split())))

def calculate(n, m, arr, brr):
    raw = []
    for ar in arr:
        raw.append([ar, 1])
    for br in brr:
        raw.append([br[1], br[0]])

    raw = sorted(raw,key=lambda x:-x[0])
    # print(raw)

    offset = 0
    sum = 0
    for ra in raw:
        if offset + ra[1] <= n:
            sum = sum + ra[1] * ra[0]
            offset = offset + ra[1]
        else:
            sum = sum + (n - offset) * ra[0]
            offset = n
            break
    print(sum)

calculate(N, M, ARR, BRR)


Measured memory_bytes: 58116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;
vector<int> edge[100010];
int c[100010];

int qv[100010];
int qd[100010];
int qc[100010];

int best[100010][11];

int main()
{
	read(n, m);
	for(;m--;){
		int a, b; read(a, b);
		edge[a].pb(b); edge[b].pb(a);
	}
	int q;
	read(q);
	for(int i=1; i<=q; ++i){
		read(qv[i], qd[i], qc[i]);
		best[qv[i]][qd[i]] = i;
	}
	
	for(int d=9; d>=0; --d){
		for(int i=1; i<=n; ++i){
			for(int j:edge[i]){
				best[i][d] = max(best[i][d], best[j][d+1]);
			}
		}
	}
	
	for(int i=1; i<=n; ++i){
		printf("%d\n", qc[*max_element(best[i], best[i]+11)]);
	}
	return 0;
}


Measured memory_bytes: 12408
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

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

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

int ok[301];
vector<PP> G[301];

int main(){
	int a, b, c;
	int f[3], r;
	int n;
	while(cin >> a >> b >> c && (a || b || c)){
		fill(ok, ok + 301, 2);
		rep(i, 301) G[i].clear();
		cin >> n;
		rep(i, n){
			cin >> f[0] >> f[1] >> f[2] >> r;
			G[f[0]].push_back(PP(r, P(f[1], f[2])));
			G[f[1]].push_back(PP(r, P(f[0], f[2])));
			G[f[2]].push_back(PP(r, P(f[0], f[1])));
			if(r == 1){
				ok[f[0]] = ok[f[1]] = ok[f[2]] = 1;
			}
		}
		for(int i = 1; i <= a + b + c; i++){
			if(ok[i] == 1) continue;
			rep(j, (int)G[i].size()){
				if(G[i][j].first == 0 && ok[G[i][j].second.first] == 1
					&& ok[G[i][j].second.second] == 1){
						ok[i] = 0;
				}
			}
		}

		for(int i = 1; i <= a + b + c; i++) cout << ok[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<cassert>

using namespace std;
typedef long long ll;

static const int MAX_N = 2000;
static const int MAX_C = 1000000000;

int w, H, N;
ll X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];

int G[MAX_N*4+1][MAX_N*4+1];


vector<ll> compress(ll *c1, ll *c2){
  vector<ll> xs;

  for ( int i = 0; i < N; i++ ){
    for ( int d = 0; d <= 1; d++ ){
      int tx1 = c1[i] + d;
      int tx2 = c2[i] + d;
      xs.push_back(tx1);
      xs.push_back(tx2);
    }
  }
  xs.push_back(MAX_C+1);

  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());

  for ( int i = 0; i < N; i++ ){
    c1[i] = find(xs.begin(), xs.end(), c1[i]) - xs.begin();
    c2[i] = find(xs.begin(), xs.end(), c2[i]) - xs.begin();
  }

  return xs;
}

int main(){
  cin >> N;
  for ( int i = 0; i < N; i++ ){
    cin >> X1[i] >> Y1[i] >> X2[i]>> Y2[i];
    assert( X1[i] < X2[i]);
    assert( Y1[i] < Y2[i]);
  }

  vector<ll> X = compress(X1, X2);
  vector<ll> Y = compress(Y1, Y2);

  memset(G, 0, sizeof(G));

  for ( int i = 0; i < N; i++ ){
    G[Y1[i]][X1[i]]++;
    G[Y2[i]][X2[i]]++;
    G[Y1[i]][X2[i]]--;
    G[Y2[i]][X1[i]]--;
  }
 for ( int y = 0; y < Y.size()-1; y++ ){
    for ( int x = 1; x < X.size()-1; x++ ){
      G[y][x] += G[y][x-1];
    }
  }
  for ( int x = 0; x < X.size()-1; x++ ){
    for ( int y = 1; y < Y.size()-1; y++ ){
      G[y][x] += G[y-1][x];
    }
  }

  ll area = 0;
  for ( int y = 0; y < Y.size()-1; y++ ){
    for ( int x = 0; x < X.size()-1; x++ ){
      if ( G[y][x] )
        area += (X[x+1]-X[x])*(Y[y+1]-Y[y]);
    }
  }

  cout << area << endl;

  return 0;
}



Measured memory_bytes: 253400