akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,x,t;cin>>n>>x>>t;
    ll ans=((n-1)/x+1)*t;
    cout <<ans <<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
using namespace std;
int main(){
   string taro,hanako;
   int n,sam1=0,sam2=0;

   cin >> n;
   for(int i=0;i<n;i++){
	cin >> taro >> hanako;

	if(taro == hanako){
		sam1 += 1;
		sam2 += 1;
	}else if(taro > hanako){
		sam1 += 3;
	}else if(taro < hanako){
		sam2 += 3;
	}

   }

   cout << sam1 << " " << sam2 << endl;

   return 0;
}

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

int main(){
  int N,L;
  cin >> N >> L;
  int sum = 0;
  int min_t = 1000;
  for(int i=0; i<N; i++){
    sum += L+i;
    if(abs(min_t) > abs(L+i)){
      min_t = L+i;
    }
  }
  cout << sum-min_t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    int i, j, h, w, H, W, mh, mw;
    scanf("%d%d%d%d", &H, &W, &h, &w);
    if(H%h==0 && W%w==0) {
        printf("No\n");
        return 0;
    }
    if(H%h) mh=h, mw=1;
    else mh=1, mw=w;
    printf("Yes\n");
    for(i=1; i<=H; i++) for(j=1; j<=W; j++)
        printf(j==W? "%d\n" : "%d ",
            (i%mh==0 && j%mw==0? -(mh+mw-2)*1000-1 : 1000));
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
double f(int p, int n)
{
	double P = p/100.0;
	double Q = 1.0 - P;
	double ans = (-n)/(2*(Q-1));
	return ans;
}
int main()
{
	int x,p;
	cin>>x>>p;
	cout.precision(10);
	double ans;
	if(x%2)
		ans = 1.0 + (p/100.0)*f(p,x-1) + ((100 - p)/100.0)*f(p,x+1);
	else
		ans = f(p,x);
	cout<<fixed<<ans<<"\n";
	return 0;
}

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var digits = new char[] { 'I', 'V', 'X', 'L', 'C', 'D', 'M' };
            var values = new int[] { 1, 5, 10, 50, 100, 500, 1000 };

            var dict = new Dictionary<char, int>();
            for (int i = 0; i < digits.Length; i++)
                dict.Add(digits[i], values[i]);

            string s;
            while ((s = Console.ReadLine()) != null)
            {
                int val = 0;

                char current = 'I';
                for (int i = 0; i < s.Length; i++)
                {
                    char c = s[s.Length-i-1];
                    if (dict[c] >= dict[current])
                    {
                        current = c;
                        val += dict[current];
                    }
                    else
                    {
                        current = c;
                        val -= dict[current];
                    }
                }
                Console.WriteLine(val);
            }
        }
    }
}

Measured memory_bytes: 5996
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	coin := 0
	if a > b {
		coin += a
		a--
	} else {
		coin += b
		b--
	}
	if a > b {
		coin += a
	} else {
		coin += b
	}
	fmt.Println(coin)
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*h, = map(int, input().split())

dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h[i-j]-h[i]))

print(dp[-1])

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

using namespace std;

int ceil(int a, int b){ return (a + b - 1)/b; }

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);

    int mn = INT_MAX;
    for(int i = 0; i < n; i++) {
        cin >> vec[i];
        mn = min(mn, vec[i]);
    }

    int cnt = 0;
    int sum = 0;
    int stop = k;
    bool ok = false;
    for(int i = 0; i < n; i++) {
        cnt++;
        if(vec[i] == mn) {
            if(ok) stop = cnt + k - 1;
            else ok = true;
        }
        if(cnt == stop) {
            if(ok) sum += ceil(cnt, k), cnt = 1, stop = k;
            else sum++, cnt = 0, stop = k, i--;
        }
    }

    if(cnt > 1) sum++;

    cout << sum;
}

Measured memory_bytes: 640
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    rep(i,201){
        for(ll j=-201;j<=200;j++){
            if(pow(i,5)-pow(j,5)==n){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4068
#include <cstdio>

const int Maxn = 100010;

int n , l;
int a[Maxn];

int main() {
	
	scanf("%d%d",&n,&l);
	for(register int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	
	register int tmp = -1;
	for(register int i=1; i<n; i++) {
		if(a[i] + a[i+1] >= l) {
			tmp = i;
			break;
		}
	}
	
	if(tmp == -1)	return !puts("Impossible");
	
	puts("Possible");
	
	for(register int i=1; i<=tmp-1; i++)
		printf("%d\n",i);
	for(register int i=n-1; i>=tmp+1; i--)
		printf("%d\n",i);
	
	printf("%d\n",tmp);
	
	return 0;
	
}

Measured memory_bytes: 1152
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
int t[30];
void Varied(){
	string s;
	cin >> s;
	for (size_t i = 0; i < s.size(); i++)
	{
		int n = s[i] - 'a';
		t[n]++;
		if (t[n] > 1) {
			cout << "no" << endl;
			return;
		}
	}
	cout << "yes" << endl;

}

int main() {
	Varied();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
template<typename T>
struct SegmentTree{
private:
    int n;
    vector<T> node;
public:
    T merge(T x,T y){
        return max(x,y);
    }
    SegmentTree(vector<T> v){
        int sz=(int)v.size();
        n=1; while(n<sz)n*=2;
        node.resize(2*n-1,-1);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--){
            node[i]=merge(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int x,T val){
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=merge(node[2*x+1],node[2*x+2]);
        }
    }
    T query(int a,int b,int idx=0,int l=0,int r=-1){ /* get [a,b) */
        if(r<0) r=n;
        if(r<=a||b<=l) return -1;
        if(a<=l&&r<=b) return node[idx];
        T vl=query(a,b,2*idx+1,l,(l+r)/2);
        T vr=query(a,b,2*idx+2,(l+r)/2,r);
        return merge(vl,vr);
    };
};
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> hoge(n-2,-1);
    SegmentTree<ll> lX(hoge);
    SegmentTree<ll> lY(hoge);
    int q; cin>>q;
    ll ans=0;
    while(q--){
        int x,y; cin >> x >> y;
        y-=2;
        if(x==1&&y==-1){
            continue;
        }else if(x==1){
            if(lX.query(0,1)>=y) continue;
            int l=-1,r=int(n-2);
            while(r-l>1){
                int mid=(l+r)/2;
                ll res=lX.query(0,mid+1);
                if(res<y) l=mid;
                else r=mid;
            }
            //rまで
            ans+=r;
            //cout << r << endl;
            lY.update(y,r-1);
        }else{
            if(lY.query(0,1)>=y) continue;
            int l=-1,r=int(n-2);
            while(r-l>1){
                int mid=(l+r)/2;
                ll res=lY.query(0,mid+1);
                if(res<y) l=mid;
                else r=mid;
            }
            //rまで
            ans+=r;
            //cout << r << endl;
            lX.update(y,r-1);
        }
    }
    ll out=(n-2LL)*(n-2LL)-ans;
    cout << out << endl;
}




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

int main() {
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int xd,yd;
  xd = x2 - x1;
  yd = y2 - y1;
  cout<< x2 - yd <<" "<< y2 + xd <<" "<< x1 - yd <<" "<< y1 + xd;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    int p = max(min(a, k), 0);
    ans += p;
    k -= p;
    int z = max(min(b, k), 0);
    k -= z;
    int m = max(min(c, k), 0);
    ans -= m;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int i;
  vector<int> h(n);
  for(i=0;i<n;i++) cin >> h[i];
  sort(h.begin(),h.end());
  long long cnt = 0;
  for(i=0;i<n-k;i++) cnt += h[i];
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 4040
import std.stdio,std.conv,std.string;

void main(){
	auto AB = readLine!int();
	if ( AB[0] <= 8 && AB[1] <= 8 ){
		writeln("Yay!");
	}else{
		writeln(":(");
	}
}

T[] readLine(T)(){
	T[] ret;
	foreach( elm ; readln().split() ){
		ret ~= elm.to!int();
	}
	return ret;
}

Measured memory_bytes: 256
a, b, c = gets.chomp.split.map(&:to_i)

a, b, c = [a, b, c].sort

ans = 0
ans += c - b
a += c - b
if (c - a) % 2 == 0
  ans += (c - a) / 2
else
  ans += (c - a) / 2 + 2
end
p ans


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    private static long BASE = 1000000007;
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[][][][] dp = new int[N + 1][4][4][4];
        dp[0][3][3][3] = 1;
        for (int length = 0; length < N; length++) {
            // 最後から3文字目
            for (int x = 0; x < 4; x++) {
                // 最後から2文字目
                for (int y = 0; y < 4; y++) {
                    // 最後から1文字目
                    for (int z = 0; z < 4; z++) {
                        // 追加予定の文字
                        for (int n = 0; n < 4; n++) {
                            if (dp[length][x][y][z] == 0) {
                                continue;
                            }
                            if (!this.ok(x, y ,z, n)) {
                                continue;
                            }
                            dp[length + 1][y][z][n] += dp[length][x][y][z];
                            dp[length + 1][y][z][n] %= BASE;
                        }
                    }
                }
            }
        }
        int sum = 0;
        for (int x = 0; x < 4; x++) {
            for (int y = 0; y < 4; y++) {
                for (int z = 0; z < 4; z++) {
                    sum += dp[N][x][y][z];
                    sum %= BASE;
                }
            }
        }
        System.out.println(sum);
    }
    public boolean ok(int x, int y, int z, int n) {
        if (y == 0 && z == 1 && n == 2) {
            return false;
        }
        if (y == 1 && z == 0 && n == 2) {
            return false;
        }
        if (y == 0 && z == 2 && n == 1) {
            return false;
        }
        if (x == 0 && z == 1 && n == 2) {
            return false;
        }
        if (x == 0 && y == 1 && n == 2) {
            return false;
        }
        return true;
    }
}


Measured memory_bytes: 23636
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
D1=0
for i in range(n):
    D1+=abs(x[i]-y[i])
D2=0
for i in range(n):
    D2+=(x[i]-y[i])**2
D2=D2**0.5
D3=0
for i in range(n):
    D3+=abs(x[i]-y[i])**3
D3=D3**(1/3)
D4=0
for i in range(n):
    if D4<=abs(x[i]-y[i]):
        D4=abs(x[i]-y[i])
print("%.6f\n%.6f\n%.6f\n%.6f\n" %(D1,D2,D3,D4))

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

int N, K, x1[ 100010 ], x2[ 100010 ], l1, l2, Ans;

int main() {
    scanf( "%d%d", &N, &K );
    for( int i = 1; i <= N; ++i ) {
        int x; scanf( "%d", &x );
        if( x >= 0 ) x1[ ++l1 ] = x; else x2[ ++l2 ] = -x;
    }
    sort( x1 + 1, x1 + l1 + 1 );
    sort( x2 + 1, x2 + l2 + 1 );
    Ans = 2147483647;
    for( int i = 0; i <= K; ++i ) {
    	if( i > l2 ) continue;
    	if( K - i > l1 ) continue;
        Ans = min( Ans, x2[ i ] * 2 + x1[ K - i ] );
        Ans = min( Ans, x1[ K - i ] * 2 + x2[ i ] );
    }
    printf( "%d\n", Ans );
    return 0;
}

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


int main()
{
	int n,c=0;
	cin>>n;
	int arr[n+10],check[n+10];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		check[i]=arr[i];
	}
	sort(arr, arr+n);
	for(int i=0;i<n;i++)
	{
		if(arr[i]!=check[i])
			c++;
	}
	if(c>2)
	{
		cout<<"NO";
	}
	else
	{
		cout<<"YES";
	}
}

Measured memory_bytes: 256
import collections
import itertools
import numpy as np
import sys
sys.setrecursionlimit(100000000)
MOD = 10**9+7

def binary_search(a,val):
    n = len(a)
    low = 0
    high = n-1
    mid =(low+high)//2
    cnt = 1
    while low < high + 1:
        if a[mid] == val:
            return True
        elif a[mid]>val:
            high = mid - 1
        else:
            low = mid + 1
        mid =(low+high)//2
        cnt += 1
    return False
#入力
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
dp = [0]*(n+2)
dp[n] = 1
broke = [0]*(n+1)
for i in range(m):
    broke[a[i]] = 1
for i in range(n-1,-1,-1):
    if broke[i]:
        dp[i] = 0
        continue
    dp[i] = dp[i+1] + dp[i+2]
    dp[i]%=MOD
print(dp[0])


Measured memory_bytes: 18764
#include <iostream>
#include <sstream>
#include <vector>
#include <stack>

using namespace std;

int stringToInt(string& s){
	int ans = 0, digit=1;
	char c;
	bool neg = (s.size()>0 && s[0]=='-')?true:false;

	for(int i=s.size()-1;i>=0;i--,digit*=10){
		c = s[i];
		if(c>='0'&&c<='9'){
			ans += (c-48) * digit;
		}
	}

	return neg?ans*-1:ans;
}

int main(){

	string receive, polish;
	getline(cin, receive);
	istringstream ss(receive);
	stack<int> nums;
	int num1, num2;

	while(ss>>polish){

		if(polish.size()==1 && (polish[0]=='+'||polish[0]=='-'||polish[0]=='*'||polish[0]=='/') ){

			num2 = nums.top();
			nums.pop();
			num1 = nums.top();
			nums.pop();

			switch(polish[0]){
				case '+' :
					nums.push( num1 + num2 );
					break;

				case '-' :
					nums.push( num1 - num2 );
					break;

				case '*' :
					nums.push( num1 * num2 );
					break;

				case '/' :
					nums.push( num1 / num2 );
					break;

				default : break;
			}

		} else {
			nums.push( stringToInt(polish) );
		}
	}

	if(nums.size()!=1){
		cout << "Something went wrong. But anyway, the result is, here it comes." << endl;
	}
	cout << nums.top() << endl;

	return 0;
}



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> vec(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  vector<bool> row(h, 0);
  vector<bool> col(w, 0);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (vec.at(i).at(j) == '#') {
        row.at(i) = 1;
        break;
      }
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = 0; i < h; i++) {
      if (vec.at(i).at(j) == '#') {
        col.at(j) = 1;
        break;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (row.at(i) and col.at(j)) {
        cout << vec.at(i).at(j);
      }
    }
      if (row.at(i)) {
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
//22
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n!=-1;){
    int lcd[7]={};
    while(n--){
      int nm;
      cin>>nm;
      for(int i=6;i>=0;i--){
	static const int on[][7]={{1,1,1,1,1,1,0},{0,1,1,0,0,0,0},{1,1,0,1,1,0,1},{1,1,1,1,0,0,1},{0,1,1,0,0,1,1},{1,0,1,1,0,1,1},{1,0,1,1,1,1,1},{1,1,1,0,0,1,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1}};
	cout<<(lcd[i]^on[nm][i]);
	lcd[i]=on[nm][i];
      }
      cout<<endl;
    }
  }
  return 0;
}

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

int main()
{
        int h, w;

        while(scanf("%d %d\n", &h, &w)){

                if( h==0 && w==0 )break;

                for(int i=0; i<h; i++){
                        for(int j=0; j<w; j++){
                                cout << "#";
                        }
                        cout << endl;
                }
cout << endl;

        }
        return 0;
}
        

Measured memory_bytes: 1204
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a = 0, b = 0;

    scanf("%d %d", &a, &b);

    if (a < 6) {
        printf("0\n");
    } else if (a >= 6 && a <= 12) {
        printf("%d\n", b/2);
    } else {
        printf("%d\n", b);
    }
    return 0;
}


Measured memory_bytes: 128
#include "stdio.h"

int main ()
{
    int a[5],b[5];
    while(scanf("%d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&b[1],&b[2],&b[3],&b[4])!=EOF)
    {
        int hit = 0,blow = 0;
        for(int i = 1;i <= 4 ;i++)
            if (a[i]==b[i])
                hit++;

        for(int i = 1;i <= 4;i++)
            for(int j = 1;j <= 4;j++)
        {
            if (i!=j&&a[i]==b[j])
                blow++;
        }

        printf("%d %d\n",hit,blow);

    }
}

Measured memory_bytes: 1028
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
        ll k;
        cin>>k;
        ll ans=0;
        for(int i=1;i<=1000000;i++)
        {
             ans=(ans*10+7)%k;
             if(ans==0)
             {
                cout<<i;
                return 0;
             }
        }
        cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 3612
import heapq

N, M = map(int, input().split())
dict = {}
keys = set([])
for i in range(N):
    a, b = map(int, input().split())
    if a in keys:
        dict[a].append(b)
    else:
        keys.add(a)
        dict[a] = [b]


cand = []
cand_num = 0
val = 0
for a in range(1, M + 1):
    # insert values in cand
    if a in keys:
        for b in dict[a]:
            heapq.heappush(cand, (-b, a))
            cand_num += 1

    if cand_num != 0:
        (b_0, a_0)= heapq.heappop(cand)
        cand_num -= 1
        val += -b_0
    else:
        pass

print(val)


Measured memory_bytes: 30120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

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>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    int cnt = 1;
    int pp;
    int qq;
    vector<int> arr(n);
    rep(i, n) arr[i] = i + 1;
    do {
        if (p == arr)
            pp = cnt;
        if (q == arr)
            qq = cnt;
        cnt++;
    } while (next_permutation(arr.begin(), arr.end()));
    cout << abs(pp - qq) << endl;
}

Measured memory_bytes: 256
#define mod 1000000007
#define MOD 100000000000000007  //233333333333333333
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-8;
const int N=1e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
inline ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
//int st[4][2]={1,0,0,1,-1,0,0,-1};
//int head[N],tot;
//struct edge{int to,next;}e[N<<1];
//void add(int u,int v){e[tot].to=v;e[tot].next=head[u];head[u]=tot++;}
//unordered_map<int,ll>q;
//map<int,ll>q;
//vector<int>vt[N];
//priority_queue<int>q;
int t,cas;
int n,m,k;
int main()
{
	
	string s;	
	while(cin>>n>>s)
	{
		int si=s.length();
		for(int i=0;i<si;i++)
		{
			s[i]+=n;
			while(s[i]>'Z')s[i]-=26;
		}
		cout<<s<<endl;
	}
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int d;
	d = A - 2 * B;
	if (d > 0) {
		cout << d << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    string st;
    cin >> st;
    stack<char> s;
    s.push('?');
    for (char c:st) {
        if (c=='T' && s.top() == 'S') s.pop();
        else s.push(c);
    }
    cout << (s.size() - 1) << '\n';
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

bool no(int u, int v, int n) {
  if (n % 2 == 0) {
    return u == n + 1 - v;
  } else {
    return u == n - v;
  }
}

int main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  int m = 0;

  for (int v = 1; v <= n; ++v)
    for (int u = v + 1; u <= n; ++u)
      if (!no(v, u, n))
        ++m;

  cout << m << "\n";
  for (int v = 1; v <= n; ++v)
    for (int u = v + 1; u <= n; ++u)
      if (!no(v, u, n))
        cout << v << " " << u << "\n";

}



Measured memory_bytes: 256
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa,bbb,ccc,ddd;
    string spc,in,store;

    a = b = c = d = 0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>in;
        if(in=="AC")
            a++;
        else if(in=="WA")
            b++;
        else if(in=="TLE")
            c++;
        else if(in=="RE")
            d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


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

template <size_t N>
class rolling_hash{
    vector<int64_t> mod;
    vector<int64_t> base;
    vector<int64_t> hash;
    queue<char> str;
    size_t len;

    int64_t mpow(int64_t x, int64_t y, int64_t m){
        if(y == 0) return 1;
        if(y == 1) return x % m;
        if(y%2 == 0) return mpow(x*x%m, y/2, m);
        return mpow(x*x%m, y/2, m)%m * x % m;
    }
public:
    rolling_hash(vector<int64_t> bases, vector<int64_t> mods)
    : base(bases), mod(mods){
        hash.resize(N);
        for(int i=0;i<N;++i){
            hash[i] = 0;
        }
        len = 0;
    }
    vector<int64_t> operator()(){
        return hash;
    }
    int64_t operator[](size_t n){
        return hash[n];
    }
    void push_back(char c){
        str.push(c);
        ++len;
        for(int i=0;i<N;++i){
            hash[i] = (hash[i]*base[i]%mod[i] + c) % mod[i];
        }
    }
    void pop_front(){
        char c = str.front();
        str.pop();
        --len;
        for(int i=0;i<N;++i){
            hash[i] = (hash[i] - c*mpow(base[i], len, mod[i])) % mod[i];
            if(hash[i] < 0) hash[i] += mod[i];
        }
    }
};

int main(){
    random_device dev;
    mt19937 rng(dev());

    int n;
    string s;
    cin >> n >> s;

    int ok = 0, ng = n;
    vector<int64_t> mod = {1'000'000'007 , 1'000'000'009};
    vector<int64_t> base = {rng() % mod[0], rng() % mod[1]};
    while(ng-ok > 1){
        int mid = (ok+ng) / 2;
        rolling_hash<2> left(base, mod), right(base, mod);
        set<pair<int64_t,int64_t>> hs;
        for(int i=0;i<mid;++i){
            left.push_back(s[i]);
            right.push_back(s[mid+i]);
        }
        hs.emplace(left[0], left[1]);
        if(hs.count({right[0], right[1]})) goto l_ok;
        for(int i=0;i+mid+mid<n;++i){
            left.push_back(s[mid+i]);
            left.pop_front();
            right.push_back(s[mid+mid+i]);
            right.pop_front();
            hs.emplace(left[0], left[1]);
            if(hs.count({right[0], right[1]})) goto l_ok;
        }
        ng = mid;
        continue;
        l_ok: ok = mid;
    }

    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 640
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int bfs(int s,  vector<vector<int>> adj, int n, vector<int> &par)
{
	vector<bool> vis(n + 1, false);
	vector<int> level(n + 1, 0);
	vis[s] = true;
	queue<int> q;
	q.push(s);
	level[s] = 0;
	while (!q.empty())
	{
		int u = q.front();
		q.pop();
		for (auto v : adj[u])
		{
			if (!vis[v])
			{
				par[v] = u;
				vis[v] = true;
				q.push(v);
			}
		}
	}
	for (int i = 1 ; i < n + 1; i++)
		if (!vis[i])
			return 0;
	return 1;
}


int main()
{

// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input1.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output1.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n + 1);
	ll u, v;
	for (int i = 0; i < m; i++)
	{
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	vector<int> par(n + 1, 0);
	if (bfs(1, adj, n, par))
	{
		cout << "Yes\n";
		for (int k = 2; k <= n; k++)
		{
			cout << par[k] << "\n";
		}
	}
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 16384
#!/usr/bin/env python3
import sys


def solve(A: int, P: int):
    print((3*A+P)//2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)

if __name__ == '__main__':
    main()


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int n, x;
  cin >> n >> x;
  vector<int> ms(n);
  for (int i = 0; i < n; i++) {
    cin >> ms[i];
  }

  vector<FiniteField> dp(x + 1);
  vector<int> dp_solved(x + 1);
  function<FiniteField(int)> solve_dp_fn = [&](int k) -> FiniteField {
    if (dp_solved[k]) return dp[k];
    FiniteField sum = 0;
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (ms[i] <= k) {
        sum += solve_dp_fn(k % ms[i]);
        count++;
      }
    }

    if (count == 0) {
      dp[k] = k;
      dp_solved[k] = 1;
      return dp[k];
    }

    dp[k] = sum / count;
    dp_solved[k] = 1;
    return dp[k];
  };
  FiniteField ans = solve_dp_fn(x);
  for (int i = 1; i <= n; i++) ans *= i;
  cout << ans.Value() << endl;
}

Measured memory_bytes: 1408
while True:
    a,b,c = input().split()
    if b == "?":
        break
    elif b == "+":
        print(int(a)+int(c))
    elif b == "-":
        print(int(a)-int(c))
    elif b == "*":
        print(int(a)*int(c))
    elif b == "/":
        print(int(int(a)/int(c)))    


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

ll n,x,sol=0;
vector<ll>V;
ll dp[200005][3][2];

int main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> x;
        V.push_back(x);
    }
    dp[0][0][0]=INT_MIN;
    dp[0][0][1]=V[0];
    dp[0][1][0]=0;
    dp[0][1][1]=INT_MIN;
    dp[0][2][0]=INT_MIN;
    dp[0][2][1]=INT_MIN;

    for (int i=1;i<n;i++) {
        dp[i][0][0]=dp[i-1][0][1];
        dp[i][1][0]=max(dp[i-1][1][1],dp[i-1][0][0]);
        dp[i][2][0]=max(dp[i-1][2][1],dp[i-1][1][0]);
        dp[i][0][1]=dp[i-1][0][0]+V[i];
        dp[i][1][1]=dp[i-1][1][0]+V[i];
        dp[i][2][1]=dp[i-1][2][0]+V[i];
    }

//    for (int i=0;i<2+n%2;i++) {
//        for (int j=0;j<2;j++) {
//            sol=max(sol,dp[n-1][i][j]);
//        }
//    }

    if (n%2==0) {
        sol=max(dp[n-1][0][0],dp[n-1][1][1]);
    }
    else {
        sol=max(dp[n-1][1][0],dp[n-1][2][1]);
    }
    cout << sol;
}




Measured memory_bytes: 14284
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

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

  REP(i, w + 2) { cout << '#'; }
  cout << endl;
  REP(i, h) { cout << '#' << s[i] << '#' << endl; }
  REP(i, w + 2) { cout << '#'; }
  cout << endl;
}


Measured memory_bytes: 256
gets
memo = Array.new(3, 0)
gets.split.map(&:to_i).each{|i| memo[(i.even? ? i%4 == 0 ? 2 : 1 : 0)] += 1 }
puts memo[0] <= (memo[2] + (memo[1] == 0 ? 1 : 0)) ? 'Yes' : 'No'

Measured memory_bytes: 8452
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;
#define inf 101010;

int n, m, k;
int g[101][101];
int dp[1<<16];
int a[16];
set<int> s;
map<int,int> ma;
queue<int> que;

void bfs(int cnt) {
    queue<int> q2;
    while (!que.empty()) {
        int bit = que.front();
        que.pop();
        
        for (int i = 0; i < k; i++) {
            int nbit = 0;
            for (int j = 0; j < m; j++) {
                int b = 1<<j;
                if (bit & b) {
                    int t = a[j];
                    int u = g[t-1][i];
                    if (s.count(u)) nbit |= 1<<ma[u];
                }
            }
            if (!nbit) {
                dp[0] = cnt+1;
                return;
            }
            else if (dp[nbit] > cnt+1) {
                dp[nbit] = cnt+1;
                q2.push(nbit);
            }
        }
    }
    que = q2;
    bfs(cnt+1);
}

int main(void){
    cin >> n >> m >> k;
    int bit = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        s.insert(a[i]);
        ma[a[i]] = i;
        bit |= 1<<i;
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> g[i][j];
        }
    }
    for (int i = 0; i < 1<<m; i++) dp[i] = inf;
    que.push(bit);
    bfs(0);
    cout << dp[0] << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define ll long long
const ll mod=1e9+7;

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<ll> d0(60,0),d1(60,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<60;j++){
            if(a[i]&1) d1[j]++;
            else d0[j]++;
            a[i]>>=1;
        }
    }
    ll ans=0;
  ll x=1;
    for(int i=0;i<60;i++){
        ans=(ans+(d0[i]*d1[i]%mod)*x%mod)%mod;
      x=x*2%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
#define SIEVE_MAX 1000000
ll ans, n;
ll L, R;
bool is_prime(ll n) {
	if (n < 2) return false;
	for (ll i = 2; i*i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}
bool sieve[1000006]; //sieve[i] == false means i is prime number
vector<ll> primes;
void get_primes() {
	sieve[0] = sieve[1] = true;
	for (int k = 2; k <= SIEVE_MAX; k++) {
		if (sieve[k] == false && is_prime(k)) {
			int val = k * 2;
			while (val <= SIEVE_MAX) {
				sieve[val] = true;
				val += k;
			}
		}
	}
	for (int i = 2; i <= SIEVE_MAX; i++) {
		if (sieve[i] == false)
			primes.push_back(i);
	}
}
void factorize(vector<pli>& factors, ll num) {
	//factors => {val, exp}
	for (ll prime : primes) {
		if (prime > num)
			return;
		if (num % prime == 0) {
			int exp = 0;
			while (num % prime == 0) {
				exp++;
				num /= prime;
			}
			factors.push_back(make_pair(prime, exp));
		}
	}
}
void get_divisors(vector<pli>& factors, size_t ptr, ll num) {
	if (ptr == factors.size()) {
		ll a = num;
		ll b = n / num;
		if (a + b - 2 < ans) {
			ans = a + b - 2;
			L = a;
			R = b;
		}
		//ans = min(ans, a + b - 2);
		return;
	}
	
	auto factor = factors[ptr];
	ll base = factor.first;
	int exp = factor.second;
	for (int i = 0; i <= exp; i++) {
		get_divisors(factors, ptr + 1, num);
		num *= base;
	}
}
int main() {
	get_primes();
	
	cin >> n;
	ans = n - 1;
	vector<pli> factors;
	factorize(factors, n);
	get_divisors(factors, 0, 1);
	cout << ans << endl;
	//cout << L << endl << R << endl;
	return 0;
}

Measured memory_bytes: 2424
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n = int(inp())
dp = [[0 for _ in range(3)] for _ in range(n)]
dp[0] = list(map(int,inp().split()))
for i in range(1,n):
    a,b,c = map(int,inp().split())
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
    dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c
out(str(max(dp[n-1])))

Measured memory_bytes: 56668
cnt=0
mod=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))
#a単体での店頭数
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            cnt+=1
ans=cnt*k%mod
cnt=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            cnt+=1
temp=((k-1)*k//2)%mod
ans+=cnt*temp%mod
ans%=mod
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

class Main{

 public static void main(String args[]){

 Scanner scan = new Scanner(System.in);

 int count = 0;

  while(true){

  int a = scan.nextInt();

  count+=1;
 
   if(a!=0){

    System.out.println("Case "+count+": "+a);
    }

    else {break;
    }
                                         }

                                        } 
           }


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

int main(){
    int n,d;
    
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> d;
        cout << "Case " << i+1 << ':' << endl;
        for(int j = 0 ; j < 10 ; j++){
            d = d*d%100000000/100%10000;
            cout << d << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1164
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

#define mod 104857601
#define pb push_back
#define ep emplace_back
#define fr first
#define sc second
#define linf  (((1ll << 62) - 1) << 1)
#define inf (((1 << 30) - 1) << 1)

const double eps = 0.000000001;
#define ll long long
#define leps 1e-18
#define mkp make_pair
#define mpi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) begin(v), end(v)
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

// ==============================Utils=================================//
random_device rd;
mt19937 mt(rd());

const int N_ = 100001;
vector<int> primes;
int *least_prime;
void cieve() {
  least_prime = new int[N_];
  fill(least_prime, least_prime + N_, -1);

  for (int i = 2; i < N_; i++) {
    if (least_prime[i] == -1) {
      least_prime[i] = i;
      primes.pb(i);
    }
    for (auto &c: primes) {
      if (c * i >= N_ || c > least_prime[i]) break;
      least_prime[c * i] = c;
    }
  }
}

template<typename NType>
NType gcd(NType a, NType b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template<typename NType>
NType lcm(NType a, NType b) { return a / gcd(a, b) * b; }
template<typename NType>
NType phi(NType n_) {
  NType ans = n_;
  for (NType i = 2; i * i <= n_; i++) {
    if (n_ % i == 0) {
      while (n_ % i == 0) n_ /= i;
      ans -= ans / i;
    }
  }
  if (n_ > 1) ans -= ans / n_;
  return ans;
}

int binpow(ll a, int n, const int M = mod) {
  ll res = 1;
  while (n) {
    if (n & 1) {
      res = (a * res) % M;
      n--;
    } else {
      a = (a * a) % M;
      n >>= 1;
    }
  }
  ((res %= M) += M) %= M;
  return res;
}
// ==========================End of Utils==============================//

void solve(int _T) {
  string s;
  cin >> s;

  int ans = 0;

  if(s[0] == 'R' && s[1] == 'S' && s[2] == 'R') ans = 1;
  if(s[0] == 'S' && s[1] == 'R' && s[2] == 'S') ans = 1;
  if(s[0] == 'R' && s[1] == 'S' && s[2] == 'S') ans = 1;
  if(s[0] == 'S' && s[1] == 'S' && s[2] == 'R') ans = 1;
  if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R') ans = 2;
  if(s[0] == 'R' && s[1] == 'R' && s[2] == 'S') ans = 2;
  if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
  cout << ans << endl;
}

#define MULTIPLE_TEST 0
#define PRECALC_CIEVE 0
int main(int argc, char const *argv[]) {
//  freopen("traffic.in", "r", stdin);
//  freopen("traffic.out", "w", stdout);

  int t{1};
  if (MULTIPLE_TEST) scanf("%d\n", &t);
  if (PRECALC_CIEVE) cieve();

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int i{0};
  while (t --> 0) {
    solve(++i);
  }
}
/*

3 1 2
1 2
1 1

 */

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	double a, b, c, C, S, L, h,pi;
	pi = M_PI;
	cin >> a; cin >> b; cin >> C;
	double X = C*pi / double(180);
	S = (0.5)*a*b*sin(X);
	c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a*b*cos(X));
	L = a + b + c;
	h = 2 * S / a;
	cout << fixed<<setprecision(6)<< S << endl;
	cout << fixed << setprecision(6) << L << endl;
	cout << fixed << setprecision(6) << h << endl;
	return 0;
}


Measured memory_bytes: 3536
//2018.09.14 6min 1WA(cout消し忘れ)

#include <iostream>
using namespace std;

int main() {

    int H,W;
    cin >> H >> W;

    char a[H][W];
    int i,j,k;

    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin >> a[i][j];
        }
    }


    bool del = true;
    for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            if(a[i-1][j-1]=='#') del = false;
        }

        if(del){
            for(k=i;k<H;k++){
                for(j=1;j<=W;j++) a[k-1][j-1] = a[k][j-1];
            }
            H--;
            i--;
        }
        del = true;
    }

    for(j=1;j<=W;j++){
        for(i=1;i<=H;i++){
            if(a[i-1][j-1]=='#') del = false;
        }

        if(del){
            for(k=j;k<W;k++){
                for(i=1;i<=H;i++) a[i-1][k-1] = a[i-1][k];
            }
            W--;
            j--;
        }
        del = true;
    }

    for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            cout << a[i-1][j-1];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)

using namespace std;

int main(){
	int x[3],w;
	int n;
	while(cin>>n,n){
		int sum=0;
		rep(i,n){
			rep(j,3)cin>>x[j];
			cin>>w;
			sort(x,x+3);
			int size=x[0]+x[1]+x[2];
			if(size<=60&&w<=2)sum+=600;
			else if(size<=80&&w<=5)sum+=800;
			else if(size<=100&&w<=10)sum+=1000;
			else if(size<=120&&w<=15)sum+=1200;
			else if(size<=140&&w<=20)sum+=1400;
			else if(size<=160&&w<=25)sum+=1600;
//			cout<<size<<" "<<w<<" "<<sum<<endl;
		}
		cout<<sum<<endl;
	}
	
}

Measured memory_bytes: 1176
// AOJ 2155: Infected Computer
// 2017.10.20 bal4u@uu
// 2017.12.13

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int t, s, d; } T;
T tbl[20002];
char f[20002];

int cmp(T *a, T *b) { return a->t - b->t; }

char buf[40], *p;
int getint(void)
{
	int n;
	n = 0; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int n, m, i, ans;
	T *t;
	char *q;

	while (fgets(p=buf, 20, stdin) && *p != '0') {
		n = getint(), m = getint();

		memset(f, 0, n+1);
		t = tbl, i = m; while (i--) {
			fgets(p=buf, 40, stdin);
			t->t = getint(), t->s = getint(), t->d = getint();
			t++;
		}
		qsort(tbl, m, sizeof(T), cmp);

		f[1] = 1, t = tbl, i = m; while (i--) f[t->d] |= f[t->s], t++;
		ans = 0, q = f+1, i = n; while (i--) ans += *q++;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2260
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

constexpr double EPS = 1e-9;

int N;
vector<double> X, Y;

bool check(double x, double y, double r) {
    rep(i, N) {
        if (hypot(X[i] - x, Y[i] - y) > r + EPS) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N;
    X.resize(N);
    Y.resize(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
    }

    double ans = 1e18;
    rep(i, N - 1) rep(j, i + 1, N) {
        double x = (X[i] + X[j]) / 2;
        double y = (Y[i] + Y[j]) / 2;
        double r = hypot(X[i] - X[j], Y[i] - Y[j]) / 2;
        if (check(x, y, r)) {
            ans = min(ans, r);
        }
    }

    rep(i, N - 2) rep(j, i + 1, N - 1) rep(k, j + 1, N) {
        if (X[i] == X[j]) {
            if (X[i] == X[k]) continue;
        }
        else {
            double a = (Y[i] - Y[j]) / (X[i] - X[j]);
            if (abs(a * X[k] + (Y[i] - a * X[i]) - Y[k]) < EPS) continue;
        }

        double alpha = (X[i] - X[j]), beta = (Y[i] - Y[j]);
        double gamma = (X[j] - X[k]), delta = (Y[j] - Y[k]);
        double z = 1 / 2.0 / (alpha * delta - gamma * beta);
        double wi = hypot(X[i], Y[i]) * hypot(X[i], Y[i]);
        double wj = hypot(X[j], Y[j]) * hypot(X[j], Y[j]);
        double wk = hypot(X[k], Y[k]) * hypot(X[k], Y[k]);
        double x = z * (delta * (wi - wj) - beta * (wj - wk));
        double y = z * (-gamma * (wi - wj) + alpha * (wj - wk));
        double r = hypot(x - X[i], y - Y[i]);
        if (check(x, y, r)) {
            ans = min(ans, r);
        }
    }

    write(ans);
}

Measured memory_bytes: 256