akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
#define r(i,n) for(int i=0;i<n;i++)
map<string,P>M;
int m,low,high;
string name,s;
stack<vector<int> >st;
void END(){
  cout<<"error"<<endl;
  exit(0);
}
void in_num(){
  vector<int>v;
  int res=0;
  r(i,s.size())res=res*10+(s[i]-'0'),res=res%256;
  v.push_back(res);
  st.push(v);
}
void in_string(){
  vector<int>v;
  int t1=M[s].first;
  int t2=M[s].second;
  for(int i=t1;i<=t2;i++)v.push_back(i);
  st.push(v);
}
void sol1(){
  set<int>se;
  vector<int>v2=st.top();st.pop();
  vector<int>v1=st.top();st.pop();
  vector<int>v;
  r(i,v1.size()){
    r(j,v2.size()){
      int t=v1[i]+v2[j];
      t=t%256;
      if(!se.count(t)){
	v.push_back(t);
	se.insert(t);
      }
    }
  }
  st.push(v);
}
void sol2(){
  set<int>se;
  vector<int>v2=st.top();st.pop();
  vector<int>v1=st.top();st.pop();
  vector<int>v;
  r(i,v1.size()){
    r(j,v2.size()){
      int t=v1[i]-v2[j];
      t=(t+256)%256;
      if(!se.count(t)){
	v.push_back(t);
	se.insert(t);
      }
    }
  }
  st.push(v);
}
void sol3(){
  set<int>se;
  vector<int>v2=st.top();st.pop();
  vector<int>v1=st.top();st.pop();
  vector<int>v;
  r(i,v1.size()){
    r(j,v2.size()){
      int t=v1[i]*v2[j];
      t=t%256;
      if(!se.count(t)){
	v.push_back(t);
	se.insert(t);
      }
    }
  }
  st.push(v);
}
void sol4(){
  set<int>se;
  vector<int>v2=st.top();st.pop();
  vector<int>v1=st.top();st.pop();
  vector<int>v;
  r(i,v1.size()){
    r(j,v2.size()){
      if(v2[j]==0)END();
      int t=v1[i]/v2[j];
      t=t%256;
      if(!se.count(t)){
	v.push_back(t);
	se.insert(t);
      }
    }
  }
  st.push(v);
}
int main(){
  cin>>m;
  r(i,m){
    cin>>name>>low>>high;
    M[name]=P(low,high);
  }
  cin>>m;
  while(m--){
    cin>>s;
    if(isdigit(s[0]))in_num();
    else if(isalpha(s[0]))in_string();
    else{
      if(s=="+")sol1();
      if(s=="-")sol2();
      if(s=="*")sol3();
      if(s=="/")sol4();
    }
  }
  cout<<"correct"<<endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s;
    int k; cin >> s >> k;
    set<string> ss;
    int n = s.size();
    for(int i=0;i<n;i++){
        for(int j=i;j<i+5;j++){
            ss.insert(s.substr(i,j-i+1));
        }
    }
    vs res;
    for(auto sss:ss)res.emplace_back(sss);
    sort(all(res));
    out(res[k-1]);
}


Measured memory_bytes: 1920
import math
import queue

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()

x = readInts()

s = x[0]
w = x[1]

if w>=s:
	print("unsafe")
else:
	print("safe")

Measured memory_bytes: 9708
#include<stdio.h>
 
int main()
{   
    int a, b;
    int count;
    while(scanf("%d %d", &a, &b) != EOF){
        count = 1;
        a = a + b;
        while(a >= 10){
            a /= 10;
            count++;
        }
        printf("%d\n", count);
    }
 
 
    return 0;
}

Measured memory_bytes: 1860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String[] line1 = br.readLine().split(" ");
        int V = Integer.valueOf(line1[0]);
        int E = Integer.valueOf(line1[1]);
        int r = Integer.valueOf(line1[2]);
        List<List<Edge>> list = new ArrayList<List<Edge>>();
        for (int i = 0; i < V; i++) {
            list.add(i, new ArrayList<Edge>());
        }
 
        for (int i = 0; i < E; i++) {
            String[] line = br.readLine().split(" ");
            int s = Integer.valueOf(line[0]);
            int t = Integer.valueOf(line[1]);
            int d = Integer.valueOf(line[2]);
            Edge edge = new Edge(t, d);
            list.get(s).add(edge);
        }
 
        int[] dist = new int[V];
        Arrays.fill(dist, 20000000);
        dist[r] = 0;
        for (int i = 0; i < V - 1; i++) {
            for (int j = 0; j < V; j++) {
                if (dist[j] != 20000000) {
                    for (int k = 0; k < list.get(j).size(); k++) {
                        Edge edge = (Edge) (list.get(j).get(k));
                        dist[edge.to] = Math.min(dist[edge.to], dist[j] + edge.dist);
                    }
                }
 
            }
        }
        //最後
        for (int j = 0; j < V; j++) {
            if (dist[j] != 20000000) {
                for (int k = 0; k < list.get(j).size(); k++) {
                    Edge edge = (Edge) (list.get(j).get(k));
                    if (dist[edge.to] > dist[j] + edge.dist) {
                        System.out.println("NEGATIVE CYCLE");
                        return;
                    }
                }
            }
        }
        for (int i = 0; i < V; i++) {
            if (dist[i] == 20000000) {
                System.out.println("INF");
            } else {
                System.out.println(dist[i]);
            }
        }
    }
 
}
 
class Edge {
 
    int to, dist;
 
    public Edge(int to, int dist) {
        this.to = to;
        this.dist = dist;
    }
}

Measured memory_bytes: 25316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    string S;
    cin >> S;
    ll ans = 0;
    for ( int i = 0; i < S.size()/2; i++ ) {
        if ( S[i] != S[S.size()-1-i] ) ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ld long double
#define ff first
#define ss second
using namespace std;

ll fact(ll a)
{
    if(a==0) return 1;
    else return a*fact(a-1);
}

int main()
{
    ll i,j,n,k,t,m,a,b;
    cin>>a>>b;
    if(a>9 || b>9) cout<<"-1";
    else cout<<a*b;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
#define MAXN 100010
int a[MAXN],dep[MAXN],n;
int Adj[MAXN],V[MAXN],nxt[MAXN],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
bool cmp(int a,int b)
{
	return a>b;
}
void dfs(int u)
{
	int l=0;
	for(int i=Adj[u];i;i=nxt[i])
		dfs(V[i]);
	for(int i=Adj[u];i;i=nxt[i])
		a[l++]=dep[V[i]];
	sort(a,a+l,cmp);
	for(int i=0;i<l;i++)
		dep[u]=max(dep[u],a[i]+i+1);
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		AddEdge(a[i],i);
	}
	dfs(1);
	printf("%d\n",dep[1]);
}

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

const int MAXN = 402;
long long int a[MAXN], sums[MAXN], dp[MAXN][MAXN];
int n;

long long int get_sum(int start, int end){
    if(start == 0)
        return sums[end];
    return sums[end] - sums[start - 1];
}

long long int find_ans(int start = 0, int end = n - 1){
    if(start == end){
        return 0;
    }else if(dp[start][end] != -1){
        return dp[start][end];
    }else{
        long long int min_ans = 1e18;
        long long int interval_sum = get_sum(start, end);
        for(int i = start; i < end; ++i){
            min_ans = min(min_ans, find_ans(start, i) + find_ans(i + 1, end) + interval_sum);
        }
        dp[start][end] = min_ans;
        return dp[start][end];
    }
}

int main(){
	cin >> n;
	long long int sum = 0;
	for(int i = 0; i < n; ++i){
      cin >> a[i];
      sum += a[i];
      sums[i] = sum;
    }
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            dp[i][j] = -1;
        }
    }
    
  	long long int ans = find_ans();
    cout << ans << "\n";
  	return 0;
}

Measured memory_bytes: 4880
N = int (input ())
L1,L2 = 2,1
L3 = 1
x = 1
for i in range (N-1):
  if x == 1:
    L1 = L1+L2
    L3 = L1
    x = 2
  else:
    L2 = L1+L2
    L3 = L2
    x = 1
print (L3)

Measured memory_bytes: 9168
N =int(input())
a = list(map(int, input().split()))
ans = 0
i = 0

while i < N:
    hol = a[i]
    count = 1
    if i == N-1:
        break
    while hol == a[i+1]:
        count += 1
        i += 1
        if i == N-1:
            break
    i += 1
    ans += count//2
print(ans)

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

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

	if (n % 10 == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	else if ((n - n % 10) % 100 == 70){
	cout << "Yes" << endl;
	return 0;
	}
	else if ((n  - n % 100) == 700) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;
	cin >>h >>w;
	vector<VI> a(h, VI(w));
	rep(i, h) rep(j, w) cin >>a[i][j];
	rep(i, h) rep(j, w){
		int b; cin >>b;
		a[i][j] = abs(a[i][j] - b);
	}
	const int SM = 80*84*2;
	vector<vector<bitset<SM*2>>> dp(h+3, vector<bitset<SM*2>>(w+3));
	dp[0][0][SM + a[0][0]] = dp[0][0][SM - a[0][0]] = true;
	rep(i, h) rep(j, w){
		dp[i][j] |= i? dp[i-1][j] <<a[i][j]: 0;
		dp[i][j] |= i? dp[i-1][j] >>a[i][j]: 0;
		dp[i][j] |= j? dp[i][j-1] <<a[i][j]: 0;
		dp[i][j] |= j? dp[i][j-1] >>a[i][j]: 0;
	}
	int ans = SM*2;
	rep(i, SM*2) if(dp[h-1][w-1][i]) ans = min(ans, abs(i-SM));
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 23424
#include <vector>
#include <iostream>
#include <algorithm>

int main(void){
  int n;
  std::cin >> n;

  std::vector<int> h(n);
  for(int i=0; i<n; i++){
    std::cin >> h[i];
  }
  std::reverse(h.begin(), h.end());

  for(int i=1; i<n; i++){
    if(h[i-1] >= h[i]) continue;
    else if(h[i-1] == h[i]-1) h[i]--;
    else{
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


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





int pow3[12] = {1}, n, m;

int dp[177147], cnt[177147];


int edcode(vector<int> S) {
  int ans = 0;
  for (int i = 0; i < 11; ++i) {
    ans += S[i] * pow3[i];
  }
  return ans;
}

vector<int> decode(int S) {
  vector<int> ans;
  for (int i = 0; i < 11; ++i, S /= 3) {
    ans.push_back(S % 3);
  }
  return ans;
}

int dfs(int S) {
  if (dp[S] != -1) return dp[S];
  else if (cnt[S] == 1) return 0;
  else {
    auto c = decode(S);
    dp[S] = INT_MAX;
    for (int i = 0; i < m; ++i) {
      if (c[i] == 2) {
        dp[S] = min(dp[S], 1 + max(dfs(S - pow3[i]), dfs(S - 2 * pow3[i])));
      }
    }
    return dp[S];
  }
}



int main() {
  for (int i = 1; i < 12; ++i) pow3[i] = pow3[i - 1] * 3;
  ios_base::sync_with_stdio(false); cin.tie(0);
  while (cin >> m >> n and n) {
    vector<int> A;

    for (int i = 0; i < n; ++i) {
      string s; cin >> s;
      int ans = 0;
      for (int i = 0; i < m; ++i) {
        ans |= (s[i] - '0')<<i;
      }
      A.emplace_back(ans);
    }
    fill(dp, dp + pow3[m], -1);

    for (int S = 0; S < pow3[m]; ++S) {
      vector<int> c = decode(S);
      cnt[S] = 0;
      for (int i = 0; i < n; ++i) {
        bool test = true;
        for (int j = 0; j < m and test; ++j) {
          test &= c[j] == 2 or c[j] == ((A[i]>>j)&1);
        }
        cnt[S] += test;
      }
    }
    cout << dfs(pow3[m] - 1) << '\n';
  }
}



Measured memory_bytes: 4616
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}

long long int combination(long long int n, long long int r) {
  if ( r * 2 > n ) r = n - r;
  long long int dividend = 1;
  long long int divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
long long int tmp(long long int n, long long int r) {
  return combination(n+r-1, r);
}


int main() {
  long long int N, D, cnt = 0;
  vector<long long int> a_v, x_v;
  cin >> N;

  for (int i = 0; i < N; i++) {
    long long int a;
    cin >> a;
    a_v.push_back(a);
  }
  x_v = a_v;
  sort(a_v.begin(), a_v.end());
  for (int i = 0; i < a_v.size(); i++) {
    if (a_v[a_v.size()-1] == x_v[i]) {
      cout << a_v[a_v.size()-2] << endl;
    }
    else {
      cout << a_v[a_v.size()-1] << endl;

    }
  }
  
  return 0;
}


Measured memory_bytes: 4848
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;


#define SIZE 101
#define INF 1000000000
#define LLINF 1000000000000000000LL

int calc(int d,int n){
  int a[SIZE],e[SIZE],r[SIZE];
  int dp[SIZE][SIZE] = {0};

  for(int i=0;i<n;i++){
    scanf("%d%d%d",&a[i],&e[i],&r[i]);
  }

  for(int i=0;i<=100;i++){
    for(int j=0;j<=d;j++){
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;
  
  for(int i=0;i<=100;i++){      
    for(int j=0;j<=d;j++){
      for(int k=0;k<n;k++){
	if(r[k] > i) continue;
	int x = min(i+e[k],100);
	int y = min(j+a[k],d);
	
	dp[x][y] = min(dp[x][y],dp[i][j]+1);
      }
    }
  }

  int ans = INF;

  for(int i=0;i<=100;i++)
    ans = min(ans,dp[i][d]);

  return ans;
}

int main(){
  int d,n,c;

  while(1){
    scanf("%d%d",&d,&n);
    if(d==0) break;

    c = calc(d,n);
    if(c!=INF)
      printf("%d\n",c);
    else
      puts("NA");
  }
  
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N,K;
  cin >> N >> K;

  ll sum = K;
  REP(i,N-1){
    sum*=K-1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,lli,N,0);
  Vec(Q,lli,N,0);
  rep(i,0,N) cin >> P[i];
  rep(i,0,N) cin >> Q[i];
  Sort(P);
  Sort(Q);Rev(Q);
  lli ok=1+pow(10,12);
  lli ng=-1;
  while(ok-ng>1){
      lli mid=(ok+ng)/2;
      num=0;
      rep(i,0,N)if(P[i]*Q[i]-mid>=0)num+=ceil((long double)(P[i]*Q[i]-mid)/Q[i]);
      if(num>K)ng=mid;
      else ok=mid;
  }
  Out(ok);
}

Measured memory_bytes: 6352
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from itertools import permutations

def main():
    n = int(input().strip())
    f = [0] * n
    p = [[] for _ in range(n)]
    for i in range(n):
        tmp = list(map(int, input().strip().split()))
        for j in range(10):
            f[i] += tmp[9-j] << j
    for i in range(n):
        p[i] = list(map(int, input().strip().split()))
    ans = -INF
    for b in range(1, 2**10):
        m = 0
        for j in range(n):
            v = fun(f[j], b)
            m += p[j][v]
        ans = max(ans, m)
    print(ans)

def fun(f, q):
    ans = 0
    r = f & q
    for i in range(10):
        ans += (r >> i) & 0x1
    return ans

if __name__ == '__main__':
    main()


Measured memory_bytes: 41324
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

struct edge{
    int u;	//?????????
    int v;	//??°??????
    double cost;	//??????
    //???????????????????????§?????§?°???¢????????????
    bool operator<(const edge& another) const {
        return cost > another.cost;
    }
};

const int MAX_N = 10002;
const int MAX_M = 500000;

P a[MAX_N];
int n,m;
edge es[MAX_M];
int par[MAX_N];
int rrank[MAX_N];

void initial(int n){		//?????????
	for(int i=0;i<n;i++){
		par[i] = i;
		rrank[i] = 0;
	}
}

int find(int x){		//??¨??????????±???????
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x,int y){	//x???????????¨??¨y???????????¨?????????
	x = find(x);	//x???????????¨??????????????????x??¨??????
	y = find(y);	//y???????????¨??????????????????y??¨??????
	if(x == y) return;
	if(rrank[x] < rrank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rrank[x] == rrank[y])
			rrank[x]++;
	}
}

bool same(int x,int y){	//x,y???????????¨???????????§?????????
	return find(x) == find(y);
}

double kruskal(int n,int m){
	initial(n);
	double res = 0;
	for(int i=0;i<m;i++){
		edge e = es[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			res += e.cost;
		}
	}
	return res;
}

double dir(P p1,P p2)
{
    return sqrt((p2.first - p1.first)*(p2.first - p1.first) + (p2.second - p1.second)*(p2.second - p1.second));
}

int main()
{
    scanf("%d%d",&n,&m);
    rep(i,n){
        scanf("%d%d",&a[i].first,&a[i].second);
    }
    rep(i,m){
        int p,q;
        scanf("%d%d",&p,&q);
        es[i] = (edge){p-1,q-1,dir(a[p-1],a[q-1])};
    }
    double sm = 0.0;
    rep(i,m){
        sm += es[i].cost;
    }
    sort(es,es+m);
    printf("%.3f\n",sm - kruskal(n,m));
	return 0;
}

Measured memory_bytes: 3828
def main():
    N,K = map(int,input().split())
    A = map(int,input().split())

    doubling = [[0]*(N+1) for _ in range(60)]
    for i,a in enumerate(A):
        doubling[0][i+1] = a
    for i in range(1,60):
        for j in range(1,N+1):
            doubling[i][j] = doubling[i-1][doubling[i-1][j]]
            
    t = 1
    for i in range(59,-1,-1):
        if (K>>i)&1:
            t = doubling[i][t]
    print(t)
main()


Measured memory_bytes: 172400
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e6+8;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,t,s;
    cin>>d>>t>>s;
    if((s*t)>=d)
        cout<<"Yes";
    else
        cout<<"No";
    cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);

    rep(i, h)
    {
        cin >> c[i];
    }

    int maxh = (int)pow(2.0, h);
    int maxw = (int)pow(2.0, w);

    int ans = 0;

    rep(x, maxh)
    {
        vector<string> temp = c;

        rep(i, h)
        {
            bool x2 = x & (1 << i);
            if (x2)
            {
                rep(j, w)
                {
                    temp[i][j] = '.';
                }
            }
        }

        rep(y, maxw)
        {
            vector<string> temp2 = temp;
            rep(i2, w)
            {
                bool y2 = y & (1 << i2);
                if (y2)
                {
                    rep(j2, h)
                    {
                        temp2[j2][i2] = '.';
                    }
                }
            }

            int cnt = 0;
            //cout << x << " " << y << endl;
            rep(_i, h)
            {
                rep(_j, w)
                {
                    if (temp2[_i][_j] == '#')
                    {
                        cnt++;
                    }
                    //cout << temp2[_i][_j];
                }
                //cout << endl;
            }
            //cout << endl;
            if (cnt == k)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];
        var D = input[2];
        var s = new string[N];
        for (int i = 0; i < N; i++)
        {
            s[i] = Console.ReadLine();
        }
        var ans = 0;
        var c = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if (s[i][j] == '.')
                {
                    c++;
                }
                if (s[i][j] == '#' || j == M - 1)
                {
                    ans += Math.Max(0, c - D + 1);
                    c = 0;
                }
            }
        }
        for (int j = 0; j < M; j++)
        {
            for (int i = 0; i < N; i++)
            {
                if (s[i][j] == '.')
                {
                    c++;
                }
                if (s[i][j] == '#' || i == N - 1)
                {
                    ans += Math.Max(0, c - D + 1);
                    c = 0;
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 18424
import sys
a = [[int(j) for j in input().split()] for i in range(3)]
n = int(input())
for i in range(n):
    n = int(input())
    for j in range(3):
        for k in range(3):
            if(a[j][k] == n):
                a[j][k] = "."

for i in range(3):
    if(a[i] == [".", ".", "."] or (a[0][i] == a[1][i]
    and a[2][i]) == "."):
        print("Yes")
        sys.exit()

if(a[0][0] == a[1][1] and a[2][2] == "." or (a[0][2] == a[1][1] and a[2][0] == ".")):
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
const int N = 1e5 + 10;
 
int x[N][2], y[N][2];
int r, c, n;
bool used[N];
 
vector<pair<pair<int, int>, int>> v;
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return (a.first.first - 1) * (b.first.second - 1) <= (a.first.second - 1) * (b.first.first - 1);
}
void solve2() {
  cin >> r >> c >> n;
  r *= 2; c *= 2;
  for (int i = 1; i <= n; i++) {
      cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
      x[i][0] *= 2; x[i][1] *= 2; y[i][0] *= 2; y[i][1] *= 2;
      int cnt = 0;
      if (x[i][0] == 0 || x[i][0] == r || y[i][0] == 0 || y[i][0] == c) cnt += 1;
      if (x[i][1] == 0 || x[i][1] == r || y[i][1] == 0 || y[i][1] == c) cnt += 1;
      if (cnt != 2) continue;
      v.push_back(make_pair(make_pair(x[i][0], y[i][0]), i)); v.push_back(make_pair(make_pair(x[i][1], y[i][1]), i));
  }
  stack<int> S;
  sort(v.begin(), v.end(), cmp);
  for (auto t : v) {
    //cout << t.first.first << " " << t.first.second << " " << t.second << endl;
    if (!used[t.second]) {
      S.push(t.second);
      used[t.second] = 1;
    } else {
      if (S.top() != t.second) {
        cout << "NO" << endl;
        return ;
      } else {
        S.pop();
      }
    }
  }
  cout << "YES" << endl; 
  return;
}
 
signed main() {
    ios::sync_with_stdio(false);
    solve2();
    return 0;
}

Measured memory_bytes: 11632
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 1e9+7;
const ll MAX = 2010;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
  init_io();
  ll s,ans=0;
  COMinit();
  cin >> s;
  for(ll i=1;;i++){
    ll ns = s-i*3;
    if(ns<0) break;
    ans += COM((i-1)+ns,ns);
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<int> P(N);
    rep( i, N ) P[i] = in;

    int ans = 0;
    for( int i=1; i<N-1; i++ ) {
        vector<int> v(3);
        v[0] = P[i-1];
        v[1] = P[i];
        v[2] = P[i+1];
        sort( all(v) );
        if( v[1] == P[i] ) ans++;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;

int main(){
string a,b;cin>>a>>b;
if(a.length()==b.length()){
if(a>b)cout<<"GREATER";
else if(a<b)cout<<"LESS";
else cout<<"EQUAL";}
else if(a.length()<b.length())cout<<"LESS";
else cout<<"GREATER";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

long long Nattack(long long n, long long m){
	long long res = 0;
	long long nd = 0, md = 0;
	bool beat = false;
	while(true){
		m -= n / 2;
		if(n % 2 == 1){
			if(md == 1){
				md = 0;
				m--;
			}else{
				md++;
			}
		}
		if(m <= 0) break;
		res++;

		if(beat){
			n -= m;
		}else{
			nd += m;
			if(nd >= n){
				beat = true;
				n -= nd - n;
			}
		}

		if(n <= 0) break;
		res++;
	}
	return res;
}

long long Mattack(long long n, long long m){
	long long res = 0;
	long long nd = 0, md = 0;
	bool beat = false;
	while(true){
		if(beat){
			n -= m;
		}else{
			nd += m;
			if(nd >= n){
				beat = true;
				n -= nd - n;
			}
		}
		if(n <= 0) break;
		res++;

		m -= n / 2;
		if(n % 2 == 1){
			if(md == 1){
				md = 0;
				m--;
			}else{
				md++;
			}
		}
		if(m <= 0) break;
		res++;

	}
	return res;
}

int main(){
	long long n, m;
	cin >> n >> m;

	cout << min(Nattack(n, m), Mattack(m, n)) << endl;
}



Measured memory_bytes: 3092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C,ans = 0;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0;i < M ;i++){
    cin >> B[i];
  }
  for(int i = 0;i < N ;i++){
    int check = C;
    for(int i = 0; i < M; i++){
      int A;
      cin >> A;
      check += A*B[i];
    }
    if(check > 0)
      ans += 1;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\0';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i/2]<A[i];i>>=1) {
        tmp = A[i/2];
        A[i/2] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      puts(buf+i+1);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


Measured memory_bytes: 5448
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int sum = 0;
	if(K - A > 0)
	{
		sum += A;
	}
	else
	{
		sum += K;
	}

	K -= A;

	if(K > 0)
	{
		K -= B;
	}

	if(K > 0)
	{
		if(K - C > 0)
		{
			sum -= C;
		}
		else
		{
			sum -= K;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep0(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;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    ll res=0;
    ll now=__gcd(a,b);
    while(k>0){
        if(a%now==0&&b%now==0){
            k--;
        }
        now--;
    }
    cout << now+1 << endl;
}


Measured memory_bytes: 3584
def init(par, n):
    global rank
    par = [i for i in range(n)]
    rank = [0] * n

def find(par, x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par, par[x])
        return par[x]

def unite(par, x, y):
    global rank
    x = find(par, x)
    y = find(par, y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

N, K, L = map(int, input().split())
roads = [i for i in range(N)]
rank = [0] * N
for i in range(K):
    p, q = map(int, input().split())
    unite(roads, p - 1, q - 1)
rails = [i for i in range(N)]
rank = [0] * N
for i in range(L):
    p, q = map(int, input().split())
    unite(rails, p - 1, q - 1)
d = {}
for i in range(N):
    d[find(roads, i), find(rails, i)] = d.get((find(roads, i), find(rails, i)), 0) + 1
for i in range(N):
    print(d[find(roads, i), find(rails, i)], end = " ")
print()

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

int a[3];
int main(){
	for(int i = 0;i < 3;i++)scanf("%d", &a[i]);
	sort(a, a+3);
	if(a[0] == a[1])printf("%d\n", a[2]);
	else printf("%d\n", a[0]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int X = sc.nextInt();
			int Y = sc.nextInt();
			if(X == 2 || Y == 2){
				System.out.println("No");
			}else{
				if(X % 2 == 0 && Y % 2 ==0){
					System.out.println( (Y < 7 || X > 7) ? "Yes" : "No");
				}else if(X % 2 == 0 || Y % 2 ==0){
					System.out.println( (X < 8 && Y > 7) ? "Yes" : "No");
				}else{
					System.out.println( (Y < 8 || X > 8) ? "Yes" : "No");
				}
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	} 
}

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

bool cmp(pair<pair<string, int>, int>& a, pair<pair<string, int>, int>& b)
{
	if (a.first.first < b.first.first)
		return true;
	else if (a.first.first > b.first.first)
		return false;
	else
	{
		if (a.first.second > b.first.second)
			return true;
		return false;
	}
}

int main()
{
	int n;
	pair<pair<string, int>, int> input[100];

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> input[i].first.first >> input[i].first.second;
		input[i].second = i + 1;
	}

	sort(input, input + n, cmp);

	for (int i = 0; i < n; i++)
		cout << input[i].second << endl;

	return 0;
}

Measured memory_bytes: 888
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int dx[] = {1,0,-1,0};
  int dy[] = {0,1,0,-1};
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];
  // int dp[w][h] = {0};
  int dp[w][h];
  rep(i,w){
    rep(j,h){
      dp[i][j] = 0;
    }
  }
  int sx,sy;
  int ans = 0;
  queue<int> px;
  queue<int> py;
  rep(i,h){
    rep(j,w){
      if(s[i].substr(j,1) == "#") continue;
      px.push(j);
      py.push(i);
      // printf("\n%d %d\n\n", j,i);
      while(!px.empty()){
        sx = px.front(); px.pop();
        sy = py.front(); py.pop();
        // printf("%d %d\n", sx, sy);
        rep(l,4){
          if(0 <= sx+dx[l] && sx+dx[l] <= w-1){
            if(0 <= sy+dy[l] && sy+dy[l] <= h-1){
              if(s[sy+dy[l]].substr(sx+dx[l],1) != "#"){
                if(dp[sx+dx[l]][sy+dy[l]] == 0 && !(sx+dx[l] == j && sy+dy[l] == i)){
                  dp[sx+dx[l]][sy+dy[l]] = dp[sx][sy] + 1;
                  px.push(sx+dx[l]);
                  py.push(sy+dy[l]);
                }else if(dp[sx+dx[l]][sy+dy[l]] > dp[sx][sy] + 1){
                  dp[sx+dx[l]][sy+dy[l]] = dp[sx][sy] + 1;
                  px.push(sx+dx[l]);
                  py.push(sy+dy[l]);
                }
              }
            }
          }
        }
      }
      rep(k,h){
        rep(l,w){
          ans = max(ans,dp[l][k]);
          // printf("%d\n", ans);
          dp[l][k] = 0;
        }
      }
    }

  }
  printf("%d", ans);

  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dp[100010][3];

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    REP(i, 100010){
        REP(j, 3){
            dp[i][j] = 0;
        }
    }

    ll N = S.length();
    ll third = 1;
    for(ll i=0; i<N; i++){
        if(S[i] == 'A'){
            dp[i+1][0] = dp[i][0] + third;
            dp[i+1][1] = dp[i][1];
            dp[i+1][2] = dp[i][2];
        }
        if(S[i] == 'B'){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1] + dp[i][0];
            dp[i+1][2] = dp[i][2];
        }
        if(S[i] == 'C'){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
            dp[i+1][2] = dp[i][2] + dp[i][1];
        }
        if(S[i] == '?'){
            dp[i+1][0] = dp[i][0]*3 + third;
            dp[i+1][1] = dp[i][1]*3 + dp[i][0];
            dp[i+1][2] = dp[i][2]*3 + dp[i][1];
            third *= 3;
            third = third % MOD;
        }

        dp[i+1][0] = dp[i+1][0] % MOD;
        dp[i+1][1] = dp[i+1][1] % MOD;
        dp[i+1][2] = dp[i+1][2] % MOD;
    }
    cout << dp[N][2] << endl;

    return 0;
}

Measured memory_bytes: 6100
N=int(input())
tmp=26
for i in range(1,1000):
    if N<=tmp:
        nl=i
        break
    else:
        tmp+=26**(i+1)

# 名前の長さnlの中で辞書順にx番目
x=N-tmp+26**nl
ans=[]
alp=[chr(i) for i in range(97, 97+26)]

for i in range(nl-1,-1,-1):   
    for j in range(1,27):
        if j*(26**i)>=x:
            ans.append(alp[j-1])
            x-=(j-1)*(26**i)
            break
print("".join(ans))   

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

p = 1
route = [p]
route_set = set([p])
for i in range(1, K+1):
    p = A[p-1]
    if p in route_set:
        li = route.index(p)
        ri = len(route)
        idx = li + (K-li) % (ri-li)
        print(route[idx])
        break
    else:
        route.append(p)
        route_set.add(p)
else:
    print(p)


Measured memory_bytes: 32376
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    ll length = abs(A-B);
    if (length <= (V-W)*T ){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

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

void debug(char * string, long int target) {
  printf("%s", string);
  printf("%ld", target);
  printf("%c", '\n');
}

int main() {
  short A, B;
  scanf("%hd%hd", &A, &B);

  printf("%d", A * B);

  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std ;
#define int long long
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;

void solve() {
    string s ;
    cin >> s ;
    if (s == "SSS") cout << 0 << endl ;
    else if (s == "RRR") cout << 3 << endl ;
    else if (s == "RRS" or s == "SRR") cout << 2 << endl ;
    else cout << 1 << endl ;
}

int32_t main() {
    fast;
    int testcases = 1 ;
    //cin >> testcases ;
    while (testcases--) {
        solve() ;
    }
    return 0;
}
/*  CODED BY:-
 ___________________________________
|                       ___         |
|  /\   /\  \ /  |  |  |___   |__|  |        
| /~~\ /~~\  |   |__|   ___|  |  |  |
|___________________________________|
*/

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    ll n, ans=1;
    cin >> n;
    REP(i, n){
        ans = ans*i%mod;
    }
    cout << ans;
}

Measured memory_bytes: 764
# https://atcoder.jp/contests/abc110/tasks/abc110_c
# 文字のカウント数についてその種類が同じならばYes

S = input()
T = input()

from collections import Counter
s_cnt = Counter(S)
t_cnt = Counter(T)


# if set(s_cnt.values()) == set(t_cnt.values()) and len(s_cnt) == len(t_cnt):
#     # 実は嘘解法 #文字のカウントの種類について、長さが等しく且つセットも等しいけど、内容が異なる場合は存在する。
#     print('Yes')
# else:
#     print('No')

for (k, v), (kk, vv) in zip(s_cnt.most_common(), t_cnt.most_common()):
    if v != vv:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3776
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<long long> factorize(long long n) {
    vector<long long> factors;

    for (long long i=2; i*i<=n; ++i)
        while (n % i == 0) {
            factors.push_back(i);
            n /= i;
        }

    if (n > 1)
        factors.push_back(n);

    sort(factors.begin(), factors.end());
    return factors;
}

int main() {
    long long n;
    scanf("%lld", &n);

    vector<long long> factors=factorize(n);

    printf("%lld: ", n);
    for (size_t i=0; i<factors.size(); ++i)
        printf("%lld%c", factors[i], i<factors.size()-1? ' ':'\n');

    return 0;
}

Measured memory_bytes: 2780
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#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>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B; 
    cin >> A >> B;
    if (A < 10 && B < 10) {
        cout << A * B << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	while(1){
		int a;
		cin>>a;
		if(cin.eof())break;
		ll t=0;
		for(int i=1; i<600/a; i++){
			t+=i*i*a*a*a;
		}
		cout<<t<<endl;
	}

	return 0;
}



Measured memory_bytes: 2976
# ABC 104 C
# bit
import math
D, G = map(int, input().split())
S = [list(map(int, input().split())) for k in range(D)]

ans = float("inf")
for k in range(2**D):
    temp_score = 0
    temp_ans = 0
    r = -1
    for l in range(D):
        if int(bin(k>>l)[-1]):
            temp_score += (l+1)*100*S[l][0] + S[l][1]
            temp_ans += S[l][0]
        else:
            r = l
    if temp_score < G:
        if G-temp_score <= (r+1)*(S[r][0]-1)*100:
            temp_ans += math.ceil((G-temp_score)/((r+1)*100))
        else:
            temp_ans = float("inf")
    ans = min(ans,temp_ans)

print(ans)


Measured memory_bytes: 3188
n, m = map(int, raw_input().split())
frq = [0] * (n + 1)
for _ in range(m):
   a, b = map(int, raw_input().split())
   frq[a] += 1
   frq[b] += 1

for x in frq:
   if x % 2 == 1:
      print "NO"
      exit(0)
print "YES"

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

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cmath>

#include <set>
#include <string>
#include <bits/stdc++.h>
#include <string>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define MAX 100
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF INT_MAX
#define ll long long
#define vi vector<int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define ull unsigned long long


using namespace  std;



const int N = 1e5 + 5;
void sol() {

    int n;
    cin >> n;
    int q = n%10;
    if(q==2 || q==4 || q==5 || q==7 || q==9) {
        cout << "hon \n";
    }

    else if(q==0 || q==1 || q==6 || q==8) {
        cout << "pon \n";
    }
    else cout << "bon \n";

}
int main() {
    fast;
    sol();




}




Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

int main() {
	int N, M; std::cin >> N >> M;
	std::vector<int> L(M);
	std::vector<int> R(M);
	for (int i = 0; i < M; ++i)
		std::cin >> L[i] >> R[i];
	std::sort(L.begin(), L.end());
	std::sort(R.begin(), R.end());
	if (R[0] - L[M - 1] < 0)
		std::cout << 0 << std::endl;
	else
		std::cout << R[0] - L[M - 1] + 1 << std::endl;

}

Measured memory_bytes: 4052