akhauriyash/Code-Regression huggingface dataset:
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 m = Integer.parseInt(sc.next());
        long[][] ab = new long[n][2];
        long[][] cd = new long[m][2];
        for (int i = 0; i < n; i++) {
            ab[i][0] = Long.parseLong(sc.next());
            ab[i][1] = Long.parseLong(sc.next());
        }
        for (int i = 0; i < m; i++) {
            cd[i][0] = Long.parseLong(sc.next());
            cd[i][1] = Long.parseLong(sc.next());
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            long idx = Long.MAX_VALUE;
            long sub = Long.MAX_VALUE;
            for (int j = 0; j < m; j++) {
                long temp = Math.abs(cd[j][0] - ab[i][0]) + Math.abs(cd[j][1] - ab[i][1]);
                if (temp < sub) {
                    sub = temp;
                    idx = j;
                }
            }
            sb.append(idx + 1);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

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

int main() {


//int n,h,w;
//int *num=new int[4];
char *s=new char[4];
cin >> s;
int res=0;
for(int i=0;i<4;i++){
if(s[i]=='2')res++;
//cout << s[i] << endl;
}

cout << res << endl;



}


Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int,input().split()))

sum_a = 0
for i in range(n):
    sum_a += a[i]

if sum_a == x:
    print(n)
elif sum_a < x:
    print(n - 1)
else:
    a.sort()
    count = 0
    while True:
        if x >= a[count]:
            x -= a[count]
            count += 1
        else:
            break
    print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
namespace Flandle_Scarlet
{
    #define N 1010
    #define MEM(x,a) memset(x,a,sizeof(x))
    #define CLS(x) memset(x,0,sizeof(x))
    int n,m;
    int a[N][N];
    void R1(int &x)
    {
        x=0;char c=getchar();int f=1;
        while(c<'0' or c>'9') f=(c=='-')?-1:1,c=getchar();
        while(c>='0' and c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        x=(f==1)?x:-x;
    }
    void Input()
    {
        R1(n),R1(m);
        for(int i=1;i<=n;++i)
        {
            for(int j=1;j<=m;++j)
            {
                R1(a[i][j]);
            }
        }
    }

    struct node
    {
        int id;//identifier
        int cnt;//favourite count
    }sport[N];bool operator<(node a,node b){return a.cnt>b.cnt;}
    bool vis[N];
    void Soviet()
    {
        //choose all
        for(int i=1;i<=n;++i)
        {
            ++sport[a[i][1]].cnt;
            sport[i].id=i;
        }

        int ans=0x3f3f3f3f;
        for(int i=1;i<=m;++i)
        {
            sort(sport+1,sport+m+1);
            //sport[1] have the max cnt
            ans=min(ans,sport[1].cnt);

            vis[sport[1].id]=1;//delete the most popular sport
            CLS(sport);
            for(int i=1;i<=m;++i)
            {
                sport[i].id=i;
            }
            for(int i=1;i<=n;++i)//for each player
            {
                for(int j=1;j<=m;++j)//find the favourite sport in all remaining sport
                {
                    if (!vis[a[i][j]])
                    {
                        ++sport[a[i][j]].cnt;
                        break;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    void IsMyWife()
    {
        if (0)
        {
            freopen("","r",stdin);
            freopen("","w",stdout);
        }
        Input();
        Soviet();
    }
};
int main()
{
    Flandle_Scarlet::IsMyWife();
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>

using namespace std;

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

int dp[201][200];

int main() {
  int d, n;
  cin >> d >> n;
  int t[d], a[n], b[n], c[n];
  rep (i, d) cin >> t[i];
  rep (i, n) cin >> a[i] >> b[i] >> c[i];
  rep (i, d - 1) rep (j, n) if (a[j] <= t[i + 1] && t[i + 1] <= b[j]) rep (k, n) if (a[k] <= t[i] && t[i] <= b[k]) {
	dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + (int)abs(c[j] - c[k]));
      }
  int res = 0;
  rep (i, n) res = max(res, dp[d - 1][i]);
  cout << res << endl;
}

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

int main(){
  string a;
  cin >> a;
  int flag = 0;
  if(a.length()%2==1){cout<< "No" << endl;
      return 0;}
  for(int i=0; i<a.length(); i++){
    if(i%2==0 && a[i]=='h'){continue;}
    if(i%2==1 && a[i]=='i'){continue;}
    else{
      cout<< "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/12  Problem: 080_abc_d / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	int CC;
	cin >> N >> CC;
	VVI cum(CC, VI(200005, 0));
	FOR(i, 0, N) {
		int a, b, c; cin >> a >> b >> c;
		a *= 2;
		b *= 2;
		a--;
		c--;
		cum[c][a]++;
		cum[c][b]--;
	}
	FOR(c, 0, CC)FOR(i, 0, 200005)cum[c][i + 1] += cum[c][i];
	FOR(c, 0, CC)FOR(i, 0, 200005)if (cum[c][i])cum[c][i] = 1;

	int ans = 0;
	FOR(i, 0, 200005) {
		int ret = 0;
		FOR(c, 0, CC) {
			ret += cum[c][i];
		}
		ans = max(ans, ret);
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 24576
A,B,C,X,Y = map(int,input().split())
ans = 10**10
for k in range(max(X,Y)+1):
    i = max((X-k),0)
    j = max((Y-k),0)
    price = A*i + B*j + C*2*k
    ans = min(ans,price)

print(ans)

Measured memory_bytes: 9060
h,w = map(int,input().split())
A = [input() for i in range(h)]
AnsH=[]
for i in range(h):
    if "#" in A[i]:
        AnsH.append(i)
AnsW=[]
for i in range(w):
    c = 0
    for j in range(h):
        if A[j][i]=="#":
            c = 1
    if c == 1:
        AnsW.append(i)
for i in AnsH:
    for j in AnsW:
        print(A[i][j],end="")

    print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,X;
  cin>>N>>X;
  vector<int> A(50),B(50);
  A[0]=1;B[0]=1;
  for(int i=1;i<50;i++)
    A[i]=A[i-1]*2+3,B[i]=B[i-1]*2+1;
  int ans=0;
  for(int i=N-1;i>=0;i--){
    if(X>A[i]+1)
      ans++;
    ans+=X/(A[i]+1)*B[i];
    X=X%(A[i]+1)-1;
    if(X<=0)
      break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
def main
  t = gets.chomp.to_i
  (1..t).each do |ca|
    edge = gets.chomp.split(/\s/).collect { |x| x.to_i}
    edge = edge.sort
    if edge[0] ** 2 + edge[1] ** 2 == edge[-1] ** 2
      puts "YES"
    else
      puts "NO"
    end
  end
end

main

Measured memory_bytes: 6116
function main(input) {
    var size, s = new Set(), i, tmp, yes=true;
    tmp = input[0].split("");
    size = tmp.length;
    for(i=0; i<size; i++){
        if(s.has(tmp[i])){
            yes = false;
        }
        s.add(tmp[i]);
    }
    console.log(yes ? "yes" : "no");
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 9032
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	m := getInt()

	if n >= m/2 {
		fmt.Println(m / 2)
	} else {
		fmt.Println((n + m/2) / 2)
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <iostream>

using namespace std;
typedef long long ll;

int MAX = 10000000;

int main(){
    int n,a,b,xmin=MAX,ymin=MAX,xmax=0,ymax=0,ans=0,ans2=0,c,d;
    vector<int> X,Y;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        
        X.push_back(a+b);
        Y.push_back(a-b);
        
        xmin=min(xmin,a+b);
        ymin=min(ymin,a-b);
        xmax=max(xmax,a+b);
        ymax=max(ymax,a-b);
    }
    
    for(int i=0;i<n;i++){
        c = max(xmax-X[i],Y[i]-ymin);
        d = max(X[i]-xmin,ymax-Y[i]);
        
        ans=max(ans,min(c,d));
        
    }
    
    for(int i=0;i<n;i++){
        c = max(xmax-X[i],ymax-Y[i]);
        d = max(X[i]-xmin,Y[i]-ymin);
        
        ans2=max(ans2,min(c,d));
        
    }
    
    printf("%d\n",min(ans,ans2));
    
    return 0;
}

Measured memory_bytes: 2140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int calc(int a, int k){
    // cout << a << " " << k << endl;
    if (a < k) return 0;
    if (a % k == 0) return a / k;
    int x = a / k + 1;
    return calc(a - (a % k + a / k) / x * x, k); 
}

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

    int gr = 0;

    REP(i,n){
        int a, k;
        cin >> a >> k;
        gr ^= calc(a, k);
    }

    cout << (gr == 0 ? "Aoki" : "Takahashi") << endl;

    return 0;
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

  
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;

}

Measured memory_bytes: 21720
#include <stdio.h>
#include <iostream>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DFOR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

struct Card{
    char suit;
    int value;
};

void bubbleSort(Card *A, int n)
{
    REP(i, n)
    {
        DFOR(j, n-1, i)
        {
            if (A[j].value < A[j-1].value)
            {
                swap(A[j], A[j - 1]);
            }
        }
    }
}

void selectionSort(Card *A, int n)
{
    int mini;
    REP(i, n)
    {
        mini = i;
        FOR(j, i, n)
        {
            if (A[j].value < A[mini].value)
            {
                mini = j;
            }
        }
        swap(A[i], A[mini]);
    }
}

void printArray(Card *A, int n)
{
    REP(i, n)
    {
        cout << A[i].suit << A[i].value;
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

int isStable(Card *C1, Card *C2, int n)
{
    REP(i, n)
    {
        if (C1[i].suit != C2[i].suit)
            return 0;
    }
    return 1;
}

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

    Card C1[101], C2[101];
    REP(i, n)
    {
        cin >> C1[i].suit >> C1[i].value;

        C2[i].suit = C1[i].suit;
        C2[i].value = C1[i].value;
    }

    bubbleSort(C1, n);
    selectionSort(C2, n);

    printArray(C1, n);
    cout << "Stable" << endl;
    printArray(C2, n);
    if (isStable(C1, C2, n))
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    
    }
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
    int L,M1,M2,sum,i,month;

    while(1){
        sum=0;
        month=0;
        scanf("%d",&L);
        if(L==0)
            break;
        for(i=0;i<12;i++){
            scanf("%d %d",&M1,&M2);
            sum+=M1-M2;
            if(sum>=L&&month==0){
                month=i+1;
            }
        }
        if(month>0&&month<=12)
            printf("%d\n",month);
        else
            puts("NA");
    }
    return 0;
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll a[200000];
int main(){

	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}

	sort(a,a+n);

	ll maxi = 0;
	REP(i,n - 1) {
		if(min(a[maxi],a[n - 1] - a[maxi]) < min(a[i],a[n - 1] - a[i])) {
			maxi = i;
		}
	}
	cout << a[n - 1] << " " << a[maxi] << endl;
	return 0;
}


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

int main() {
  long long X, Y; cin >> X >> Y;
  
  int ans = 0;
  
  while(X<=Y) {
    X *= 2;
    ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
using namespace std;

int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> x(n), y(n), a(n);
	for (int i = 0; i < n; i++) {
		cin >> x.at(i) >> y.at(i) >> a.at(i);
	}
	int minX = 0;
	int minY = 0;
	int maxX = w;
	int maxY = h;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			minX = max(minX, x[i]);
		}
		else if (a[i] == 2) {
			maxX = min(maxX, x[i]);
		}
		else if (a[i] == 3) {
			minY = max(minY, y[i]);
		}
		else if (a[i] == 4) {
			maxY = min(maxY, y[i]);
		}
	}
	if (minX > maxX || minY > maxY) {
		cout << 0 << endl;
	}
	else {
		cout << (maxX - minX) * (maxY - minY) << endl;
	}
}


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

long long search(long long r, long long c) {
	long long low = -1, high = 100ll * c;
	while(high - low > 1) {
		const long long mid = (low + high) / 2;
		if(r * mid / 100ll >= c) {
			high = mid;
		}
		else {
			low = mid;
		}
	}

	return high;
}

inline long long f(long long x, long long r, long long c) {
	return (r * x / 100 - c) * 100 / r;
}

int main() {
	long long M, rD, rR, cD, cR;
	cin >> M >> rD >> rR >> cD >> cR;

	long long minXD = search(rD, cD);
	long long minXR = search(rR, cR);

	long long ans = -1;

	if(minXD + minXR <= M) {
		for(int i = 0; i < 100; ++i) {
			for(int j = 0; j < 100; ++j) {
				const long long payD = minXD + i;
				const long long payR = minXR + j;
				const long long rest = M - payD - payR;
				if(rest < 0)
					continue;

				ans = max(ans, rest + f(payD, rD, cD) + f(payR, rR, cR));
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

#define MAX 200100
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void fact() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    fact();
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll ans=0;
    for(ll i=0;i<=B-1;++i){
        ans-=comb(W-2-i+A,A-1)*comb(H-A-1+i,i)%MOD;
        ans=(ans+MOD)%MOD;
    }
    ans+=comb(H+W-2,W-1);
    ans%=MOD;
    prt(ans)
    return 0;
}


Measured memory_bytes: 4992
function Main(input) {

    var n = parseInt(input);

    if ((n % 2) === 0) {
        console.log(n);
    } else {
        console.log(n * 2);
    }
    console.log();
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int a,b;
    cin>>a>>b;
    set<int> st;
    rep(i,3) st.insert(i+1);
    st.erase(a);
    st.erase(b);
    cout<<*begin(st);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
#include<assert.h>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const int N=310;
int a[N][N];
int b[N][N];
int s1[N][N];
int n,m;
void rotate()
{
	memset(b,0,sizeof b);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			b[j][n-i+1]=a[i][j];
	swap(n,m);
	memcpy(a,b,sizeof a);
}
ll gao1()
{
	memset(s1,0,sizeof s1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			s1[i][j]=a[i][j]+s1[i-1][j-1];
	ll res=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=2;i+k-1<=n&&j-k+1>=1&&i-1+m-j>=k-1;k++)
				if(a[i+k-1][j]&&a[i][j-k+1])
				{
					ll temp=0;
					temp+=(j+k-1>m?s1[i-(j+k-1-m+1)+1][m]:s1[i][j+k-1]);
					temp-=(i-k+1<1?s1[0][j-(i-k+1)+1-1]:s1[i-k][j-1]);
					res+=temp;
				}
	return res;
}
ll gao2()
{
	ll res=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=2;i+k-1<=n&&j+k-1<=m&&j-k+1>=1;k++)
				if(a[i][j-k+1]&&a[i][j+k-1]&&a[i+k-1][j])
					res++;
	return res;
}
char str[N];
ll ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		
		for(int j=1;j<=m;j++)
			a[i][j]=(str[j]=='#');
	}
	ans+=gao1();
	ans-=gao2();
	rotate();
	ans+=gao1();
	ans-=gao2();
	rotate();
	ans+=gao1();
	ans-=gao2();
	rotate();
	ans+=gao1();
	ans-=gao2();
	rotate();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int dp[1000002];

int solve(int n){
  if(n == 1) return 0;
  if(dp[n] != -1) return dp[n];

  return dp[n] = (solve(n%2==0 ? n/2 : n*3+1) + 1);
}

int main(){
  int n;
  memset(dp,-1,sizeof(dp));

  while(cin>>n,n){
    cout<<solve(n)<<endl;
  }
}

Measured memory_bytes: 0
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
module Main (main) where
import qualified Data.IntSet as IS
import Control.Monad
import Control.Applicative
main :: IO ()
main = do
  n <- read <$> getLine
  as <- replicateM n $ read <$> getLine
  print $ solve as
{-# INLINE solve #-}
solve :: [Int] -> Int
solve as = IS.size $ foldl f IS.empty as
  where
    f s e = case IS.lookupGE e s of
      Just ix | e < ix     -> IS.insert e $ IS.delete ix s
              | otherwise -> s
      Nothing -> IS.insert e s

Measured memory_bytes: 68652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
                for(int i=0;i<H;i++){
                    for(int j=0;j<W;j++){
                        if(j==0 || i==0 ||j==W-1 ||i==H-1){
                        System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
        } 
          sc.close();
    }

}


Measured memory_bytes: 59212
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0

for i in reversed(range(N)):
  if A[i+1] > B[i]:
    ans += B[i]
  else:
    ans += A[i+1]
    B[i] -= A[i+1]
    if A[i] > B[i]:
      ans += B[i]
      A[i] -= B[i]
    else:
      ans += A[i]
      A[i] = 0
print(ans)

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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define vll vector<ll>
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define db(x) cout << '>' << #x << ':' << x << endl;
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
#define MOD 1000000007
const ll N = 2e5;

int main()
{
    speed;
    double l;
    cin>>l;
    cout.precision(20); cout<<fixed; 
    cout<<2*PI*l<<endl;
    return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
//#include <cmath.h>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

int main() {
  int N; // 変数の宣言
  cin >> N; // 標準入力
  vector<int> h(N);
  rep(i,N){
  cin >> h.at(i);
  }
  vector<int> cost(N);
  rep(i,N){
  cost.at(i) = -1;
  }
  cost.at(0) =0;
  cost.at(1) = abs(h.at(1)-h.at(0));
  for(int i=2;i<N;i++){
  cost[i]= min (cost.at(i-2) +abs(h.at(i)-h.at(i-2)),
               (cost.at(i-1)+abs(h.at(i)-h.at(i-1))));
  }
 
  
  cout << cost.at(N-1)<< endl; // 標準出力
}

Measured memory_bytes: 1024
function main()
  
  (N, M) = map(x -> parse(Int, x), split(readline()))
  H = map(x -> parse(Int, x), split(readline()))
  
  check = zeros(Int, N)
  for i in 1:M
    (A, B) = map(x -> parse(Int, x), split(readline()))
    check[A] = max(check[A], H[B])
    check[B] = max(check[B], H[A])
  end
  
  ans = 0
  
  for i in 1:N
    if H[i] > check[i]
      ans += 1
    end
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 201300
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

int n, w;
ll arr[110][2];
ll dp[110][100010];

void solve(){
    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            if(arr[i-1][0] > j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j], arr[i-1][1] + dp[i-1][j-arr[i-1][0]]);
            }
        }
    }

    cout<<dp[n][w]<<endl;
}

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    cin>>n>>w;
    for(int i=0; i<n; i++){
        cin>>arr[i][0]>>arr[i][1];
    }
    solve();

    return 0;
}


Measured memory_bytes: 79360
#include<cstdio>
#include<cmath>
#include<algorithm>
#define MAXN 100006
using namespace std;
int n,x[MAXN],d[MAXN][30],L,Q,l,r,m;
int find(int p)
{
	int l=0,r=n;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(x[mid]<=p) l=mid;
		else r=mid-1;
	}
	return l;
}
int cont(int l,int r)
{
	int re=0;
	int cnt=0;
	while(l!=r)
	{
		while(d[l][cnt]<r)
			cnt++;
		while(d[l][cnt]>=r)
			cnt--;
		cnt=max(cnt,0);
		re+=1<<cnt;
		l=min(d[l][cnt],r);
	}
	return re;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	scanf("%d",&L);
	scanf("%d",&Q);
	for(int i=1;i<=n;i++)
		d[i][0]=find(x[i]+L);//lower_bound(x+1,x+1+n,x[i]+L)-x;
	/*for(int i=1;i<=n;i++)
		printf("%d ",d[i][0]);*/
	for(int j=1;(1<<j)<=n*2;j++)
		for(int i=1;i<=n;i++)
			d[i][j]=d[d[i][j-1]][j-1];
	for(int i=1;i<=Q;i++)
	{
		scanf("%d%d",&l,&r);
		if(l>r) swap(l,r);
		printf("%d\n",cont(l,r));
	}
}

Measured memory_bytes: 12800
///help nisi bujar jnne youtube +blog
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
// string x(w.size(),'1');
#define MAX 100005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007

 ll value[MAX],weight[MAX];
 ll dp[MAX][105];
int main()
{
 //O_O ;
 ll n,w;cin>>n>>w;
 for(ll i=0;i<n;i++){
    cin>>weight[i]>>value[i];
 }
  //  dp[0][0]=0;
memset(dp,0,sizeof(dp));
for(ll j=1;j<=w;j++)
     {

 for(ll i=0;i<n;i++)
 {
       dp[j][i]=dp[j][i-1];
         if(j>=weight[i]){
            dp[j][i]=max(dp[j][i],dp[j-weight[i]][i-1]+value[i]);
            //cout<<dp[j][i]<<nn;
         }
     }
 }
 cout<<dp[w][n-1]<<nn;



    return 0;
}


Measured memory_bytes: 85620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	ll a, b;
	cin >> a >> b;

	if (a * b == 0 || a * b < 0) co("Zero");
	else if (a > 0 && b > 0) co("Positive");
	else if ((a + b) % 2) co("Positive");
	else co("Negative");



	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    std::cin >> s >>t;
    int cnt=0;
    for (int i = 0; i < 3; i++) {
        if(s[i]==t[i]){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
}


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

processes = [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]]


elapsed_time = 0
while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time)

Measured memory_bytes: 24372
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		System.out.println(solve());
	}
 
	public static int solve() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		return 6 - A - B;
	}
}

Measured memory_bytes: 21332
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long x;
    cin >> x;
    long long ans = 0;
    ans += x / 500 * 1000;
    x = x % 500;
    ans += x / 5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
    *Makacha
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const int inf = 1e9;
const int mod = 1e9 + 7;
const int N = 111;

int n, m, res, a[N][N], dx[N][N];
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif //makacha
    read(n);
    read(m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            a[i][j] = readch() == '#';
    queue <ii> q, t;
    q.push(ii(1, 1));
    while (q.size()) {
        if (a[q.front().fi][q.front().se])
            res++;
        while (q.size()) {
            int d = q.front().fi,
                c = q.front().se;
            q.pop();
            if (d == n && c == m)
                return cout << res, 0;
            if (d < n && !dx[d + 1][c]) {
                if (a[d + 1][c] == a[d][c])
                    dx[d + 1][c] = 1,
                    q.push(ii(d + 1, c));
                else
                    dx[d + 1][c] = 1,
                    t.push(ii(d + 1, c));
            }
            if (c < m && !dx[d][c + 1]) {
                if (a[d][c + 1] == a[d][c])
                    dx[d][c + 1] = 1,
                    q.push(ii(d, c + 1));
                else
                    dx[d][c + 1] = 1,
                    t.push(ii(d, c + 1));
            }
        }
        while (t.size()) {
            q.push(t.front());
            t.pop();
        }
    }
}


Measured memory_bytes: 384
s = str(input())
n = len(s)

ans = 0
for i in range(n):
    for j in range(i,n):
        # ACGTに、sの一文字cが当てはまる場合1
        # それをsの文字ごとにループして調査する
        # すべてのsの文字が当てはまるなら、ansにsの長さを代入する
        if all('ACGT'.count(c) == 1 for c in s[i:j+1]):
            ans = max(ans, j-i+1)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;


void solve(){
  string x, y; cin >> x >> y;
  if(x < y) cout << "<\n";
  else if(x > y) cout << ">\n";
  else cout << "=\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI stp,edp;
VI dir;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,l,t;
  cin>>n>>l>>t;
  stp.resize(n);
  dir.resize(n);
  in totl=0;
  forn(i,n){
    cin>>stp[i]>>dir[i];
    if(dir[i]==1){
      ++totl;
      edp.PB((stp[i]+t)%l);
    }
    else{
      --totl;
      edp.PB(((stp[i]-t)%l+l)%l);
    }
  }
  in chtotcor=totl*t;
  sort(all(edp));
  in chi=0;
  forv(i,stp){
    chi+=(edp[i]-stp[i]);
  }
  chtotcor-=chi;
  chtotcor%=n*l;
  chtotcor+=n*l;
  chtotcor%=n*l;
  assert(chtotcor%l==0);
  in cofs=chtotcor/l;
  forn(i,n)
    cout<<edp[(i+cofs)%n]<<"\n";
  
  return 0;
}

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

int main(){
	int N,L,min(300),sum,min_idx;
	cin >> N >> L;
	for(int i(1);i<N+1;++i){
		if(min>abs(L+i-1)){
			min = abs(L+i-1);
			min_idx = i;
		}
		sum += L+i-1;
	}
	cout << sum - (L+min_idx-1) << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto b = scanString.count!"a=='9'"!=0;
  if(b)end("Yes");end("No");
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,char> PIIC;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOREACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)

#define MOD 1000000007
#define INF 2000000000

int GI(LL& x) { return scanf("%lld", &x); }

vector<string> pat = { "dreamer", "eraser", "erase", "dream"};

bool solve(string buf) {
    int last = 0;
    bool flag = false;

    while (last < buf.length()) {
//	cout << buf.substr(last, buf.length()) << last << "\n";
	bool found = false;

	FORN(i, 4) {
//	    cout << "          finding " << pat[i] << ": " << (int)buf.find(pat[i], last) << " vs " << last<< "\n";
	    if (buf.find(pat[i], last) == max(last, 0)) {
//		cout << pat[i] << ": " << pat[i].length() << "\n";
		last += pat[i].length();
		found = true;
		break;
	    }
	}
	if (!found) {
	    if (flag) return false;

	    if (buf[last-3] == 's') last -= 0;
	    else last -= 2;

	    flag = true;
	    if (last < 0) return false;
	} else {
	  flag = false;
	}
    }
    return true;
}

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

    if (solve(buf)) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

    int s = sc.nextInt();
    int w = sc.nextInt();

    if (w >= s) {
      System.out.println("unsafe");
    } else {
      System.out.println("safe");
    }
  }
}


Measured memory_bytes: 35828
# coding: utf-8
# Your code here!

S = input()
T = input()

# print(S)
# print(T)

count = 0

for i in range(3):
    # print(S[i])
    # print(T[i])
    
    if S[i] == T[i]:
        count += 1
        
print(count)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}
#define   pi       2*acos(0.0)
#define   inf      (int)1e18
const int mod =    1e9 + 7, mxn =    2e5 + 5;

#define   vt       vector
#define   ff       first
#define   ss       second
#define   int      long long
#define   db       long double
#define   pii      pair<int,int>
#define   Maxpq(x) priority_queue<x>
#define   Minpq(x) priority_queue<x,vt<x>,greater<x>>

#define   pb       push_back
#define   si(x)    (int)x.size()
#define   all(x)   x.begin(),x.end()
#define   mem(a,x) memset(a,x,sizeof(a))
#define   rep(n)    for(int i =0 ; i<n ; i++)
#define   forr(i,n) for(int i=0;i<n;i++)
#define   FOR(a)   for(auto& x :  a )

template <typename T>
T power(T base, T exp, T modulus) {
	base %= modulus;
	T result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % modulus;
		base = (base * base) % modulus;
		exp >>= 1;
	}
	return result;
}

int mainx() {
	int n;
	cin >> n;
	if ( n < 2)
	{
		cout << 0 << endl;
	}
	else if ( n == 2)
	{
		cout << 2 << endl;
	}
	else
	{
		int ans = 0;
		int x , y , z;
		x = power<int>(10 , n , mod);
		y = power<int>(9 , n , mod);
		z = power<int>(8 , n , mod);
		y = 2 * y;
		y %= mod;
		ans = (x - y + z + mod) % mod;
		cout << ans << endl;
	}

	return 0;
}


bool cmp(pii &a , pii &b) {
	if (a.ff < b.ff)return true;
	if (a.ff == b.ff )return a.ss < b.ss;
	return false;
}
inline void INCLUDE() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
}
int32_t main() {

	//INCLUDE();

	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		// cout<<"Case #"<<t<<": ";
		mainx();
	}
	return 0 ;
}



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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k<=a){
    cout << k;
  }else if(k<=a+b){
    cout << a;
  }else{
    cout << a+(-1)*(k-a-b);
  }
}

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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
	cin >> n;
	if (n < 105)
	{
		cout << 0 << endl;
		return 0;
	}
	int counter = 0;
	for(int i = 105 ; i<=n ; i++)
	{
		int divisors = 0;
		if(i%2!=0)
		{
			for(int j = 1 ; j<=i ; j++)
			{
				if(i % j == 0)
					divisors++;
			}
			if(divisors >= 8 )
				counter++;
		}

	}
	cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  int flag[10]={};
  flag[a]++;
  flag[b]++;
  flag[c]++;
  if(flag[5]==2&&flag[7]==1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  double H, M;
  cin >> H >> M;
  
  double pi = 3.14159265358979323846;
  
  double Hc = H * 30 + M / 2;
  double Mc = 6 * M;
  double thetad = min(Hc-Mc, 360-(Hc-Mc));
  //cout << thetad << endl;
  double theta = thetad * pi / 180;
  //cout << theta << endl;
  double cm = A*A + B*B - 2*A*B*cos(theta);
  double C = sqrt(cm);
  
  cout << fixed << setprecision(20) << C << endl;

}

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

using namespace std;

int main(){
    int n;
    map < string , int > cnt;
    cin >> n;
    while(n--){
        string x;
        cin >> x;
        cnt[x]++;
    }
    cout << "AC x " << cnt["AC"] << "\n";
    cout << "WA x " << cnt["WA"] << "\n";
    cout << "TLE x " << cnt["TLE"] << "\n";
    cout << "RE x " << cnt["RE"] << "\n";

}


Measured memory_bytes: 3632
public fun readln() = readLine()!!
public fun readlnByte() = readln().toByte()
public fun readlnShort() = readln().toShort()
public fun readlnInt() = readln().toInt()
public fun readlnLong() = readln().toLong()

const val mod = (1e9 + 7).toLong()

fun main() {
    val N = readlnLong()
    var ans = (powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N) ) % mod
    ans = (ans + mod ) % mod
    println("%d".format(ans))
}

fun powmod(x: Long, y: Long): Long {
    var res: Long = 1
    for (i in 0 until y) {
        res = (res * x) % mod
    }
    return res
}

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

int main() {
  int N;
  cin >> N;
  vector<int> raw_number(N);
  for(int i=0; i<N ; i++){
    cin >> raw_number.at(i);
  }
  
  int k = 1;//現在の数字
  int c = 0;//潰すレンガの数
  int i = 0;//繰り返す数
  while(i<N){
    if(raw_number.at(i) == k)
      k++;
    else
      c++;
    i++;
  }
  if(c == N)
    cout << -1 << endl;
  else 
    cout << c << endl;
}

Measured memory_bytes: 1024