akhauriyash/Code-Regression huggingface dataset:
program am
    implicit none
    integer::N
    integer,allocatable,dimension(:)::A
    integer::i
    integer::D,P!D for Diagonal move
    logical::check
    read*,N
    allocate(a(N))
    read*,A
    do i=1,N
      a(i)=-a(i)
    end do
    call heapsort(N,A)
    do i=1,N
      a(i)=-a(i)
    end do

    D=1
    do
      if(D==N)exit
      if(A(D+1)<D+1)exit
      D=D+1
    end do
    P=D
    do
      if(P==N)exit
      if(A(P+1)<D)exit
      P=P+1
    end do
    check = (mod(A(D)-D,2)==1).or.(mod(P-D,2)==1)

    print"(A)",trim(merge("First ","Second",check))
contains
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  integer::i,k,j,l
  integer:: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end program am

Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////


int K;

int main(){
    scanf("%d",&K);
    printf("%d\n",(K/2+K%2)*(K/2));
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		new Main();
	}
	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	int len;
	char[] s;
	long[] cmp;

	Main() {
		s = in.next().toCharArray();
		cmp = new long[len = s.length];
		int at = 0;
		for (int i = 0; i < len; i++) {
			int j = i;
			while (j < len && s[i] == s[j])
				j++;
			cmp[at++] = j - i;
			i = j - 1;
		}

		long ans = 0;
		if (s[0] == '>') {
			for (int i = 1; i < at - 1; i += 2) {
				ans += tri(max(cmp[i], cmp[i + 1]));
				ans += tri(min(cmp[i], cmp[i + 1]) - 1);
			}
			if (at %2 == 0)
				ans += tri(cmp[at - 1]);
			ans += tri(cmp[0]);
		}
		else {
			for (int i = 0; i <= at - 2; i += 2) {
				ans += tri(max(cmp[i], cmp[i + 1]));
				ans += tri(min(cmp[i], cmp[i + 1]) - 1);
			}
			if (at %2 == 1)
				ans += tri(cmp[at - 1]);
		}

		out.println(ans);
		out.close();
	}

	long tri(long a) {
		return a*(a + 1L)/2L;
	}

	long min(long a, long b) {
		if (a < b)
			return a;
		return b;
	}
	long max(long a, long b) {
		if (a > b)
			return a;
		return b;
	}
}

Measured memory_bytes: 34768
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
const LL MOD = 998244353;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char *argv[]) {
	int sh, sw, eh, ew;
	cin >> sh >> sw >> eh >> ew;
	vector<modll> dp(eh + 1, 0);
	dp[sh] = 1;
	for (int i = sh + 1; i <= eh; ++i) {
		dp[i] = dp[i - 1] * sw;
	}
	for (int col = sw + 1; col <= ew; ++col) {
		vector<modll> next(eh + 1, 0);
		modll sum = 0;
		for (int row = sh; row <= eh; ++row) {
			next[row] = dp[row] * row + next[row - 1] * col - dp[row - 1] * (row - 1) * (col - 1);
		}
		dp = next;
	}
	cout << dp[eh] << endl;
	return 0;
}


Measured memory_bytes: 3652
#def main(S, b):
if __name__ == '__main__':
    k, n = map(int, input().split())

    A = list(map(int, input().split()))

    for i in range(n):
        A.append(A[i] + k)

    #print(A)
    ans = 10000000000
    for i in range(n):
        #print(ans, A[i + n - 1], A[i])
        if (ans > A[i + n - 1] - A[i]):
            ans = A[i + n - 1] - A[i]

    print(ans)


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

#define F first
#define S second
#define ll long long
#define ln cout<<'\n'
#define Z class
typedef pair<int,int> P;

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * 

int main(){

    // input 
    ll n,m;
    cin >> n >> m;
    P a[m];   // 要望：pair <終わり、始点＞
    rep(i,m) cin >> a[i].S >> a[i].F;  // pair <終わり、始点＞
    
    // 終わりが早い順にソート
    sort(a,a+m);
    // pari <始点、終わり＞　に戻す
    rep(i,m) swap(a[i].F,a[i].S);

    int ans=0,x=0;
    rep(i,m) {
        if(a[i].F<x) continue;
        else {
             x=a[i].S;
             ans++;
        }
    }

    // output 
    pr(ans);


    
    return 0;

}

Measured memory_bytes: 4404
# include<iostream>
using namespace std;
int main ()
{
	 int N;
	 cin>>N;
	 int D[N];
	 for(int i=0;i<N;i++)
	 {
	 	cin>>D[i];
	 }
	 
	 long long sum =0;
	 for(int i=0;i<N;i++)
	 {
	 	 for(int j=i+1;j<N;j++)
	 	 {
	 	 	 sum+=D[i]*D[j];
		  }
	 }
	 cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a, b) memset(a, b, sizeof(a))
const ll MOD = 1000000007;
using namespace std;

int32_t main()
{
	vaibhavv06;
	int a, b;
	cin >> a >> b;
	string x="", y="";

	for (int i = 0; i < a; i++)
		x += (b+'0');
	for (int i = 0; i < b; i++)
		y += (a+'0');
	if (x < y)
		cout << x << endl;
	else
		cout << y << endl;
}

Measured memory_bytes: 256
N = gets.to_i
 
p N.times.map{
    x, u = gets.chomp.split
    x = x.to_f
    
    case u
    when "JPY" then
        x
    when "BTC" then
        x * 380000.0
    end
}.inject(:+)
N = gets.to_i

puts N.times.map{
    x, u = gets.chomp.split
    x = x.to_f
    
    case u
    when "JPY" then
        x
    when "BTC" then
        x * 380000.0
    end
}.inject(:+)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n,m,c; cin >> n >> m >> c;
    int cnt = 0;
    int b[m]; inarray(b,m);
    for(int i = 0; i < n; i++){
        int p = 0;
        for(int j = 0; j < m; j++){
            int a; cin >> a;
            p += a*b[j];
        }
        if(p + c > 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll n, m; cin >> n >> m;
    cout << abs((n - 2) * (m - 2)) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(sc.nextLine());

		List<String> order = new ArrayList<String>();

		for (int i = 0; i < v; i++) {
			order.add(sc.nextLine());
		}

		for (String string : order) {
			String[] orders = string.split(" ");
			int v1 = Integer.parseInt(orders[1]);
			int v2 = Integer.parseInt(orders[2]);
			if (orders[0].equals("replace")) {
				StringBuilder first = new StringBuilder();
				StringBuffer sb = new StringBuffer(line.substring(v1, v2 + 1));
				sb.replace(0, v2 - v1 + 1, orders[3]);
				first.append(line.substring(0, v1));

				first.append(sb);
				first.append(line.substring(v2 + 1));
				line = first.toString();
			}

			else if (orders[0].equals("reverse")) {
				StringBuffer sb = new StringBuffer(line.substring(v1, v2 + 1));
				sb.reverse();
				line = line.replace(line.substring(v1, v2 + 1), sb);
			} else if (orders[0].equals("print")) {
				System.out.println(line.substring(v1, v2 + 1));
			}
		}
	}
}

Measured memory_bytes: 28988
def main():
    abcd = list( map( int , list( input() ) ) )

    for i in range( 2 ** 3 ):
        ans = str( abcd[0] )
        sum = abcd[0]
        x = i

        for j in range( 1,4 ):
                
            y = x % 2
            if y:
                sum += abcd[ j ]
                ans += '+'
            else:
                sum -= abcd[ j ]
                ans += '-'
            
            ans += str( abcd[ j ] )

            x = x // 2
        if sum == 7:
            ans += '=7'
            break
    print(ans)





main()

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

int main() {
  int k,a,b,flag;
  cin>>k>>a>>b;
  flag=0;
  for(int i=a; i<=b; i++){
    if(i%k==0) flag=1; 
  }
  if(flag==1) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    RSORT(A);
    ll ans = A[0];
    REP1(i, N - 2)
    {
        ans += A[(i + 1) / 2];
    }
    OUT(ans);
}

Measured memory_bytes: 4840
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int mod = 1e9 + 7,N = 4e3;
int n,m; ll Ans = 1,a[N],f[N][N];
int main()
{
	n = read(); m = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	for(int i = 1;i <= n;i ++) for(int j = 1;j <= n;j ++) f[i][j] = a[i] > a[j];
	int x,y,inv2 = (mod + 1) / 2;
	while(m --)
	{
		Ans = (Ans << 1) % mod;
		x = read(); y = read();
		f[x][y] = f[y][x] = 1ll * ((f[x][y] + f[y][x]) % mod + mod) % mod * inv2 % mod;
		for(int i = 1;i <= n;i ++)
		{
			if(i == x || i == y) continue;
			f[x][i] = f[y][i] = 1ll * ((f[x][i] + f[y][i]) % mod + mod) % mod * inv2 % mod;
			f[i][x] = f[i][y] = 1ll * ((f[i][x] + f[i][y]) % mod + mod) % mod * inv2 % mod;
		}
	}
	int tot = 0;
	for(int i = 1;i <= n;i ++) for(int j = i + 1;j <= n;j ++) tot = (tot + f[i][j]) % mod;
	cout << ((1ll * Ans * tot % mod) + mod) % mod;
}

Measured memory_bytes: 94336
# coding: utf-8
S = input()
ans = 0
P = 2019
N = len(S)
S = S[::-1]
cnt = [0 for _ in range(P)]
cnt[0] = 1
v = 0
bai = 1
for i in range(N):
    v += int(S[i]) * bai
    v %= P
    bai *= 10
    bai %= P
    cnt[v] += 1
for i in range(P):
    ans += ((cnt[i] - 1) * cnt[i]) // 2
print(ans)

Measured memory_bytes: 9348
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>

using namespace  std;

int n,k,a[100001];
int main()
{
	int s=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=k) 
		{
			s++;
		}
	}
	cout<<s;
	return 0;
}





Measured memory_bytes: 640
import sys

input = sys.stdin.readline
N, Q = map(int,input().split())
s = input()
query = [list(input().split()) for i in range(Q)]

def leftOK(index):
    for q in query:
        if q[0] == s[index]:
            if q[1] == "L":
                index -= 1
            else:
                index += 1
        if index == -1:
            return True
        elif index == N:
            return False
    return False
    
def rightOK(index):
    for q in query:
        if q[0] == s[index]:
            if q[1] == "L":
                index -= 1
            else:
                index += 1
        if index == N:
            return True
        elif index == -1:
            return False
    return False
    
def nibutan(f,ng,ok):
    count = 0
    while abs(ok-ng) > 1:
        count += 1
        mid = (ok + ng)//2
        if f(mid):
            ok = mid
        else:
            ng = mid
    return ok
    
left = nibutan(leftOK,N,-1)
right = nibutan(rightOK,-1,N)
print(right-left-1)

Measured memory_bytes: 77648
#include <stdio.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=1; i<=n; i++)

int main()
{
	int N, i, cnt=0;
	int A[50], B[50], C[50];
	
	scanf("%d", &N);
	lop(i, N){
		scanf("%d", &A[i]);
	}
	lop(i, N){
		scanf("%d", &B[i]);
	}
	lop(i, N-1){
		scanf("%d", &C[i]);
	}
	
	A[0]=0; B[0]=0; C[0]=0;
	
	lop(i, N){
        cnt+=B[A[i]];
        if(B[A[i]]==B[A[i-1]+1]){
            cnt+=C[A[i-1]];
        }
    }
          
    printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>id(n),a(n);
  rep(i,n)cin>>a[i];
  int maxid=0;
  rep(i,n)if(abs(a[maxid])<abs(a[i]))maxid=i;
  vector<pair<int,int>>res;
  rep(i,n)
  {
    res.push_back({maxid+1,i+1});
  }
  sort(all(id),[&](int p,int q){return a[p]<a[q];});
  if(a[maxid]<0)
  {
    rep(i,n-1)
    {
      res.push_back({n-i,n-i-1});
    }
  }
  else
  {

      rep(i,n-1)
      {
        res.push_back({i+1,i+2});
      }
  }
  cout<<res.size()<<"\n";
  for(auto t:res)cout<<t.first<<" "<<t.second<<"\n";
  cout<<endl;


  return 0;

}


Measured memory_bytes: 256
(let* ((n (read))
       (a (loop repeat n collect (read)))
       (m 1000))
  (setf a (loop with state = (if (> (first a) (second a))
                                 :down
                                 :up)
                with val = (first a)
                with result = (if (eql state :down)
                                  (list)
                                  (list (first a)))
                for i in (rest a)
                do (if (eql state :down)
                       (if (>= val i)
                           (setf val i)
                           (progn
                             (push val result)
                             (setf val i
                                   state :up)))
                       (if (<= val i)
                           (setf val i)
                           (progn
                             (push val result)
                             (setf val i
                                   state :down))))
                finally
                   (return (reverse `(,@(if (/= (or (first result) 0) val)
                                            (list val))
                                      ,@result)))))
  (loop for (i j . k) on a by 'cddr
        do (when j
             (multiple-value-bind (x y) (floor m i)
               (setf m (+ (* x j) y)))))
  (format t "~A~%" m))

Measured memory_bytes: 24496
inf = 10 ** 15
mod = 10 ** 9 + 7
x1, y1, x2, y2 = map(int, input().split())
x3, y3 = x2 - (y2-y1), y2 - (x1-x2)
x4, y4 = x3 - (y3-y2), y3 - (x2-x3)
print('{} {} {} {}'.format(x3, y3, x4, y4))

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

/* 配列使用２ */
int main(){
  int N;
  cin >> N;
  vector<int> mochi;
  
  int size;
  for(int i = 0; i < N; i++){
    cin >> size;
    // 配列に同じ値がなければ追加
    int j;
    for(j = 0; j < mochi.size(); j++){
      if(size == mochi.at(j))break;
    }
    if(j == mochi.size()){
      mochi.push_back(size);
    }
  }
  cout << mochi.size() << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

// ================================================= //

/*starry sky tree
 add(O(logN)):区間[a, b)に値xを加算する
 getMin(O(logN)): 区間の最小値を得る
 */
static const int MAX_SIZE = 1 << 17; // 2^n !!
typedef long long ll;
ll segMin[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];

void add(int a, int b, int x, int k = 0, int l = 0, int r = MAX_SIZE){
    if (r <= a || b <= l) return; //もし交差しない区間であれば終える.
    
    if (a <= l && r <= b){ //もし今みている区間[l, r)が[a, b)に完全に内包されていれば
        segAdd[k] += x;  //区間[l, r)にkを加算する.
        return;
    }
    
    //子の区間に(必要があれば)xを加算する.
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    
    //親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値 である.一様に加算される値は更新しなくて良い.
    segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1], segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
}

ll getMin(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE){
    if (r <= a || b <= l) return (LLONG_MAX);
    if (a <= l && r <= b) return (segMin[k] + segAdd[k]); //完全に内包されていれば,その区間の最小値を返す.
    
    ll left = getMin(a, b, k * 2 + 1, l, (l + r) / 2); //子の区間の最小値を求める.
    ll right = getMin(a, b, k * 2 + 2, (l + r) / 2, r); //子の区間の最小値を求める
    
    //親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値
    return (min(left, right) + segAdd[k]);
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    
//    SegTree ST(n);
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
           // ST.update(s,t+1,x);
            add(s,t+1,x);
        }else{
            int s,t; cin >> s >> t;
            //cout << ST.query(s,t+1) <<endl;
            cout << getMin(s,t+1) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 5564
//============================================================================
// Name        : Graph.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

void writeMatrix(vector<vector<int> > matrix){
	for(int i=0; i<matrix.size(); i++){
		for(int j=0; j<matrix.at(i).size()-1; j++){
			cout << matrix.at(i).at(j) << " ";
		}
		cout << matrix.at(i).at(matrix.at(i).size()-1);
		cout << "\n";
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > matrix;

	for(int i=0; i<n; i++){
		vector<int> vec(n);
		matrix.push_back(vec);
	}

	for(int i=0; i<n; i++){
		int id, k;
		cin >> id >> k;
		for(int j=0; j<k; j++){
			int input;
			cin >> input;
			//cout << "id: " << id << ", k: " << k << "\n";
			matrix.at(id-1).at(input-1) = 1;
		}
	}

	writeMatrix(matrix);

	return 0;
}



Measured memory_bytes: 3248
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll gcd(ll a,ll b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}

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


int main()
{
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	--A;

	ll numA = A - A / C - A / D + A / lcm(C, D);
	ll numB = B - B / C - B / D + B / lcm(C, D);

	cout << numB - numA << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int k,x;
	cin >> k >> x;
	cout << ((500*k<x)?"No":"Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
#define Endl "\n"
#define tests int t1234;cin>>t1234;for(int i1234=1;i1234<=t1234;i1234++)
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);std::cout << std::fixed;std::cout << setprecision(20);
#define takearr(a,n) ll a[n];for(ll i=0;i<n;i++)cin>>a[i]
#define pii pair<int,int>
#define F first
#define S second
#define rep(i,n) for( int i=0;i<(int)n;i++)
#define f(i,a,b) for( int i=(int)a;i<=(int)b;i++)
#define mods ((1000000007))
#define init1d(arr,n,val) for(int i=0;i<n;i++)arr[i]=val;
#define init2d(arr,x,y,val) for(int i=0;i<x;i++)for(int j=0;j<y;j++)arr[i][j]=val;
#define pb push_back
#define mass(vec) (int)vec.size()
#define lb(vec,n,val) ((int)(lower_bound(vec,vec+n,val)-vec))
#define ub(arr,n,val) ((int)(upper_bound(arr,arr+n,val)-arr))


typedef tree<int,null_type, less<>, rb_tree_tag,tree_order_statistics_node_update> oset;
//order_of_key   *find_by_order
typedef tree<int,int, less<>, rb_tree_tag,tree_order_statistics_node_update> omap;
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: ", cerr << to_string(__VA_ARGS__) << endl<<endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); }string to_string(string &s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; }string to_string(const char* s) { string tmp(s); return to_string(tmp); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(char c){ return string({c}); }template<size_t N> string to_string(bitset<N> &b, int x1=0, int x2=1e9){ string t = ((x1 < b.size()) ? (b.to_string()).substr(x1, x2-x1+1) : "");reverse(begin(t), end(t)); return '"' + t + '"'; }template <typename A, typename... C> string to_string(A (&v), int x1=0, int x2=1e9, C... coords);int l_v_l_v_l = 0, t_a_b_s = 0;template <typename A, typename B> string to_string(pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")";l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' ');string res = ""; bool first = true; if(l_v_l_v_l == 0) res += endl; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1);auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++;if(e != l){ if(rnk > 1) { res += endl; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]";if(l_v_l_v_l == 0) res += endl; return res; }
const int N=5*(1<<17);

int32_t main()
{
  fastio;
  int n,a,b;cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
}




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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> c(n), p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}

	vector<vector<long long>> a(n);
	vector<long long> cyc(n);
	for (int i = 0; i < n; i++) {
		a[i].emplace_back(0);
		long long sum = c[i];
		int next = p[i];
		while (next != i) {
			a[i].emplace_back(sum);
			sum += c[next];
			next = p[next];
		}
		cyc[i] = sum;
	}
	
	long long ans = -101010101010101010;
	for (int i = 0; i < n; i++) {
		if (cyc[i] > 0) {
			long long t = k / a[i].size() * cyc[i];
			ans = max(ans, t);
		} else {
			ans = max(ans, cyc[i]);
		}
		for (int j = 1; j <= min(k, (int)a[i].size() - 1); j++) {
			if (cyc[i] > 0) {
				long long t = (k - j) / a[i].size() * cyc[i] + a[i][j];
				ans = max(ans, t);
			} else {
				ans = max(ans, a[i][j]);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 218600
H,W=map(int,input().split(' '))

s=[0]*H
for i in range(H):
  s[i] = list(input())


def main():
  for i in range(H):
    for j in range(W):
      if s[i][j]=='.':
        continue
  
      flg=0
      l=j-1
      r=j+1
      t=i-1
      u=i+1
      if l>=0 and s[i][l]=='#':
        flg=1
  
      if r<W and s[i][r]=='#':
        flg=1
      
      if t>=0 and s[t][j]=='#':
        flg=1
  
      if u<H and s[u][j]=='#':
        flg=1
  
      if not flg:
        print("No")
        return
  
  print("Yes")

main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int temp = 0;
        int max = 0;
        int idx = 0;
        String s = sc.next();
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'W') {
                temp++;
            } else {
                temp--;
            }
            if (temp < max) {
                idx = i;
                max = temp;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (i == idx) {
                continue;
            } else if (i < idx && s.charAt(i) == 'W') {
                ans++;
            } else if (i > idx && s.charAt(i) == 'E') {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 30976
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //cout << fixed << setprecision(7);

    int a, b;
    int cnt = 0;
    while (cin >> a >> b)
    {
        if (a == 0 && b == 0)
            break;
        if (cnt)
            cout << endl;
        vector<int> ans;
        for (int year = a; year <= b; ++year)
        {
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                ans.push_back(year);
        }
        cnt++;
        if (ans.size() == 0)
        {
            cout << "NA" << endl;
        }
        else
        {
            for (auto e : ans)
                cout << e << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main(){
  float a,b,c,d,e,f;

  while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f) != EOF){
  float x = (c*e-b*f)/(a*e-b*d);
  float y = (a*f-c*d)/(a*e-b*d);

  if (x == -0.000000){
    x = 0.000000;
  } else if (y == -0.000000){
    y = 0.000000;
  }

  printf("%.3f %.3f\n",x,y);
  }

  return 0;
  
}

Measured memory_bytes: 644
#include <iostream>

using namespace std;

#define M 210
int main(){
  int N, a[M], i, ans=0;
  cin >> N;
  for (i = 0; i < N; i++)
    cin >> a[i];
  for (i = 0; i < N; i++)
    ans |= a[i];
  int num=0;
  
  while (ans%2 == 0){
    num++;
    ans >>= 1;
    
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,f[100005],g[100005],ans;
string s;
map<char,int> m;
void initmap(){
	m['p']=1;
	m['g']=0;
	m['P']=1;
	m['G']=0;
}
int pk(int x,int y){
	return x-y;
}
int main(){
	initmap();
	cin>>s;
	n=s.length();
	for(int i=1;i<=n;i++){
		g[i]=m[s[i-1]];
	}
	ans+=pk(0,g[1]);
	int cnt=1;
	for(int i=2;i<=n;i++){
		if(cnt>0){
			if(pk(1,g[i])==1){cnt--;ans++;continue;}
			if(pk(0,g[i])==1){cnt++;ans++;continue;}
			if(pk(0,g[i])==0){cnt++;continue;}
			if(pk(1,g[i])==0){cnt--;continue;}
		}
		else{
			ans+=pk(0,g[i]);
			cnt++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 896
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
list=[]
list.append(a)
list.append(b)
list.append(c)
list.append(d)
list.append(e)
if max(list)-min(list)>k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N,M;
vi PP;

int invmap[114514];
map<int,int> mm;
vi datas; 
int main(){
	cin>>N;
	string str;
	cin>>str;
	int A[5555]={0};
	string S;
	int ans=0;
	rep(mo,str.size()){
		S=str[N-1-mo]+S;
		A[0] = S.size();
		int i = 1, j = 0;
		while (i < S.size()) {
			while (i+j < S.size() && S[j] == S[i+j]) ++j;
			A[i] = j;
			if (j == 0) { ++i; continue;}
			int k = 1;
			while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
			i += k; j -= k;
		}
		int ma=0;
		rep(i,N){
			A[i]=min(A[i],i);
			ma=max(ma,A[i]);
		}
		ans=max(ans,ma);
	}
	cout<<ans<<endl;
	
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
   long int X,t,R=0;
    scanf("%ld %ld",&X,&t);
    if(1<=X && X<=pow(10,9) && 1<=t && t<=pow(10,9))
    {
     R = X - t;
     if(R<0) printf("0");
     else printf("\n%ld\n",R);
    }
return 0;
}

Measured memory_bytes: 1732
n,k = map(int,input().split())
mod = 10**9+7
gcd = [0]*(k+1)#gcdがiとなるようなものの個数
ans = 0
for i in range(k,0,-1):
    tmp = pow(k//i,n,mod)
    for j in range(i*2,k+1,i):
        tmp -= gcd[j]
    gcd[i] = tmp
    ans += tmp*i
    ans %=mod
print(ans)


    

Measured memory_bytes: 68944
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    ll N,M,V,P; cin >> N >> M >> V >> P;
    vector<Pl> A(N);
    rep(i,N){
        cin >> A[i].first;
        A[i].second = i;
    }

    sort(A.begin(),A.end());
    int ok = N-1,ng = -1;
    while(ok-ng > 1){
        vector<Pl> B = A;
        int mid = (ok+ng)/2;
        bool flag = false;
        if(mid+1 >= V){
            if(N-mid <= P) flag = true;
        }
        ll k = V-(mid+1);
        B[mid].first += M;
        ll t = B[mid].first;
        ll sum = 0;
        vector<ll> used(N);
        repr(i,mid+1,N){
            ll d = max(t-B[i].first,0LL);
            B[i].first += d;
            sum += d;
            used[i] += d;
            if(sum >= k*M){
                B[i].first -= sum-k*M;
                used[i] -= sum-k*M;
                break;
            }
        }
        ll e = max(k*M-sum,0LL);
        ll sum2 = 0;
        for(int i = N-1; i >= mid+1; i--){
            B[i].first += M-used[i];
            sum2 += M-used[i];
            if(sum2 >= e){
                B[i].first -= sum2-e;
                break;
            }
        }
        sort(B.begin(),B.end(),greater<Pl>());
        rep(i,P){
            if(B[i].first == t) flag = true;
        }
        if(flag) ok = mid;
        else ng = mid;
    }
    cout << N-ok << endl;

}



Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}
ll llpow(ll a, ll n){ll res=1;REP(_,n){res*=a;}return res;}

ll llgcd(ll a, ll b){
    if(b == 0)
        return a;
    return llgcd(b, a % b);
}

int main(){
    ll k;
    cin >> k;
    ll ans = 0;
    PREP(a, 1, k+1){
        PREP(b, 1, k+1){
            PREP(c, 1, k+1){
                ans += llgcd(llgcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi x(n);

  REP(i, 0, n)  cin >> x[i];
  sort(all(x));
  int L = x[0], R = x[n - 1];

  ll ans = 1e9;
  REP(i, L, R + 1){
    ll stamina = 0;
    REP(j, 0, n){
        stamina += (x[j] - i) * (x[j] - i);
    }
    ans  = min(ans, stamina);
  }

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


Measured memory_bytes: 256
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
res=0
i1=0
while(i1<n):
    i2=0
    j=t[i1]+k
    if i1==n-1:
        res+=1
        break
    while(i1+i2<len(t) and t[i1+i2]<=j and i2<c):
        i2+=1
    res+=1
    i1+=i2
print(res)

Measured memory_bytes: 50648
#include <bits/stdc++.h>
#define INF 1e7
#define dsec 86400

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> tii;
typedef tuple<long long int,long long int,long long int> tll;
typedef tuple<double,double,double> tdd;



int main()
{
   ll A,B,K; cin >> A >> B >> K;
   if(A <= K)
   {
       B -= K-A;
       if(B < 0) B = 0;
       A = 0;
       cout << A << " " << B << endl;
   }
   else
   {
       cout << A - K << " " << B << endl;
   }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vector<ll> ba(N + 1, 0), cb(N);
    for(int i = 0; i < N; i++){
        cb[i] = lower_bound(B.begin(), B.end(), C[i]) - B.begin();
        ba[i + 1] = ba[i] + lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    }
    ll total = 0;
    for(int i = 0; i < N; i++){
        total += ba[cb[i]];
    }
    cout << total << endl;
    return 0;

}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

int main(void){

	char a,b;
	cin>>a>>b;
	int c,d;
	c=(int)a;
	d=(int)b;
	if(c>d)
		printf(">\n");
	else if(c<d)
		printf("<\n");
	else
		printf("=\n");
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, x, y;
    cin >> n >> x >> y;
    int c[SIZE] = {};
    for(int i = 1; i < n; ++i) {
        for(int j = i + 1; j <= n; ++j) {
            if(i <= x && y <= j) {
                c[j - i - (y - x - 1)]++;
                continue;
            }
            if(j <= x || i >= y) {
                c[j - i]++;

            } else {
                if(x <= i && j <= y) {
                    int d = j - i;
                    d = min(d, i - x + y - j + 1);
                    c[d]++;

                } else if(x <= i) {
                    int d = j - i;
                    d = min(d, i - x + j - y + 1);
                    c[d]++;

                } else {
                    int d = j - i;
                    d = min(d, x - i + y - j + 1);
                    c[d]++;
                }
            }
        }
    }

    for(int i = 1; i < n; ++i) {
        cout << c[i] << endl;

    }
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
int main(){
  int a,b,c,n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a+b*b==c*c) printf("YES\n");
    else if(a*a+c*c==b*b) printf("YES\n");
    else if(b*b+c*c==a*a) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

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

Measured memory_bytes: 3064
N = gets.to_i
A = gets.split.map(&:to_i)
count = 0
for i in 0...N
  minj = i
  for j in i...N
    if A[j] < A[minj]
      minj = j
    end
  end
  A[i], A[minj] = A[minj], A[i]
  count += 1 if i != minj
end
puts A.join(' ')
puts count



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

typedef struct {
  int ch[11];
  int num;
  int time;
  int tnum;
} lg;
int M,T,R,P;
vector<lg> team;

bool asc(lg t1,lg t2);

int main(){
  int i,j,m,t,p;

  for(i=0;i<51;i++){
    lg x;
    team.push_back(x);
  }
  while(1){
    cin >> M >> T >> P >> R;
    if(M==0&&T==0&&P==0&&R==0)break;
    for(i=0;i<=T;i++){
      team[i].num=0;
      team[i].time=0;
      team[i].tnum=i+1;
      for(j=0;j<=P;j++)team[i].ch[j]=0;
    }
    for(i=0;i<R;i++){
      cin >> m >> t >> p >> j;
      if(j!=0)team[t-1].ch[p]++;
      else{
	team[t-1].time+=20*team[t-1].ch[p];
	team[t-1].num++;
	team[t-1].time+=m;
      }
    }

    sort(team.begin(),team.begin()+T,asc);

    for(i=0;i<T;i++){
      if(i==0)cout << team[i].tnum;
      else if(team[i-1].num==team[i].num&&team[i-1].time==team[i].time)cout << "="<<team[i].tnum;
      else cout << ","<<team[i].tnum;
    }
    cout << endl;
  }
  return 0;
}

bool asc(lg t1,lg t2){
  if(t1.num>t2.num)return 1;
  else if(t1.num==t2.num&&t1.time<t2.time)return 1;
  else if(t1.num==t2.num&&t1.time==t2.time&&t1.tnum>t2.tnum)return 1;
  else return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <utility>
#include <set>
using namespace std;

typedef pair<int, int> pi;

int A, B, C, D, E, F;
set<int> W;
vector<pi> P;

int main(void) {
	cin >> A >> B >> C >> D >> E >> F;
	for (int i = 0; i <= F / (100 * A); ++i) {
		for (int j = 0; j <= F / (100 * B); ++j) {
			int water = 100 * A * i + 100 * B * j;
			if (water > F)
				break;
			W.insert(water);
		}
	}
	set<int>::iterator it;
	for (it = W.begin(); it != W.end(); ++it) {
		int water = *it;
		if (water == 0)
			continue;
		int sugar_max = E * water / 100;
		for (int i = 0; i <= (F - water) / C; ++i) {
			for (int j = 0; j <= (F - water) / D; ++j) {
				int sugar = C * i + D * j;
				if (sugar > sugar_max)
					break;
				if (water + sugar > F)
					break;
				P.push_back(make_pair(water, sugar));
				if (sugar == sugar_max) {
					i = F;
					it = W.end();
					--it;
					break;
				}
			}
		}
	}
	int id = 0;
	double max_val = 0.0;
	for (int i = 0; i < (int)P.size(); ++i) {
		double val = 100.0 * P[i].second / (P[i].first + P[i].second);
		if (val > max_val) {
			max_val = val;
			id = i;
		}
	}

	cout << P[id].first + P[id].second << ' ' << P[id].second << '\n';
	return 0;
}


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

int main(){
    int A,B,i;
    char *S;
    cin >> A >> B;
    S = new char[A+B+1];
    cin >> S;
    for(i=0;i<A;i++){
        if(S[i]=='-'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(S[A]!='-'){
        cout << "No" << endl;
        return 0;
    }
    for(i=1;i<=B;i++){
        if(S[A+i]=='-'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include <algorithm>
using namespace std;
using ll = long long;

typedef pair<ll,ll> P;
 


int main(void){
    string str;
    cin >> str;
    if(str[str.length()-1]=='s'){
        cout <<str<<"es"<<endl;
    }else{
        cout <<str<<"s"<<endl;
    }
}

Measured memory_bytes: 3624
<?php
  fscanf(STDIN, "%d", $n);
  $p = explode(" ", trim(fgets(STDIN)));
  $ans = 0;

  for ($i = 0; $i < $n - 2; $i++) {
    $x = 0;
    if ($p[$i+1] < $p[$i]) $x++;
    if ($p[$i+1] < $p[$i + 2]) $x++;
    if ($x === 1) {
      $ans++;
    }
  }

  echo $ans;


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
using namespace std;
const int mod=1e9+7;
int arr[21][21];
ll dp[21][(ll)1<<21];
int n;
ll add_self(ll &p, ll q)
{
    p+=q;
    if(p>=mod) p-=mod;
}
ll DP(int pos, int bit)
{
    if(pos>=n) return 1;
    if(dp[pos][bit]!=-1) return dp[pos][bit];
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        if(arr[pos][i] && !(bit&(1<<i)))
        {
            ll temp=DP(pos+1, (bit|(1<<i)));
            add_self(ans, temp);
        }
            //ans=(ans+DP(pos+1, (bit|(1<<i))))%mod;
    }
    return dp[pos][bit]=ans;
}
int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            scanf("%d", &arr[i][j]);
    }
    ll ans=DP(0, 0);
    
    
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 344320
s=input()
t=input()
ls,lt=len(s),len(t)
if not set(t)<=set(s):print(-1);exit()
co=0
ind=-1
for i in range(lt):
  ind=s.find(t[i],ind+1)
  if ind==-1:
    ind=s.find(t[i])
    co+=1
print(co*ls+ind+1)

Measured memory_bytes: 3316