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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

  vector<ll> h(n+10); REP(i, n) cin >> h[i];
  vector<ll> a(m+10);
  vector<ll> b(m+10);
  vector<ll> t(n+10); REP(i, n) t[n] = 0;
  REP(i, m) {
    cin >> a[i] >> b[i];
    a[i] --; b[i] --;
    if(h[a[i]] >= h[b[i]]) {t[b[i]] = 1; }
    if(h[b[i]] >= h[a[i]]) {t[a[i]] = 1; }
  }
  ll ans = 0;

  REP(i, n) {
    if(t[i]==0) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 6428
ans = 'Yes'
n = gets.to_i
a = []
n.times { a << gets.split.map(&:to_i) }
a.sort_by!{|e| e[1]}
cnt1 = 0
a.each do |e|
  cnt1 += e[0]
  ans = 'No' if cnt1 > e[1]
end
puts ans

Measured memory_bytes: 22928
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int ja(int i){
  if(i%100!=0) return 0;
  return ja(i/100)+1;
}

int main(){
  int d,n;
  cin>>d>>n;
  int cnt=0;
  for(int i=1;;i++){
    if(ja(i)==d){
      cnt++;
    }
    if(cnt==n){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  int s = accumulate(begin(a), end(a), 0);
  int res, mn = 1e9;
  for (int i = 0; i < n; ++i) {
    if (abs(n * a[i] - s) < mn) {
      mn = abs(n * a[i] - s);
      res = i;
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;  using i64 = int64_t;  using str = string;
using u32 = uint32_t; using u64 = uint64_t; using usize = size_t;
using f64 = double_t; template <typename T> using vec = vector<T>;
#define times(n, i) for (i64 i = 0; i < (n); ++i)
#define range(n, m, i) for (i64 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i64 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i64 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n, m;
i32 c[100000];
bool r[100000];

i32 main()
{
    cin >> n >> m;
    times(n, i) {
        c[i] = 1;
    }
    r[0] = 1;

    times(m, i) {
        i32 x, y; cin >> x >> y;
        x--; y--;
        c[x]--; c[y]++;
        if (r[x])
            r[y] = true;
        if (c[x] == 0)
            r[x] = false;
    }

    i32 ans = 0;
    times(n, i) {
        if (r[i])
            ans++;
    }

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

Measured memory_bytes: 768
#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; cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());

	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
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 fi first
#define sc second
#define rep(i,x) for(int i=0;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())
#define mod 1000000007
int n;
ll x,y;
int main(){
	string s; cin >> s;
	int zan = 0,ret = 0;
	for(int i=0;i<s.size();i++){
		if(!zan){
			if(s[i] == 'p') ret--;
			zan++;
		}
		else{
			if(s[i] == 'g') ret++;
			zan--;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
pii p[MAXN],rg[MAXN];
int L[MAXN],R[MAXN],st[MAXN],top;
int dp[MAXN],s[MAXN];
vector<int> v[MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);
    int x,v;
    for(int i = 1 ; i <= N ; ++i) {
	read(x);read(v);p[i] = mp(v,x);
    }
    sort(p + 1,p + N + 1);
    
    for(int i = 1 ; i <= N ; ++i) {
	rg[i].fi = i;
	if(!top || p[st[top]].se < p[i].se) st[++top] = i;
	if(top) {
	    int l = 1,r = top;
	    while(l < r) {
		int mid = (l + r) >> 1;
		if(p[st[mid]].se >= p[i].se) r = mid;
		else l = mid + 1;
	    }
	    rg[i].fi = st[l];
	}
	
    }
    top = 0;
    for(int i = N ; i >= 1 ; --i) {
	rg[i].se = i;
	if(!top || p[st[top]].se > p[i].se) st[++top] = i;
	if(top) {
	    int l = 1,r = top;
	    while(l < r) {
		int mid = (l + r) >> 1;
		if(p[st[mid]].se <= p[i].se) r = mid;
		else l = mid + 1;
	    }
	    rg[i].se = st[l];
	}
	
    }
    sort(rg + 1,rg + N + 1);
    s[0] = 1;dp[0] = 1;
    int k = 1;
    for(int i = 1 ; i <= N ; ++i) {
	while(k <= rg[i].se) {
	    s[k] = inc(s[k - 1],dp[k]);
	    ++k;
	}
	int t = s[rg[i].se];
	if(rg[i].fi != 1) update(t,MOD - s[rg[i].fi - 2]);
	update(dp[rg[i].se],t);
	
	s[rg[i].se] = inc(s[rg[i].se - 1],dp[rg[i].se]);
    }
    out(dp[N]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 11904
import Data.List
main = do
 _ <- getLine
 s1 <- getLine
 s2 <- getLine
 print $(`mod` 1000000007)$analyze s1


analyze :: String -> Integer
analyze str = foo $ map length $ group str

foo :: [Int] -> Integer
foo [] = 1
foo [1] = 3
foo [2] = 6
foo (1:1:xs) = 2 * foo(1:xs)
foo (2:1:xs) = 2 * foo(1:xs)
foo (1:2:xs) = 1 * foo(2:xs)
foo (2:2:xs) = 3 * foo(2:xs)

Measured memory_bytes: 508
# coding: utf-8
 
 
def is_unique(seq):
    return len(seq) == len(set(seq))
 
 
def main():
    n = int(input())
    shiri = True
 
    w = []
    for i in range(n):
        w.append(input())
 
    for i in range(n-1):
        if w[i][-1] != w[i + 1][0]:
            shiri = False
            break
 
    if not is_unique(w):
        shiri = False
 
    if shiri:
        print('Yes')
    else:
        print('No')
 
 
if __name__ == '__main__':
    main()

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

int main(){
  int N,count=0,p[10001];

 for(int i=2;i<=10000;i++){
    p[i]=1;
 }
 for(int i=2;i*i<=10000;i++){
   if(p[i]==1){
     for(int j=2;j<=10000/i;j++){
       p[i*j]=0;
     }
   }
 }


  while( cin>>N){
    count=0;
    for(int i=2;i<=N;i++){
      if(p[i]==1 && p[N-i+1]==1) count++;
    }


  cout<<count<<endl;
  }
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
//#define int __int128
//#define ll __int128
//typedef __int128 long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}



void smain() {

    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int m = int.Parse(input[1]);
        int x = int.Parse(input[2]);
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        for (int i = 0; i < m; i++)
        {
            if (a[i] > x)
            {
                Console.WriteLine(Math.Min(i,m-i));
                break;
            }
        }
    }
}

Measured memory_bytes: 13140
from collections import deque

# 辿り着けないと INF
def bfs(sx, sy):
    ma = 0
    # すべての点を INF で初期化
    d = [[float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    # スタート地点をキューに入れ、その点の距離を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                temp = d[p[0]][p[1]] + 1
                d[nx][ny] = temp
                if temp >= ma:
                  ma = temp
             
    return ma


n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]

ans = 0
for i in range(n):
  for j in range(m):
    if maze[i][j] != "#":
      a = bfs(i,j)
      if a >= ans:
        ans = a
    
print(ans)

Measured memory_bytes: 3692
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int n,k;
int nums[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k;
    rep(i,n) cin>>nums[i];
    
    bool f=0;
    int g=nums[0];
    rep(i,n){
        if(nums[i]>=k) f=1;
        g=__gcd(g,nums[i]);
    }
    
    if(f&&k%g==0){
        cout1("POSSIBLE")
    }else{
        cout1("IMPOSSIBLE")
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  int count =0;
  while(true){
    bool odd=false;
    for (int i=0;i<n;i++){
      if(a[i]%2!=0){
        odd=true;
      }
    }
    if(odd){
        break;
      }
    for(int i=0;i<n;i++){
        a[i]/=2;
      }
    count++;
  }
  cout << count << 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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  ll ans = 0;
  ll wx = 0;
  ll n = 0;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'W') {
      wx += i;
      n++;
    }
  }
  ans = wx - (n * (n - 1)) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#define int long long
using namespace std;
int N,ans,d,can;
string a,b;
signed main(){
    cin>>N;
    cin>>a;
    for(int i=0;i<N;i++){
        cin>>b;
        can=0;
        //cout<<a.size()<<" "<<b.size()<<endl;
        for(int j=0;j<b.size();j++){
            if(b[j]==a[0]){
                for(int k=j;k<b.size();k++){
                    if(b[k]==a[1]){
                        d=k-j;
                        for(int l=0;l<a.size();l++){
                            //cout<<l<<" "<<a.size()<<endl;
                            if((d*l)+j>=b.size())break;
                            if(a[l]!=b[(d*l)+j])break;
                            if(l==a.size()-1){
                                ans++;
                                can=1;
                                break;
                                //cout<<1;
                            }
                        }
                    }
                    if(can==1)break;
                }
            }
            if(can==1)break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int a, b, ans;

    cin >> a >> b;

    if (a != b) {
        ans = max(a, b) * 2 - 1;
    } else {
        ans = 2 * a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int a[110], n, s, m, u, v;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    FOR(i,1,n) {
        cin >> a[i];
        s += a[i];
    }
    cin >> m;
    while (m--) {
        cin >> u >> v;
        s = s - a[u] + v;
        cout << s << endl;
        s = s + a[u] - v;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#include <stack>
#include <stdio.h>
#include <map>
#include <set>
#include <time.h>
#include <string>
#include <fstream>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <assert.h>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pdd pair<double,double>
#define pii pair<ll,ll>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD2 1000000009
#define INF ((ll)1e+18)
#define x1 fldgjdflgjhrthrl
#define x2 fldgjdflgrtyrtyjl
#define y1 fldggfhfghjdflgjl
#define y2 ffgfldgjdflgjl
#define N 131072
#define SUM 377
#define MAG 33554431
#define RED 0
#define BLUE 1
#define ALP 26
typedef long long ll;
typedef long double ld;
using namespace std;
ll i,j,n,k,l,m,tot, flag,r,ans,z, K,x1,y1,x2,y2,x3,y3,x,y,h,num,h2,timer,sz,q,nn;
string s,t;
ll a[500500][28], pa[500050], b[500500][20];
vector<pii> merged[30];
int main() {
	//freopen("input.txt","r",stdin);
 	//freopen("output.txt","w",stdout);
    cin >> s;
    n = s.size();
    for (i = 0; i < n; i++)
        s[i] -= 'a';
    for (i = 0; i <= ALP; i++)
        a[n][i] = a[n+1][i] = n+1;
    for (i = n-1; i >= 0; i--)
    {
        a[i][s[i]] = i+1;
        for (j = s[i]+1; j <= ALP; j++)
            a[i][j] = a[a[i][j-1]][j-1];
        for (j = 0; j < s[i]; j++)
            a[i][j] = a[a[i][ALP]][j];
    }
    for (i = 0; i <= n+1; i++)
    {
        b[i][0] = a[i][ALP];
    }

    for (j = 0; j < 19; j++)
    for (i = 0; i <= n+1; i++)
        b[i][j+1] = b[b[i][j]][j];
    cin >> q;
    for (i = 0; i < q; i++)
    {
        cin >> x >> y;
        x--;
        for (j = 19; j >= 0; j--)
            if (b[x][j] <= y)
            {
                x = b[x][j];
            }
        if (x == y)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 190724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long ans = 1;
		for(int i=1;i<=n;i++) {
			ans = (long) (ans * i%(Math.pow(10, 9)+7));
		}
		System.out.println(ans);
	}

}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(3*N);
    
    for(int i = 0; i<N; i++){
        cin >> a.at(i);
        a.at(N+i)=a.at(i)+1;
        a.at(2*N+i)=a.at(i)-1;
    }
    
    sort(a.begin(), a.end());
    
    int e = a.at(0);
    int count = 0;
    int count_max = 0;
    
    for(int f : a){
        if (f == e){
            count ++;
            if (count >= count_max){
                count_max = count;
            }
        }
        else{
            count = 1;
            e = f;
        }
    }
    
    cout << count_max << endl;
    
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main (void)
{
 int a,b,k,i,s;
  cin>>k>>a>>b;
  i=0;
  while(1)
  {
    i++;
    s=k*i;
   if(s>b){cout<<"NG";break;}
   else if(s>=a){cout<<"OK";break;}
  }
}


Measured memory_bytes: 3608
A=input()
B=input()
C=input()
moto=A
suji="a"
while True:
  if len(moto)==0:
    if suji=="a":
      print("A")
      exit()
    if suji=="b":
      print("B")
      exit()
    if suji=="c":
      print("C")
      exit()
  s=moto[0]
  if suji=="a":
    A=A[1:]
  if suji=="b":
    B=B[1:]
  if suji=="c":
    C=C[1:]
  if s=="a":
    moto=A
    suji="a"
  if s=="b":
    moto=B
    suji="b"
  if s=="c":
    moto=C
    suji="c"

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++){
        cin >> a[i];
    }
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    dp[0][0] = 1;
    for(int i = 1; i < h; i++){
        if(a[i][0] == '.'){
            dp[i][0] = dp[i-1][0];
        }else{
            dp[i][0] = 0;
        }
    }
    for(int i = 1; i < w; i++){
        if(a[0][i] == '.'){
            dp[0][i] = dp[0][i-1];
        }else{
            dp[0][i] = 0;
        }
    }
    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            if(a[i][j]=='.'){
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
            }else{
                dp[i][j] = 0;
            }
        }
    }

    cout << dp[h-1][w-1]%MOD << endl;

}


Measured memory_bytes: 9216
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
    ios;
	ll n,k;
    cin>>n>>k;
    ll left=n%k;
    if(k-left<left){
        cout<<k-left<<endl;
    }
    else{
        cout<<left<<endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	int n,a,max,box,i,cnt;
	max=-1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		cnt=0;
	    box=i;
		while(box%2==0){
			box=box/2;
			cnt++;
		}
		if(cnt>max){
			max=cnt;
			a=i;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 'None'

n,m = map(int,input().split())
l = 1
r = n
for i in range(m):
    a,b = map(int,input().split())
    if a > l:
        l = a
    if b < r:
        r = b
x = r-l+1
if x < 0:
    x = 0
print(x)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int ct[1145140];
int dist[55][55];
int p2[61];
vector<int> nex[55];
vector<int> pth[55][55];
bool col[1145140][55];
void nuri( int bi, int s, int t ){
	for(int i=0;i<pth[s][t].size();i++){
		col[bi][ pth[s][t][i] ] = true;
	}
}
signed main(){
	int n;
	cin>>n;
	vector<int> aa(n),bb(n);
	for(int i=0;i<n-1;i++){
		cin>>aa[i]>>bb[i];
		nex[aa[i]].pb(bb[i]);
		nex[bb[i]].pb(aa[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if( i!=j ) dist[i][j] = LINF;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<nex[i].size();j++){
			dist[i][nex[i][j]] = 1;
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				dist[i][j] = min( dist[i][j], dist[i][k] + dist[k][j] );
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=0;k<n-1;k++){
				if( dist[i][j] == dist[i][aa[k]] + dist[aa[k]][j] ){
					if( dist[i][j] == dist[i][bb[k]] + dist[bb[k]][j]){
						pth[i][j].pb(k);
					}
				}
			}
		}
	}
	int m;
	cin>>m;
	p2[0] = 1;
	for(int i=1;i<=60;i++){
		p2[i] = p2[i-1] * 2;
	}
	vector<int> u(m),v(m);
	for(int i=0;i<m;i++){
		cin>>u[i]>>v[i];
	}
	ct[0] = p2[n-1];
	for(int bi = 1; bi < (1<<m); bi ++ ){
		int mb = -1;
		int prv = bi;
		for(int i=0;i<m;i++){
			if( ( bi >> i ) % 2 == 1 ){
				mb = i;
				prv -= (1<<mb);
				break;
			}
		}
		for(int i=0;i<n-1;i++){
			col[bi][i] = col[prv][i];
		}
		nuri( bi, u[mb], v[mb] );
		int arb = 0;
		for(int i=0;i<n-1;i++){
			if( !col[bi][i] ) arb ++;
		}
		ct[bi] = p2[arb];
	}
	//for(int i=0;i<(1<<m);i++){cout<<ct[i]<<endl;}
	int ans = 0;
	for(int i=0;i<(1<<m);i++){
		int bc = 0;
		for(int j=0;j<m;j++){
			if( (i>>j) % 2 ) bc ++;
		}
		if( bc%2 == 0 ){
			ans += ct[i];
		}
		else{
			ans -= ct[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 66432
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,s;
  cin >> n >> s;
  ll p=998244353;
  ll dp[n+1][s+1];
  rep(i,n+1)rep(j,s+1)dp[i][j]=0;
  int a[n];
  rep(i,n)cin >> a[i];
  rep(i,n){
    rep(j,s+1){
      if(a[i]+j<=s)dp[i+1][a[i]+j]=(dp[i][j]+dp[i+1][a[i]+j])%p;
      dp[i+1][j]=(dp[i][j]+dp[i+1][j])%p;
    }
    if(a[i]<=s)dp[i+1][a[i]]=(dp[i+1][a[i]]+1)%p;
    dp[i+1][0]=(1+dp[i+1][0])%p;
  }
  ll ans=0;
  rep(i,n){
    ans=(ans+dp[i+1][s])%p;
  }
  //rep(i,n+1)rep(j,s+1)cout << dp[i][j] << endl;
  cout << ans << endl;
}


Measured memory_bytes: 73912
#include <stdio.h>
int main(void){
	int num,i;
	char string[10001];
	scanf("%d%s",&num,&string);
	for(i=0;string[i]!='\0';i++){
		string[i]+=num;
		if(string[i]>'Z'){
			string[i]-=('Z'-'A'+1);
		}
	}
	printf("%s",string);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 500000000
#define IOS ios_base::sync_with_stdio(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
    string s,t;
bool check(int n,int p){return (1<<p)&n;}
bool match(int pos)
{
    int j=0;
    for(int i=pos;i<s.length()&&j<t.length();i++,j++)
    {
        if(s[i]=='?'||s[i]==t[j])continue;
        else break;
    }
    if(j==t.length())return 1;
    return 0;
}
int main()
{
    IOS;
    cin>>s>>t;
    int ans=-1;
    for(int i=0;i<s.length();i++)
    {
        if(match(i))
            ans=i;
    }
    if(ans==-1)cout<<"UNRESTORABLE"<<endl;
    else
    {
        for(int i=0;i<t.length();i++)
            s[i+ans]=t[i];
        for(int i=0;i<s.length();i++)if(s[i]=='?')s[i]='a';
        cout<<s<<endl;
    }
}
/*
?DD?ZCD???df????ff???ff
ffabc

*/







Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);



int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<int> a(n);
    int k=0;
    rep(i,n) {
        cin >> a[i]; 
        k=k^a[i];
    }
    rep(i,n) cout << (k^a[i]) << ' ';
    cout << endl;

    return 0;
}


Measured memory_bytes: 3996
nm = input().split()
n = int(nm[0])
m = int(nm[1])
xlist = [int(x) for x in input().split()]

xlist.sort()

sublist = []
prev_x = None
for x in xlist:
    if prev_x is not None:
        sublist.append(x - prev_x)
    prev_x = x

sublist.sort()

ans = 0
for i in range(max(m - n, 0)):
    ans += sublist[i]

print(ans)


Measured memory_bytes: 13840
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
  
X, Y = map(int, input().split())
if (X+Y) % 3 != 0 or not (X <= 2*Y and Y <= 2*X):
    print(0)
    exit()

n = (X+Y) // 3
r = Y - n
#print(n, r)
print(combination(n, r))

Measured memory_bytes: 3064
using System;

class M {
  public static void Main(String[] a) {
    double total = 0;
    
    var N = int.Parse(Console.ReadLine()); 
    for ( int I=0 ; I<N ; ++I ) {
      var A = Console.ReadLine().Split(' ');
      var val = double.Parse(A[0]);
      var currency = A[1];
      
      if ( currency.Equals("JPY") ) {
        total += val;
        continue;
      }
      
      if ( currency.Equals("BTC") ) {
        total += val * 380000.0;
      }
    }
    Console.Write(""+total);
      
  }
    
}


Measured memory_bytes: 11092
#[allow(unused_imports)]
use std::io::{self, BufRead};
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(dead_code)]
fn readln_to_vec<T>(buf: &mut BufRead) -> Vec<T> 
where T: std::str::FromStr,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    let mut s = String::new();
    buf.read_line(&mut s).unwrap();
    s.split(" ")
        .map(|x| x.trim())
        .filter(|x| !x.is_empty())
        .filter_map(|x| x.parse().ok())
        .collect()
}

#[allow(dead_code)]
fn readln_to<T>(buf: &mut BufRead) -> T
where T: std::str::FromStr + std::clone::Clone,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    readln_to_vec::<T>(buf)[0].clone()
}

#[allow(unused_macros)]
macro_rules! readln_to_tuple {
    (
        $bufRead: expr, ( $( $t: ty ),* )
    ) => (
        {
            let buf: &mut BufRead = $bufRead;
            let ln = readln_to_vec::<String>(buf);
            let mut i = ln.into_iter();
            ( $( i.next().unwrap().parse::<$t>().unwrap() ),* )
        }
        )
}


fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    let stdin = &mut stdin;

    let x: String = readln_to(stdin);
    let mut s = "".to_string();
    for c in x.chars() {
        s.push(c);
        while s.len() >= 2 && &s[s.len() - 2 .. s.len()] == "ST" {
            s.pop();
            s.pop();
        }
    }
    println!("{}", s.len());
}





Measured memory_bytes: 4352
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
    }

    let ans = if b % 2 == 0 && a * 2 <= b && b <= a * 4 {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


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

typedef long long ll;
const int MOD=1e9+7;

struct modint {
    int val;
    modint inv() const{
        int tmp,a=val,b=MOD,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return modint(x);
    }
public:
    modint():val(0){}
    modint(ll x){if((val=x%MOD)<0)val+=MOD;}
    modint pow(ll t){modint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    modint& operator+=(const modint& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
    modint& operator-=(const modint& x){if((val+=MOD-x.val)>=MOD)val-=MOD; return *this;}
    modint& operator*=(const modint& x){val=(ll)val*x.val%MOD; return *this;}
    modint& operator/=(const modint& x){return *this*=x.inv();}
    bool operator==(const modint& x) const{return val==x.val;}
    bool operator!=(const modint& x) const{return val!=x.val;}
    bool operator<(const modint& x) const{return val<x.val;}
    bool operator<=(const modint& x) const{return val<=x.val;}
    bool operator>(const modint& x) const{return val>x.val;}
    bool operator>=(const modint& x) const{return val>=x.val;}
    modint operator+(const modint& x) const{return modint(*this)+=x;}
    modint operator-(const modint& x) const{return modint(*this)-=x;}
    modint operator*(const modint& x) const{return modint(*this)*=x;}
    modint operator/(const modint& x) const{return modint(*this)/=x;}
};

int main() {
  int n;
  cin >> n;
  vector<int> color(3);
  modint ans(1);
  for (int i = 0; i < n; ++i) {
    vector<int> ok;
    int a;
    cin >> a;
    for (int i = 0; i < 3; ++i) { 
      if (color[i] == a) ok.push_back(i);
    }
    if (ok.size() == 0) {
      cout << 0 << endl;
      return 0;
    }
    ans *= (int)ok.size();
    color[ok[0]] += 1;
  }
  cout << ans.val << endl;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	ll n, k;
	cin >> n >> k;
	ll c[50][2];	// count of bits
	rep(i, 50) rep(j, 2) c[i][j] = 0;
	ll a[N];
	rep(i, n) cin >> a[i];
	rep(i, n) rep(j, 50) {
		c[j][(a[i] >> j) % 2]++;
	}
	ll x = 0;
	for(int i = 49; i >= 0; i--) {
		if(c[i][0] > c[i][1] && (x | (1ll << i)) <= k) {
			x |= 1ll << i;
		}
	}
	ll ans = 0;
	rep(i, n) ans += a[i] ^ x;
	cout << ans << endl;
}


Measured memory_bytes: 1024
from collections import deque


n = int(input())
a = list(map(int, input().split()))
q = deque([])
for i in range(n):
    if i % 2 == 0:
        q.append(a[i])
    else:
        q.appendleft(a[i])
if n % 2 ==0:
    print(*list(q))
else:
    print(*list(q)[::-1])

Measured memory_bytes: 100564
#include<iostream>

using namespace std;

/*
解法
クラスは３０人固定
サイズが30の固定長配列に提出したかどうか記録。
小さい順に提出していない受講生を探す。

*/

int main() {
	bool students[30] = {};

	for (int i = 0; i < 28; ++i) {
		int temp;
		cin >> temp;
		students[temp - 1] = true;
	}

	for (int i = 0; i < 30; ++i) {
		if (students[i] == false) {
			cout << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt(), c = in.nextInt(), pre[] = new int[k + 1], suf[] = new int[k + 1];
        String s = in.next();
        for (int i = 1; i <= k; i++) {
            int j = 0;
            if (i != 1)
                j = pre[i - 1] + c;
            for (; j < n; j++) {
                if (s.charAt(j) == 'o') {
                    pre[i] = j + 1;
                    break;
                }
            }
        }
        for (int i = k; i > 0; i--) {
            int j = n - 1;
            if (i != k)
                j = suf[i + 1] - 1 - c - 1;
            for (; j >= 0; j--) {
                if (s.charAt(j) == 'o') {
                    suf[i] = j + 1;
                    break;
                }
            }
        }
        for (int i = 1; i <= k; i++) {
            if (pre[i] == suf[i] && pre[i] != 0)
                System.out.println(pre[i]);
        }
    }

}


Measured memory_bytes: 56764
n = int(input())
xs = []
for i in range(n-1):
    c,s,f = list(map(int,input().split()))
    xs.append((c,s,f))

for i in range(n):
    cur = 0
    #print(i, "---------")
    for j in range(i,n-1):
        c,s,f = xs[j]
        if cur <= s:
            cur = s
        else:
            if cur % f != 0:
                cur = ((cur // f) + 1) * f
        cur += c
        #print(cur)
    print(cur)


Measured memory_bytes: 42092
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<set>
using namespace std;
const int N=100000+10;
int a[N],b[N],n,m;
int main()
{

    while(~scanf("%d%d",&n,&m)){
        int ans=1;
        for(int i=1;i<=n;i++){
            if(ans>=m) ans+=m;
            else ans*=2;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
vector<P> ans;

int main(void)
{
	cin >> n >> k;
	if(k > (n-1)*(n-2)/2){
		cout << -1 << endl;
		return 0;
	}
	
	for(int i = 1; i <= n-1; i++){
		ans.push_back(make_pair(i, n));
	}
	llint rem = (n-1)*(n-2)/2 - k;
	for(int i = 1; i <= n-1; i++){
		for(int j = 1; j <= n-1; j++){
			if(i >= j) continue;
			if(rem > 0){
				ans.push_back(make_pair(i, j));
				rem--;
			}
		}
	}
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << endl;
	
	return 0;
	
}

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

string S;

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

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

using namespace std;

using ll = long long;
using dd = double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<dd, dd>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<dd>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

template <class T, class V>
istream& operator>>(istream& in, pair<T, V>& pair) {
    return in >> pair.first >> pair.second;
}

template <class T>
istream& operator>>(istream& in, vector<T>& elements) {
    for (size_t i = 0; i < elements.size(); ++i) {
        in >> elements[i];
    }
    return in;
}

template <class Container, class Element>
bool Contains(const Container& container, const Element& element) {
    return container.find(element) != container.end();
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& elements) {
    for (const T& element : elements) {
        out << element << ' ';
    }
    return out;
}

template <class T, class V>
ostream& operator<<(ostream& out, const pair<T, V>& pair) {
    return out << pair.first << ' ' << pair.second;
}

#define FOR(i,n) for(size_t i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(c) sort((c).begin(), (c).end())
#define SUM(c) accumulate((c).begin(), (c).end(), 0ll)

vector<unordered_set<int>> tree;

void Normalize(vi& result, int cur_sum = 0, int vertex = 0, int parent = -1) {
    for (int child : tree[vertex]) {
        if (child != parent) {
            Normalize(result, cur_sum + result[vertex], child, vertex);
        }
    }
    result[vertex] += cur_sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    
    string s, t;
    cin >> s >> t;
    
    unordered_map<char, vi> poses(t.size());
    FOR(i, s.size()) {
        poses[s[i]].push_back(i);
    }
    
    int count = 0;
    ll cur_rel_pos = -1;
    FOR(i, t.size()) {
        if (!Contains(poses, t[i])) {
            cout << -1 << endl;
            return 0;
        }
        const vi& p = poses.at(t[i]);
        auto next_rel_pos = upper_bound(p.begin(), p.end(), cur_rel_pos);
        if (next_rel_pos == p.end()) {
            ++count;
            next_rel_pos = p.begin();
        }
        cur_rel_pos = *next_rel_pos;
    }
    cout << count * s.size() + cur_rel_pos + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 2000
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n,x,y;
    cin>>n>>x>>y;
    x--; y--;
    vector<ll> ans(n,0);
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            if(i<=x && j<=x){
                ans[j-i-1]++;
            }else if(i<=x && j>=x & j<=y){
                ll now=min(j-i,x-i+1+y-j);
                ans[now-1]++;
            }else if(i<=x && j>=y){
                ans[j-y+x-i]++;
            }else if(i>=x && i<=y && j>=y){
                ll now=min(j-i,j-y+1+i-x);
                ans[now-1]++;
            }else if(i>=x && i<=y && j>=x && j<=y){
                ll now=min(j-i,y-j+1+i-x);
                ans[now-1]++;
            }else{
                ans[j-i-1]++;
            }
        }
    }
    for(ll i=0;i<n-1;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void) {
	int a, b, c,ans,x,y,z;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	if (a < b) {
		if (b < c) { x = c; y = b; z = a; }
		else if (a < c) { x = b; y = c; z = a; }
		else { x = b; y = a; z = c; }
	}
	
	else {
		if (a < c) { x = c; y = a; z = b; }
		else if (b < c) { x = a; y = c; z = b; }
		else {
			x = a; y = b; z = c;
		}
	}

	ans = x - z;
	printf("%d", ans);

		









	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
	int t,n,up,down,x,y;
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>n;
		up=0,down=0;
		cin>>y;
		for(int i=1;i<n;i++){
			cin>>x;
			if(x-y>up)
				up=x-y;
			if(y-x>down)
				down=y-x;
			y=x;
		}
		cout<<up<<" "<<down<<endl;
	}
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
ll n;
ll arr[25][25];
ll dp[25][1<<22];
ll func(ll i,ll mask)
{

    if(i==n+1)
        return 1;
    else if(dp[i][mask]!=-1)
        return dp[i][mask];
    ll ans=0;
    for(ll j=1;j<=n;j++)
    {
        if(arr[i][j] and !((mask>>j)&1))
        {
            ans=(ans+func(i+1,mask|(1<<j)))%mod;
        }
    }   
    return dp[i][mask]=ans;
   
}
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        cin>>n;
        for(ll i=1;i<=n;i++)
            for(ll j=1;j<=n;j++)
                cin>>arr[i][j];
        memset(dp,-1,sizeof(dp));
        cout<<func(1,0);

    }
    return 0;
}

Measured memory_bytes: 819456
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

fn main() {
  let n = read::<usize>();
  let a = read_n::<f64>(n);
  let mut answer: f64 = 0.0;

  for i in 0..a.len() {
    answer += 1.0 / a[i];
  }

  println!("{}", 1.0 / answer);
}


Measured memory_bytes: 4352
#include <iostream>

// 最大公約数
template <typename T>
T gcd(T a, T b) {
  if (b > a) {
    T tmp = a;
    a = b;
    b = tmp;
  }

  T r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
// 最小公倍数
template <typename T>
T lcm(T a, T b) {
  return a * b / gcd(a, b);
}

int main() {
  uint64_t a, b, c, d;
  std::cin >> a >> b >> c >> d;

  uint64_t cs = ((a % c) == 0) ? (a / c) : (a / c + 1);
  uint64_t ce = b / c;

  uint64_t ds = ((a % d) == 0) ? (a / d) : (a / d + 1);
  uint64_t de = b / d;

  uint64_t l = lcm(c, d);
  uint64_t ls = ((a % l) == 0) ? (a / l) : (a / l + 1);
  uint64_t le = b / l;

  std::cout << b - a + 1 - ((ce - cs + 1) + (de - ds + 1) - (le - ls + 1))
            << std::endl;
  return 0;
}


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

int main() {
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> vec(m);
  for(int i=0;i<m;i++){
    cin>>vec.at(i);
    }
  int answer=0,count=0,a;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a;
      count+=a*vec.at(j);
      }
    if(count+c>0){
      answer++;
      }
    count=0;
    }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.InputMismatchException;
class Main{
public static void main(String args[]){

    Scanner scan = new Scanner(System.in);
    try{
	int x;
	int cnt=1;
while(true){
    x = scan.nextInt();
    if ( x == 0 ) break;

    	System.out.println("Case "+cnt+": "+ x);
        cnt++;


}



}catch (InputMismatchException e) {
        	System.out.println("try again!!");
        }





}
}



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

const int MAXN = 2001;

using bs = bitset<MAXN * MAXN>;

bs a;

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.tie(nullptr); cin.tie(nullptr);
    int n;
    cin >> n;
    int s = 0;
    a[0] = 1;

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a |= (a << x);
        s += x;
    }

    for (int i = (s + 1) / 2; i <= s; ++i) {
        if (a[i]) {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int tag[2000005];
int d[2000005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>tag[i];
    }
    for(int i=1;i<n;i++)
    {
        d[i]=tag[i]-tag[i-1];
        //cout<<d[i]<<' ';
    }
    //cout<<endl;
    int thisum=0,maxsum=d[1];
    for(int i=1;i<n;i++)
    {
        thisum+=d[i];
        if(thisum>maxsum) maxsum=thisum;
        if(thisum<0) thisum=0;
    }
    cout<<maxsum<<endl;

}

Measured memory_bytes: 4664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  vector<int> v(n), c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  rep(i, n) {
    if (v[i] > c[i])
      ans += v[i]-c[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 1e5;

int a[2 * MaxN + 5];

int main()
{
	long long n,cnt,ans,flag;
	while(~scanf("%lld",&n))
	{
		flag = 0;ans = 0;cnt = 0;
		for(long long i = 1;i <= n;i++)
		{
			scanf("%lld",&a[i]);
			if(a[i] > cnt) flag = 1;
			cnt = a[i] + 1;
			if(flag || i == 1) continue;
			if(a[i] == a[i - 1] + 1) ans++;
			else ans = ans + a[i];
		}
		if(flag) printf("-1\n");
		else printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 896