akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b/a>c)
        cout << c << endl;
    else
        cout << b/a << endl;
    return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll dp[1010][1010];

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

    // input
    ll N;
    cin >> N;

    FOR(i, 0, N){
        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        dp[y1][x1]++;
        dp[y1][x2]--;
        dp[y2][x1]--;
        dp[y2][x2]++;
    }

    // horizontal imos
    FOR(y, 0, 1010){
        FOR(x, 1, 1010){
            dp[y][x] += dp[y][x-1];
        }
    }

    // vertical imos
    FOR(x, 0, 1010){
        FOR(y, 1, 1010){
            dp[y][x] += dp[y-1][x];
        }
    }

    ll ma = 0;
    FOR(x, 0, 1010){
        FOR(y, 0, 1010){
            chmax(ma, dp[y][x]);
        }
    }
    p(ma);
    
    return 0;
}


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

using namespace std;

int mod = (int)1e9 + 7;

int main() {
    int H, W, w;

    scanf("%d %d\n", &H, &W);
    vector<vector<int>> dp(H, vector<int>(W));
    vector<vector<char>> gd(H, vector<char>(W));

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            scanf("%c\n", &gd[i][j]);
            if (!i && !j) {
                dp[i][j] = 1;
                continue;
            }
            if (gd[i][j] == '.') {
                if (i && gd[i - 1][j] == '.')
                    dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                if (j && gd[i][j - 1] == '.')
                    dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            }
        }
    }

    printf("%d\n", dp[H - 1][W - 1]);

    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int count[26]={};
	rep(i,s.size())count[s[i]-'a'+1]++;
	rep(i,s.size())if(count[i]>1){puts("no");return 0;}
	puts("yes");
}


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

int lcm(int a, int b)
{
    // 大きい方を小さい方で割ったときのあまりを求める
    int amari;
    int big, small;
    if(a > b)
    {
        big = a;
        small = b;
    }
    else
    {
        big = b;
        small = a;
    }

    // int型なので割り算した値は商になる
    amari = big - small * (big / small);

    // 余りが0のとき、その時の小さい値がが最小公倍数
    if(amari == 0)
    {
        return small;
    }

    // 小さい方の値と余りの値で改めて余りを求める
    return lcm(small, amari);
}

int main()
{
    long long A, B;
    cin >> A >> B;
    long long ret = A * B / lcm(A, B);
    cout << ret;
  
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    input! {
    a:usize,
    b:[usize;a],
  }
    let c: usize = b.iter().sum();
    let mut d: usize = 100000;
    if c % 10 != 0 { println!("{}", c);exit(0) }
    for i in 0..a {
        if b[i] % 10 != 0 {
            if b[i] < d { d = b[i] }
        }
    }
    if d == 100000 {
        println!("0")
    } else {
        println!("{}", c - d)
    }
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    cout << n-m+1 << endl;
}


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

int main(void){
    int H,W;
    int c[10][10],a[200][200];
    cin>>H>>W;
    rep(i,10)rep(j,10)cin>>c[i][j];
    rep(y,H)rep(x,W)cin>>a[y][x];
    rep(i,10)rep(j,10)rep(k,10) c[j][k] = min(c[j][k],c[j][i]+c[i][k]);
    
    int cost = 0;
    rep(y,H)rep(x,W){
        if(a[y][x] != -1){
            cost += c[a[y][x]][1];
        }
    }
    cout<<cost<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	void run(){
		
		int n = sc.nextInt();
		
		int a[] = new int[n];
		int b[] = new int[n];
		for(int i = 0; i < n ; i++){
			a[i] = sc.nextInt();
			b[i] = a[i];
		}
		
		Arrays.sort(b);
//		System.out.println(Arrays.toString(b));
		for(int i =0 ; i < n ;i++){
			if(a[i] >= b[n/2]){
//				System.out.println("::"+a[i]);
				System.out.println(b[n/2-1]);
			}else{
				System.out.println(b[n/2]);
			}			
		}
	}
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
	}
}



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

int main() {
  int num;
  cin >> num;
  int n = num % 10;

  switch(n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}


Measured memory_bytes: 3560
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N, D;
  while(cin>>N>>D,N){
	VI sum(N, 0);
	VVI xs(N, VI());
	REP(i,N){
	  int m; cin >> m;
	  xs[i].assign(m, 0);
	  REP(j,m){
		cin >> xs[i][j];
		sum[i] += xs[i][j];
	  }
	}

	while(true){
	  bool up = false;
	  for(int j=0;j<N;++j){
		if(xs[j].empty()) continue;
		int d = sum[j] - xs[j].back(), i;
		for(i=0;i<N;++i){
		  if(i == j) continue;
		  if(abs(sum[i] - d) > D) break;
		}
		if(i == N){
		  sum[j] = d;
		  xs[j].pop_back();
		  up = true;
		}
	  }
	  if(!up) break;
	}
	bool ok = true;
	REP(i,N) if(!xs[i].empty()) ok = false;
	cout << (ok? "Yes": "No") << endl;
  }
  
  return 0;
}

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


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		String [] str = bufferedReader.readLine().split(" ");
		Integer a = Integer.parseInt(str[0]);
		Integer b = Integer.parseInt(str[1]);
		Integer c = Integer.parseInt(str[2]);
		if (a < b && b < c)  {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24224
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
constexpr int MAX = 2000001;
lint fact[MAX], finv[MAX], inv[MAX];
void cominit() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, MAX){
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint K;
    cin >> K;
    string S;
    cin >> S;
    cominit();
    lint ans = 0;
    REP(i, K+1) {
        ans = (ans + ncr(S.size()+i-1, S.size()-1, MOD) * power(26, K-i, MOD) % MOD * power(25, i, MOD) % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 51220
var
	a:array[0..100010]of longint;
	i,n,k,x,y:longint;
	s:int64;
function min(x,y:longint):longint;
begin
	if x<y then exit(x) else exit(y);
end;
begin
	readln(n,k);
	for i:=1 to n do read(a[i]);
	s:=maxlongint;
	for i:=1 to n-k+1 do
	begin
		x:=abs(a[i]);
		y:=abs(a[k+i-1]);
		if a[i]<=0 then
			if a[k+i-1]<=0 then s:=min(s,-a[i])
			else s:=min(s,min(x*2+y,y*2+x))
		else s:=min(s,a[k+i-1]);
	end;
	writeln(s);
end.

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  cout<<180*(N-2)<<endl;
  return 0;
}


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

int main(){
	int x,y,w,h,r;
	cin >> w >> h >> x >> y >> r;
	
	if((x<=w-r)&&(x>=r)&&(y<=h-r)&&(y>=r )) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3112
def solve(n, aaa, bbb):
    ccc = [a1 ^ a2 for a1, a2 in zip(aaa, aaa[1:])] + [aaa[-1] ^ aaa[0]]
    ddd = [b1 ^ b2 for b1, b2 in zip(bbb, bbb[1:])] + [bbb[-1] ^ bbb[0]]

    ans = []

    m = 2147483647
    g = 1000000007
    s = 0
    for c in ccc:
        s = (s * g + c) % m
    t = 0
    for d in ddd:
        t = (t * g + d) % m
    u = pow(g, n, m) - 1
    for i in range(n):
        if s == t:
            ans.append((i, aaa[i] ^ bbb[0]))
        s = (s * g - ccc[i] * u) % m
    ans.sort()
    return ans


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
ans = solve(n, aaa, bbb)
print(''.join('{} {}\n'.format(*answer) for answer in ans))


Measured memory_bytes: 66896
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int d,n;
  cin>>d>>n;
  if(n==100)n++;
  if(d>0)cout<<(int)(pow(100,d))*n<<endl;
  else if(d==0)printf("%d",n);
  return 0;
}

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


int main(){
 
  ll N,M,ans=0;
  cin >> N >> M;
  
  if(M<=N){
    cout << 0 << endl;
    return 0;
  }
  
  vector <ll> X(M);
  
  rep(i,M){
    cin >> X.at(i);
  }
  
  sort(X.begin(),X.end());
  
  /*if(N==1){
    cout << X.end() - X.begin() << endl;
    return 0;
  }*/
  
  vector <ll> dif(M-1);
  
  rep(i,M-1){
    dif.at(i)=X.at(i+1)-X.at(i);
  }
  
  sort(dif.begin(),dif.end());

  
  rep(i,M-N){
    ans+=dif.at(i);
  }
    
 
  
  cout << ans << endl;
  
  
  
  
}

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

#define ll long long

using namespace std;


int main(){
    int n,c=0,k=0;
    cin>>n;
    int a[n];
    
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<n; i++){
        if(a[i]%2==0){
            c++;
            if((a[i]%3==0)||(a[i]%5==0)){
                k++;
            }
            
        }
    }   
    

    if(c==k){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }



}



Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
s_ac=s.count('AC')
s_wa=s.count('WA')
s_tle=s.count('TLE')
s_re=s.count('RE')
print('AC x',s_ac)
print('WA x',s_wa)
print('TLE x',s_tle)
print('RE x',s_re)

      

Measured memory_bytes: 16296
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
s = list(s)
l = []
M = 10**9+7
prv = "L"
l.append(prv)
if not (s[0]==s[-1]=="B"):
    ans = 0
else:
    for i in range(1,2*n-1):
        if s[i-1]==s[i]:
            l.append("R")
            s[i] = "W" if s[i]=="B" else "B"
        elif s[i-1]!=s[i]:
            l.append("L")
        else:
            ans = 0
            break
    else:
        l.append("R")
        if sum(item=="R" for item in l)!=n:
            ans = 0
        else:
            num = 0
            ans = 1
            for item in l[::-1]:
                if item=="R":
                    num += 1
                else:
                    ans *= num
                    ans %= M
                    num -= 1
            for i in range(1, n+1):
                ans *= i
                ans %= M
print(ans)

Measured memory_bytes: 96992
#include<bits/stdc++.h>
using namespace std;
int main(){
    string in;
    vector <string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    int turn = 0;
    while(1){
        if(s[turn].size() == 0){
            switch(turn){
                case 0:
                    cout << 'A' << endl;
                    break;
                case 1:
                    cout << 'B' << endl;
                    break;
                case 2:
                    cout << 'C' << endl;
            }
            break;
        }else{
            char kari = *s[turn].begin();
            s[turn].erase(s[turn].begin());
            if(kari == 'a')
                turn = 0;
            else if(kari == 'b')
                turn = 1;
            else
                turn = 2;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int nmax=100005;
vector<int> A[nmax],B[nmax];

void DFS(int u,int N,int color[nmax]){
    bool check=true;
    for(int i=0;i<N;i++){
        if(color[i]==0){
            check=false;
            break;
        }
    }
    if(check){
        for(int i=0;i<N;i++){
            cout<<color[i]%2<<endl;
        }
        return;
    }
        for(int i=0;i<A[u].size();i++){
            if(color[A[u][i]]==0){
                color[A[u][i]]=color[u];
                DFS(A[u][i],N,color);
            }
            }
        for(int i=0;i<B[u].size();i++){
            if(color[B[u][i]]==0){
                color[B[u][i]]=color[u]%2+1;
                DFS(B[u][i],N,color);
            }
        }
    return;
        }

int main(){
   
    int N;
    cin>>N;
    for(int i=0;i<N-1;i++){
        int x,y,z;
        cin>>x>>y>>z;
        if(z%2==0){
            A[x-1].push_back(y-1);
            A[y-1].push_back(x-1);
        }
        else if(z%2==1) {
            B[x-1].push_back(y-1);
            B[y-1].push_back(x-1);
        }
        
    }

    int color[nmax];
  	for(int i=0;i<N;i++)color[i]=0;//すべてのcolorを0で初期化
    color[0]=2;
    DFS(0,N,color);
}


Measured memory_bytes: 13696
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
    int x, y;
    int flag=0;
    int turu=0;
    int kame=0;
    scanf("%d %d",&x,&y);
    int i;
    for(turu=0;turu<=x;turu++){
        kame = x-turu;
        if(y == turu*2+kame*4){
            flag = 1;
        }
    }
    if(flag==1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
// ------------------------------------
// Date:2018/ 2/23
// Problem:ABC 047 1DReversi c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

#define MOD 1000000007

int main()
{
  string S;
  int cnt = 0;
  cin >> S;
  FOR(i,1,S.size()) {
    if (S[i-1] != S[i]) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;
const ll N = 1e6;

ll mod_pow(ll x,ll n,ll mod){

  if(n==0)return 1;

  ll res=mod_pow( x*x%mod , n/2 , mod );

  if( n & 1 )res = res*x%mod;

  return res;

}

ll fact[N];
ll infact[N];

void make_factorial(void){

  fact[0] = 1;

  for( ll i = 1 ; i < N ; i++ ){

    fact[i] = fact[i-1] * i;

    fact[i] %= MOD;

  }

  for( ll i = 0 ; i < N ; i++ ){

    infact[i] = mod_pow( fact[i] , MOD-2 , MOD );

  }

}

ll comb(ll a,ll b){

  if(a == 0 && b == 0)return 1;

  if(a < b || a < 0)return 0;

  ll tmp = infact[a-b]* infact[b] % MOD;

  return tmp * fact[a] % MOD; 

}

ll dp[1111];

ll f(ll n,ll k){
  
  if(dp[k]!=-1)return dp[k];
  
  ll ex=1;
  for(int i=0;i<n;i++){
	ex*=k;
	ex%=MOD;
  }
  
  ll sum=0;
  for(int i=1;i<k;i++){
	sum+=(f(n,i)*comb(k,i))%MOD;
	sum%=MOD;
  }
  
  return dp[k]=(MOD+ex-sum)%MOD;
}


int main(){
  ll n,k;
  cin>>n>>k;
  make_factorial();
  fill_n(dp,1111,-1);
  dp[1]=1;
  ll ans=0;
  for(int i=k;i>=1;i--){
	ans+=(f(n,i)*infact[i])%MOD;
	ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}



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

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var s = new int[n].Select(_ => Console.ReadLine().Replace("AB", "!")).ToArray();

		var r = s.Sum(x => x.Count(c => c == '!'));
		var d = s.Select(x => (x[0] == 'B' ? 1 : 0) | (x.Last() == 'A' ? 2 : 0)).GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count());
		for (int i = 0; i < 4; i++) if (!d.ContainsKey(i)) d[i] = 0;
		if (d[3] > 0)
		{
			r += d[3] - 1;
			if (d[1] > 0) { r++; d[1]--; }
			if (d[2] > 0) { r++; d[2]--; }
		}
		r += Math.Min(d[1], d[2]);
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 14048
use std::io;
use std::str;
use std::vec::Vec;

fn main() {
    // Nは捨てる
    input_str();
    // an
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let split: Vec<&str> = input.as_str().split_whitespace().collect();
    // i32に変換
    let mut numbers: Vec<i32> = split.into_iter().map(|x| x.parse().unwrap()).collect();
    // 降順ソート
    numbers.sort_by(|a, b| a.cmp(b).reverse());
    let mut is_a = true;
    let mut a_total = 0;
    let mut b_total = 0;
    for num in numbers {
        if is_a {
            a_total += num;
            is_a = false;
        } else {
            b_total += num;
            is_a = true;
        }
    }

    println!("{}", a_total - b_total);
}

fn input_str() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.as_str().split_whitespace().collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
 
const int MAX = 2000010;
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;
}

ll d[110];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N, X;
  cin >> N >> X;

  d[0] = 0;
  int cnt = 1;
  for(int i=0; i<N; i++){
    int l; cin >> l;
    d[i+1] = d[i] + l;
    if(d[i+1] <= X) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
int main() {
	string n;
	cin >> n;
	cout << (n[0]=='7'||n[1]=='7'||n[2]=='7'?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const ll mo = 1e10 +7;
const int M = 100+50;
struct dish{
	ll a,b,c;
};
bool cmp(dish a,dish b){
	return a.c>b.c;
}
int main(){
	int n;
	scanf("%d",&n);
	dish eat[n+5];
	for(int i=0;i<n;i++){
		scanf("%lld %lld",&eat[i].a,&eat[i].b);
		eat[i].c=eat[i].a+eat[i].b;
	}
	sort(eat,eat+n,cmp);
	ll ah=0,bh=0,ans=0;
	for(int i=0;i<n;i++){
		if(i%2==0)
		    ans+=eat[i].a;
		else
		    ans-=eat[i].b;
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>

using namespace std;

int main(){
 string s;
 string res="";
  cin >> s;
  
  for(int i=0;i<s.length();i++){
   if(s[i]!='B') res+=s[i];
   else if(res.length()>0) res=res.substr(0,res.length()-1);
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int K,S;

    cin >> K >> S;

    int ans =0;
    rep(i,K+1){
        rep(j,K+1){
            if( 0 <= S-(i+j) &&   S-(i+j) <= K ) {
                ans += 1;
            }
        }
    }
    cout << ans  << endl;

}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int m;
    cin >> m;
    int ans = 24+(24-m);
    cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int n,r;

signed main() {
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r+100*(10-n) << endl;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll n, m;
    cin >> n >> m;
    ll x[100060];
    ll y[100060];
    ll X = 0;
    ll Y = 0;
    for(int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    for(int i = 1; i <= m; i++) {
        cin >> y[i];
    }
    ll dx[100060];
    ll dy[100060];
    for(ll i = 1; i < n; i++) {
        dx[i] = x[i + 1] - x[i];
        X = (X + dx[i] * i * (n - i)) % mod;
    }
    for(ll i = 1; i < m; i++) {
        dy[i] = y[i + 1] - y[i];
        Y = (Y + dy[i] * i * (m - i)) % mod;
    }
    cout << X * Y % mod << endl;
    return 0;
}


Measured memory_bytes: 1792
import collections
n=int(input())
s=[]
for _ in range(n):
	s.append(input())
c=collections.Counter(s)
m=int(input())
for _ in range(m):
	t=input()
	c[t] -= 1
if max(c.values()) >= 0:
	print(max(c.values()))
else:
	print(0)

Measured memory_bytes: 3316
from collections import deque


N, M = map(int, input().split())

# 辺集合Eとグラフの構築
G = [[] for _ in range(N)]
E = []
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    E.append((a, b))
    G[a].append(b)
    G[b].append(a)
# print(G)

cnt = 0
for edge_to_remove in E:
    
    i, j = edge_to_remove
    G[i].remove(j)
    G[j].remove(i)

    # 深さ優先探索
    seen = [False] * N
    todo = deque()
    todo.append(0)
    seen[0] = True
    while todo:
        here = todo.pop()
        for neighbor in G[here]:
            if seen[neighbor] == False:
                seen[neighbor] = True
                todo.append(neighbor)
    # print(seen)
    if False in seen:
        cnt += 1
    
    G[i].append(j)
    G[j].append(i)
print(cnt)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string S; cin >> S;
  ll K; cin >> K;
  int i = 0;
  while (i<K) {
    if (S[i]!='1') break;
    i++;
    
  }
  if (i==K) cout << 1 << endl;
  else cout << S[i] << endl;

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

	char a,b;
	cin >> a >> b;
	
	bool ans = false;
	if (((a == 'H') && (b == 'H')) || ((a=='D') && (b=='D')))
		ans = true;
	cout << (ans ? 'H' : 'D') << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> T;
    for(int i=0;i<K;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int A;
            cin >> A;
            T.push_back(A);
        }
        }
        sort(T.begin(), T.end());
        T.erase(std::unique(T.begin(), T.end()), T.end());
    int s=T.size();
    cout << N-s << endl;

}

Measured memory_bytes: 3652
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr << #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }


void solve()
{ 

  string s,t;
  cin>>s;
  t=s;
  int f1=0,f2=0,f3=0;
  reverse(all(t));
  if(s==t)
  	  f1=1;
    string u=s.substr(0,len(s)/2);
      string u1=u;
      reverse(all(u1));

     // cout<<u<<" "<<u1<<endl;
      if(u==u1)
      	  f2=1;

    string v=t.substr(0,len(s)/2);
      string v1=v;
      reverse(all(v1));
     // cout<<v<<" "<<v1<<endl;
      if(v==v1)
      	  f3=1;
      	if(f1 and f2 and f3)
      		  cout<<"Yes";
      		else 
      			cout<<"No";





   
 }

  

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












Measured memory_bytes: 256
n,m=map(int,input().split())

l=[0 for i in range(n)]
ll=[0 for i in range(n)]
w=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):ll[int(p)-1]+=1
    if(s=="AC"):
        l[int(p)-1]=1
        w+=ll[int(p)-1]
        a+=1
print(a,w)

Measured memory_bytes: 4656
// Code for C - Sum of product of pairs
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

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

  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  ll t = 0;
  ll u = 0;
  REP(i, N - 1) {
    u = ( u + A[i] % MOD ) % MOD;
    t = ( t + ( u * A[i+1] ) % MOD ) % MOD;
  }

  cout << t << endl;
  return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = -1;
    for (int i=1; i<=10000; i++) {
        int x = i*0.08;
        int y = i*0.1;
        if (x==a && y==b) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			long n = long.Parse(Console.ReadLine());

			List<int> slist = new List<int>();
			List<int> hlist = new List<int>();
			List<int> clist = new List<int>();
			List<int> dlist = new List<int>();
			for (int i = 1; i <= 13; ++i) {
				slist.Add(i);
				hlist.Add(i);
				clist.Add(i);
				dlist.Add(i);
			}

			for (int i = 0; i < n; ++i) {
				string line = Console.ReadLine();
				string[] array = line.Split(' ');
				string mark = array[0];
				int number = int.Parse(array[1]);

				switch (mark) {
					case "S":
					default:
						slist.Remove(number);
						break;
					case "H":
						hlist.Remove(number);
						break;
					case "C":
						clist.Remove(number);
						break;
					case "D":
						dlist.Remove(number);
						break;
				}
			}

			foreach (var item in slist){
				Console.WriteLine($"S {item}");
			}

			foreach (var item in hlist) {
				Console.WriteLine($"H {item}");
			}

			foreach (var item in clist) {
				Console.WriteLine($"C {item}");
			}

			foreach (var item in dlist) {
				Console.WriteLine($"D {item}");
			}

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}


Measured memory_bytes: 17828
#include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int age[7] = {0};
		int ag[] = {10, 20, 30, 40, 50, 60};
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			for (int i = 0; i < 7; i++) {
				if (i == 6) {
					age[6]++;
				} else {
					if (a < ag[i]) {
						age[i]++;
						break;
					}
				}
			}
		}
		for (int i = 0; i < 7; i++) {
			cout << age[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
n, k = list(map(int, input().split(' ')))
ts = []
for i in range(n):
  ts.append(int(input()))
ts = sorted(ts)  # 1e5 * log(1e5)
ans = 1e10
for i in range(n-k+1):  # 1e5
  ans = min(ans, ts[i + k - 1] - ts[i])
print(ans)


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

int main(void){
  int n;
  string s, t;
  cin >> n >> s >> t;
  int count = 0;
  int num, temp;
  while(count < n){
    num = 0;
    temp = 0;
    for(int i = count; i < n; i++){
      if(s[i] == t[temp]) num++;
      temp++;
    }
    if(num == n - count) {
      break;
    }
    count++;
  }
  n += count;
  cout << n << endl;
  return 0;
}


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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll S_MAX = 10;

string S;

void input() {
	cin>>S;
}

void solve() {

	ll D=S.size()-1;
	vector<int> pattern(D+1,0);
	ll ans=0;
	while(1){
		ll t=S[0]-'0';
		rep(i,D){
			ll tt=S[i+1]-'0';
			if(pattern[i]){
				ans+=t;
				debug(t);
				t=tt;
			}else{
				t=t*10+tt;
			}
		}
		ans+=t;
		debug(t);
		//カウントアップ 4^nを列挙できる
		pattern[0]++;
		rep(i,D){
			if(pattern[i]==2){
				pattern[i]=0;
				pattern[i+1]++;
			}
		}
		if(pattern[D]>0)break;
	}

	printf("%lld\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
# GCD
def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d


x, y = [int(i) for i in input().split()]

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

d = gcd(x, y)

print(d)

Measured memory_bytes: 6724
<?php
  
$s = trim(fgets(STDIN));
$w = [];
for($i=1; $i<=strlen($s); $i++){
  $w[$i] = $s[$i-1];
}

$num = 0;
$len = 0;
for($i=count($w); $i>=1; $i--){
  unset($w[$i]);
  $num = count($w);
  if ($num%2 == 0){
    $h = $num/2;
    $l = array_slice($w,0,$h);
    $r = array_slice($w,$h,$h); 
    if ($l == $r) {
      $len = $num;
      break;
    }
  }  
}

echo $len;

?>

Measured memory_bytes: 4604
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S, T;
ll N, turn, ans, now = 0;
vector <ll> cnt[26];
int Now_Index[26];

int main(){
  cin >> S >> T;
  N = S.length();

  for (int i = 0; i < N; i++){
    cnt[S[i] - 'a'].push_back(i + 1);
  }

  for (int i = 0; i < T.length(); i++){
    int num = T[i] - 'a';
    if (cnt[num].size() == 0){
      printf("-1\n"); return 0;
    }
    
    int C = cnt[num].size();
    if (now >= cnt[num][C - 1]){
      turn++;
      fill(Now_Index, Now_Index + 26, 0);
      now = cnt[num][0];
      Now_Index[num] = 0;
    }else{
      for (int j = Now_Index[num]; j < C; j++){
        if (now < cnt[num][j]){
          now = cnt[num][j];
          Now_Index[num] = j + 1;
          break;
        }
      }

    } 
  }
  ans = N * turn + now;
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
   int n,m,i,j,k;string s;
   cin>>s;n=s.size();
   bool f=true;
   if(s[0]!='A') f=false;
   int c=0;
   for(i=1;i<n;i++)
   {
       if(int(s[i])<96 && s[i]!='C') {f=false;break;}
 
       if(s[i]=='C' && (i==1 || i==n-1)) {f=false;break;}
 
       if(i>=2 && i<=n-2)
       {
           if(s[i]=='C') c++;
       }
   }
   if(c!=1) f=false;
   if(f) cout<<"AC";
   else cout<<"WA";
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
int main(){
    std::map<int,int> m;
    int a,b,c;
    std::cin >> a >> b >> c;
    m[a]++;
    m[b]++;
    m[c]++;
    std::cout << m.size() << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int H,h,K,k,a,b,c,d,x=0,y=0;
	scanf("%d%d%d%d%d%d%d%d",&H,&h,&K,&k,&a,&b,&c,&d);
	x=H*a+h*b+(H/10)*c+(h/20)*d;
	y=K*a+k*b+(K/10)*c+(k/20)*d;
	if(x>y){
		printf("hiroshi\n");
	}else if(x<y){
		printf("kenjiro\n");
	}else{
		printf("even\n");
	}
	return 0;
}



Measured memory_bytes: 2056
//id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
vector<ll> A;
int cnt= 0;
void merge(int left, int mid, int right){
    int n1= mid-left, n2= right-mid;
    ll l[n1+1],r[n2+1];

    for(int i=0; i<n1; i++) l[i]= A[left+i];
    for(int i=0; i<n2; i++) r[i]= A[mid+i];
    l[n1]= INF; r[n2]= INF;
    int cntl= 0,cntr= 0;
    for(int i=0; i<right-left; i++){
        cnt++;
        if(l[cntl]<r[cntr]){
            A[left+i]= l[cntl];
            cntl++;
        } else{
            A[left+i]= r[cntr];
            cntr++;
        }
    }
}
void divide(int left, int right){
    if(left+1<right){
        int mid= (left+right)/2;
        divide(left,mid);
        divide(mid,right);
        // cout << ((left==0)?"(":" ");
        // REP(i,A.size()) cout << A[i] << ((i==left-1)?"(":((i==mid-1)?"|":((i==right-1)?")":" ")));
        // cout << endl;   
        merge(left,mid,right);
    }
}

int main(){
    int n;
    cin >> n;
    A.resize(n);
    REP(i,n) cin >> A[i];
    divide(0,n);
    REP(i,n) cout << A[i] << ((i!=n-1)?" ":"");
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 10688
// AOJ 1159
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int NMAX = 60;

int solve(int n, int p) {
  int candidates[NMAX];
  REP(i, n) { candidates[i] = 0; }
  int cup = p;
  int i = 0;
  while (true) {
    if (cup > 0) {
      cup--;
      candidates[i]++;
      if (candidates[i] == p) return i;
    } else {
      cup += candidates[i];
      candidates[i] = 0;
    }
    i = (i + 1) % n;
  }
}


int main() {
  int n, p;
  while (cin >> n >> p and n) {
    cout << solve(n, p) << endl;
  }
}

Measured memory_bytes: 1160
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int C[4] = {10, 50, 100, 500};
    int N; bool init = true;
    while(cin >> N && N) {
        if(init) init = false;
        else cout << '\n';
        vector<int> num(4);
        for(int& x : num) cin >> x;
        int rest = 0;
        for(int i : in(4)) rest += C[i] * num[i];
        rest -= N;
        vector<int> ans(4, 0);
        for(int i : in(3, -1)) {
            int amari = rest / C[i];
            rest -= amari * C[i];
            ans[i] = max(0, num[i] - amari);
        }
        for(int i : in(4))
            if(ans[i])
                cout << C[i] << ' ' << ans[i] << '\n';
    }
                
    return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  vi a(4); in(a);
  sort(all(a));
  vi b = {1,4,7,9};
  out(a==b ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 1e5;

vector<int> adj[N+5];
int pred[N+5];


int main(){
    AC
    int n, m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    queue<int> Q;
    Q.push(1);
    pred[1] = -1;
    int visited = 1;
    while(!Q.empty()){
        int cur = Q.front();
        Q.pop();
        for(int v : adj[cur]){
            if(!pred[v]){
                pred[v] = cur;
                visited++;
                Q.push(v);
            }
        }
    }

    if(visited==n){
        cout<<"Yes"<<endl;
        for(int i=2; i<=n; i++){
            cout<<pred[i]<<endl;
        }
    }
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 10584