akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
  string str, code;
  int code_num;

  cin >> str >> code_num;

  for(int i=0; i<code_num; i++){
    cin >> code;
    
    int start, end;
    string buf;
    
    if(code == "replace"){
      cin >> start >> end >> buf;

      for(int i=0; i<=end-start; i++){
        str[start + i] = buf[i];
      }
    }else if(code == "reverse"){
      cin >> start >> end;
      buf = str;
      for(int i=0; i<=end-start; i++){
        str[start + i] = buf[end - i];
      }
    }else if(code == "print"){
      cin >> start >> end;
      for(int i=start; i<=end; i++){
        cout << str[i];
      }
      cout << endl;
    }

  }

  return(0);

}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
string s;
main()
{
	int n;cin>>n>>s;
	int f=0,l=0,now=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='(')now++;
		else
		{
			if(now)now--;
			else f++;
		}
	}
	now=0;
	for(int i=s.size();i--;)
	{
		if(s[i]==')')now++;
		else
		{
			if(now)now--;
			else l++;
		}
	}
	for(int i=0;i<f;i++)cout<<'(';
	cout<<s;
	for(int i=0;i<l;i++)cout<<')';
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d,r;
    double f;
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    cout<<d<<' '<<r<<' ';
    printf("%9lf\n",f);
}


Measured memory_bytes: 3236
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    char x;
    int n,sum;
    while(1) {
        sum = 0;
        scanf("%c", &x);
        if(x=='0')
            break;
        while(x!='\n') {
              n=x-'0';
              sum+=n;
              scanf("%c", &x);
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 2736
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    ll mx = -x, my = -y;
    ll ans = 1e18;
    if(x < y) chmin(ans, y - x);
    if(mx <= y) chmin(ans, y - mx + 1);
    if(x <= my) chmin(ans, my - x + 1);
    if(mx <= my) chmin(ans, my - mx + 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
pp = list(map(int, input().split()))

sorted_pp = pp[:]
sorted_pp.sort()

count = 0
for i in range(N):
    if pp[i] != sorted_pp[i]:
        count += 1

if count == 2 or count == 0:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 3060
//直線グラフ「1-2-3-…-N」で条件を満たす ⇔ YES,らしい。必要性の証明が難しい。
#include <iostream>
#include <vector>
using namespace std;

int n, m;
vector<int> et[100000];
int imos[100001];

signed main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		imos[a]++;
		imos[b]--;
	}
	
	for (i = 1; i <= n; i++) imos[i] += imos[i - 1];
	for (i = 0; i < n; i++) {
		if (imos[i] % 2 != 0) { cout << "NO" << endl; return 0; }
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(void){
	

  	long long int m,ans,i,n;
  
  	scanf("%lld %lld",&n,&m);
  
  	if(n == 1){
    	printf("%lld\n",m);
      	return 0;
    }
  
  	for(i=m/n;i >=1;i--){
      if(m % i ==0 && m >= i*n){
      	ans = i;
        break;
      }
    }
	 
  	printf("%lld\n",ans);
  
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {   
    char b;
    scanf("%c",&b);
    char ans;
    switch (b) {
    case 'A':ans = 'T'; break;
    case 'C':ans = 'G'; break;
    case 'G':ans = 'C'; break;
    case 'T':ans = 'A'; break;
    }
    printf("%c",ans);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 0;
        int min = 10;
        for (int i = 0; i < 5; i++) {
            float a = sc.nextFloat();
            n += Math.ceil(a / 10) * 10;
            String str = String.valueOf((int)a);
            int b = Integer.parseInt(str.substring(str.length() - 1));
            if (b < min && b >= 1) {
                min = b;
            }
        }
        System.out.println(n + min - 10);
    }
}

Measured memory_bytes: 23124
#include<cstdio>

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

using namespace std;

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

int h,w;
char B[10][11];

int num;
char ans[31];
bool dfs(int i,int x,int y,int dir){
	if(i==num) return true;

	B[y][x]='.';
	rep(k,4) if(k!=((dir+2)&3)) {
		bool ok=false;
		int xx=x,yy=y;
		while(0<=xx && xx<w && 0<=yy && yy<h){
			if(B[yy][xx]=='o'){ ok=true; break; }
			xx+=dx[k];
			yy+=dy[k];
		}
		if(ok){
			ans[i]="RULD"[k];
			if(dfs(i+1,xx,yy,k)) return true;
		}
	}
	B[y][x]='o';

	return false;
}

int main(){
	scanf("%d%d",&h,&w);
	rep(i,h) scanf("%s",B[i]);

	int sx,sy;
	rep(i,h) rep(j,w) {
		if(B[i][j]=='o') num++;
		if(B[i][j]!='o' && B[i][j]!='.') sx=j, sy=i;
	}

	int f[128];
	f['R']=0;
	f['U']=1;
	f['L']=2;
	f['D']=3;
	dfs(0,sx,sy,f[B[sy][sx]]);

	puts(ans);

	return 0;
}

Measured memory_bytes: 1012
#include                <bits/stdc++.h>
#define ff              first
#define ss              second
#define pb(x)           emplace_back(x)
#define dbg(a)          cout<< #a <<" --> "<<(a)<<endl;
#define read            freopen("tst.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> PP;

#define mx 200002
vector<int> v[mx];
int deg[mx],ans;

struct node{
    int a,b,c;
    bool operator < (const node &n) const{
        if(a!=n.a)  return a<n.a;
        return b<n.b;
    }
};

map<pp,int> mp;
int color[mx];

void dfs(int u,int a,int cnt){

    for(int i:v[u]){
        if(i==a)    continue;
        cnt++;
        cnt%=ans;
        color[mp[{u,i}]] = cnt+1;
//        st.insert({u,i,cnt});
        dfs(i,u,cnt);
    }
}

main(){
//read;
int n;
cin>>n;
for(int i = 0; i<n-1; i++){
    int a,b;
    cin>>a>>b;
    v[a].pb(b);
    v[b].pb(a);
    deg[a]++;
    deg[b]++;
    mp[{a,b}] = i;
    mp[{b,a}] = i;
}

for(int i = 1; i<=n; i++)
    ans = max(ans,deg[i]);

cout<<ans<<endl;

dfs(1,0,0);

for(int i = 0; i<n-1; i++)
    cout<<color[i]<<endl;

return 0;
}


Measured memory_bytes: 21888
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int sum[maxn];
int main()
{
  int n , m;
  scanf("%d%d",&n,&m);
  for(int i = 0 ; i < m ; i++)
  {
    int s,e;scanf("%d%d",&s,&e);
    sum[s]++;
    sum[e+1]--;
  }
  int te = 0 , ans = 0;
  for(int i = 1 ; i <= n ; i++)
  {
    te += sum[i];
    if(te == m) ans++;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a,b;
    String str;
    while(true){
      a = sc.nextInt();
      str = sc.next();
      b = sc.nextInt();

      if(str.equals("?")) break;

      switch(str){
        case "+":
        System.out.println(a+b);
        break;

        case "-":
        System.out.println(a-b);
        break;

        case "*":
        System.out.println(a*b);
        break;

        case "/":
        System.out.println(a/b);
        break;
      }//switch

    }//while
  }

}


Measured memory_bytes: 26168
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e12 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;

using namespace std;

ll dp[110][N];
ll w[N], v[N];

int main()
{
	barnarnar
	int n, W;
	cin >> n >> W;
	forn1(i, n)	cin >> w[i] >> v[i];
	forn(i, n + 1)	forn(j, N)	dp[i][j] = inf;
	dp[0][0] = 0ll;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= N; j++)
		{
			dp[i][j] = dp[i - 1][j];
			if(j - v[i] >= 0)
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
		}
	}
	ll ans = 0;
	for(int j = 0; j < N; j++)	if(dp[n][j] <= W)	ans = j;
	cout << ans;
	return 0;
}



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

using ll = long long;
ll MOD = 998244353;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, s;
  cin >> n >> s;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll inv2 = power(2, MOD - 2, MOD);
  
  vector<vector<ll>> dp(n + 1, vector<ll>(s + 1));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < s; j++) {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= MOD;
      if (a.at(i) + j > s) continue;
      dp[i + 1][j + a.at(i)] += (dp[i][j] * inv2) % MOD;
      dp[i + 1][j + a.at(i)] %= MOD;
    }
  }
  
  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += (power(2, n, MOD) * dp[i][s]) % MOD;
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 73652
H, W, N, *A = map(int, open(0).read().split())

C = []
for i, a in enumerate(A):
    C += [i + 1] * a

for i, r in enumerate(zip(*[iter(C)] * W)):
    if i % 2 == 0:
        print(*r)
    else:
        print(*reversed(r))

Measured memory_bytes: 3828
#include <stdio.h>

#define WHITE 1
#define GRAY 2
#define BLACK -1

int f[101], d[101], Adj[101][101], time, n;

visit(int *color, int u){
  int v;

  color[u] = GRAY;
  d[u] = ++time;

  for(v=1; v<=n; v++){
    if(Adj[u][v] && color[v] == WHITE){
      visit(color, v);
    }
  }

  color[u] = BLACK;
  f[u] = ++time;
}


dfs(){
  int u, time;
  int color[n+1];

  for(u=1; u<=n; u++){
    color[u] = WHITE;
    time = 0;
  }

  for(u=1; u<=n; u++){
    if(color[u] == WHITE){
      visit(color, u);
    }
  }
}

int main(){
  int i, j, u, k, temp;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d",&temp);
      Adj[u][temp] = 1;
    }
  }

  dfs();

  for(i=1; i<=n; i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }

  return 0;

}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int b,c;
    cin >> b >> c;
    string a; a="Odd";
    if (b*c%2==0) {
      a = "Even";
    }

    // 出力
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
s=input()

n1=int(s[:2])
n2=int(s[2:])

if 0<n1<=12 and 0<n2<=12:
    print("AMBIGUOUS")
elif 0<n1<=12:
    print("MMYY")
elif 0<n2<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, int> BC;
#define mp(a, b) make_pair(a, b)

int main(int argc, char const *argv[]) {
  int n, m;

  cin >> n;
  cin >> m;

  int a;
  priority_queue<BC> q;
  for (int i = 0; i < n; i++) {
    cin >> a;
    q.push(mp(a, 1));
  }

  long long int b, c, tmp;
  for (int i = 0; i < m; i++) {
    cin >> b;
    cin >> c;
    q.push(mp(c, b));
  }

  long long int sum = 0;
  long long int count = 0;
  BC p;
  while (count < n) {
    p = q.top();
    q.pop();

    b = p.second;
    c = p.first;

    if (count + b < n) {
      sum += b * c;
      count += b;
    } else {
      sum += c * (n - count);
      count += (n - count);
      break;
    }
  }
  cout << sum;

  return 0;
}


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

using namespace std;

#define li long long int

const int N 	= 1e2 + 3;
const int M 	= 1e5 + 3;
const int mod 	= 1e9 + 7;

int n, k;
int a[N];
li dp[N][M];
li prefix[N][M];

void solve() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= n; i++) {
		dp[i][0] = 1;
	}
	for (int i = 1; i <= n; i++) {
		prefix[i - 1][0] = dp[i - 1][0];
		for (int j = 1; j <= k; j++) {
			prefix[i - 1][j] = prefix[i - 1][j - 1] + dp[i - 1][j];
			prefix[i - 1][j] %= mod;
		}
		for (int j = 1; j <= k; j++) {
			if (j - a[i] >= 1) {
				dp[i][j] = prefix[i - 1][j] - prefix[i - 1][j - a[i] - 1];
				dp[i][j] %= mod;
				if (dp[i][j] < 0) dp[i][j] += mod;
			} else {
				dp[i][j] = prefix[i - 1][j];
			}
		}
	}
	cout << dp[n][k];
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 160000
#include <iostream>

using namespace std;

typedef long long ll;

ll INF = 1e12;

ll N,M,L;
ll m[301][301];
ll n[301][301];
ll Q;
ll s[100000];
ll t[100000];

int main(){
    cin >> N >> M >> L;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            m[i][j] = INF;
            n[i][j] = INF;
        }
    }
    ll a,b,c;
    for(int i=0;i<M;i++){
        cin >> a >> b >> c;
        m[a][b] = m[b][a] = c;
    }
    cin >> Q;
    for(int i=0;i<Q;i++){
        cin >> s[i] >> t[i];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                m[j][k] = min(m[j][k],m[j][i]+m[i][k]);
            }
        }
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            if(m[i][j] <= L) n[i][j] = 1;
        }
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                n[j][k] = min(n[j][k],n[j][i]+n[i][k]);
            }
        }
    }
    for(int i=0;i<Q;i++){
        if(n[s[i]][t[i]] == INF){
            cout << -1 << endl;
            continue;
        }
        cout << n[s[i]][t[i]] - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
# ABC104b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input()[:-1]
#print(s.count('C', 2, -1))
if (s[0] != 'A' or s.count('C', 2, -1) != 1):
    print('WA')
    # print('hi')
    exit()
cPos = s.find('C', 2, -1)
if (s[1:cPos].islower() and s[cPos + 1:].islower()):
    # print('hi')
    print('AC')
    exit()
print('WA')

Measured memory_bytes: 3064
module Main where
import Data.List
main = interact $ printer . solver . parser
int = read :: String -> Int

printer = unlines . (:[]) . show
parser = map int . tail . words

solver is = sum v3
  where
    v1 = sort is
    v2 = group v1
    v3 = map delcnt v2
    delcnt ss
      | v5 < v4 = v5
      | v5 > v4 = v5 - v4
      | otherwise = 0
      where
        v4 = head ss
        v5 = length ss




Measured memory_bytes: 17660
n = int(input())
li = list(map(int, input().split()))
li2 = [[0 for i in range(2)] for j in range(n)]

for i, item in enumerate(li):
    li2[i][0] = i + 1
    li2[i][1] = item

sortedList = sorted(li2, key=lambda x: x[1])
line = ""
for i in range(n):
    line += str(sortedList[i][0]) + ' '
print(line[:-1])

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

public class Main {
	public static void main(String[] args) throws IOException {
     Scanner sc = new Scanner(System.in);
     int health = sc.nextInt(); 
     int attack = sc.nextInt(); 
     int ans = 0; 
     while( health > 0) {
    	 health -= attack ; 
    	 ans++ ;
     }
     System.out.println(ans); 
	}
}

Measured memory_bytes: 21716
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int a, b;
    scan(a, b);

    if (a >= 13) {
        writeln(b);
    }
    else if (a >= 6) {
        writeln(b / 2);
    }
    else {
        writeln(0);
    }
}





















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
import math

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

#p
p_n=0
q_n=0
for i in range(n):
    count_p=p[i]-1
    count_q=q[i]-1
    for j in range(i):
        if p[j]<p[i]:
            count_p-=1
        if q[j]<q[i]:
            count_q-=1
    p_n+=math.factorial(n-i-1)*count_p
    q_n+=math.factorial(n-i-1)*count_q

print(abs(p_n-q_n))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>ch;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ch.push_back(x);
	}
	sort(ch.begin(),ch.end());
	reverse(ch.begin(),ch.end());
	ll ans=ch[0];
	ll cnt1=0;
	ll j=1;
	for(ll i=1;i<n-1;i++){
		if(cnt1==2){
			cnt1=0;
			j++;
		}
		ans+=ch[j];
		cnt1++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main(){
    
    int N;
    cin >> N;
    
    long long A[N];
    for(int i = 0; i < N;i++)cin >> A[i];
    
    sort(A,A+N,greater<long long>());
    
    
    vector<long long> vec;
    for(int i = 0; i < N-1;i++){
        //cout << A[i] << " "<<A[i+1]<<endl;
        if(A[i]==A[i+1]){
            vec.push_back(A[i]);
            i = i+1;
        }
        if(vec.size()==2)break;
    }
    
    
    if(vec.size()!=2){
        cout << 0 <<endl;
        return 0;
    }
    long long ans = 1;
    for(auto u:vec)ans *= u;
    
    //for(auto u:vec)cout << u;
    //cout << endl;
    
    cout << ans <<endl;
    
    
    
}

    
    



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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);
  int n ;
  cin >> n;
  map<string,int> pol ;
  set<string> sett ;
  REP(i,n){
    string s ; 
    cin >> s ;
    sett.insert(s) ;
    if(pol.count(s)==0){
      pol[s] = 1 ;
    }
    else{
      pol[s]++ ;
    }
  }
  
  int m = 0 ;
  for(auto itr = sett.begin();itr!=sett.end();itr++){
    if(pol[(*itr)]>=m){
      m = pol[(*itr)] ;
    }
  }

  for(auto itr = sett.begin();itr!=sett.end();itr++){
    if(pol[(*itr)]==m){
      cout << (*itr) <<endl ;
    }
  }
 

  
  
  return 0 ;
}



Measured memory_bytes: 33280
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    var s = readLine()!! 
    val k = readLine()!!.toInt()

    var point = s[k-1]

    var list = mutableListOf<Char>()


    for(i in 0..n-1){
        if(s[i] != point){
            list.add('*')
        }
        else{
            list.add(s[i])

        }

    }

for(i in 0..n-1){
    print(list[i])
}
println()
}

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

string s[8];
char c[2]={'o','x'};
int dx[8]={1,1,0,-1,-1,-1,0,1},dy[8]={0,1,1,1,0,-1,-1,-1};
int t;

int dfs(int d,int x,int y){
  if(min(x,y)<0||7<max(x,y)||s[y][x]=='.')return -9;
  if(s[y][x]==c[t])return 0;
  return dfs(d,x+dx[d],y+dy[d])+1;
}

void solve(){

  int ct=0;

  while(ct++<150){  

    int px=-1,py=-1,mx=0;
    
    for(int y=0;y<8;y++)
      for(int x=0;x<8;x++){

	int xx=x,yy=y,res=0;
	if(t)xx=7-x,yy=7-y;
	if(s[yy][xx]!='.')continue;
	for(int i=0;i<8;i++)
	  res+=max(0,dfs(i,xx+dx[i],yy+dy[i]));
	if(res>mx)px=xx,py=yy,mx=res;
      }

    if(mx)
      for(int i=0;i<8;i++){
	int res=dfs(i,px+dx[i],py+dy[i]);
	for(int j=0;j<=res;j++)
	  s[py+j*dy[i]][px+j*dx[i]]=c[t];
      }
    
    t=!t;
  }
  
}

int main(){
  for(int i=0;i<8;i++)cin>>s[i];
  
  solve();
  
  for(int i=0;i<8;i++)cout<<s[i]<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

string t="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {

	int h,w;

	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			string s;
			cin>>s;
			if(s=="snuke"){
				cout<<t[j]<<i+1<<endl;
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(r: int):
    ret = r * r
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    long long N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << '\n';
        return 0;
    }

    long long left = (A - 1) + 1 + (B - A - 1) / 2;
    long long right = (N - B) + 1 + (B - A - 1) / 2;
    cout << min(left, right) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,a[100],key,i,j,k;
void insertsort(){
    for (i = 0; i < n; i++){
        key = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > key){
            a[j + 1] = a[j];
            j--;
        }
        a[++j] = key;
        
        for (k = 0; k < n; k++){
            if (k ==n - 1){cout<<a[k]<<endl;}
            else cout << a[k] << " ";
        }
    }
}
int main(){
    cin >> n;
    for (i = 0;i < n; i++)
    cin >> a[i];
    insertsort ();
    return 0; 
}

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

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

    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    }
    else if (b < 0 && (b - a) % 2 == 0) {
        cout << "Negative" << endl;
    }
    else {
        cout << "Positive" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, T;
  cin >> N >> T;

  ll ans = 0;
  ll before = -INF;
  rep(i, N) {
    ll a;
    cin >> a;
    ans += T;
    if (before + T >= a) ans -= ((before + T) - a);
    before = a;
  }
  ANS;
  return 0;
}

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

typedef long long ll;

int n;
vector<int> vcost;
vector<vector<pair<int, int> > > edges;

vector<pair<pair<int,int>, int> > order;

void dfs(int v, int p) {
	for (size_t j = 0; j < edges[v].size(); j++) {
		int w = edges[v][j].first;
		if (w == p) continue;
		order.push_back(make_pair(make_pair(w, v), edges[v][j].second));
		dfs(w, v);
	}
}

vector<vector<pair<ll, int> > > best;

void prop_edge(int v, int w, int c) {
	// 保证两个末端不同
	for (int j = 0; j < 2; j++) {
		if (best[v][j].second == best[w][0].second) {
			swap(best[w][0], best[w][1]);
		}
		best[w][1] = min(best[w][1], make_pair(best[v][j].first + c, best[v][j].second));
		if (best[w][0] > best[w][1]) {
			swap(best[w][0], best[w][1]);
		}
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	vcost.resize(n);
	for (int i = 0; i < n; i++) cin >> vcost[i];
	edges.resize(n);
	for (int i = 0; i < n-1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		edges[a].push_back(make_pair(b, c));
		edges[b].push_back(make_pair(a, c));
	}
	order.reserve(n-1);
	dfs(0, -1);

	ll total = 0;
	vector<vector<int> > cc_edges(n);
	vector<int> vis(n);
	vector<int> which_cc(n);
	vector<int> cc;
	cc.reserve(n);
	best.assign(n, vector<pair<ll, int> >(2));
	vector<pair<ll, int> > cc_best;
	cc_best.reserve(n);
	vector<vector<int> > ccs;
	ccs.reserve(n);
	while (true) {
		fill(vis.begin(), vis.end(), 0);
		fill(which_cc.begin(), which_cc.end(), -1);
		ccs.clear();
		for (int i = 0; i < n; i++) {
			if (vis[i]) continue;
			cc.clear();
			cc.push_back(i);
			vis[i] = 1;
			for (int s = 0; s < int(cc.size()); s++) {
				int v = cc[s];
				for (size_t j = 0; j < cc_edges[v].size(); j++) {
					int w = cc_edges[v][j];
					if (!vis[w]) {
						vis[w] = 1;
						cc.push_back(w);
					}
				}
			}
			for (size_t j = 0; j < cc.size(); j++) {
				which_cc[cc[j]] = int(ccs.size());
			}
			ccs.push_back(cc);
		}
		if (ccs.size() == 1) break;
		for (int v = 0; v < n; v++) {
			best[v][0] = make_pair(vcost[v], which_cc[v]);
			best[v][1] = make_pair(1e18, -1);
		}
		for (int i = n-2; i >= 0; i--) {
			pair<pair<int, int>, int>& e = order[i];
			prop_edge(e.first.first, e.first.second, e.second);
		}
		for (int i = 0; i < n-1; i++) {
			pair<pair<int, int>, int>& e = order[i];
			prop_edge(e.first.second, e.first.first, e.second);
		}
		cc_best.resize(ccs.size());
		fill(cc_best.begin(), cc_best.end(), make_pair(1e18, -1));
		for (int v = 0; v < n; v++) {
			for (int j = 0; j < 2; j++) {
				if (best[v][j].second != which_cc[v]) {
					cc_best[which_cc[v]] = min(cc_best[which_cc[v]], 
											   make_pair(best[v][j].first + vcost[v], best[v][j].second));
				}
			}
		}
		for (int k = 0; k < int(ccs.size()); k++) {
			int l = cc_best[k].second;
			if (cc_best[l].second == k && l < k) continue;
			total += cc_best[k].first;
			cc_edges[ccs[k].front()].push_back(ccs[l].front());
			cc_edges[ccs[l].front()].push_back(ccs[k].front());
		}
	}
	cout << total << '\n';
}


Measured memory_bytes: 81576
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;

#define ll long long

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a < c && c < b && a < b)cout << "Yes" << endl;
	else if(b<c && b<a&&c<a)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!.toCharArray()
    var k = readLong()

    for (i in s.indices) {
        if (k == 0L) break

        val tmp = 'z' - s[i] + 1
        if (s[i] != 'a' && tmp <= k) {
            s[i] = 'a'
            k -= tmp
        }
    }

    s[s.lastIndex] = (((s[s.lastIndex] - 'a' + k) % ('z' - 'a' + 1)) + 'a'.toInt()).toChar()
    out.println(s.joinToString(""))
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 40268
#include<iostream>
#include <cstdio>
#include<cctype>
#include <algorithm>
#include<string>

using namespace std;

int main(){
	string w, t;
	int cnt = 0;
	
	cin >> w;
	transform(w.begin(), w.end(), w.begin(), ::toupper);
	
	while(cin >> t){
		if(t == "END_OF_TEXT") break;
		else transform(t.begin(), t.end(), t.begin(), ::toupper);
		
		if(t == w) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1192
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	char a;
	cin>>a;
	if(a>='A'&&a<='Z') cout<<"A"<<endl;
	else cout<<"a"<<endl;
	return 0;
}


Measured memory_bytes: 3532
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    cin >> n;
    Vec<Vec<int> > f(n, Vec<int>(10));
    Vec<Vec<int> > p(n, Vec<int>(11));

    FOR (i, 0, n) {
        FOR (j, 0, 10) {
            cin >> f[i][j];
        }
    }
    FOR (i, 0, n) {
        EFOR (j, 0, 10) {
            cin >> p[i][j];
        }
    }

    int max_profit = -INF;

    FOR (i, 1, 1024) {
        int profit = 0;
        FOR (j, 0, n) {
            int count = 0;
            RFOR (k, 9, -1) {
                if ((i & (1 << k)) != 0 && f[j][9 - k] == 1) {
                    count++;
                }
            }
            profit += p[j][count];
        }
        //cout << i << " " << profit << endl;
        max_profit = max(max_profit, profit);
    }
    cout << max_profit << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 3e3+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[N][N]; // #perm from [1:n] with last digit being x
string s;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n >> s;
    memset(dp, 0, sizeof(dp));
    dp[1][1] = 1;
    for (int i = 2; i <= n; ++i) {
        ll pref[N] = {};
        for (int x = 1; x < i; ++x) pref[x] = add(dp[i-1][x], pref[x-1]);
        for (int x = 1; x <= i; ++x) {
            if (s[i-2] == '<') dp[i][x] = pref[x-1];
            else dp[i][x] = sub(pref[i-1], pref[x-1]);
        }
    }
    ll ans = 0;
    rep (i, 1, n+1) ans = add(ans, dp[n][i]);
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const int N = (int)5e5 + 50;

int n;
int res[N];
string str;

int main() {
    cin >> str;
    n = str.length() + 1;
//    for(int i = 0; i < n; i++) {
//        if(i == 0 || i == n - 1 || (str[i-1] == '>' && str[i] == '<')) res[i] = 0;
//    }
    for(int i = 1; i < n; i++) {
        if(str[i-1] == '<') res[i] = max(res[i], res[i-1] + 1);
    }
    for(int i = n - 2; i >= 0; i--) {
        if(str[i] == '>') res[i] = max(res[i], res[i+1] + 1);
    }
    ll sum = 0;
    for(int i = 0; i < n; i++) sum += res[i];
    cout << sum << endl;
}

Measured memory_bytes: 2820
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;
// use std::collections::BTreeSet;


// const INF: i64 = 1_000_000_000;
// const MOD: i64 = 998244353;


fn argsort(xs: &[i32]) -> Vec<usize> {
    let n = xs.len();
    let mut is: Vec<usize> = (0..n).into_iter().collect();
    is.sort_by_key(|&i| xs[i]);
    is
}

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());
    let n: usize = sc.read();
    let mut a: Vec<i32> = vec![];
    let mut b: Vec<i32> = vec![];
    for _ in 0..n {
        a.push(sc.read());
    }
    for _ in 0..n {
        b.push(sc.read());
    }
    let a = a;
    let b = b;
    let ia = argsort(&a);
    let ib = argsort(&b);
    // println!("{:?}", a);
    // println!("{:?}", ia);
    let mut perm = vec![!0; n];
    let mut good = true;
    for k in 0..n {
        good &= a[ia[k]] <= b[ib[k]];
        perm[ia[k]] = ib[k];
    }
    let mut uniq = true;
    for k in 0..n-1 {
        uniq &= a[ia[k+1]] > b[ib[k]]
    }
    let mut cyc = true;
    {
        let mut k = 0;
        for _ in 0..n-1 {
            k = perm[k];
            cyc &= k != 0;
        }
    }
    let ans = good && !(uniq && cyc);
    println!("{}", if ans { "Yes" } else { "No" });
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


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

char otherc(char c) { return c == 'R' ? 'L' : 'R'; }

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    char prev = s[0];
    int idx = 0;
    bool ok = false;
    while (k > 0 && idx < s.size()) {
        while (idx < s.size() && s[idx] == prev) {
            if (ok) s[idx] = otherc(prev);
            idx++;
        }
        if (ok) k--;
        ok = !ok;
        if (idx < s.size()) prev = s[idx];
    }
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'R' && i + 1 < s.size() && s[i + 1] == 'R') ans++;
        if (s[i] == 'L' && i > 0 && s[i - 1] == 'L') ans++;
    }
    cout << ans << endl;
}


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

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

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

  vector<ll> l(n);
  rep(i,n) cin >> l.at(i);
  int ans=0;
  sort(l.begin(),l.end());

  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(l.at(i)+l.at(j)>l.at(k)&&l.at(i)!=l.at(j)&&l.at(i)!=l.at(k)&&l.at(k)!=l.at(j)) ans++;
      }
    }
  }

  cout << ans;
}

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

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

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


int main(){
	int n;
	cin >>n;
	VI a(n);
	rep(i,n) cin >>a[i];
	const int INF = 1e9+1111;
	VI hk(n, INF);
	for(auto x: a) *lower_bound(all(hk), x) = x;
	cout << lower_bound(all(hk), INF) - hk.begin() << endl;
	return 0;
}




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

int main() {
  int N, Y;
  cin >> N >> Y;

  for (int x = 0; x <= N; ++x) {
    for (int y = 0; y <= N-x; ++y) {
      int z = N - x - y;
      if (x*10000+y*5000+z*1000 == Y) {
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }  
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
// Template //
#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()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    string N;
    cin >> N;
    if (N == "ABC") cou("ARC");
    else cou("ABC");


}

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


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

  int N;
  cin >> N;
  cout << 2 << ' ';
  int count = 1;

  for(int i=0;i<=55555;i++){
    if(count == N) break;
    int p = 10 *i + 7;
    bool ans = true;
    for(int j=3;j*j<=p;j++){
      if(p % j == 0){
        ans = false;
        break;
      }
    }
    if(ans){
      cout << p << ' ';
      count++;
    }
  }
  cout << endl;
}

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

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

    if (n%2 == 1) {
        for (int i=1; i<=m; i++) {
            cout << i << " " << n - i + 1 << endl;
        }
        return 0;
    }

    int s1 = 1;
    int s2 = 2;
    int x1 = 2;
    int x2 = n/2 + 1;

    for (int i=1; i<=m; i++) {
        if (i%2 == 1) {
            int a = x1 - s1;
            if (a <= 0) a += n;
            cout << x1 << " " << a << endl;
            x1++;
            s1 += 2;
        } else {
            cout << x2 << " " << x2 + s2 << endl;
            x2--;
            s2 += 2;
        }
    }
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int MAX = 210000;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	COMinit();

	int N, M;
	cin >> N >> M;

	map<int, int> nmap;
	int t = M;
	for (int i = 2; i <= (int)sqrt(M); i += (i == 2 ? 1 : 2))
	{
		int c = 0;
		while (t%i == 0)
		{
			c++;
			t /= i;
		}
		if (c > 0)
		{
			nmap[c]++;
		}
	}
	if (t != 1)
	{
		nmap[1]++;
	}

	int ans = 1;
	for (auto p : nmap)
	{
		int comb = COM(p.first + N - 1, p.first);
		rep(i, 0, p.second)
		{
			ans = (ans*comb) % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
int main()
{
    long long  n,m,sum=0,b,c,k,d,t;
    long long  a[100005],l[100005]={0};
    scanf("%lld",&n);
    for(m=0;m<n;m++)
    {
        scanf("%lld",&a[m]);
        t=a[m];
        l[t]++;
        sum=sum+a[m];
    }
    scanf("%lld",&d);
    for(t=0;t<d;t++)
    {
        scanf("%lld %lld",&b,&c);
        sum=sum-b*l[b]+c*l[b];
        l[c]=l[c]+l[b];
        l[b]=0;
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3292
x = int(input())
p = int(input())
l = p / 100

def f(d):
    return (d / 2) * 100 / p

if x % 2 == 0:
    res = f(x)
else:
    res = 1 + l * f(x - 1) + (1 - l) * f(x + 1)

print(res)

Measured memory_bytes: 38384