akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val S = ns()
    val N = S.length
    val zero = S.count(_ == '0')
    val one = S.count(_ == '1')
    val remain = abs(zero - one)
    val ans = N - remain
    out.println(ans)

  }

  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


Measured memory_bytes: 27400
#include <cstdio>
#include <map>
#include <cstring>
#include <string>

int main(void)
{
	std::map<std::string, bool> dic;
	int n;
	scanf("%d", &n);
	for(int i = 0; i != n; i++) {
		char command[10], str[13];
		scanf("%s", command);
		if(!strcmp(command, "insert")) {
			scanf("%s", str);
			dic[str] = true;
		}
		if(!strcmp(command, "find")) {
			scanf("%s", str);
			if(dic[str]) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 47052
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;


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

  string s; cin >> s;
  int a=s.size(), z;
  rep(i, s.size()) {
    if(a==s.size() && s[i]=='A')a = i;
    if(s[i]=='Z')z = i;
  }
  cout << z-a+1 << endl;


  return 0;
}


Measured memory_bytes: 720
X = int(input())

if 400 <= X < 600:
    print('8')
elif 600 <= X < 800:
    print('7')
elif 800 <= X <1000:
    print('6')
elif 1000 <= X < 1200:
    print('5')
elif 1200 <= X < 1400:
    print('4')
elif 1400 <= X < 1600:
    print('3')
elif 1600 <= X < 1800:
    print('2')
else:
    print('1')

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

int main()
{
    int n, r = 0;
    bool c[10];
    memset(c, false, sizeof(c));
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a < 3200)
        {
            c[a / 400] = true;
        }
        else
        {
            r++;
        }
    }
    int cnt = 0;
    for (int i = 0; i <= 7; i++)
    {
        if (c[i])
            cnt++;
    }
    cout << (cnt == 0 ? 1 : cnt) << ' ' << cnt + r << endl;
}

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

using namespace std;

const int LOG = 60;
const int MOD = 1e9 + 7;

long long n;
map<pair<int, long long>, int> f;

int power(int a, int n) {
	int ret = 1;
	for (int i = 1; i <= n; i++) {
		ret = 1LL * ret * a % MOD;
	}
	return ret;
}

int dfs(int i, long long n) {
	if (i == -1) {
		return 1;
	}
	if (f.count({i, n})) {
		return f[{i, n}];
	}
	if ((1LL << (i + 2)) - 1 <= n) {
		return power(3, i + 1);
	}
	int &ret = f[{i, n}];
	ret = 0;
	for (long long v = 0; v < 2; v++) {
		if ((v << i) > n) continue;
		ret += dfs(i - 1, n - (v << i));
		ret %= MOD;
		if (v == 0 && (1LL << (i + 1)) <= n) {
			ret += dfs(i - 1, n - (1LL << (i + 1)));
			ret %= MOD;
		}
	}
	return ret;
}

int main() {
	cin >> n;
	cout << dfs(LOG, n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
ll n, k;

int main() {
    cin >> n >> k;
    priority_queue<ll> h;
    for(ll i=0; i<n; i++){
        ll htemp;
        cin >> htemp;
        h.push(htemp);
    }
    ll sum = 0;
    for(ll j=0; j<n; j++){
        if(j>=k){
            sum += h.top();
        }
        h.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 2548
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    B = inputList()
    
    A_sum = 0
    for i in A:
        A_sum += i
    
    B_sum = 0
    for i in B:
        B_sum += i
        
    if A_sum < B_sum:
        print(-1)
        sys.exit()
        
    tarinai = []
    tariteru = []
    flg = False
    for i in range(N):
        if A[i] < B[i]:
            tarinai.append(B[i] - A[i])
            tariteru.append(0)
            flg = True
        else:
            tarinai.append(0)
            tariteru.append(A[i] - B[i])
            
    if flg == False:
        print(0)
        sys.exit()
        
    tariteru.sort()
    tariteru = tariteru[::-1]
            
    ans = 0
    tameru = 0
    for i in tarinai:
        if i == 0:
            continue
        ans += 1
        tameru += i
        
    for i in tariteru:
        ans += 1
        tameru -= i
        if tameru <= 0:
            break
            
    print(ans)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 97260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
double p[3005];
double dp[3005][3005];
int main(){
	scanf("%d",&n);
	repn(i,n) scanf("%lf",&p[i]);
	dp[0][0] = 1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i-1;j++){
			dp[i][j+1] += dp[i-1][j]*p[i];
			dp[i][j] += dp[i-1][j]*(1.0-p[i]);
		}
	}
	double ans = 0.0;
	for(int i=0;i<=n;i++) if(i > n-i) ans += dp[n][i];
	printf("%.12f\n",ans);
	}

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

int naive (string s )
{
    int count = 0 ; 
    string t  = "ABC" ; 
    for ( int i = 0 ; i<=s.size () - t.size () ; i++ ) 
    {
        int j ; 
        for ( j = 0 ; j <t.size () ; j++ ) 
        {
            if (s[i+j] != t[j] ) 
                break ;
        }
        if ( j == t.size () ) 
            count ++ ;  
    }
    return count ; 
}


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

    string s, t ; 
    cin >> s >> t ; 

    string m ; 
    for ( int i = 0 ; i< s.size () ; i ++ ) 
    {
       m.push_back ( s[i] ) ; 
       m.push_back ( t[i] ) ; 
    } 
    cout << m <<  endl ; 
    return 0 ; 
} 



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

using namespace std;

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



Measured memory_bytes: 3900
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int ans = k;
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    ans = a[n - 1] - a[0];
    for(int i = 1; i < n; i++) {
      ans = Math.min(ans, k - (a[i] - a[i - 1]));
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 60436
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  int a,b;
  cin>>a>>b;

  cout << a*a-b << endl;
}

Measured memory_bytes: 256
import numpy as np

N, M, C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(N)]
A = np.array(A)
B = np.array(B).reshape(-1, 1)

ans = (np.dot(A, B) + C > 0).sum()
print(ans)


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

int constexpr M = 1e9 + 9, N = 134;
int p[N];

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    string s, t;
    cin >> n >> s >> t;
    int a = 0, b = 0;
    p[0] = 1;
    for(int i = 1; i < N; ++i) {
        p[i] = 31ll * p[i - 1] % M;
    }

    int ans = 2 * n;
    reverse(begin(s), end(s));
    for(int i = 0; i < n; ++i) {
        a += p[i] * (s[i] - 'a');
        a %= M;
        b = 31ll * b % M;
        b += t[i] - 'a';
        b %= M;
        if(a == b) ans = 2 * n - (i + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
input_xy = input().split()
input_xy = [int(i) for i in input_xy]

if input_xy[0] == 1 and input_xy[1] == 1:
    print(1000000)
    exit()

res = 0

if input_xy[0] == 1:
    res += 300000
elif input_xy[0] == 2:
    res += 200000
elif input_xy[0] == 3:
    res += 100000

if input_xy[1] == 1:
    res += 300000
elif input_xy[1] == 2:
    res += 200000
elif input_xy[1] == 3:
    res += 100000     

print(res)


Measured memory_bytes: 3064
n=gets.chomp.to_i

def solve(n,i,acc)
  if n==0
    return acc
  end

  if n%2 != 0
    solve((n-1)/(-2),i+1,"1"+acc)
  else
    solve((n-1)/(-2),i+1,"0"+acc)
  end

end
if n==0
  puts 0
  exit
end

puts solve(n,0,"")


Measured memory_bytes: 1788
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,M = inpl()
ABs = [inpl() for _ in range(N)]
ABs.sort()

ind = 0
ans = 0
cnt = 0
while cnt < M:
    ans += ABs[ind][0]
    ABs[ind][1] -= 1
    if ABs[ind][1] == 0:
        ind += 1
    cnt += 1

print(ans)


Measured memory_bytes: 28968
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int b[MAX],a[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=1; i<n; i++)
        cin>>b[i];
    a[1]=b[1];
    a[n]=b[n-1];
    for(int i=2; i<n; i++)
    {
        a[i]=min(b[i],b[i-1]);
    }
    ll sum=0;
    for(int i=1; i<=n; i++)
        sum+=a[i];
    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void){
    int n;cin>>n;
    vector<int> l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i+1;j--){
            if(l[j-1]<l[j]-l[i])continue;
            int k = upper_bound(l.begin(),l.end(),l[j]-l[i])-l.begin();
            if(k<=i){
                ans += j-i-1;
            }
            else ans+= j-k;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n, q;
	cin >> n >> q;
	st s;
	cin >> s;
	vi l(q), r(q);
	f_v2I(l, r, q);
	vi sum(n + 1);
	sum[0] = sum[1] = 0;
	f(i, 0, n - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			sum[i + 2] = sum[i+1] + 1;
		}
		else {
			sum[i + 2] = sum[i + 1];
		}
	}
	f(i, 0, q) {
		cout << sum[r[i]] - sum[l[i]] << endl;
	}
	return 0;
}

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

void checkDistance(int a , int b){
	if((b - a + 1) % 2 == 0){
		cout << "Borys" << endl;
	}
	else{
		cout << "Alice" << endl; 
	}
}

int main(){
	int n , a , b;
	cin >> n >> a >> b;
	if(n == 2){
		cout << "Borys" << endl;
		exit(0);
	}

	if(b == a + 1){
		cout << "Borys" << endl;
	}
	else{
		checkDistance(a , b);
	}
}

Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

void inp_str(int*);

int main(void) {

int input1[100];
inp_str(input1);

int N,K;
N=input1[0];
K=input1[1];

char S[100];
scanf("%s",S);

S[K-1]=tolower(S[K-1]);

printf("%s\n",S);



    return 0;




}


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val S = rd.readString()
    val N = S.length

    var ans = 0
    var len = 0
    for (i in 0 until N) {
        if (S[i] == 'R') {
            len++
        } else {
            len = 0
        }
        ans = max(ans, len)
    }

    println(ans)
}


//val rd = debug.Reader("abc", "175", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 34600
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  ll n;
  ll ans=0;
  ll a[100000],b[100000],c[100000];
  pair<ll,pair<ll,ll> > p[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    c[i]=a[i]+b[i];
    p[i]=make_pair(c[i],make_pair(a[i],b[i]));
  }
  sort(p,p+n);
  for(int i=n-1;i>=0;i--){
    if((n-i)%2==1) ans+=p[i].second.first;
    else ans-=p[i].second.second;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
    // 配列の最大値を取得
    int max = *max_element(vec.begin(), vec.end());
    // 配列の最大値のイテレータを取得
    vector<int>::iterator maxIt = max_element(vec.begin(), vec.end());
    // 配列の最大値までの距離を取得
    int maxIndex = distance(vec.begin(), maxIt);
    // 隣り合う重複要素を削除し、末尾のゴミを削除
    // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す)
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
*/

int main() {
    int x, y; cin >> x >> y;

    cout << x + y / 2 << endl;
}




Measured memory_bytes: 256
using System;

namespace ABC055_B_Training_Camp
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long power = 1;

			for (int i = 1; i <= n; i++)
				power = (i * power) % ((long)Math.Pow(10, 9) + 7);
			
			Console.WriteLine(power);
		}
	}
}

Measured memory_bytes: 11092
/*https://atcoder.jp/contests/abc139/tasks/abc139_b*/\
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int a, b;
	cin >> a >> b;
	int count = 0, out = 1;
	while (out < b)
	{
		out--;
		out += a;
		count++;
	}
	cout << count;
}

Measured memory_bytes: 3616
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for (int i = 0; i < n; i++) {
      double [][] xyr = new double[2][3];
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 3; k++) {
          xyr[j][k] = sc.nextDouble();
        }
      }
      double d = Math.sqrt(Math.pow((xyr[0][0]-xyr[1][0]),2)+Math.pow((xyr[0][1]-xyr[1][1]),2));
      if (xyr[0][2] + xyr[1][2] < d) {
        System.out.println(0);
      }
      else if (xyr[0][2] + xyr[1][2] == d) {
        System.out.println(1);
      }
      else {
        if (Math.abs(xyr[0][2] - xyr[1][2]) < d) {
          System.out.println(1);
        }
        else if (Math.abs(xyr[0][2] - xyr[1][2]) == d) {
          System.out.println(1);
        }
        else {
          if (xyr[0][2] > xyr[1][2]) {
            System.out.println(2);
          }
          else {
            System.out.println(-2);
          }
        }
      }
    }
  }
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef long long LL;
int t,n,m,ans;
int a[maxn];
int main()
{
    scanf("%d",&t);printf("%d",t*t);
    //while(t--)
    //{
    //scanf("%d%d",&n,&m);

    //printf("%d",ans);
    //}
    return 0;
}


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

int main(){
    long long int X,Y;
    cin >> X >> Y;
    long long int Z = X;
    int c = 0;
    while(Z <= Y){
        Z = 2*Z;
        c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

ll n, u, v;
vector<vector<ll>> g;
vector<ll> distU;
vector<ll> distV;

void dfsU(ll current, ll d) {
	if (distU[current] != -1) return;
	distU[current] = d;
	if (current == v) return;
	if (distU[current] >= distV[current]) return;
	for (auto e : g[current]) {
		dfsU(e, d + 1);
	}
}

void dfsV(ll current, ll d) {
	if (distV[current] != -1) return;
	distV[current] = d;
	for (auto e : g[current]) {
		dfsV(e, d + 1);
	}
}

int main(void)
{
	cin >> n >> u >> v;
	g.resize(n + 1);
	distU.resize(n + 1, -1);
	distV.resize(n + 1, -1);
	rep(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfsV(v, 0);
	dfsU(u, 0);
	ll ma = 0;
	for (int i = 1; i <= n; i++) {
		if (distU[i] == -1) continue;
		ma = max(ma, max(0LL, distV[i] - 1));
	}
	cout << ma << endl;
	return 0;
}


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

int main(){
	int x,y;
	for(int i=1;i>=1;i++){
		cin>> x >> y ;
		if((x==0)&&(y==0)){
		break;
		}
		if(x<y){
		    cout<< x <<" " << y <<endl;
		}else{
			cout<< y <<" " << x <<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int N;cin>>N;
  vector< pair <string, P> > pairs(N);
  int i,j;
  rep(i,N) cin>>pairs[i].first>>pairs[i].second.first;
  rep(i,N) pairs[i].second.first = - pairs[i].second.first;
  repn(i,N) pairs[i-1].second.second = i;
  sort(pairs.begin(),pairs.end());
  rep(i,N) cout<<pairs[i].second.second<<endl;
}


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

ans = ''
if a <= 0 && 0 <= b
  ans = 'Zero'
elsif 0 <= a
  ans = 'Positive'
else
  if (a - b) % 2 == 0
    ans = 'Negative'
  else
    ans = 'Positive'
  end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
using ll=long long;
ll c[MAX_N+1];

int main(){
  int n;
  ll k;
  cin>>n>>k;
  for(int i=0;i<n;++i){
    int a,b;
    cin>>a>>b;
    c[a]+=b;
  }
  for(int i=1;i<=MAX_N;++i){
    if(k<=c[i]){
      cout<<i<<endl;
      break;
    }
    k-=c[i];
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
/*   -- AUTHOR -- 
  ---- cervotrex ---- 
*/
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
// ordered_set <int> s  ;
// auto x=s.find_by_order(k);
// s.order_of_key(val);

vector<vector<int> > adj;
vector<bool> vis;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  // cin>>t;
  while(t--){
    ll n; cin>>n;
    vector<int> ans(n+1, 0);
    for(int j=1;j*j<=n;j++){
    	int cnt=0;
    	for(int k=1;k*k<=n;k++){
    		for(int p=1;p*p<=n;p++){
    			ll v=j*j+k*k+p*p+j*k+k*p+p*j;
    			if(v<=n)
    				ans[v]++;
    		}
    	}
    }

    for(int i=1;i<=n;i++)
    	cout<<ans[i]<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3472
import Data.Bits
import Data.List
import Control.Monad

getVals :: Read a => IO [a]
getVals = getLine >>= (return . map read . words)
getStrs = getLine >>= (return . words)

toBits ss = [sum [(shift 1 $ si-1) | si <- s] | s <- ss]
check i (b, p) = p == (popCount $ b .&. i) `mod` 2
solve n ss ps = length [i | i <- [0..(shift 1 n)-1] :: [Int], 
                        all (check i) xs]
    where
        xs = zip (toBits ss) ps

main = do
    [n, m] <- getVals :: IO [Int]
    ss <- replicateM m $ getVals >>= (return . tail) :: IO [[Int]]
    ps <- getVals :: IO [Int]
    print $ solve n ss ps

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

using namespace std;

int main(){
  vector<int>coin(6);
  for(int i=0;i<coin.size();i++){
    cin>>coin[i];
  }
  int sum = coin[0]*1 + coin[1]*5 + coin[2]*10 + coin[3]*50 + coin[4]*100 + coin[5]*500;
  if(sum>=1000){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3104
s = input()
t = input()

n = len(s)
m = len(t)

ans = 1000

for i in range(n-m+1):
    a = 0
    for j in range(m):
        if s[i+j] != t[j]:
            a += 1
    ans = min(ans,a)

print(ans)

Measured memory_bytes: 67760
using System;
using System.Runtime.CompilerServices;

namespace ITP1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] strs = str.Split(new char[] {' '});
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);
            Console.WriteLine((a * b) + " " + ((a + b) * 2));
        }
    }
}



Measured memory_bytes: 15876
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)
const p = 10^9+7

function main()
	n = readline() |> parseInt
	a = Tuple{Int,Int}[(0,0) for i in 1:n]
	for i in 1:n
		s,t = readline() |> split |> parseMap
		a[i] = (s,t)
	end
	d = Dict{Tuple{Int,Int},Int}()
	ct = zeros(Int,n)
	for i in 1:n
		v = (0,0)
		m = 1
		if a[i][1]!=0||a[i][2]!=0
			g = gcd(a[i][1],a[i][2])
			if a[i][1]!=0&&a[i][2]!=0
				if a[i][1]>0&&a[i][2]<0||a[i][1]<0&&a[i][2]>0
					m = -1
				end
			end
			if a[i][1]==0
				v=(0,1)
			elseif a[i][2]==0
				v=(1,0)
			else
				v = (m*div(abs(a[i][1]),g),div(abs(a[i][2]),g))
			end
		end
		if haskey(d,(-m*abs(v[1]),abs(v[2])))
			ct[i]=d[(-m*abs(v[1]),abs(v[2]))]
		end
		if haskey(d,v)
			d[v]+=1
		else
			d[v]=1
		end
	end
	bx = ones(Int,n+1)
	for i in 2:n+1
		bx[i]=bx[i-1]*2%p
	end
	ans = 1
	for i in keys(d)
		if i!=(0,0)
			m = 1
			if i[1]!=0
				m = div(abs(i[1]),i[1])
			end
			if i[1]==0||i[2]==0
				if i[1]==1&&haskey(d,(0,1))
					x=d[(1,0)]
					y=d[(0,1)]
					ans = ans*mod(bx[x+y+1]-(bx[x+1]-1)*(bx[y+1]-1)%p,p)%p
				elseif i[1]==1||(i[2]==1&&!haskey(d,(1,0)))
					ans = ans*bx[d[i]+1]%p
				end
			else
				if haskey(d,(-m*abs(i[2]),abs(i[1])))
					if i[1]>0
						x = d[i]
						y = d[(-m*abs(i[2]),abs(i[1]))]
						ans = ans*mod(bx[x+y+1]-(bx[x+1]-1)*(bx[y+1]-1)%p,p)%p
					end
				else
					ans = ans*bx[d[i]+1]%p
				end
			end
		end
	end
	if haskey(d,(0,0))
		ans = (ans+d[(0,0)])%p
	end
	println(mod(ans-1,p))
end

main()

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

int main() {
  string S, T; cin>>S>>T;
  int N=S.size();
  bool dame=0;
  for(int i=0; i<N; i++){
    if(S[i]!=T[i]) dame=1;
  }
  if(dame) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint W, H, N;
    cin >> W >> H >> N;
    vec<vec<lint>> points(N);
    range(i, 0, N) {
        lint x, y, a;
        cin >> x >> y >> a;
        points.at(i) = {x, y, a};
    }
    // [lx, ux], [ly, uy] is the white region
    lint lx = 0, ux = W, ly = 0, uy = H;
    range(i, 0, N) {
        lint x = points.at(i).at(0), y = points.at(i).at(1), a = points.at(i).at(2);
        if (a == 1) lx = max(lx, x);
        else if (a == 2) ux = min(ux, x);
        else if (a == 3) ly = max(ly, y);
        else uy = min(uy, y);
    }
    cout << max(0LL, ux - lx) * max(0LL, uy - ly) << "\n";
}

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

int main() {
  string s; cin >> s;
  int res, mins = 10000;

  for(int i = 0; i < s.size()-2; i++) {
    int n = stoi(s.substr(i, 3));
    res = abs(n - 753);
    mins = min(res, mins);
  }
  cout << mins << endl;
}


Measured memory_bytes: 256
#include <iostream>

enum week { Mon, Tue, Wed, Thu, Fri, Sat, Sun };

using namespace std;

int main() {
  string x;
  cin >> x;
  enum week day;

  if (x == "MON") day = Mon;
  else if (x == "TUE") day = Tue;
  else if (x == "WED") day = Wed;
  else if (x == "THU") day = Thu;
  else if (x == "FRI") day = Fri;
  else if (x == "SAT") day = Sat;
  else if (x == "SUN") day = Sun;

  if (Sun - day == 0) std::cout << "7" << std::endl;
  else std::cout << Sun - day << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n;
    cin >> n;

    s64 ans = 0;
    for (s64 i = 1; i <= n; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }

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



Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			StringBuffer S = new StringBuffer(in.next());
			String T = in.next();
			String ans = "UNRESTORABLE";
			for(int i = S.length() - T.length(); i >=0 ; i--) {
				String tmp = S.substring(i, i + T.length());
				int count = 0;
				for(int j = 0; j < T.length(); j++) {
					if(tmp.charAt(j) == T.charAt(j) || tmp.charAt(j) == '?') {
						count++;
					}
				}
				if(count == T.length()) {
					ans = String.valueOf(S.replace(i, i + T.length(), T));
					ans = ans.replace	("?", "a");
					break;
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 21460
n=int(input())
l=[]
for i in range(n):
    s,p=[x for x in input().rstrip().split()]
    l.append([s,int(p),i+1])
l.sort(key=lambda x:x[1],reverse=True)
l.sort(key=lambda x:x[0])


for i,x,z in l:
    print(z)




Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,A[1000][1000],cnt,B[1000][1000],p;
vector<pair<int,int>>v[1000][1000];
queue<pair<int,int>>q;
int main(){
	cin>>N;
	for(int i=0;i<N;++i){
		for(int j=0;j<N-1;++j){
			cin>>A[i][j];
			--A[i][j];
		}
	}
	for(int i=0;i<N;++i){
		for(int j=1;j<N-1;++j){
			++B[min(i,A[i][j])][max(i,A[i][j])];
		}
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<N-2;++j){
			v[min(i,A[i][j])][max(i,A[i][j])].push_back(mkp(min(i,A[i][j+1]),max(i,A[i][j+1])));
		}
	}
	for(int i=0;i<N;++i){
		for(int j=i+1;j<N;++j){
			if(B[i][j]==0){
				q.push(mkp(i,j));
			}
		}
	}
	p=N*(N-1)/2;
	while(p){
		if(q.empty()){
			cout<<-1<<endl;
			return 0;
		}
		queue<pair<int,int>>que;
		++cnt;
		while(!q.empty()){
			--p;
			int x=q.front().first;
			int y=q.front().second;
			q.pop();
			for(pair<int,int>p:v[x][y]){
				--B[p.first][p.second];
				if(!B[p.first][p.second]){
					que.push(mkp(p.first,p.second));
				}
			}
		}
		q=que;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 47104
program main
implicit None
	integer(8)::a(5),n,b(5) =(/1,2,3,4,5/),c=5
	read*,n
	read*,a
	call h2(a,b,c)
	
	print "(i0)",n/a(1)+(1-(a(1)-mod(n,a(1)))/a(1))+4
end program main

subroutine h2(a,b,n)
implicit None
	integer(8)::a(n),b(n),x,y
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);y = b(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie);y = b(ie)
		a(ie) = a(1);b(ie) = b(1)
		a(1) = x;b(1) = y
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h2

Measured memory_bytes: 256
extern crate core;

use std::collections::HashSet;
use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize){n;list:#});
    let list = list
        .into_iter()
        .map(|x| x.chars().collect::<Vec<_>>())
        .collect::<Vec<_>>();
    let mut next = list[0][0];
    let mut set = HashSet::new();
    for x in list {
        if x[0] != next {
            return "No".to_string();
        }

        let len = x.len();
        next = x[len - 1];

        if set.contains(&x) {
            return "No".to_string();
        }

        set.insert(x);
    }
    "Yes".to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4\nhoge\nenglish\nhoge\nenigma" => "No",
    test2: "9\nbasic\nc\ncpp\nphp\npython\nnadesico\nocaml\nlua\nassembly" => "Yes",
    test3: "8\na\naa\naaa\naaaa\naaaaa\naaaaaa\naaa\naaaaaaa" => "No",
    test4: "3\nabc\narc\nagc" => "No",
}


Measured memory_bytes: 4352
N = int(input())
A,B = map(int,input().split())
P = list(map(int, input().split()))
m1 = []
m2 = []
m3 = []
for i in range(N):
    if P[i] <= A:
        m1.append(i)
    elif A+1 <= P[i] <= B:
        m2.append(i)
    elif B+1 <= P[i]:
        m3.append(i)
print(min(len(m1),len(m2),len(m3)))
    

Measured memory_bytes: 61788
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        String s=next();
        int[]A=new int[n+2];
        int r=0;
        int w=0;
        for (int i=1;i<=n;i++) {
            if (s.charAt(i-1)=='R') { r++; A[i]=1; }
            else w++;
        }
        
        int ans=Math.min(r,w);
        
        A[0]=-1;
        A[n+1]=-1;
        int a2=0;
        int p=0;
        int q=n+1;
        while (r>0 && w>0) {
            while (A[p]!=0) p++;
            while (A[q]!=1) q--;
            if (p>q) break;
            A[p]=1;
            A[q]=0;
            a2++;
            r--;
            w--;
        }
        ans=Math.min(ans,a2);
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 37440
import Control.Applicative
import qualified Control.Monad as Monad

type Card = (String, Int)

main = do
    n <- read <$> getLine
    hc <- map (toCard . words) <$> Monad.replicateM n getLine
    mapM_ (putStrLn . fromCard) $ missingCards hc

toCard :: [String] -> Card
toCard [p,r] = (p, read r)

fromCard :: Card -> String
fromCard (p,r) = p ++ " " ++ (show r)

missingCards :: [Card] -> [Card]
missingCards hc = [ (p,r) | p <- ["S","H","C","D"], r <- [1..13], not $ (p,r) `elem` hc ]

Measured memory_bytes: 4000
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

h,n = inp
t = []
n.times do
  t << inp
end
dp1 = na(h+10000,1e20)
dp2 = na(h+10000,1e20)
dp2[0] = 0
dp1[0] = 0
t.each.with_index do |a,i|
  d,c = a
  min = 1e20
  (0...d).each do |j|
    dp1[j] = small(dp2[j],c)
  end
  (d..h).each do |j|
    dp1[j] = small(dp2[j],dp1[j-d]+c)
  end
  dp1,dp2 = dp2,dp1
end
p dp2[h]


Measured memory_bytes: 4348