akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1
 
 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)
 
*/
 
int main() {
 
  ll n, m, count=0, ans=0;
  string s;
 
  cin >> n>>m;
  
  cout << n*m << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main {
    public static void main(String[] args) {
    
      Scanner sc = new Scanner(System.in);
      
      //入力
      double N = sc.nextDouble();//木の本数
      double D = sc.nextDouble();
      
      //1人の監視員が監視できる範囲
      double one = (D*2.0)+1.0;
      
      //監視員が最低何人必要か求める
      double min = N/one;
      
      
       //BigDecimalクラスを利用して小数点以下すべて切り上げ
          //BigDecimal min1 = new BigDecimal(String.valueOf(min));
          //double ans = min.setScale(0, RoundingMode.UP);
       BigDecimal min1 = new BigDecimal(min);  	
       BigDecimal ans = min1.setScale(0, BigDecimal.ROUND_UP);
       System.out.println(ans);
    }
}

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

using namespace std;

string a;
int main()
{
    int k;
    cin>>a>>k;
    set<string>s;
    for(int i=0;i<a.length();i++)
    {
        for(int j=0;j<5;j++)
        {
            if(i+j>= a.length()) continue;
            s.insert(a.substr(i,j+1));
        }
    }
    for(int i=0;i<k-1;i++) s.erase(s.begin());
    cout<<*s.begin()<<endl;
    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            int[] A = ReadIntArray();
            double ans = 1.0 / A.Select(a => 1.0 / a).Sum();
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int K = sc.nextInt();
    
    if(K<=A){
        System.out.println(K);
    }else if(K<=A+B){
        System.out.println(A);
    }else if(K<=A+B+C){
        System.out.println(A-(K-A-B));
    }else{
        System.out.println(A-C);        
    }
      }
}


Measured memory_bytes: 35704
fun main(array: Array<String>) {
    var (n, x) = readLine()!!.split(" ").map{ it.toInt()}
    val a = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var cnt = 0
    repeat(n) {
        x -= a[it]
        if(x >= 0) {
            cnt++
        }
        else {
            print(cnt)
            return
        }
    }
    if(0 < x && cnt == n) cnt--
    print(cnt)
}

Measured memory_bytes: 37896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//-----CODE------//
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> > vp (N);
  for (int i = 0; i < N; i++)
  {
    cin>>vp[i].first>>vp[i].second;
  }
  vector<pair<int,int> > ckpt (M); 
  for (int i = 0; i < M; i++)
  {
    cin>>ckpt[i].first>>ckpt[i].second;
  }
  vector<int> ANS (N,-1);
  for (int i = 0; i < N; i++)
  {
    int MIN = INF;
    int X = vp[i].first;int Y = vp[i].second;
    int index = -1;
    for (int j = 0; j < M; j++)
    {
      int pX = ckpt[j].first;
      int pY = ckpt[j].second;
      int DIST = abs(X - pX) + abs(Y - pY);
      if(chmin(MIN,DIST))
      {
        index = j;
      }
    }
    ANS[i] = index+1;
    
  }
  for (int i = 0; i < N; i++)
  {
    cout<<ANS[i]<<endl;
  }
  
  
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 10010;

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

    Graph G(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> Q;

    vector<int> c(n);
    vector<int> deg(n);
    rep(i, n) {
        cin >> c[i];
        deg[i] = G[i].size();
        if(G[i].size() == 1) {
            Q.push(i);
        }
    }

    sort(c.begin(), c.end());

    vector<int> d(n);
    int M = 0;    
    rep(i, n) {

        int v = Q.front();
        Q.pop();

        d[v] = c[i];

        if(i < n-1) {
            M += c[i];
        }

        rep(j, G[v].size()) {
            int to = G[v][j];
            deg[to]--;
            if(deg[to] == 1) {
                Q.push(to);
            }
        }
    }

    cout << M << "\n";

    rep(i, n) {
        cout << d[i] << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
Scanf.scanf "%s %s" @@ fun s' t->
let reg = Str.global_replace (Str.regexp ".") "[\\0\\?]" t in
print_endline @@ try
  let i = Str.search_backward (Str.regexp reg) s' (String.length s') in
  let s' = Str.string_before s' i ^ t ^ Str.string_after s' (i+String.length t) in
  let s' = String.map (function | '?' -> 'a' | c -> c) s' in
  s'
with _ -> "UNRESTORABLE"

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

bool solve(vector<int> a){
	sort(a.begin(), a.end());
	int d = a.front() * 2;
	if(a[0] == a[1]) d -= 1;
	if((int)a.size() > 2 && a[0] == a[2]) return false;
	if(a[(int)a.size() - 1] != d) return false;
	if(a[(int)a.size() - 2] != d) return false;
	for(int i = 0; i + 1 < (int)a.size(); i++){
		if(a[i] + 1 < a[i+1]) return false;
	}
	for(int i = 0; i + 2 < (int)a.size(); i++){
		if(a[i+1] != a[i] && a[i+1] != a[i+2]) return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	cout << (solve(a) ? "Possible" : "Impossible") << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 405
#define o 203
using namespace std;

int n,H,in[maxn];
int F[maxn],hd[maxn],sz[maxn];
int Find(int u){ return !F[u] ? u : F[u] = Find(F[u]); }

int main(){
	scanf("%d%d",&n,&H);
	for(int i=1;i<=n;i++){
		int A,B,C,D;
		scanf("%d%d%d%d",&A,&B,&C,&D);
		int x , y;
		if(C == 0) x = A;
		else x = - C;
		if(D == 0) y = -B;
		else y = D;
		x += o , y += o;
		in[y] ++ ,in[x] --;
		if(Find(x) != Find(y))
			F[Find(x)] = Find(y);
		sz[Find(y)] = 2; 
	}
	bool ER = 0;
	for(int i=1;i<maxn;i++){
		if(i < o && in[i] < 0) ER = 1;
		if(i > o && in[i] > 0) ER = 1;
		if(i > o && in[i] < 0) hd[Find(i)] = 1;
	}
	for(int i=1;i<maxn;i++) if(Find(i) == i && sz[i] > 1 && !hd[i])
		ER = 1;
	if(ER) puts("NO");
	else puts("YES");
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
struct Node
{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k)
{
  Node *y = NIL;  // parent node of x
  Node *x = root; // root node of the tree
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

  z->parent = y;
  if (y == NIL)
  {
    root = z;
  }
  else
  {
    if (z->key < y->key)
    {
      y->left = z;
    }
    else
    {
      y->right = z;
    }
  }
}

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

void inorder(Node *u)
{
  if (u == NIL)
    return;
  inorder(u->left);
  cout << ' ' << u->key;
  inorder(u->right);
}

void preorder(Node *u)
{
  if (u == NIL)
    return;
  cout << ' ' << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int N, x;
  string com;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> com;
    if (com == "insert")
    {
      cin >> x;
      insert(x);
    }
    else if (com == "find")
    {
      cin >> x;
      Node *t = find(root, x);
      if (t != NIL)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    else if (com == "print")
    {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
}



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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll N;
  cin >> N;
  
  vector<ll> A(N);
  REP(i, N) { 
      cin >> A[i];
  }
  
  ll Nh = N / 2;
  vector<ll> X(Nh);
  REP(i, Nh) {
    X[i] = A[2*i] ^ A[2*i+1];
  }
  ll sum = 0;
  REP(i, Nh) {
    sum ^= X[i];
  }
  REP(i, N) {
    cout << (sum ^ A[i]) << " ";
  }
  cout << endl;
} 


Measured memory_bytes: 5516
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 29;
const double EPS = 1e-10;

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
char dc[] = {'^', '>', 'v', '<'};
char field[100][100];

void make_move(int &x, int &y, int &d, char c){
  if(c == 'S'){
    int sy = y;
    int sx = x;
    while(field[sy][sx] != '#' && field[sy][sx] != '*'){
      sy += dy[d];
      sx += dx[d];
    }
    if(field[sy][sx] == '*'){
      field[sy][sx] = '.';
    }
  }else {
    if(c == 'U') d = 0;
    if(c == 'D') d = 2;
    if(c == 'L') d = 3;
    if(c == 'R') d = 1;
    int y2 = y + dy[d];
    int x2 = x + dx[d];
    if(field[y2][x2] == '.') {
      y = y2;
      x = x2;
    }
  }
}



int main(){
  int T;
  int x, y, d;
  int H, W, n;
  string order; 
  cin >> T;
  rep(t, T) {
    if(t != 0) cout << endl;
    fill(&field[0][0], &field[0][0] + 100 * 100, '#');
    cin >> H >> W;
    rep(i, H)rep(j, W){
      cin >> field[i+1][j+1];
      switch(field[i+1][j+1]){
      case '^':
	field[i+1][j+1] = '.';
	x = j + 1;
	y = i + 1;
	d = 0;
	break;
      case '>':
	field[i+1][j+1] = '.';
	x = j + 1;
	y = i + 1;
	d = 1;
	break;
      case 'v':
	field[i+1][j+1] = '.';
	x = j + 1;
	y = i + 1;
	d = 2;
	break;
      case '<':
	field[i+1][j+1] = '.';
	x = j + 1;
	y = i + 1;
	d = 3;
	break;
      }
    }
    cin >> n;
    cin >> order;
    rep(i, (int)order.size()){
      make_move(x, y, d, order[i]);
    }
    field[y][x] = dc[d];
    rep(i, H){
      rep(j, W) cout << field[i+1][j+1];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=1e5+5,mod=1e9+7;
int n,w,ans,inv[N],fac;
int main(){
	scanf("%d",&n);
	inv[1]=1; rep (i,2,n) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	rep (i,1,n) inv[i]=(inv[i]+inv[i-1])%mod; fac=1;
	rep (i,1,n){
		scanf("%d",&w);
		ans=(ans+(ll)(inv[i]+inv[n-i+1]-1)%mod*w%mod)%mod;
		fac=(ll)fac*i%mod;
	}
	printf("%d\n",(ll)ans*fac%mod);
	return 0;
}

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

int main()
{
    int i, c=0;
    string s, t;
    cin >> s >> t;
    for(i=0; i<s.length(); i++)
      if(s[i] != t[i])
        c++;
    cout << c << endl;
    
    return 0;
}

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

using namespace std;

int t;
double tmp, ans;
string s;

int main() {
	scanf("%d", &t);
	while(t--) {
		cin>>tmp;
		cin>>s;
		if (s=="BTC") ans+=tmp*380000;
		else ans+=tmp;
	}
	printf("%.8f\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
const int MAXN = 100100;
const int P = (1 << 18);
const int MOD = 1e9 + 7;

int N, M;
vector <pair <int, int> > lr;
int x[MAXN], y[MAXN];

ll seg[2*P+100];

map <int, int> mm;

void upd (int cloc, ll cval)
{
    cloc += P;
    while (cloc)
    {
        seg[cloc] = (seg[cloc] + cval) % MOD;
        cloc /= 2;
    }
}

ll add (int cloc)
{
    cloc += P;
    ll res = 0;
    while (cloc > 1)
    {
        if (cloc & 1)
            res += seg[cloc-1];
        cloc /= 2;
    }
    return res % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N >> M;
    for (int i = 0; i < N; i++)
        cin >> x[i];
    for (int i = 0; i < M; i++)
        cin >> y[i];

    int cy = 0;
    for (int i = 0; i < N; i++)
    {
        while (cy < M && y[cy] < x[i])
            cy++;
        if (cy == 0 || cy >= M)
            continue;
        lr.push_back(make_pair(y[cy-1] - x[i], y[cy] - x[i]));
    }

    sort (lr.begin(), lr.end());
    N = lr.size();
    for (int i = 0; i < N; i++)
        mm[lr[i].second];

    M = 0;
    for (map<int, int>::iterator it = mm.begin(); it != mm.end(); it++)
        it->second = M++;
    upd (M, 1);

    for (int i = 0; i < N; i++)
    {
        if (i > 0 && lr[i] == lr[i-1])
            continue;
        int cc = mm[lr[i].second];
        ll ctot = (MOD + add (M + 2) - add (cc + 1)) % MOD;
        upd (cc, ctot);
        // x <= cc
        // 0, impossible
        // 1, stay

        // x > cc
        // 0, stay
        // 1, push all to cc
    }

    cout << add (M + 2) << "\n";
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(int n, int k, const vector<int> &a) {
	int ma = -1;
	for (auto v : a) {
		ma = max(ma, v);
	}

	if (ma < k) {
		return false;
	}

	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);
	}

	return (k % g == 0);
}

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

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	for (auto &v : a) {
		cin >> v;
	}

	cout << (solve(n, k, a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	int c;
	for (int i = 1;; i++){
		cin >> a >> b;
		if (a > b){
			c = a;
			a = b;
			b = c;
		}
		if (a == 0 && b == 0)break;
		else{
			cout << a << " " << b << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3012
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    string s;
    cin>>s;
    
    if(s[0]=='S' && s[1]=='S' && s[2]=='S'){
        cout<<"0\n";
    }
    else if(s[0]=='S' && s[1]=='S' && s[2]=='R'){
        cout<<"1\n";
    }
    else if(s[0]=='R' && s[1]=='S' && s[2]=='S'){
        cout<<"1\n";
    }
    else if(s[0]=='R' && s[1]=='R' && s[2]=='R'){
        cout<<"3\n";
    }
    else if(s[0]=='R' && s[1]=='S' && s[2]=='R'){
        cout<<"1\n";
    }
    else if(s[0]=='S' && s[1]=='R' && s[2]=='S'){
        cout<<"1\n";
    }
    else if(s[0]=='R' && s[1]=='R' && s[2]=='S'){
        cout<<"2\n";
    }
    else if(s[0]=='S' && s[1]=='R' && s[2]=='R'){
        cout<<"2\n";
    }
        
    return 0;
}







     


 



 

   



Measured memory_bytes: 3624
from heapq import heappush, heappop
INF = 10 ** 20

n, m, k, s = map(int, input().split())
p, q = map(int, input().split())
z_dist = [INF] * n
que = []
for _ in range(k):
  c = int(input()) - 1
  z_dist[c] = 0
  heappush(que, (0, c))

edges = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  edges[a].append(b)
  edges[b].append(a)

while que:
  total, node = heappop(que)
  for to in edges[node]:
    if z_dist[to] > total + 1:
      z_dist[to] = total + 1
      heappush(que, (total + 1, to))

cost = [INF] * n
cost[0] = 0
que = []
heappush(que, (0, 0))
while que:
  total, node = heappop(que)
  for to in edges[node]:
    if to == n - 1:
      print(total)
      que = []
      break
    if z_dist[to] == 0:
      continue
    if z_dist[to] <= s:
      price = q
    else:
      price = p

    if cost[to] > total + price:
      cost[to] = total + price
      heappush(que, (total + price, to))


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    ll n;
    cin >> n;
    
    v_ll sum(n+1);

    irep2(i, 1, n) {
        sum[i] += i + sum[i-1]; 
    }
    
    auto it = lower_bound(sum.begin(), sum.end(), n);
    int d = distance(sum.begin(), it);
    ll diff = *it - n; 

    lrep2(i, 1, d) {
        if(diff != i) {
            cout << i << endl;
        } 
    }
    return 0;
}
/** atcoder **/



Measured memory_bytes: 78336
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int answer = 0;
        String line;
        while ((line = br.readLine()) != null) {
            char[] arr = line.toCharArray();
            boolean isConstruct = false;

            String s = "";
            for (int i = 0; i < arr.length; i++) {
                if ('0' <= arr[i] && arr[i] <= '9') {
                    if (isConstruct) {
                        s = s + arr[i];
                    } else {
                        s = String.valueOf(arr[i]);
                        isConstruct = true;
                    }
                } else {
                    if (isConstruct) {
                        answer += Integer.parseInt(s);
                        s = "";
                        isConstruct = false;
                    }
                }
            }

            if (isConstruct) {
                answer += Integer.parseInt(s);
            }

        }

        System.out.println(answer);
    }
}


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

ll mod = 1000000007;


int main() {
	long long x; cin >> x;
	int cnt = 0;
	long long money = 100;
	while(money < x){
		long long tmp = money /100;
		money += tmp;
		cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3616
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18
 
N,K=rl()
 
W = [[0 for _ in range(K+3)] for _ in range(K+3)]
for i in range(N):
    x,y,c=input().split()
    x = int(x)%(2*K)
    y = (int(y) if c=='W' else int(y)+K)%(2*K)
    if (x<K)^(y<K):
        x %= K
        y %= K
        W[0][y+1] += 1
        W[x+1][y+1] -= 2
        W[0][K+1] -= 1
        W[x+1][K+1] += 1
        W[x+1][0] += 1
        W[K+1][0] -= 1
        W[K+1][y+1] += 1
    else:
        x %= K
        y %= K
        W[0][0] += 1
        W[x+1][0] -= 1
        W[0][y+1] -= 1
        W[x+1][y+1] += 2
        W[K+1][y+1] -= 1
        W[x+1][K+1] -= 1
        W[K+1][K+1] += 1
 
for x in range(0,K+2):
    for y in range(0,K+2):
        W[x][y] += W[x][y-1]
for y in range(0,K+2):
    for x in range(0,K+2):
        W[x][y] += W[x-1][y]
 
ans = 0
for x in range(K+1):
    for y in range(K+1):
        res = W[x][y]
        ans = max(ans,res,N-res)
 
print(ans)

Measured memory_bytes: 63836
import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    Y = [deque() for _ in range(n)]
    Y_id = []
    order = []
    for i in range(m):
        p, y = nm()
        Y[p - 1].append(y)
        order.append(p)

    for y in Y:
        d = {}
        for i, y_s in enumerate(sorted(y)):
            d[y_s] = i + 1
        Y_id += [d]

    for o in order:
        print('{:06}'.format(o) +
              '{:06}'.format(Y_id[o - 1][Y[o - 1].popleft()]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 103980
#include<stdio.h>

int main()
{
    int n,a[20],max=-1,i,sum=0,div,p;

    scanf("%d",&n);

    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]>max)
        {
            max = a[i];
            p = i;
        }

    }

    div = max/2;

    for(i=1;i<=n;i++)
    {
        if(i!=p)
            sum = sum + a[i];
    }

    sum = sum + div;

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

    return 0;
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  string s;
  cin >> s;
  REP(i,4) cout << s[i];
  cout << " ";
  for(int i = 4; i < s.length(); ++i) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	string s;
	cin>>s;
	int sum = 0;
	for (int i=0; i<s.length(); i++){
		sum += s[i] - '0';
	}
	if(sum % 9 == 0)	cout<<"Yes";
	else	cout<<"No";
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define f first
#define s second
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll t = 0;
    REP(i, 0, n)
        if (s[i] == 'R')
            t++;
    ll ans = t, sm = 0;
    REP(i, 0, n) {
        if (s[i] == 'R')
            sm++;
        ans = min(ans, max(t, i+1) - sm);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3688
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n+1],b[n];
    for(int i=0;i<n+1;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    long long p=0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            p+=b[i];
            continue;
        }
        else{
            p+=a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i]){
                p+=b[i];
                a[i+1]-=b[i];
            }
            else{
                p+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout<<p;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[][][] f = new int[n][5][2];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 5; j++) {
				for (int k = 0; k < 2; k++) {
					f[i][j][k] = sc.nextInt();
				}
			}
		}

		int[][] p = new int[n][11];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = sc.nextInt();
			}
		}

		long max = Long.MIN_VALUE;
		for (int i = 1; i < 0x1 << 10; i++) {
			int[] cnt = new int[n];
			for (int j = 0; j < 10; j++) {
				if ((i & 0x1 << j) != 0) {
					int d = j / 2;
					int ampm = j % 2;

					for (int k = 0; k < n; k++) {
						if (f[k][d][ampm] == 1) {
							cnt[k]++;
						}
					}
				}
			}

			long tmp = 0;
			for (int j = 0; j < n; j++) {
				tmp += p[j][cnt[j]];
			}

			max = Math.max(max, tmp);
		}

		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 26968
#include<stdio.h>




int main(){
	
int a;
int b;
int c;
int i;
int x=0;
long z=0;
scanf("%d%d%d",&a,&b,&c);
for(i=1;i<100;i++){
	z=a*i;
	//printf("%d\n",z);
	if(z%b==c){
		printf("YES\n");
		x++;
		break;
		
	}
	
	
	
	
	
	
	
}
if(x==0){
printf("NO\n");
}
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int k; cin>>k;
  set<string> st;
  for(int i=1; i<=k; i++){
    for(int j=0; j<=n-i; j++){
      st.insert(s.substr(j,i));
    }
  }
  int tmp=0;
  for(auto x : st){
    tmp++;
    if(tmp==k){
      cout<<x<<endl;
      return 0;
    }
  }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct City{
    int x;
    int y;
    int id;
};

struct Edge{
    int cost;
    int from;
    int to;
};

struct UnionFind {
    vector<int> d; // 根なら (-サイズ), そうでないなら親の番号
    UnionFind(int N) : d(N, -1){} // 全て根として初期化

    int root(int x) { // データ x が属する木の根を再帰で得る
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y) { // x と y の木を併合. 併合した場合 true
        x = root(x); y = root(y); // x <- x の根, y <- y の根
        if (x == y) return false; 
        // merge technique（データ構造をマージするテク. 小を大にくっつける）
        if (d[x] > d[y]) swap(x, y);    // x の木のサイズ > y の木のサイズにする. d[x], d[y] < 0 に注意.
        d[x] += d[y];   // x の木のサイズ += y の木のサイズ
        d[y] = x;   // y の親は x
        return true;
    }

    bool same(int x, int y) { // 2つのデータ x, y が属する木が同じなら true
        return root(x) == root(y);
    }
    
    int size(int x) { // 素集合のサイズ
        return -d[root(x)]; // d[root(x)] < 0 に注意.
    }
};

void Main(){
    int n; cin >> n;
    vector<City> c(n);
    rep(i, n){
        int a, b; cin >> a >> b;
        c[i] = {a, b, i};
    }
    sort(all(c), [&](City a, City b){
        return a.x == b.x ? a.y < b.y : a.x < b.x;
    });
    
    /*
    for(auto [x, y, id] : c){
        cout << "(" << x << "," << y << ") : " << id << endl;
    }
    */
    
    vector<Edge> G;
    rep(i, n-1){
        int j = c[i].id, k = c[i+1].id;
        G.pb({abs(c[i].x - c[i+1].x), j, k}); 
        G.pb({abs(c[i].y - c[i+1].y), j, k}); 
    }
    
    sort(all(c), [&](City a, City b){
        return a.y == b.y ? a.x < b.x : a.y < b.y;
    });

    /*
    for(auto [x, y, id] : c){
        cout << "(" << x << "," << y << ") : " << id << endl;
    }
    */
    
    rep(i, n-1){
        int j = c[i].id, k = c[i+1].id;
        G.pb({abs(c[i].x - c[i+1].x), j, k}); 
        G.pb({abs(c[i].y - c[i+1].y), j, k}); 
    }
    
    sort(all(G), [&](Edge a, Edge b){
        return a.cost < b.cost; 
    });
    
    /*
    for(auto [c, f, t] : G){
        cout << c << " " << f << " " << t << endl;
    }
    */
    
    UnionFind UF(n);
    ll ans = 0;
    for(auto [c, f, t] : G){
        if(UF.same(f, t)) continue;
        ans += c;
        UF.unite(f, t);
    }
    
    cout << ans << endl;    
    return;
}

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

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

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

int main(){
    int a;
    cin>>a;
    if(a<1200){
        cout<<"ABC"<<endl;
    }else if(a<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A,B,C;

  scanf("%d %d %d", &A,&B,&C);
  if(A+B>=C){
    printf("%d\n", B+C);
  }else{
    printf("%d\n", A+B+1+B);
  }

  return 0;
}

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


int main(){

    string a,b;
    cin >> a >> b;
    int x = stoi(a + b);
    
    for(int i = 0;i < 1000;i++){
        if(x == i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;


    return 0;
}

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

using namespace std ;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdbl ;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int,int> > vpii ;
typedef vector<pair<ll,ll> > vpll ;
typedef priority_queue<int, vector<int>, greater<int> > spqint ; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll ; //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint ; //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll ; //大きい順に取り出し


#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define IREP(i,v) for(auto i=v.begin(); i !=v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(),(v).end()
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------




















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n ;
  cin >> n ;
  double a, b, c ;
  bool f = false ;

  FOR(i,1,3500+1){
      FOR(j,1,3500+1){
          if(4*i*j-n*(i+j)>0){
            double k = (n*i*j)/(4*i*j-n*(i+j)) ;
            if(ceil(k)==floor(k)){
                a = i ;
                b = j ;
                c = k ;
                f = true ;
                break ;
            }
          }
      }
      if(f){
          break ;
      }
  }

  cout << (int)a <<" "<< (int)b <<" "<<  (int)c <<endl ; 
  
  
  
  
  return 0 ;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A_list = list(map(int, input().split()))
Q = int(input())

A_dict = defaultdict(int)
for a in A_list:
    A_dict[a] += 1

total = sum(A_list)

for i in range(Q):
    B, C = map(int, input().split())
    total += (C - B)*A_dict[B]
    print(total)
    A_dict[C] += A_dict[B]
    A_dict[B] = 0

Measured memory_bytes: 24072
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
using namespace std;
using ll = long long;

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

    float a[100];
    
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
    float sum=0;
    
    for (int i=0;i<N;i++){
        sum += 1/a[i];
    }
    cout << 1 / sum;

        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long A;
    long B;
    cin >> A >> B;

    long l = max(A,B);
  
    long ANS = A*B;
    for (int i=2; i<=l; i++) {
        while (A%i==0 && B%i==0) {
          	A = A/i;
          	B = B/i;
            ANS = ANS/i;
        }
    }
    
    cout << ANS << endl;
}


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

int main() {
  int N = 0, d = 0, x = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
 
  for(int j = 0; j < N; j++){
    
    for(int i = 0; i < N; i++){ // sarch d-max
      if(A.at(i) > d){
        d = A.at(i);
      }
    }
    
    if(d != 0){  
      x++;  // count-up
      for(int i = 0; i < N; i++){	//d-max = 0
        if(d == A.at(i)){
          A.at(i) = 0;
        }
      }
      d = 0;	// reset-d
    }
    else{
      break;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n,h; cin>>n>>h;
	int a[n],b[n],c[2*n];
	rep(i,n){
		cin>>a[i]>>b[i];
		c[2*i]=a[i];c[2*i+1]=b[i];
	}
	sort(c,c+2*n);
	map<int,long> sword;
	rep(i,n) if(sword[a[i]]<INF) sword[a[i]]=INF;
	rep(i,n) sword[b[i]]++;

	long ans=0,i=2*n-1;
	while(h>0){
		if(sword[c[i]]==INF){
			ans+=(h+c[i]-1)/c[i];
			break;
		}
		if(sword[c[i]]>0){
			h-=c[i];
			sword[c[i]]--;
			ans++;
		}else{
			i--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(void) {

    long long a,b,c;
    cin >> a >> b >> c;

    if((a + 2 * sqrtl(a*b) + b) < c ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N	100000
#define M	100000
#define MD	1000000007

int ll[N], rr[N];

int compare_l(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return ll[i] != ll[j] ? ll[i] - ll[j] : rr[j] - rr[i];
}

int compare_r(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return rr[i] != rr[j] ? rr[i] - rr[j] : ll[j] - ll[i];
}

int ft[N + 1];

void update(int i, int n, int x) {
	while (i < n) {
		ft[i] = (ft[i] + x) % MD;
		i |= i + 1;
	}
}

int query(int i) {
	int x = 0;

	while (i >= 0) {
		x = (x + ft[i]) % MD;
		i &= i + 1, i--;
	}
	return x;
}

int main() {
	static int xx[N], yy[M], ii[N];
	int n, m, n_, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &xx[i]);
	for (j = 0; j < m; j++)
		scanf("%d", &yy[j]);
	n_ = 0;
	for (i = 0, j = 0; i < n; i++) {
		while (j < m && yy[j] < xx[i])
			j++;
		if (j > 0 && j < m)
			ll[n_] = xx[i] - yy[j - 1], rr[n_] = yy[j] - xx[i], n_++;
	}
	n = n_;
	for (i = 0; i < n; i++)
		ii[i] = i;
	qsort(ii, n, sizeof *ii, compare_l);
	n_ = 0;
	for (i = 0; i < n; i++)
		if (n_ == 0 || ll[ii[n_ - 1]] != ll[ii[i]] || rr[ii[n_ - 1]] != rr[ii[i]])
			ii[n_++] = ii[i];
	n = n_;
	qsort(ii, n, sizeof *ii, compare_r);
	for (i = 0; i < n; i++)
		rr[ii[i]] = i + 1;
	qsort(ii, n, sizeof *ii, compare_l);
	update(0, n + 1, 1);
	for (i = 0; i < n; i++)
		update(rr[ii[i]], n + 1, query(rr[ii[i]] - 1));
	printf("%d\n", query(n));
	return 0;
}


Measured memory_bytes: 4436
<?php
  
fscanf(STDIN,"%d",$n);
$h_li = explode(" ",trim(fgets(STDIN)));
$start = 0;
$re = array();
for($i=0;$i<$n;$i++){
  if($i != $n-1 && $h_li[$i]>=$h_li[$i+1]) {
    $re[$start]++;
  }else{
    $start=$i+1;
  }
  
}
//print_r($re);
if(count($re)>0){
echo max($re)."\n";
}else{
  echo "0\n";
}


Measured memory_bytes: 16884
from collections import defaultdict


def prime_decomposition(n):
    table = defaultdict(int)

    i = 2
    while n % i == 0:
        n //= i
        table[i] += 1

    i = 3
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i] += 1
        i += 2

    if n > 1:
        table[n] += 1

    return table


def main():
    mod = 10 ** 9 + 7

    n = int(input())
    *a, = map(int, input().split())

    lcm_d = defaultdict(int)
    for x in a:
        pd = prime_decomposition(x)
        for prime, power in pd.items():
            lcm_d[prime] = max(lcm_d[prime], power)

    lcm_ = 1
    for prime, power in lcm_d.items():
        lcm_ = (lcm_ * pow(prime, power, mod)) % mod

    ret = 0
    for x in a:
        ret = (ret + pow(x, mod - 2, mod)) % mod
    ret = (ret * lcm_) % mod

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4852
N, M = [int(_) for _ in input().split()]
PY = [[i] + [int(_) for _ in input().split()] + [0] for i in range(M)]

nums = [1] * (N + 1)
PY.sort(key=lambda x:x[2])

for row in PY:
    y = row[1]
    row[3] = nums[y]
    nums[y] += 1

PY.sort(key=lambda x:x[0])

for row in PY:
    print("%06d%06d" % (row[1], row[3]))


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

int main() {
  int N;
  while (cin >> N, N) {
    int ans = 0;
    for (int i = 1; i < N; i++) {
      int c = i, sum = 0;
      while (sum < N) {
        sum += c;
        c++;
      }
      if (sum == N)
        ans++;
    }
    cout << ans << endl;
  }
}

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

int main(){
    int32_t N;
    std::cin >> N;
    std::vector<int32_t> B(N-1);
    for(auto& i : B){
        std::cin >> i;
    }

    // A0 = B0, A1 = min(B1,B0), A2 = B1, A3 = B2 ... AN = Bn-1
    B.push_back(B[N-2]);
    int32_t sum = B[0];
    for(int32_t i = 1; i < N; i++){
        sum += std::min(B[i], B[i-1]);
    }
    std::cout << sum;
    return 0;
}


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

int main() {

  int n;
  cin >> n;
  int t, x, y, a=0, b=0, c=0;
  rep(i,n) {
    int T, X, Y;
    cin >> T >> X >> Y;
    t = T-a;
    x = X-b;
    y = Y-c;
    if(abs(x)+abs(y)>t || (x+y+t)%2!=0) {
      cout << "No" << endl;
      return 0;
    }
    a=T; b=X; c=Y;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
class PQueue
  def initialize(data = [], &cmp)
    @data = [nil] + data.sort(&cmp)
    @cmp = cmp
  end
  def size; @data.size - 1; end
  def empty?; @data.size == 1; end
  def peek; empty? ? nil : @data[1]; end

  def push(el)
    j = @data.size
    @data << el
    while j > 1
      break if @cmp.call(@data[j / 2], @data[j]) < 0
      
      @data[j] = @data[j / 2]
      @data[j / 2] = el
      j /= 2
    end
    self
  end
  alias_method :<<, :push
  
  def shift
    return nil if empty?
    return @data.pop if size == 1
    
    el = @data[1]
    tail = @data.pop
    
    @data[1] = tail
    j = 1
    while 2 * j < @data.size
      i = 2 * j
      i += 1 if i + 1 < @data.size && @cmp.call(@data[i + 1], @data[i]) < 0

      break if @cmp.call(@data[j], @data[i]) < 0
      
      @data[j] = @data[i]
      @data[i] = tail
      j = i
    end
    return el
  end
end
# dp[s][c] : 駅sをコインc枚以上もって、出発するときの最小時間
# dp[v][j] = min{ dp[u][j + a] + b } (j >= 0)
def min(a,b); a < b ? a : b; end
INF = Float::INFINITY

N,M,S = gets.split.map(&:to_i)
dp = Array.new(N + 1){ Array.new(2520, INF) }

E = Array.new(M)
V = Array.new(N + 1)

M.times do |i|
  E[i] = gets.split.map(&:to_i)
end
(1 .. N).each do |i|
  V[i] = gets.split.map(&:to_i)
end

G = Array.new(N + 1){ [] }
E.each do |(u, v, a, b)|
  G[u] << [v, a, b]
  G[v] << [u, a, b]
end

q = PQueue.new{|a,b| [a[0],-a[1]] <=> [b[0],-b[1]] }
q << [0, min(S, 2500), 1]

until q.empty?
  t,w,v = q.shift
  c,d = V[v]

  next if t >= dp[v][w]
  w.downto(0) do |w_|
    if dp[v][w_] > t
      dp[v][w_] = t 
    else
      break
    end
  end
  
  G[v].each do |u,a,b|
    q << [t + b, w - a, u] if w >= a && dp[u][w - a] > t + b
  end
  q << [t + d, min(w + c, 2500), v] if dp[v][min(w + c, 2500)] > t + d
end
puts (2 .. N).map{|i| dp[i].min }


Measured memory_bytes: 15672
#include <iostream>

int main() {
  uint64_t N;
  std::cin >> N;

  // 指定の並びを満たすレンガの個数を計算する
  uint64_t count = 0;  // 採用された個数
  for (uint64_t i = 0; i < N; ++i) {
    uint64_t a = 0;
    std::cin >> a;
    
    // 採用された個数+1の番号を持つレンガを採用する
    if (a == count + 1) count++;
  }

  // 結果発表
  if (count == 0) {
    std::cout << "-1";
  } else {
    std::cout << (N - count);
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int total = 0;
		int loginCount = 0;

		while(true) {
			loginCount++;
			total += a;
			if(loginCount % 7 == 0) total += b;

			if(total >= c) break;
		}
		System.out.println(loginCount);
	}
}



Measured memory_bytes: 26392
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll f(ll a){
  return a*(a+1)/2;
}
int main(void){
  int n;
  scanf("%d",&n);
  int a[n],b[n];
  FOR(n)scanf("%d %d",&a[i],&b[i]);
  double ans=0;
  FOR(n-1){
    for(int j=i+1;j<n;j++){
      ans+=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
    }
  }
  PRF(ans/n*2);
  return 0;
}


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

int main() {
    int a, b, c, x, y;
    int ans = 1000000000;
    cin >> a >> b >> c >> x >> y;
    for (int i = 0; i <= pow(10, 5); ++i) {
        int tmp = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b;
        ans = min(ans, tmp);
    }

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

Measured memory_bytes: 3600