akhauriyash/Code-Regression huggingface dataset:
/*~~~~~~~~~~~~~~~~~~~~~~
  Code by gkothyari 
~~~~~~~~~~~~~~~~~~~~~~~*/    
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define rep(i,n) 			  for(int i=0;i<(n);i++)
#define FOR(i,a,b) 			  for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) 		  for(int i=(a);i>=(b);i--)
#define DEBUG(x) 			  cout << '>' << #x << ':' << x << endl;
#define foreach(it, c)        for( typeof( (c).begin()) it = (c).begin();  it != (c).end(); ++it)
#define endl 				  "\n"
#define pb                    push_back
#define eb                    emplace_back
#define ll					  long long
#define ld					  long double
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MAX                   1e9
#define MIN                   -1e9
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(v)                v.begin(),v.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sqr(x) 				  ((x)*(x))
#define ones(x) 			  __builtin_popcount(x)
#define onesll(x) 			  __builtin_popcountll(x)
#define PI                    acos(-1.0)
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

int main()
{
	cout<<fixed<<setprecision(15);
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	ios_base:: sync_with_stdio(false); cin.tie(0);
	    
	ll i,n;
	cin>>n;
	ll a[n+1];
	ll b[n];
	rep(i,n+1){
		cin>>a[i];
	}
	// ll count[n];
	// for(i=0;i<n;i++){
	// 	count[i]=a[i]+a[i+1];
	// }
	rep(i,n){
		cin>>b[i];
	}
	ll res[n+1];
	rep(i,n+1)
		res[i]=0;
	// for(i=0;i<n;i++){
	// 	if(b[i]<count[i]){
	// 		res[i]=b[i];
	// 	}
	// 	else{
	// 		res[i]=count[i];
	// 	}
	// }
	rep(i,n){
		if(a[i]<b[i]){
			res[i] += a[i];
			b[i] = b[i]-a[i];
			a[i]=0;
		}
		else{
			res[i] +=b[i];
			a[i] = a[i]-b[i];
			b[i] = 0;
		}
		if(a[i+1]<b[i] && b[i]!=0){
			res[i+1] += a[i+1];
			b[i] = b[i]-a[i+1];
			a[i+1]=0;
		}
		else if(b[i]!=0){
			res[i+1] +=b[i];
			a[i+1] = a[i+1] - b[i];
			b[i] = 0;
		}
	}
	ll sum=0;
	rep(i,n+1)
	sum+=res[i];
	cout<<sum<<endl;
	return 0;
}
 

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	string S, T;
	cin >> N >> S >> T;
	int res = 2*N;
	for(int i = 0; i < N; i++) {
		bool flg = true;
		for(int j = i; j < N; j++) {
			if(S[j] != T[j-i])
				flg = false;
		}
		if(flg) {
			res = N+i;
			break;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 384
from collections import deque
n=int(input())

alpha=list('abcdefghijk')

q=deque([])
q.append(alpha[0])

for i in range(1,n):
    qi=deque([])

    while(len(q)>0):
        qij=q.popleft()
        qij_setnum=len(set(list(qij)))
        for j in range(qij_setnum+1):
            qi.append(qij+alpha[j])

    q=qi

q=list(q)
q.sort()
for i in range(len(q)):
    print(q[i])

Measured memory_bytes: 13988
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL dp[N];
string S;
int32_t main(void) {
    boost;
    cin>>S;
    LL huj=1;
    f0(i,S.size()) {
        if(S[i]=='?') {
            dp[3]*=3;
            dp[3]+=dp[2];
            dp[2]*=3;
            dp[2]+=dp[1];
            dp[1]=dp[1]*3+huj;
            huj*=3;
        }
        if(S[i]=='C') {
            dp[3]+=dp[2];
        }
        if(S[i]=='B') {
            dp[2]+=dp[1];
        }
        if(S[i]=='A') {
            dp[1]+=huj;
        }
        huj%=mod;
        f0(j,5) dp[j]%=mod;
    }
    cout<<dp[3];
}


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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const long double EPS = 1e-10;
const bool debug = 0;

struct BIT {
	vector<int> bit;
	int n;
	
	BIT() {}
	BIT(int n) : bit(vector<int>(n + 2, 0)), n(n) {}
	
	
	int sum(int i) {
		i++;
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	
	void add(int i, int x) {
		i++;
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
	
	int lower_bound(int x) {
		int l = -1, r = bit.size();
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (sum(m) >= x) r = m;
			else l = m;
		}
		if (r == bit.size()) r = -1;
		
		return r;
	}
};

int N, C;
ll sum[112345];
int cmd[112345], fir[112345], sec[112345];

int main() {
	cin >> N >> C;
	REP(i, C) {
		scanf("%d", cmd + i);
		if (cmd[i] == 0) {
			scanf("%d %d", fir + i, sec + i);
			fir[i]--;
		}
		else scanf("%d", fir + i);
	}
	
	vector<pll> cx;
	REP(i, N) cx.push_back(pll(0, i));
	
	REP(i, C) {
		if (cmd[i] == 0) {
			sum[fir[i]] += sec[i];
			cx.push_back(pll(-sum[fir[i]], fir[i]));
		}
	}
	
	sort(ALL(cx));
	
	BIT bit(cx.size() + 1);
	REP(i, N) bit.add(lower_bound(ALL(cx), pll(0, i)) - cx.begin(), 1);
	
	memset(sum, 0, sizeof(sum));
	
	REP(i, C) {
		if (cmd[i] == 0) {
			bit.add(lower_bound(ALL(cx), pll(-sum[fir[i]], fir[i])) - cx.begin(), -1);
			sum[fir[i]] += sec[i];
			bit.add(lower_bound(ALL(cx), pll(-sum[fir[i]], fir[i])) - cx.begin(), 1);
		}
		else {
			int idx = bit.lower_bound(fir[i]);
			
			printf("%lld %lld\n", (cx.begin() + idx)->se + 1, -(cx.begin() + idx)->fi);
		}
	}
	
	return 0;
}

Measured memory_bytes: 9004
#include<stdio.h>
using namespace std;
int main()
{
   int A, B;
   char op;
   scanf("%d %c %d", &A, &op, &B);
   if(op == '+'){
    printf("%d\n", A+B);
   }
   else if(op == '-'){
    printf("%d\n", A-B);
   }
   return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final int INTERVAL = 10;

    private static class Dish{
        final int time;
        final int roundUp;
        final int timeWasted;

        private Dish(int time, int roundUp, int timeWasted){
            this.time = time;
            this.roundUp = roundUp;
            this.timeWasted = timeWasted;
        }

        static Dish fromInt(int i){
            int roundUp = ((i+INTERVAL -1)/INTERVAL)*INTERVAL;
            int timeWasted = roundUp-i;
            return new Dish(i, roundUp, timeWasted);
        }

        int getRoundUp(){
            return this.roundUp;
        }
    }

    public static String process(int a, int b, int c, int d, int e) {
        List<Integer> times = Arrays.asList(a,b,c,d,e);
        List<Dish> dishes = times.stream().map(Dish::fromInt).collect(Collectors.toList());
        dishes.sort((d1, d2)->Integer.compare(d1.timeWasted, d2.timeWasted));

        int sum = 0;
        int lastDish = dishes.size()-1;
        int lastDishTime = dishes.get(lastDish).time;
        int totalTime = lastDishTime + IntStream.range(0, lastDish ).mapToObj(dishes::get).mapToInt(Dish::getRoundUp).sum();

        return String.valueOf(totalTime);
    }
    // Util func

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();

        final String result = process(a, b, c, d, e);

        output(result);
    }

    private static void output(String result) {
        System.out.println(result);
    }
}


Measured memory_bytes: 29012
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[(N - (N - int.Parse(input[i]))) - 1] = i + 1;
    }
    Console.WriteLine(string.Join(" ", arr));
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    string s;
    cin >> s;

    bool ans = true;
    int k = 1000;
    REP(i,4){
        int x = s[i] - '0';
        if(x == k){
            ans = false;
        }
        k = x;
    }

    if(ans)
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;
    return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = 0; i < n - 1; i++) {
    sort(begin(v), end(v));
    v[1] = (v[0] +  v[1]) / 2;
    v.erase(v.begin());
  }
  cout << v.front() << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans = 0
l_max = 0
r_min = n+1
for i in range(m):
  l, r = map(int, input().split())
  if r < r_min:
    r_min = r
  if l > l_max:
    l_max = l
for i in range(1, n+1):
  if i >= l_max and i <= r_min:
    ans += 1
print(ans)





Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

//vector<int> ms;

bool ms[300005];

void make_monday_saturday_number (void )
{
	memset (ms, false, sizeof (ms ) );
//	m.clear(), s.clear();
	for (int i = 1; i < 300000; i++ ){
		if (i % 7 == 1 && i != 1 ){
			ms[i] = true;
//			m.push_back (i );
		}else
		if (i % 7 == 6 ){
			ms[i] = true;
//			s.push_back (i );
		} // end if

	} // end for
	for (int i = 0; i < 300000; i++ ){
		if (ms[i] ){
			for (int j = 2*i; j < 300000; j += i ){
				ms[j] = false;
			} // end for
		} // end if
	} // end for

}

int main()
{
//	cut here before submit 
//	freopen ("testcase.MSPF", "r", stdin );
	make_monday_saturday_number ();

	int n;
	while (scanf ("%d", &n ) && n != 1 ){
//		cout << n << ": ";
		vector<int> res; res.clear();
		rep (i, n+1 ){
			if (ms[i] && n % i == 0 ){
//				cout << ms[i] << ' ';
				res.push_back (i );
//				printf ("%d ", i );
			} // end if
		} // end rep
//		cout << endl;
		printf ("%d: ", n );
		rep (i, res.size() ){
			cout << res[i] << (i != res.size() - 1 ? ' ' : '\n' );
		} // end rep 
//		printf ("\n" );
	} // end loop
	
	return 0;
}

Measured memory_bytes: 1548
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut edge: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _i in 0..m {
        let ai: usize = read();
        let bi: usize = read();
        edge[ai - 1].push(bi - 1);
        edge[bi - 1].push(ai - 1);
    }
    let visited: [bool; 8] = [false; 8];
    println!("{}", dfs(0, n, &visited, &edge, 0));
}

fn dfs(i: usize, n: usize, visited: &[bool; 8], edge: &Vec<Vec<usize>>, mut cnt: i32) -> i32 {
    let mut u_visited = *visited;
    u_visited[i] = true;
    if is_all_visited(n, u_visited) {
        cnt += 1;
    } else {
        for j in &edge[i] {
            if u_visited[*j] == false {
                cnt = dfs(*j, n, &u_visited, &edge, cnt);
                u_visited[*j] = false;
            }
        }
    }
    cnt
}

fn is_all_visited(n: usize, visited: [bool; 8]) -> bool {
    let mut flag: bool = true;
    for i in 0..n {
        if !visited[i] {
            flag = false;
        }
    }
    flag
}

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")
}

Measured memory_bytes: 4352
D, G = map(int, input().split())
T = []
acc = 0
for i in range(D):
    p, c = map(int, input().split())
    acc += p
    T.append([p, c])
dp = [[0]*(acc+1) for _ in range(D+1)]
l = 0
for i in range(1, D + 1):
    for j in range(1, acc + 1):
        l += T[i-1][0]
        for k in range(T[i-1][0] + 1):
            if j <= l and j - k >= 0:
                if k == T[i-1][0]:
                    dp[i][j] = max([dp[i - 1][j - k] + 100 * i * k + T[i - 1][1], dp[i - 1][j]])
                else:
                    dp[i][j] = max([dp[i - 1][j - k] + 100 * i * k, dp[i - 1][j]])

for i in range(acc + 1):
    if dp[D][i] >= G:
        print(i)
        break

Measured memory_bytes: 73976
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int MAX = 510000;
const int MOD = 1000000007;
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;
}
int main()
{
    COMinit();
    int H, W, N; cin >> H >> W >> N;
    vector<Int> R(N+2), C(N+2), odd(N+2), even(N+2), indeg(N+2);
    vector<vector<tuple<int, int, int>>> G(N+2);
    for (int i = 0; i < N; i++) {
        cin >> R[i] >> C[i];
    }
    int start = N, goal = N+1;
    R[start] = 1, C[start] = 1;
    R[goal] = H, C[goal] = W;
    for (int i = 0; i < N+2; i++) {
        for (int j = 0; j < N+2; j++) {
            if (i != j && R[i] <= R[j] && C[i] <= C[j]) {
                int r = R[j] - R[i], c = C[j] - C[i];
                G[i].emplace_back(j, +1, COM(r+c, r));
                G[j].emplace_back(i, -1, COM(r+c, r));
                indeg[j]++;
            }
        }
    }
    even[start] = 1;
    indeg[start] = 1;
    function<void(int)> recur = [&](int node) {
        indeg[node]--;
        if (indeg[node] != 0) return;
        for (auto t : G[node]) {
            int dst, dir, weight;
            tie(dst, dir, weight) = t;
            if (dir == -1) {
                even[node] = (even[node] + odd[dst] * weight) % MOD;
                odd[node] = (odd[node] + even[dst] * weight) % MOD;
            }
        }
        for (auto t : G[node]) {
            int dst, dir, weight;
            tie(dst, dir, weight) = t;
            if (dir == +1) recur(dst);
        }
    };
    recur(start);
    cout << (odd[goal] + MOD - even[goal]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 146304
def func(n):
    if n % 2 == 0:
        return n / 2

    return 3 * n + 1

if __name__ == "__main__":
    s = int(input())
    num_pool = set([s])
    m = 1
    while True:
        s = func(s)
        m += 1
        if s in num_pool:
            break
        
        num_pool.add(s)

    print(m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string s;
  cin>>s;
  string f=s.substr(0,2),l=s.substr(2,2);
  if((f>"12" or f=="00") and (l>"12" or l=="00")) cout<<"NA"<<endl;
  else if(f>"12" or f=="00") cout<<"YYMM"<<endl;
  else if(l>"12" or l=="00") cout<<"MMYY"<<endl;
  else cout<<"AMBIGUOUS"<<endl;
  return 0;
}


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

int main()
{


        long long n,m,a,b=2,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=-1,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        scanf("%lld",&n);

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

        for(i=1;i<=n;i++)printf("%lld\n",mp[i]);







    return 0;
}





Measured memory_bytes: 16292
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d", &a,&b);
  if(a == 1 && b == 1){
    printf("Draw");
    return 0;
  }else if(a == 1){
    printf("Alice");
    return 0;
  }else if(b == 1){
    printf("Bob");
    return 0;
  }

  if(a < b){
    printf("Bob");
  }else if(a > b){
    printf("Alice");
  }else{
    printf("Draw");
  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int N;
  int i,num;
  int a[100];
  
  scanf("%d", &N);
  for(i = 0;i < N;i++) {
    scanf("%d", &a[i]);
  }

  num = 0;
  for(i = 0;i < N;i++) {
    if(a[i] == a[i+1]) {
      num++;
      i++;
    }
  }

  printf("%d", num);
  
  return 0;
}


Measured memory_bytes: 128
def fr(x):
    if x==0:
        return 0
    o=1
    for i in range(1,x+1):
        o*=i
    return o
        
def nu(x):
    o=0
    y=[0]*n
    for i in range(n):
        for j in range(i):
            if x[i]>x[j]:
                y[i]+=1
    for i in range(n):
        o+=max(0,x[i]-y[i]-1)*fr(n-1-i)
    return o

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

a=nu(p)
b=nu(q)

print(abs(a-b))


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

int main(void){
    char A, B, ans;
    cin >> A >> B;
    if(A > B) ans = '>';
    if(A == B) ans = '=';
    if(A < B) ans = '<';
    
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 2019;
int INF = (int)2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    bool check = true;
    for (int i = 1; i < N; i++) {
        if (H[i - 1] < H[i]) {
            --H[i];
        } else if (H[i - 1] == H[i]) {
            //nothing to do
        } else {
            check = false;
        }
    }
    cout << (check ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let D: usize = read();
    let points: Vec<(i64, i64)> = (0..N).map(|_| (read(), read())).collect();
    let ans = points.into_iter().fold(0, |acc, (x, y)| {
        if ((x.pow(2) + y.pow(2)) as f64).sqrt() <= D as f64 {
            acc + 1
        } else {
            acc
        }
    });
    println!("{}", ans)
}


Measured memory_bytes: 5136
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main(void) {
	int n, m, i, j, a, b, r[100003] = {}, vf, vs, ans = 0;
	vector<P> v;

	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		v.push_back(P(b, a));
	}

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

	for (i = 0; i < m; i++) {
		vf = v[i].first;
		vs = v[i].second;
		if (i > 0) {
			j = v[i - 1].first;
			while (j < vf) {
				r[j] = r[j - 1];
				j++;
			}
		}
		if (r[vf - 1] - r[vs - 1] == 0) {
			r[vf - 1]++;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int n,aaa[maxn],pos[maxn],num[maxn];
int top,ans;
bool check(int ans)
{
    top=0;
    for(int i=2;i<=n;i++)
    if(aaa[i]<=aaa[i-1])
    {
        int x=aaa[i];
        while(top&&pos[top]>x) top--;
        while(top&&pos[top]==x&&num[top]==ans) top--,x--;
        if(x==0) return 0;
        else if(pos[top]<x)
        {
            pos[++top]=x;
            num[top]=2;
            if(ans==1)
                return 0;
        }
        else num[top]++;
    }
    return 1;
}
int main(int argc, char** argv)
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&aaa[i]);
    int l=1,r=n,ans;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid))
            r=mid-1,ans=mid;
        else
            l=mid+1;
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
  int N, K;
  cin >> N;
  cin >> K;
  vector<int> okasi(N,0);
  for (int i=0;i<K;i++)
  {
    int d;
    cin >> d;
    for (int j=0; j<d; j++)
    {
      int k;
      cin >> k;
      okasi.at(k-1) +=1;
    }
  }
  
  int count = 0;
  for (int i=0; i<N; i++)
  {
    if (okasi.at(i)==0)
    {
      count +=1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3604
local N = io.read("n")
local A = {}
for i=1,N do
    A[i] = io.read("n")
end
local max_ltoi = {}
local max_itor = {}
max_ltoi[0] = -1
max_itor[N+1] = -1
for i=1,N do
    max_ltoi[i] = math.max(max_ltoi[i-1], A[i])
end
for i=N,1,-1 do
    max_itor[i] = math.max(max_itor[i+1], A[i])
end
for i=1,N do
    local m = math.max(max_ltoi[i-1], max_itor[i+1])
    print(m)
end

Measured memory_bytes: 16744
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    private static void nCombination3(int c) {
        int count = c;
        int num = 0;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    num++;
                }
            }
        }
    }



    public static void main(String[] args) {
        // write your code here
        Scanner sc=new Scanner(System.in);
        double X=sc.nextDouble();
        boolean flag = false;
        long temp = 100;
        for(int i=1;i<=100000;i++){
            temp *= 1.01;
            if(temp>=X){
                System.out.println(i);
                break;
            }
        }





    }
}


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

int main() {
  uint64_t n, k;
  std::cin >> n >> k;
  std::vector<std::pair<uint64_t, uint64_t>> sushi(n);
  for (auto &i : sushi) {
    std::cin >> i.second >> i.first;
  }
  std::sort(sushi.begin(), sushi.end());

  uint64_t oishi = 0;
  uint64_t neta_count = 0;
  std::vector<bool> neta(n + 1, false);
  std::vector<std::pair<uint64_t, uint64_t>> kouho;
  kouho.reserve(n);

  for (uint64_t i = 0; i < k; i++) {
    oishi += sushi.back().first;
    if (!neta[sushi.back().second]) {
      neta_count++;
      neta[sushi.back().second] = true;
    } else {
      kouho.push_back(std::move(sushi.back()));
    }
    sushi.pop_back();
  }

  uint64_t manzoku = oishi + neta_count * neta_count;

  while (!kouho.empty() && !sushi.empty()) {
    oishi -= kouho.back().first;
    kouho.pop_back();
    while (!sushi.empty()) {
      if (!neta[sushi.back().second]) {
        neta_count++;
        neta[sushi.back().second] = true;
        oishi += sushi.back().first;
        sushi.pop_back();
        break;
      } else {
        sushi.pop_back();
      }
    }
    manzoku = std::max(manzoku, oishi + neta_count * neta_count);
  }

  std::cout << manzoku << std::endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    int n;  cin >> n;
    vector<ll> x(n), y(n), h(n);
    REP(i, n)   cin >> x.at(i) >> y.at(i) >> h.at(i);


    
    REP(i, 101){
        REP(j, 101){
            ll H=0; 
            bool flag=true; 
            priority_queue<ll> que;
            REP(k, n){
                ll tmp = abs(x[k]-i)+abs(y[k]-j);
                if(h[k]==0){
                    que.push(tmp);
                    continue;
                }

                if(0<H && H != h[k]+tmp){
                    flag = false;
                    break;
                }
                H = h[k]+tmp;
            }
            while(flag && !que.empty()){
                if(que.top()<H) flag = false;
                que.pop();
            }

            if(flag){    
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
        

        } 
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;

int		main(void)
{
	int		N;
	string	A;
	cin >> N >> A;
	int		cnt = 0;
	int		ans = 0;
	for (auto &i : A)
	{
		if (i == 'A')
			cnt = 1;
		else if (cnt == 1)
		{
			if (i == 'B')
				cnt++;
			else
				cnt = 0;
		}
		else if (cnt == 2)
		{
			if (i == 'C')
				ans++;
			cnt = 0;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  int l[n];
  for(int i=0;i<n;i++) cin >> l[i];
  std::sort(l,l+n,std::greater<>());
  int max = l[0];
  int sum = 0;
  for(int i=1;i<n;i++) sum += l[i];
  if(max<sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S[0] != S[1] && S[0] != S[2] && S[1] != S[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int N;
vector<int> preorder;
map<int, int> inorderPos;

struct Node {
  int id;
  Node *left;
  Node *right;

  Node(int id) : id(id), left(NULL), right(NULL) {};

  ~Node() {
    delete left;
    delete right;
  }
};

Node *construct(int &idx, Node *lastLeftParent) {
  int id = preorder[idx];
  Node *node = new Node(id);

  ++idx;
  if (idx < N && inorderPos[preorder[idx]] < inorderPos[id]) {
    node->left = construct(idx, node);
  }

  if (idx < N && (!lastLeftParent || inorderPos[preorder[idx]] < inorderPos[lastLeftParent->id])) {
    node->right = construct(idx, lastLeftParent);
  }

  return node;
}

void generatePostorder(Node *node, vector<int> &vec) {
  if (node->left) {
    generatePostorder(node->left, vec);
  }
  if (node->right) {
    generatePostorder(node->right, vec);
  }
  vec.push_back(node->id);
}

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

  cin >> N;

  for (auto i = 0; i < N; ++i) {
    int t;
    cin >> t;
    preorder.push_back(t);
  }
  for (auto i = 0; i < N; ++i) {
    int t;
    cin >> t;
    inorderPos[t] = i;
  }

  int idx = 0;
  Node *root = construct(idx, NULL);

  vector<int> postorder;
  generatePostorder(root, postorder);

  for (auto i = 0; i < N; ++i) {
    if (i) {
      cout << " ";
    }
    cout << postorder[i];
  }
  cout << endl;

  delete root;

  return 0;
}



Measured memory_bytes: 3220
from collections import deque
class Dinic:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
    """
    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))
        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break            

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    self.E[vertex][i].cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0
        
        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)        

V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    u, v, cap = map(int, input().split())
    edge[u].append((v, cap))
print(Dinic(V, edge, 0, V-1).maxflow)

Measured memory_bytes: 7420
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=200000;

int main() {
    int n,m;
    string s[110],t[110];
    map<string,int> b,r;
    cin>>n;
    fori(n){cin>>s[i];++b[s[i]];}
    cin>>m;
    fori(m){cin>>t[i];++r[t[i]];}

    int ans=-100;
    fori(n){
        if(ans<b[s[i]]-r[s[i]]){
            ans=b[s[i]]-r[s[i]];
        }
    }
    if(ans<0)
        ans=0;
    cout<<ans;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m, s = map(int,input().split())
    E = [None] * m
    S = 0
    for i in range(m):
        u, v, a, b = map(int,input().split())
        S += a
        E[i] = (u - 1, v - 1, -a, b)

    exchange = [tuple(map(int,input().split())) for _ in range(n)]
    dp = [[INF] * (S + 1) for _ in range(n)]
    dp[0][min(s, S)] = 0

    for _ in range(2 * n - 3):
        # 先に両替を済ませる
        for v in range(n):
            for s in range(S + 1):
                ds, dt = exchange[v]
                dp[v][min(s + ds, S)] = min(dp[v][min(s + ds, S)], dp[v][s] + dt)
        # 移動する
        for u, v, ds, dt in E:
            for s in range(S + 1):
                ns = s + ds
                if ns < 0:
                    continue
                dp[u][ns] = min(dp[u][ns], dp[v][s] + dt)
                dp[v][ns] = min(dp[v][ns], dp[u][s] + dt)

    for v in range(1, n):
        print(min(dp[v][j] for j in range(S + 1)))
resolve()

Measured memory_bytes: 79860
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        Edge[] edges = new Edge[m];
        boolean[][] adj = new boolean[n + 1][n + 1];
        for (int i = 0; i < m; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            edges[i] = new Edge(a, b);
            adj[a][b] = adj[b][a] = true;
        }
        int num = 0;
        for (int i = 0; i < m; i++) {
            Set<Integer> visited = new HashSet<>();
            Queue<Integer> toVisit = new PriorityQueue<>();
            toVisit.add(1);
            visited.add(1);
            int count = 0;
            adj[edges[i].a][edges[i].b] = adj[edges[i].b][edges[i].a] = false;
            while (!toVisit.isEmpty()) {
                int a = toVisit.remove();
                count++;
                for (int j = 0; j < n + 1; j++) {
                    if (adj[a][j] && !visited.contains(j)) {
                        visited.add(j);
                        toVisit.add(j);
                    }
                }
            }
            adj[edges[i].a][edges[i].b] = adj[edges[i].b][edges[i].a] = true;
            if (count != n) {
                num++;
            }
        }
        System.out.println(num);
    }
}

class Edge {
    int a, b;
    boolean active = true;
    public Edge(int c, int d) {
        a = c; b = d;
    }
}


Measured memory_bytes: 22484
#include<stdio.h>
void bubblesort(int[], int);
void swap(int *, int *);
int main()
{
    int i,N,A[100];
    
    scanf("%d",&N);
    
    for(i=0; i<N; i++)
    {
        scanf("%d",&A[i]);
    }
    bubblesort(A,N);

    return 0;
    
}

void bubblesort(int A[], int N)
{
  int count=0,i,j;

  for(i=0; i<N; i++)
    {
      for(j=N-1; j>=i+1; j--)
	{
	 
	  if(A[j]<A[j-1])
	    {
	      swap(&A[j],&A[j-1]);
	      count++;
	    }
	  else continue;
	}
    }
  

 
  for(i=0; i<N; i++)
    {
      if(i!=N-1)printf("%d ",A[i]);
      else printf("%d",A[i]);

    }
  
  printf("\n");
   printf("%d\n",count);
  
}

void swap(int *a, int *b)
{
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;

}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <cstdio>
#include <stack>
using namespace std;

// Weight(0031)
int main()
{
	int n;
	const int pow2[] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
	while (cin >> n) {
		vector<int> ans;
		for (int i = 0; i < 10; ++i) {
			if (n >= pow2[i]) {
				ans.push_back(pow2[i]);
				n -= pow2[i];
			}
		}
		sort(ans.begin(), ans.end());

		for (int i = 0; i < ans.size()-1; ++i)
			cout << ans[i] << " ";
		cout << ans.back() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main () {
  int a[4];
  int b[4];

  while(cin >> a[0]){
    for(int i = 1; i < 4; i++) {
      cin >> a[i];
    }
    for(int i = 0; i < 4; i++) {
      cin >> b[i];
    }

    int hit = 0, blow = 0;

    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
        if(a[i] == b[j]) {
          if(i == j) {
            hit++;
          }
          else {
            blow++;
          }
        }
      }
    }

    cout << hit << ' ' << blow << endl;
  }
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static ConsoleApplication.Utils;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var abx = ReadLongs().ToArray();
            var res = func(abx[1], abx[2]) - func(abx[0] - 1, abx[2]);
            WriteLine(res);
        }

        private static long func(long n, long x)
            => n == -1 ? 0 : n/x + 1;
    }

    public static class Utils
    {
        #region Extensions for IO

        public static int ReadInt()
            => ReadLine().ToInt();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static long ReadLong()
            => ReadLine().ToLong();

        public static IEnumerable<long> ReadLongs()
            => ReadStrings().Select(long.Parse);

        public static ulong ReadUlong()
            => ReadLine().ToUlong();

        public static IEnumerable<ulong> ReadUlongs()
            => ReadStrings().Select(ulong.Parse);
            

        public static IEnumerable<string> ReadStrings()
            => ReadLine().Split(' ');

        public static IEnumerable<string> ReadLines(int n)
        {
            foreach (var i in Enumerable.Range(0, n))
            {
                yield return ReadLine();
            }
        }

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;

        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static ulong ToUlong(this string str)
            => ulong.Parse(str);

        public static double ToDouble(this string str)
            => double.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion

        public static TSource Min<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
            where TKey : IComparable
            => source.OrderBy(keySelector).First();

        public static TSource Max<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
            where TKey : IComparable
            => source.OrderByDescending(keySelector).First();

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }

        public static IEnumerable<T> Peek<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
            return source;
        }
    }
}


Measured memory_bytes: 2776
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int n;
	while( cin >> n){

		if(n==0 || cin.eof()) break;
		vector<int> nb(n,0);
		rep(i, n) cin >> nb[i];
		sort(nb.begin(), nb.end());
		long long ans=0;
		rep(i,n-1) ans += nb[i] * (n-1-i);
		cout << ans << endl;
	}

	return 0;
	
}

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

int main()
{
  int h, w, m = -1;
  cin >> h >> w;
  string field[h];

  for (int i = 0; i < h; i++){
    cin >> field[i];
  }

  for (int i = 0; i < h; i++){
    m = -1;
    for (int j = 0; j < w; j++){
      char c = field[i][j];
      if (j != 0) cout << ' ';
      if (m == -1 && c == '.') cout << m;
      else if (c == 'c'){
        m = j;
        cout << 0;
      }
      else {
        cout << j - m;
      }
    }
    cout << "\n";
  }
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int a, b, x; cin >> a >> b >> x;
	cout << ((a<=x && x<=a+b)?"YES":"NO") << endl;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
approve=0
for k in range(0,n):
  if a[k]%2==0:
    if (a[k]%3==0)or(a[k]%5==0):
      approve=approve+0
    else:
      approve=approve+1

if approve==0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
n, k = gets.split(' ').map(&:to_i)

portals = gets.split(' ').map(&:to_i)

slow = 1
fast = 1
length = 0

loop do
  length += 1
  slow = portals[slow - 1]
  fast = portals[portals[fast - 1] - 1]

  break if slow == fast
end

pre_len = 0
slow = 1
while slow != fast
  pre_len += 1
  slow = portals[slow - 1]
  fast = portals[fast - 1]
end

if k < pre_len
  cycle = k
  slow = 1
else
  cycle = (k - pre_len) % length
end

cycle.times do
  slow = portals[slow - 1]
end

puts slow


Measured memory_bytes: 27352
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  ll a,b;
  cin>>a>>b;
  ll x = b-a;
  ll len = (x*(x+1))/2;
  ll sn_co = len-b;
  cout<<sn_co<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,a[200005],r=0,g=0,b=0,res=1;
string str;
int main() {
	cout << fixed << setprecision(18);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(r==g&&g==b&&r==a[i]){res*=3;r++;}
		else if(r==g&&r==a[i]){res*=2;r++;}
		else if(r==b&&r==a[i]){res*=2;r++;}
		else if(g==b&&g==a[i]){res*=2;g++;}
		else if(r==a[i]){r++;}
		else if(g==a[i]){g++;}
		else if(b==a[i]){b++;}
		else{cout<<0;return 0;}
		res%=mod;
		//cout<<r<<" "<<g<<" "<<b<<" "<<res<<endl;
	}
	cout<<res;
} 


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

main(){
    ios
    int n=in();
    vec b;
    b.pb(1e8);
    rep(i,n-1)b.eb(in());
    b.pb(1e8);
    ll sum=0;
    rep(i,n){
        sum+=min(b[i],b[i+1]);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

s = input()
t = input()

alp = 'abcdefghijklmnopqrstuvwxyz'
alp_pos = {}
for a in alp:
    alp_pos[a] = []

for i,v in enumerate(s):
    alp_pos[v].append(i+1)


loop = 0
curr_pos = 0
for ti in t:
    if not alp_pos[ti]:
        print(-1)
        exit()
    curr_alp_poss = alp_pos[ti]
    ind = bisect_right(curr_alp_poss, curr_pos)
    if ind >= len(curr_alp_poss):
        loop += 1
        curr_pos = curr_alp_poss[0]
    else:
        curr_pos = curr_alp_poss[ind]

print(loop*len(s)+curr_pos)



Measured memory_bytes: 79696