akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char S[100050];

int main() {
  scanf("%s", S);
  int cnt[3] = {};
  for (int i = 0; S[i]; ++i) {
    cnt[S[i] - 'a']++;
  }

  const int ma = max({cnt[0], cnt[1], cnt[2]});
  const int mi = min({cnt[0], cnt[1], cnt[2]});
  puts(ma - mi <= 1 ? "YES" : "NO");

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,T;
vector<ll> A;
void input(){
    fast_io();
    cin >> N >> T;
    A = fetch_vec<ll>(N);
}

int solve(){
    priority_queue<ll> pq;
    vector<ll> cnt(N,0);
    map<ll,ll> cal;
    ll ma = 0;
    for (int i = N-1; i >= 0; i--)
    {
        pq.push(A[i]);
        cnt[i] = pq.top()-A[i];
        cal[cnt[i]]++;
        ma = max(ma,cnt[i]);
    }
    cout << cal[ma] << endl;
    
    return 0;
}   

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

Measured memory_bytes: 8820
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define reps(i, start, end) for(int i = start; i < (int)(end); ++i)
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    if(p > q) swap(p, q);
    int cnt = 0;
    do {
        if(p >= q) break;
        cnt++;
    } while(next_permutation(p.begin(), p.end()));
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, a[200010], check[1000010] = {0}, count = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < n; i++)
    {
        if (check[a[i]] > 0)
        {
            check[a[i]] = 2;
            continue;
        }
        else
        {
            for (int j = a[i]; j <= 1000000; j += a[i])
                check[j]++;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (check[a[i]] == 1)
            count++;
    }

    // for (int i = 0; i < 30; i++)
    //     printf("%d %d\n", i, check[i]);

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

Measured memory_bytes: 6416
import java.util.ArrayList;
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args){
		while(true){
			int n = si();
			if(n==0) break;
			ListArray[] lista = new ListArray[30];
			for(int i=0;i<30;i++) lista[i] = new ListArray();
			long[] map = new long[n];
			int res = -1;
			for (int i = 0; i < n; i++) {
				int m = si();
				map[i]=1L<<i;
				for (int j = 0 ;j < m ; j++)
					lista[si()-1].list.add(i);
			}
			for (int i = 0; i < 30; i++) {
				long tmp = 0;
				for (Integer e : lista[i].list)
					tmp |= map[e];
				for (Integer e : lista[i].list)
					map[e]=tmp;
				if(tmp==(1L<<n)-1){
					res = i+1;
					break;
				}
			}
			out.println(res);
		}
		out.flush();
	}
	static int si(){
		return Integer.parseInt(scan.next());
	}
}

class ListArray{
	ArrayList<Integer> list = new ArrayList<Integer>(50);
}

Measured memory_bytes: 69832
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)

def beat_monsters(i, j)
    if A[i] > B[j] 
        tmp = B[j]
        A[i] -= B[j]
        B[j] = 0
        tmp
    else
        tmp = A[i]
        A[i] = 0
        B[j] -= tmp
        tmp
    end
end

ans = 0

for i in 0..N-1 do
    ans += beat_monsters(i, i)
    ans += beat_monsters(i + 1, i) if B[i] > 0
end

puts(ans)

Measured memory_bytes: 17564
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  long long k;
  cin >> n >> k;
  map<int, long long> a;
  for (int i = 0; i < n; i++) {
	int s, t;
	cin >> s >> t;
	if (a.find(s) != a.end()) {
	  a[s] += t;
	}
	else {
	  a.emplace(s, t);
	}
  }
  long long cnt = 0;
  for (auto i = a.begin(); i != a.end(); i++) {
	cnt += i->second;
	if (cnt >= k) {
	  cout << i->first << endl;
	  return 0;
	}
  }

  return 0;
}



Measured memory_bytes: 4224
import math


def resolve():
    A, B, H, M = map(int, input().split())

    degree_H = M * 0.5 + H * 30
    degree_M = M * 6

    if degree_H == 0 or degree_M == 0:
        tmp = max(degree_H, degree_M)
        if tmp > 180:
            degree = abs(180 - tmp)
        else:
            degree = tmp
    else:
        if degree_H <= 180 and degree_M >= 180:
            degree = 360 - degree_M + degree_H
        elif degree_M <= 180 and degree_H >= 180:
            degree = 360 - degree_H + degree_M
        else:
            degree = abs(degree_H - degree_M)

    radian = math.radians(degree)
    cos_AB = math.cos(radian)
    ans = A ** 2 + B ** 2 - 2 * A * B * cos_AB

    print(math.sqrt(ans))


resolve()

Measured memory_bytes: 9536
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    int n, k, board = 1,A,B;
    cin >> n >> k;

    for(int i=0;i<n;i++){
       A = board*2;
       B = board + k;
       if(A<B){
           board = A;
       } else{
           board = B;
       }

    }
    cout << board << endl;
}


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

using namespace std;

int main () {
    string S;

    while (cin >> S) {
        int ok = 1;
        for (int i = 0;i < S.length();i++) {
            if (i%2) {
                if (S[i] == 'R') {
                    ok = 0;
                    break;
                }
            }
            else {
                if (S[i] == 'L') {
                    ok = 0;
                    break;
                }
            }
        }
        if (ok) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    while(~scanf("%d",&N))
    {
        int l,r;
        int ans=0;
        while(N--){
            scanf("%d%d",&l,&r);
            ans+=r-l+1;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int a,b,h;
	cin >> a >> b >> h;
	cout << (a+b)*h/2 <<endl;
	
	return 0;
}

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

using namespace std;
typedef long long LL;

const int maxn = 200000 + 50;
LL nums[maxn], N, pre_sum[maxn], res;

int main()
{
	
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> nums[i];
	
	pre_sum[0] = nums[0];
	for (int i = 1; i < N; i++)
		pre_sum[i] = pre_sum[i - 1] + nums[i];

	LL mini = 0x7fffffff, summ = pre_sum[N - 1];
	for (int i = 0; i < N - 1; i++)
	{
		LL tmp_1 = summ - pre_sum[i];
		LL tmp_2 = pre_sum[i];
		if (abs(tmp_1 - tmp_2) < mini)
		{
			mini = abs(tmp_1 - tmp_2);
		}
	}
	cout << mini << endl;
	return 0;
}

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

typedef struct Point {
	double x;
	double y;
} Point;

typedef struct Vector {
	struct Point point;
	double size;
} Vector;

Point VectorAddition(Point, Point, int);
double Vectormultiplication(Point, Point);
double VectorSize(Point);
double Range(Point, Point);

int main(void) {

	Point point1, point2, point3, ans, k;
	Vector vector1, vector2;
	int q, i, co = 0;

	scanf("%lf %lf %lf %lf %d", &point1.x, &point1.y, &point2.x, &point2.y, &q);

	vector1.point = VectorAddition(point1, point2, 2);
	vector1.size = VectorSize(vector1.point);

	for (i = 0; i < q; i++) {

		scanf("%lf %lf", &point3.x, &point3.y);

		vector2.point = VectorAddition(point1, point3, 2);
		vector2.size = VectorSize(vector2.point);

		if (Range(vector1.point, vector2.point) < 0) {
			ans.x = (fabs(Vectormultiplication(vector1.point, vector2.point)) / pow(vector1.size, 2) * vector1.point.x * -1) + point1.x;
			ans.y = (fabs(Vectormultiplication(vector1.point, vector2.point)) / pow(vector1.size, 2) * vector1.point.y * -1) + point1.y;
		}
		else {
			ans.x = (fabs(Vectormultiplication(vector1.point, vector2.point)) / pow(vector1.size, 2) * vector1.point.x) + point1.x;
			ans.y = (fabs(Vectormultiplication(vector1.point, vector2.point)) / pow(vector1.size, 2) * vector1.point.y) + point1.y;
		}

		printf("%.9lf %.9lf\n", ans.x, ans.y);
	}

	return 0;
}

Point VectorAddition(Point p1, Point p2, int sign) {
	Point point;
	switch (sign) {
	case 1:
		point.x = p2.x + p1.x;
		point.y = p2.y + p1.y;
		break;
	case 2:
		point.x = p2.x - p1.x;
		point.y = p2.y - p1.y;
		break;
	}
	return point;

}

double Vectormultiplication(Point p1, Point p2) {
	Point point;
	double i;
	point.x = p1.x * p2.x;
	point.y = p1.y * p2.y;
	i = point.x + point.y;
	return i;
}

double VectorSize(Point p) {
	return sqrt(pow(p.x, 2) + pow(p.y, 2));
}

double Range(Point p1, Point p2) {
	return Vectormultiplication(p1, p2) / (VectorSize(p1) * VectorSize(p2));
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
int WA[105000];
bool AC[105000];
 
void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for(int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        boolean count[] = new boolean[100001];
        int N = in.nextInt();

        int prev = 0;
        int act = 0;
        for (int i = 0 ; i < N; i++) {
            int inp = in.nextInt();

            if (count[inp]) {
                if (prev == 0) {
                    prev = inp;
                } else {
                    act += 1;
                    prev = 0;
                }
            }

            count[inp] = true;
        }
        if (prev != 0) {
            act += 1;
        }

        out.print(N - act * 2);
    }
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
}


Measured memory_bytes: 31700
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define pb push_back
using namespace std;
const int maxn=1e5+10;
int n,K,x,ans,dep[maxn];vector<int> G[maxn];
void dfs(int u,int fa){
	for(int v:G[u]) dfs(v,u),dep[u]=max(dep[u],dep[v]+1);
	if((u^1)&&(fa^1)&&dep[u]==K-1) ++ans,dep[u]=-1;
}
int main(){
	scanf("%d%d",&n,&K);
	rep(i,1,n){
		scanf("%d",&x);
		if(i==1&&x!=1) ++ans;
		if(i^1) G[x].pb(i);
	}
	dfs(1,0);printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll A,B,C;
    cin >> A >> B >> C;
    ll K; cin >> K;
    if (K % 2 == 0) OUT(A-B)
    else OUT(B-A)

    return 0;
}

Measured memory_bytes: 256
import Data.Functor( (<$>))
import Data.Char( isLower, isUpper, toUpper, toLower)

main = do
    str <- getLine
    let
	toggleCase c
	    |	isLower c = toUpper c
	    |	isUpper c = toLower c
	    |	otherwise = c

    putStrLn $ toggleCase <$> str



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

using namespace std;

long long q, h, s, d, n, res;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    cin >> q >> h >> s >> d;
    cin >> n;
    h = min(h, q * 2);
    s = min(s, h * 2);
    s = min(s, q * 4);
    d = min(d, s * 2);
    d = min(d, h * 4);
    d = min(d, q * 8);
    res = (n / 2) * d;
    n %= 2;
    res += n * s;
    cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int i,j,k,n;
	cin >> n;
	float count=0.0,g;
	float a[n];
	for(i=0;i<n;i++){cin >> a[i];
	}
	for(i=0;i<n;i++){
		count=count+(1/(a[i]));
	}
	g=1/(count);
	printf("%6f",g);
	return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
m=[]
for i in range(a,min(a+k,b+1)):
    m.append(i)
for i in range(max(b-k+1,a),b+1):
    m.append(i)
l=set(m)
ll=list(l)
lll=sorted(ll)
for i in range(len(lll)):
    print(lll[i])


Measured memory_bytes: 38256
import sys
from collections import defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    h = LI()

    dict = defaultdict(set)
    for _ in range(m):
        a, b = MI()
        dict[a].add(b)
        dict[b].add(a)

    c = n
    for k, v in dict.items():
        for t in v:
            if h[t - 1] >= h[k - 1]:
                c -= 1
                break

    print(c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 107600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,ans=1; bool start=false, up;
  cin >>N >>a;
  for(int i=1; i<N; i++){
    int b; cin>>b;
    if(start==false){
      if(a<b) up=true, start=true;
      else if(a>b) up=false, start=true;
      a=b;
    }
    else{
      if(a<b && up==false) ans++, up=true, start=false;
      else if(a>b && up==true) ans++, up=false, start=false;
      a=b;
    }
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
import sys
N,M = map(int,input().split(' '))
A = set([int(sys.stdin.readline()) for _ in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 0 if 1 in A else 1

for i in range(2,N+1):
  dp[i] = 0 if i in A else (dp[i-2] + dp[i-1]) % (10**9+7)
print(dp[N])
  

Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
int func(long long a){
  int ans = 0;
  string A = to_string(a);
  for(int i=0;i<A.size();i++){
    int p = A.at(i) - '0';
    ans+=p;
  }
  return ans;
}
int main(){
  long long N;
  cin>>N;
  int p = func(N);
  if(N%p==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll n;   cin >> n;
    vector<vector<ll>> p(n, vector<ll>(10)), cost(n, vector<ll>(11));

    rep(i, n)   rep(j, 10) cin >> p[i][j];
    rep(i, n)   rep(j, 11) cin >> cost[i][j];
    ll res=-LINF;
    for(int bit=1; bit<(1<<10); bit++){
        ll sum=0;
        vector<ll> open(n, 0);
        rep(i, 10){
            if(bit & 1<<i){
                rep(j, n)   open[j] += p[j][i];
            }
        }
        
        rep(j, n)   sum += cost[j][open[j]];    
        res = max(res, sum);
        
    }
    cout << res << endl;
}


Measured memory_bytes: 3632
from numpy.linalg import solve
X, Y = map(int, input().split())

left=[[1,1],[2,4]]
right=[X,Y]

a=solve(left,right)

if a[0] >=0 and a[1] >= 0 and a[0].is_integer() and a[1].is_integer():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27360
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << "x";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s;
        cin >> s;
        //cout << s << endl;
        long long sum = 0;
        for(int i = 0; i < s.length(); i++){
                sum += s[i]-48;
        //      cout << sum << endl;
        }
        if(sum % 9 == 0) puts("Yes");
        else puts("No");
}

Measured memory_bytes: 3696
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, B, K = map(int, readline().split())
    if K < A:
        print(A - K, B)
    elif K < A + B:
        print(0, A + B - K)
    else:
        print(0, 0)

    return


if __name__ == '__main__':
    main()


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

using namespace std;

vector<int> prime;
bool isPrime[1000001];

void erats(){
	fill(isPrime,isPrime+1000001,true);
	isPrime[0]=false;
	isPrime[1]=false;
	for(int i = 2; i < 1000000; i++){
		if(isPrime[i]){
			prime.push_back(i);
			for(int j = i*2; j < 1000000; j+=i){
				isPrime[j]=false;
			}
		}
	}
}

int main(){

	erats();
	int n;
	while(cin>>n&&n!=0){
		long long sum=0;
		for(int i = 0; i < n; i++){
			sum+=prime[i];
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
vector<LL> g[200010];
LL kosuu[200010];
LL n;

LL beki(LL a,LL b)
{
	if(b==0)return 1;
	LL x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

LL inv(LL a)
{
	return beki(a,MOD-2);
}

LL add(LL a,LL b){
  return (a+b)%MOD;
}

LL prod(LL a,LL b){
  return (a*b)%MOD;
}

LL dfs(LL v,LL p){
  kosuu[v]++;
  for(LL w:g[v]){
    if(w==p)continue;
    else kosuu[v]+=dfs(w,v);
  }
  return kosuu[v];
}

int main(){
  cin>>n;
  for(LL i=0;i<n-1;i++){
    LL a,b;cin>>a>>b;a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0,-1);
  
  LL sum=0;
  for(LL i=0;i<n;i++){
    LL pe=1;
    vector<LL> hoge;
    for(LL w:g[i]){
      if(kosuu[w]>=kosuu[i])continue;
      hoge.push_back(kosuu[w]);
    }
    if(i!=0)hoge.push_back(n-kosuu[i]);
    
    for(LL h:hoge){
      pe=add(pe,beki(2,h)-1);
    }
    //cout<<prod(po,beki(2,n-kosuu[i])-1)<<endl;
    sum=add(sum,add(beki(2,n-1),MOD-pe));
  }
  cout<<prod(sum,inv(beki(2,n)))<<endl;
  return 0;
}

Measured memory_bytes: 19712
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint A,B;
    cin >> A >> B;
    cout << A*B << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

#include<queue>

using namespace std;

struct NODE
{

};

int main() {

	int r, d, x;
	cin >> r >> d >> x;

	int tmp = x;
	for (int i = 0; i < 10; i++)
	{
		if (i != 0)
		{
			cout << endl;
		}
		tmp = r * tmp - d;
		cout << tmp;
	}

	return 0;
}




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

#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

long long res;

int main (int argc, char const* argv[]) {
  string raw;
  string map = "IVXLCDM";
  const int weight[7] = {1,5,10,50,100,500,1000};
  while (cin>>raw) {
    res = 0;
    rep(i,7) rep(j,raw.size()) if (raw[j] == map[i]) {
      raw[j] = '0' + i;
    }
    char prev = '8';
    rep(i,raw.size()) {
      if (prev < raw[i]) {
        res += weight[raw[i] - '0'] - weight[prev - '0'] * 2;
        //puts("why");
      } else {
        res += weight[raw[i] - '0'];
      }
      prev = raw[i];
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

/*long sigma(long N){
  long Sum=0;
  long K = 1;
  do{
    Sum += K;
  }while(K++<N);

    return Sum;
    }*/
int gcd(int a,int b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}

int main(){
  int Num,Non;
  long Sum =0;
  std::cin >> Num;
  
  for(int i=1;i<=Num;i++){
    for(int j=1;j<=Num;j++){
      for(int k=1;k<=Num;k++){
	
	if(i == k){
	  if(i == j)
	    Sum += i;	  
	  else
	    Sum += gcd(i,j);
	}
	else
	  if(i == j)
	  Sum += gcd(i,k);
	  else{
	    Non = gcd(k,j);
	    Sum += gcd(Non,i);
	  }
	//std::cout << i << " " << j << " " << k << std::endl;
      }
    }
  }
  std::cout << Sum << std::endl;
  return 0;
}


Measured memory_bytes: 3620
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll x,y; cin>>x>>y;
  if(y%2){
    cout<<"No"<<endl;
    return 0;
  }
  if(2*x <= y && y <= 4*x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
    int n;
    cin >> n;
    int h[n+10], dp[n+10];
    for(int i=0; i<n; i++){
        cin >> h[i] ;
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++){
    		dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }
    
    cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
#include <cstring>

using namespace std;
#define fi first
#define se second

const int maxn = 223456;


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

pii a[maxn];
int ad[maxn], mi[maxn];
int main(){
    // freopen("input.txt", "r", stdin);
    ll r, d, x;
    cin>>r>>d>>x;
    int T = 10;
    while(T--){
        x = r * x - d;
        cout<<x<<endl;
    }
    return 0;
}

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

typedef long long ll;
#define M 1000000007

int main(){
	
	int n;
	cin>>n;
	
	string a;
	string b;
	
	cin>>a>>b;
	
	string ans;
	for(int i=0;i<n;i++){
		cout<<a[i]<<b[i];
	}
	
	
	
}

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

int main() {
    int a, b, c, d;
    int i, k=0;
    cin >> a >> b >> c >> d;
    for (;;) {
        c -= b;
        if (c <= 0) {
            k = 1;
            break;
        }
        a -= d;
        if (a <= 0) {
            k = 2;
            break;
        }
    }
    if (k == 1)cout << "Yes" << endl;
    else if (k == 2)cout << "No" << endl;
}

Measured memory_bytes: 3636
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Console.ReadLine();
		var N = S.Length / 2;
		for (var n = N - 1; n >= 1; n--)
		{
			var flag = true;
			for (var i = 0; flag && i < n; i++) flag &= S[i] == S[i + n];
			if (flag)
			{
				Console.WriteLine(2 * n);
				break;
			}
		}
	}
}


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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    cout << ((a * b) - (a + b - 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	while(1){
		int x,y;
		scanf("%d %d\n",&x,&y);
		if(x==0 && y==0){
			break;
		}else{
			if(x>y){
				int k;
				k = x;
				x = y;
				y = k;
				printf("%d %d\n",x,y);
			}else{
				printf("%d %d\n",x,y);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int x,y;
    cin>>x>>y;
    x--;y--;
    vi a={0,2,0,1,0,1,0,0,1,0,1,0};
    cout<<(a[x]==a[y]?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 2e5 + 10, oo = 1e9 + 100;
vector < int > way;
int p[N];
bool f[N];
void solve(){
	ll n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; ++i)cin >> p[i];
	int j = 1;
	while(!f[j]){
		way.push_back(j);
		f[j] = 1;
		j = p[j];
	}
	int ind = 0;
	for(int i = 0; i < way.size(); ++i){
		if(way[i] == j)ind = i;
	}
	int cnt = way.size() - ind;
	if(k <= ind){
		cout << way[k] << '\n';
		return;
	}
	k -= ind;
	k %= cnt;
	cout << way[ind + k] << '\n';
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 5252
import math

a,b,x=map(int,input().split())
half = a*b*a/2

tan1=(b*b*a)/(2*x)
tan2=(2*b/a) - 2*x/(a**3)

if x>=half:
    print(math.degrees(math.atan(tan2)))
else:
    print(math.degrees(math.atan(tan1)))

Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
bool is(string s, string rs){
    rep(i, s.size()){
        if(s[i] != rs[i]){
            return false;
        }
    }
    return true;
}
int main(void){
    ld l;
    cin >> l;

    cout << fixed << setprecision(10) << pow(l/3.0, 3.0) << endl;


    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++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(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2){
        cout << b-a << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}

Measured memory_bytes: 3536
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 2e5;

int n, m;

int main() {
	scanf("%d%d", &n, &m);
	int a = n + m;
	bool flag = 0;
	if(n % 3 == 0 || m % 3 == 0 || a % 3 == 0) flag = 1;
	if(flag) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 128
import sys
from pprint import pprint
from collections import Counter
from math import factorial

memo = {}
def ncr(n, r):
    if r > n:
        return 0
    key = "_".join(map(str, (n, r)))
    if key in memo:
        return memo[key]

    ans = factorial(n) // factorial(r) // factorial(n - r)
    memo[key] = ans
    return ans

N = int(sys.stdin.readline().strip())
A = list(sys.stdin.readline().strip().split())

counter = Counter(A)
sum_ans = 0
for key in counter:
    sum_ans += ncr(counter[key], 2)

for a_i in A:
    print(sum_ans - ncr(counter[a_i], 2) + ncr(counter[a_i] - 1, 2)) 

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

int main(void){

  int a,b,c,d;
  cin >>a >>b >>c ;
  
  if (a > b){
    d = a;
    a = b;
    b = d;
  }
  if(b > c){
    d = b;
    b = c;
    c = d;
  }
  if(b < a){
    d = a;
    a = b;
    b = d;
  }
  
  cout <<a <<" " <<b <<" " <<c <<"\n";
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  int a,b;
  cin>>a>>b;
  rep(i,1000){
    double x=(double)i+1.0;
    if((int)(0.08*x)==a){
      if((int)(0.1*x)==b){
        cout<<x;return;
      }
    }
  }
  cout<<-1;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	//cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

class Program {
	static void Main() {
		var a = Console.ReadLine();
		var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Array.Sort(b);
		int cnt = 0;
		for(int i = 0;i < b.Length;i += 2) {
			cnt += Math.Min(b[i],b[i + 1]);
		}
		Console.WriteLine(cnt);
	}
}

Measured memory_bytes: 3032
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, m) = readListOfLong() 

    val ans = if(n * 2L <= m) n + (m - n * 2L) / 4L else m / 2L
    println(ans)

    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37908
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007


void solve(void)
{ 
  string str;
  cin>>str;
  int index = 0;
  while (true)
  {
    if(str.substr(index,11) == "dreameraser")
    {
      index += 11;
    }
    else if(str.substr(index,10) == "dreamerase")
    {
      index += 10;
    }
    else if(str.substr(index,7) == "dreamer")
    {
      index += 7;
    }
    else if(str.substr(index,5) == "dream")
    {
      index += 5;
    }
    else if(str.substr(index,6) == "eraser")
    {
      index += 6;
    }
    else if(str.substr(index,5) == "erase")
    {
      index += 5;
    }
    else
    {
      index = -1;
      break;
    }

    if(index == str.size())
    {
      break;
    }
    else if(index > str.size())
    {
      break;
    }

  }
    if(index == (int)str.size())
    {
      cout<<"YES"<<endl;
    }
    else
    {
      cout<<"NO"<<endl;
    }
  return;
  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string s, t;
    cin >> s >> t;
    SORT(s);
    SORT(t);
    REVERSE(t);
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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



int main(void){
    int H,W,D;
    scanf("%d %d %d",&H,&W,&D);
    int cost[D][H*W/D+1];
    int x[H*W];
    int y[H*W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        int nari;
        scanf("%d",&nari);
        x[nari-1]=j;
        y[nari-1]=i;
    }
    for(int i=0;i<D;i++)for(int j=0;i+j*D<H*W;j++){
        if(j==0)cost[i][0]=0;
        else cost[i][j]=cost[i][j-1]+abs(x[i+j*D]-x[i+(j-1)*D])+abs(y[i+j*D]-y[i+(j-1)*D]);
    }
    int Q;
    scanf("%d",&Q);
    int ans=0;
    for(int i=0;i<Q;i++){
        int L,R;
        scanf("%d %d",&L,&R);
        L--;
        R--;
        ans+=cost[R%D][R/D]-cost[L%D][L/D];
        printf("%d\n",ans);
        ans=0;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a,b;cin>>a>>b;
  int ans=1001;
  for(int i=1;i<1001;i++){
    bool fl=false;
    if((int)(i*0.08)==a && (int)(i*0.1)==b) fl=true;
    if(fl) chmin(ans,i);
  }
  if(ans<=1000){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s, t;
	cin >> s >> t;
	
	int ans = 1e9;
	int sn = (int)s.size();
	int tn = (int)t.size();
	
	for(int i = 0; i < sn - tn + 1; ++i) {
		int cnt = 0;
		for(int j = 0; j < tn; ++j) {
			if( s[i + j] != t[j] ) cnt++;
		}
		
		ans = min(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3640
n = int(input())
a=[]
for i in range(1,int(n**0.5)+1):
    if  n%i == 0:
        a.append([i,n//i])
b = 10**14
for i in range(len(a)):
    b = min(b,(a[i][0]-1)+(a[i][1]-1))
print(b)

Measured memory_bytes: 3464
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int main()
{
	long long n=io::G();
	int ans=0,fl=1;
	while(n>=10)
	{
		ans+=9;
		if(n%10!=9)fl=0;
		n/=10;
	}
	if(fl)printf("%d\n",ans+n);
		else printf("%d\n",ans+n-1);
	return 0;
}



Measured memory_bytes: 128