akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char A[11],B[11],C[11];
    int flag=0;
    cin>>A>>B>>C;
    int l1=strlen(A);
    int l2=strlen(B);
    int l3=strlen(C);
    if(A[l1-1]==B[0] && B[l2-1]==C[0])
    {
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
  long N,a,i;
  int c=0;
  
  scanf("%ld",&N);
  
  for(i=0;i<N;i++) {
    scanf("%ld",&a);
    if(a%2==1) c=1;
  }
  
  if(c==1) printf("first\n");
  else printf("second\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        // 針の角度
        double hour = (h % 12 * 30) + (m * 0.5);
        double minute = m * 6;
        double kakudo = Math.max(hour, minute) - Math.min(hour, minute);
        if (180 < kakudo) {
            kakudo = 360 - kakudo;
        }

        // 辺の長さ
        double numA = Math.pow(a, 2);
        double numB = Math.pow(b, 2);
        double numC = 2 * a * b * Math.cos(Math.toRadians(kakudo));
        double result = Math.sqrt(numA + numB - numC);

        // 出力
        System.out.println(result);
    }
}


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

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

  int tmp;
  vector< vector<int> > XY(N);
  for (int i = 0; i < N; i++) {
    cin >> tmp; XY[i].push_back(tmp);
    cin >> tmp; XY[i].push_back(tmp);
  }

  int prevmod, mod;
  prevmod = (XY[0][0] + XY[0][1]) % 2 != 0;
  for (int i = 1; i < N; i++) {
    mod = (XY[i][0] + XY[i][1]) % 2 != 0;
    if (mod != prevmod) {
      cout << -1 << endl;
      return 0;
    }
    prevmod = mod;
  }

  vector<long> D;
  if (mod == 0) {
    D.push_back(1);
  }
  for (int i = 0; i < 32; i++) {
    D.push_back(pow(2, i));
  }
  reverse(D.begin(), D.end());

  int m = D.size();
  cout << m << endl;
  for (int i = 0; i < m - 1; i++) {
    cout << D[i] << ' ';
  }
  cout << D[m - 1] << endl;

  for (int i = 0; i < N; i++) {
    long x = XY[i][0];
    long y = XY[i][1];
    for (int j = 0; j < m; j++) {
      if (0 < x + y && 0 < x - y) {
        cout << 'R';
        x -= D[j];
      } else if (0 < x + y && x - y <= 0) {
        cout << 'U';
        y -= D[j];
      } else if (x + y <= 0 && x - y <= 0) {
        cout << 'L';
        x += D[j];
      } else {
        cout << 'D';
        y += D[j];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 512
#include<stdio.h>
#define M 1000001
char p[M]={1,1};
int main(){
  int i,j,n;
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n),n){
    j=0;
    for(i=3;i<=n/2;i+=2){
      if(p[i]+p[n-i]==0)j++;
    }
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()

int main(void){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	sort(A.rbegin(),A.rend());
	long long ans = 0;
	if(N%2==0){
		for(int i=0;i<N;i++){
			if(i== (N/2)-1){
				ans += A[i];
			}else if(i== (N/2)){
				ans -= A[i];
			}else if(i < (N/2)){
				ans += 2*A[i];
			}else ans -= 2*A[i];
		}
	}else{
		long long res1 = 0;
		for(int i=0;i<(N/2)-1;i++)res1 += A[i]*2;
		res1 += A[(N/2)-1] + A[N/2];
		for(int i=(N/2)+1;i<N;i++)res1 -=A[i]*2;
		
		long long res2 = 0;
		for(int i=0;i<N/2;i++)res2 += A[i]*2;
		res2 -= A[N/2] + A[(N/2)+1];
		for(int i= (N/2)+2;i<N;i++)res2 -= A[i]*2;
		ans = max(res1,res2);
	}
	cout << ans << endl;
}

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

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

  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N = 1;
    int ans[100000];
   cin >> N;
   for(int i = 1;i < N + 1;i++){
       int h = 0;
       cin >> h;
       ans[h] = i;
   }
   for(int i = 1;i < N + 1;i++)
   cout << ans[i] << " ";
}


Measured memory_bytes: 1152
#include<cstdio>
int main()
{
    long long n,k,x,y;
    scanf("%lld%lld%lld%lld",&n,&k,&x,&y);
    if(n>=k)
        printf("%lld",k*x+(n-k)*y);
    else
        printf("%lld",n*x);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
const long double PI = acos(-1);

int n,k,v[100006],s,mx;

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i=1;i<=k;i++){
        cin >> v[i];
        s += v[i];
        mx = max(mx, v[i]);
    }
    cout << max(0, 2*mx-s-1) << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;
ll mod = 1000000007;
#define f first
#define s second
#define ss string
#define mp make_pair
#define pb push_back
#define p pair<int, int>
#define pp pair<int, p>
#define v vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<p>
#define vpp vector<pair<int, p>>
#define vv vector<v>
#define vvl vector<vl>
#define vvp vector<vp>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repa(i, a, n) for(int i = a; i <= (n); ++i)
#define repd(i, n) for(int i = n; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    v a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(all(a));
    ll sum = 0;
    rep(i, k){
        sum += a[i];
    }
    cout << sum;
    return 0;
}   

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;

ll can_div_count(ll n){
    ll count = 0;
    while(n > 1){
        n = n/2;
        count++;
    }
    return count;
}


int main(void){
    FAST_IO
    
    ll n;
    cin >> n;
    n--;
    string s = "";
    bool out = false;
    while(n >= 0){
        if(n == 0) {out = true;}
        char c= (char)('a' + (n % 26));
        s = c + s;
        if(out) break;
        n /= 26;
        n--;
    }
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 3108
def gets_HW_char
  h, w = gets.split.map(&:to_i)
  board = h.times.map { gets.chomp.chars }
  return h, w, board
end

H, W, c = gets_HW_char

H.times do |i|
  W.times do |j|
    count = 0
    (-1..1).each do |di|
      (-1..1).each do |dj|
        if di==0 && dj==0
          # c[i][j] の処理
        elsif 0 <= i + di && i + di < H && 0 <= j + dj && j + dj < W
          # c[i + di][j + dj] の処理
          count += 1 if c[i + di][j + dj] == "#"
        else
          # 範囲外のときの処理
        end
      end
    end
    # c[i][j] の処理
    c[i][j] = count.to_s if c[i][j] != "#"
  end
end

c.each do |e|
  puts e.join
end


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

    int ptn = S.size() - 1;
    int64_t sum = 0;
    for (int tmp = 0; tmp < (1 << ptn); tmp++) {
        bitset<11> bs(tmp);
        //cout << bs << endl;

        if (bs.count() == 0) {
            sum += stol(S);
            //cout << "cnt=0:" << sum << endl;
        }
        else {
            int cnt = 0;
            for (int i = 0; i < S.size(); i++) {
                if (bs.test(i) == 1) {
                    string x = S.substr(cnt, i - cnt + 1);
                    int n = stoi(x);
                    cnt = i + 1;
                    sum += n;
                    //cout << "else sum:" << sum << endl;
                }

                if (i == S.size() - 1) {
                    string x = S.substr(cnt, S.size() - cnt + 1);
                    int n = stoi(x);
                    sum += n;
                    //cout << "last sum:" << sum << endl;
                }
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int dp[100002];
vector<int> graph[100002];


int dfs(int i)
{
    if (dp[i] != -1)
    {
        return dp[i];
    }

    int result = 0;
    for (int j = 0; j < graph[i].size(); j++)
    {
        result = max(result, dfs(graph[i][j]) + 1);
    }

    return dp[i] = result;
}

int main()
{
    int n, m, x, y;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));


    int result = 0;
    for (int i = 0; i < n; i++)
    {
        result = max(result, dfs(i));
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 11436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String result = "";

		for (int i = 0; i < 3000; i++) {
			String line = sc.nextLine();
			String[] n = line.split(" ");
			int a = Integer.parseInt(n[0]);
			int b = Integer.parseInt(n[1]);
			if (a == 0 && b == 0) {
				break;
			} else if (a <= b) {
				System.out.println(a + " " + b);
			} else if (a > b) {
				System.out.println(b + " " + a);
			}

		}

	}

}


Measured memory_bytes: 34960
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = 0;
    rep(x, 1e4)
    {
        rep(i, N)
        {
            if (a[i] >= N)
            {
                ll del = a[i] / N;
                ans += del;
                a[i] -= del * N;
                rep(j, N) if (i != j) a[j] += del;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int l,ll,k,bit,c;
int main(){
    scanf("%d", &l);
    ll = l; while(ll) k++, ll /= 2;
    bit = __builtin_popcount(l) - 1;
    printf("%d %d\n",k,2*(k-1)+bit);
    c = 1<<(k-1);
    for(int i = k-2; i >= 0; i--){
        printf("%d %d %d\n",i+1,i+2,1<<i);
        printf("%d %d %d\n",i+1,i+2,0);
        if((1<<i)&l){
            printf("%d %d %d\n",i+1,k,c);
            c += 1<<i;
        }
    }
}

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

typedef struct tag_ab{
    int a,b;
}aandb;

int comp(const void *x,const void *y){
    return ((aandb*)x)->a - ((aandb*)y)->a;
}

int main(void){
    int n;
    long long k;
    scanf("%d %lld",&n,&k);
    aandb a_b[n];
    for(int i = 0;i < n;i++)scanf("%d %d",&a_b[i].a,&a_b[i].b);
    qsort(a_b,n,sizeof(aandb),comp);
    int ind = 0;
    while(k - a_b[ind].b > 0){
        k -= a_b[ind].b;
        ind++;
    }
    printf("%d",a_b[ind].a);
    return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	ll ans = 0;
	rep(i, n) {
		ans += a[i] - 1;
	}
	cout << ans << endl;
	return 0;
}













Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
  
signed main(){
  int n;
  cin >> n;
  int a[n-1],b[n-1];
  for(int i=0;i<n-1;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  int c[n];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(c,c+n);
  reverse(c,c+n);
  int count[n]={};
  for(int i=0;i<n-1;i++){
    count[a[i]]++;
    count[b[i]]++;
  }
  int root=-1;
  for(int i=0;i<n;i++){
    if(count[i]==1) root=i;
  }
  int ans=0;
  for(int i=1;i<n;i++){
    ans+=c[i];
  }
  cout << ans << endl;
  int ret[n]={};
  int k=1;
  ret[root]=c[0];
  while(k<n){
    for(int i=0;i<n-1;i++){
      if(ret[a[i]]>0&&ret[b[i]]==0){
        ret[b[i]]=c[k];
        k++;
      }
      if(ret[b[i]]>0&&ret[a[i]]==0){
        ret[a[i]]=c[k];
        k++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << ret[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define	LL long long
using namespace std;

template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

int n,P,f[5005][5005][2];
#define upd(x) x >= P ? x -= P : 0
int main(){
	int i,j,k; int m;
	read(n),read(P); m=(n-1)/2;
	if (n==1){cout<<1%P<<endl;return 0;}
	for (i = 0; i <= m; ++i) f[0][i][0] = f[0][i][1] = 1;
	for (i = 1; i <= n; ++i)
	for (j = 1; j <= m; ++j){
		//f[i][j][0] f[i][j][1]
		
		f[i][j][0] += f[i][j-1][1],upd(f[i][j][0]);
		if (i >= j) f[i][j][0] += f[i-j][j][0],upd(f[i][j][0]);
		f[i][j][1] = f[i][j][0];
		if (i >= j) f[i][j][1] += f[i-j][j][1],upd(f[i][j][1]);
		/*
		f[i][j][1] += f[i][j-1][0],upd(f[i][j][1]);
		if (i >= j) f[i][j][1] += f[i-j][j][1],upd(f[i][j][1]);
		f[i][j][0] = f[i][j][1];
		if (i >= j) f[i][j][0] += f[i-j][j][0],upd(f[i][j][0]);*/
	}
	if (n%2==1){
		LL ans = 0;
		for (i = 1; i <= n; ++i)
		for (j = 0; j * (m+1) <= n-i; ++j) ans += f[n-i-j*(m+1)][m][1];
		ans %= P;
		cout << ans << endl;
		return 0;
	}
	LL ans = 0;
	for (i = 1; i <= n; ++i)
	for (j = 0; j * (m+1) <= n-i; ++j) ans += 1ll * f[n-i-j*(m+1)][m][1] * (j+1) % P;
	ans %= P;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 194560
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

typedef complex<double> Point;
const static double EPS = 1e-12;

int main(){
  string expr;
  int bob_ans;
  while(cin >> expr >> bob_ans){
    vector<char> ope;
    vector<int> ope_pos;
    vector<int> nums;
    for(int i = 0; i< expr.size();i++){
      if(isdigit(expr[i])){
        int sum = 0;
        while(i < expr.size() && isdigit(expr[i])){
          sum *= 10;
          sum += expr[i] - '0';
          i++;
        }
        nums.push_back(sum);
        i--;
      }
      else if(expr[i] == '+'){
        ope.push_back(expr[i]);
        ope_pos.push_back(i);
      }
      else if(expr[i] == '*'){
        ope.push_back(expr[i]);
        ope_pos.push_back(i);
      }
    }

    vector<int> multi_first_num(nums);
    vector<char> order;
    order.push_back('*');
    order.push_back('+');

    bool used[1001];
    memset(used,false,sizeof(used));

    for(int order_i = 0; order_i < order.size(); order_i++){
      for(int i = 0; i < ope.size();i++){
        if(order[order_i] == ope[i]){
          int res = 0;
          if(ope[i] == '*') res = multi_first_num[i] * multi_first_num[i+1];
          if(ope[i] == '+') res = multi_first_num[i] + multi_first_num[i+1];

          for(int j = i+1; j < multi_first_num.size(); j++){
            multi_first_num[j] = res;
            if(j == multi_first_num.size() || !used[j]) break;
          }
          for(int j = i; j >= 0; j--){
            multi_first_num[j] = res;
            if(j == 0 || !used[j - 1]) break;
          }

          used[i] = true;
        }
      }
    }


    vector<int> left2right_num(nums);
    memset(used,false,sizeof(used));

    for(int i = 0; i < ope.size();i++){
      int res = 0;
      if(ope[i] == '*') res = left2right_num[i] * left2right_num[i+1];
      if(ope[i] == '+') res = left2right_num[i] + left2right_num[i+1];
      
      for(int j = i+1; j < left2right_num.size(); j++){
        left2right_num[j] = res;
        if(j == left2right_num.size() || !used[j]) break;
      }
      for(int j = i; j >= 0; j--){
        left2right_num[j] = res;
        if(j == 0 || !used[j - 1]) break;
      }
      used[i] = true;
    }

    if(bob_ans == multi_first_num[0]
       && bob_ans != left2right_num[0]){
      printf("M\n");
    }
    else if(bob_ans != multi_first_num[0]
            && bob_ans == left2right_num[0]){
      printf("L\n");
    }
    else if(bob_ans == multi_first_num[0]
            && bob_ans == left2right_num[0]){
      printf("U\n");
    }
    else{
      printf("I\n");
    }
  }    
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define PI (3.14159265358979323846)
#define ld long double
#define int long long
#define MOD 998244353
#define w(x) int x; cin >> x; while(x--)
#define F first
#define S second
#define PB push_back
     
const char nl = '\n';
const int N = 1e5 + 5;
    


void solve(){

    int a, b, c, d; cin >> a >> b >> c >> d;

    int q = a*c;
    int w = a*d;
    int r = b*c;
    int t = b*d;

    cout << max(t, max(q, max(w, r))) << nl;


}


int32_t main(){
         
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    
    
     
    return 0;
    
             
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
	int n;
	float s, t, a[3];
	
	while(1){
		cin >> a[0] >> a[1] >> a[2];
		if(a[0] == 0){
			break;
		}
		sort(a, a+3);
		cin >> n;
		s = sqrt((a[1]*a[1])+(a[0]*a[0]));
		s /= 2;
		for(int i = 0; i < n; i++){
			cin >> t;
			if(t > s){
				cout << "OK" << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>
using namespace std;
int main(){
	int p[10];
	for(int i=0;i<2;i++){
		for(int j=0;j<10;j++)cin>>p[j];
		sort(p,p+10);
		if(i)cout<<" ";
		cout<<p[7]+p[8]+p[9];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,k;
int h[100005];
int dp[100005];

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for(int j=2;j<=k&&j<i;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	printf("%d\n",dp[n]);
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	long double x[52];
	long double y[52];
	for(ll i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	ll cnt=0;
	long double lx=0;
	long double rx=1002.0;
	while(cnt<=99){
		cnt++;
		long double x1=(lx*2+rx)/3;
		ll cnt2=0;
		long double ly=0;
		long double ry=1002.0;
		long double Ans1=0;
		while(cnt2<=99){
			cnt2++;
			long double y1=(ly*2+ry)/3;
			long double ans1=0;
			for(ll i=0;i<n;i++){
				long double now=(x1-x[i])*(x1-x[i])+(y1-y[i])*(y1-y[i]);
				now=sqrt(now);
				ans1=max(now,ans1);
			}
			long double y2=(ly+ry*2)/3;
			long double ans2=0;
			for(ll i=0;i<n;i++){
				long double now=(x1-x[i])*(x1-x[i])+(y2-y[i])*(y2-y[i]);
				now=sqrt(now);
				ans2=max(now,ans2);
			}
			if(ans1<ans2){
				ry=y2;
			}
			else{
				ly=y1;
			}
			if(cnt2==100){
				Ans1=min(ans1,ans2);
			}
		}
		
		long double x2=(lx+rx*2)/3;
		cnt2=0;
		ly=0;
		ry=1002;
		long double Ans2=0;
		while(cnt2<=99){
			cnt2++;
			long double y1=(ly*2+ry)/3;
			long double ans1=0;
			for(ll i=0;i<n;i++){
				long double now=(x2-x[i])*(x2-x[i])+(y1-y[i])*(y1-y[i]);
				now=sqrt(now);
				ans1=max(now,ans1);
			}
			long double y2=(ly+ry*2)/3;
			long double ans2=0;
			for(ll i=0;i<n;i++){
				long double now=(x2-x[i])*(x2-x[i])+(y2-y[i])*(y2-y[i]);
				now=sqrt(now);
				ans2=max(now,ans2);
			}
			if(ans1<ans2){
				ry=y2;
			}
			else{
				ly=y1;
			}
			if(cnt2==100){
				Ans2=min(ans1,ans2);
			}
		}
		if(Ans1<Ans2){
			rx=x2;
		}
		else{
			lx=x1;
		}
		if(cnt==100){
			long double fa=min(Ans1,Ans2);
			printf("%.10Lf",fa);
		}
	//	printf("%.10Lf\n",Ans1);
	//	printf("%.10Lf\n\n",Ans2);
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3700
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var n = sc.NextLong();
        long a = sc.NextLong();
        long b = sc.NextLong();
        if (a + b == 0)
        {
            Console.WriteLine(0);
            return;
        }

        long d = n / (a + b);

        long ans = d * a;

        long m = n % (a + b);

        ans += Math.Min(m, a);
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#define ll long long

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	for (int i=0; i<s.size(); i++) {
		if (s[i] == '7') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 3648
import Control.Monad
import Control.Applicative
import Data.List


  
main :: IO ()
main = do
  input <- getLine
  let uuu = map read (words input ) :: [Integer] 
  putStrLn (solve (abs (head uuu)) (head (tail uuu)) (head (tail (tail uuu))))



--solve :: Integer -> Integer -> Integer  -> String

solve qX qK qD = show (max (min ((((qK*qD)-qX)) `mod` (qD+qD)) (qD+qD-((((qK*qD)-qX)) `mod` (qD+qD))))  (qX-(qK*qD)))






Measured memory_bytes: 4104
#include <iostream>
#include <string>
typedef long long LL;
using namespace std;
const int mod = 1000000007;


int main() {
//    freopen("test.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    string s1,s2;
    cin >> s1 >> s2;
    LL ret = 1;
    int ava = 3;
    for (int i = 0; i < n; i++) {
        if (s1[i] == s2[i]) {
            ret = (ret * ava) % mod;
            ava = 2;
        }
        else {
            if (ava == 1) ret = (ret*3) % mod;
            else if (ava == 2) ret = (ret*2) % mod;
            else ret = (ret*6) % mod;
            ava = 1;
            i++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
# include <stdio.h>

int main() {
  int n, count = 0, mh = 0, a;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a >= mh) {
      count++;
      mh = a;
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
L = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    L[a].append(b)
    L[b].append(a)

ans = [0 for _ in range(N+1)]
now = [1]
next = []

while len(now):
    for x in now:
        for y in L[x]:
            if (ans[y] == 0):
                ans[y] = x
                next.append(y)
    now = next.copy()
    next = []

print("Yes")
for x in range(2, N+1):
    print(ans[x])


Measured memory_bytes: 101732
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <list>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    ll n,k; cin>>n>>k;
    vector<ll> A(n);
    REP(i,n)cin>>A[i];
    
    ll minv=A[0];
    map<ll,ll> diff;
    for(int i=1;i<n;i++){
        if(diff.find(A[i]-minv)==diff.end())diff[A[i]-minv]=1;
        else diff[A[i]-minv]++;
        minv=min(minv,A[i]);
    }
    
    vector< pair<ll,ll> > ans;
    for(auto itr=diff.begin();itr!=diff.end();itr++){
        ans.push_back(make_pair(itr->first,itr->second));
    }
    
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    
    cout<<ans[0].second<<endl;
    
    return 0;
}




Measured memory_bytes: 9464
object Main extends App {
  val N = io.StdIn.readLine().toInt
  val d = io.StdIn.readLine().split(" ").map(_.toInt)
  val sortedD = d.sortBy(identity)
  val mid = N / 2
  val a1 = sortedD(mid - 1)
  val a2 = sortedD(mid)
  println(a2 - a1)
}

Measured memory_bytes: 58184
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int r, c;
        r = scan.nextInt();
        c = scan.nextInt();
        int a[][] = new int[r + 1][c + 1];
        for(int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                a[i][j] = scan.nextInt();
                a[r][j] += a[i][j];
                a[i][c] += a[i][j];
                a[r][c] += a[i][j];
            }
        }
        for(int i = 0; i < r + 1; i++){
            for(int j = 0; j < c + 1; j++){
                System.out.print(a[i][j]);
                if(j == c) System.out.println();
                else System.out.print(" ");
            }
        }
    }
}



Measured memory_bytes: 42688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll solve() {
	var(int, n);
	vec(ll, a, n);
	sort(all(a));
	int c0 = n / 2 - 1, c1 = n / 2, c2 = n / 2 + 1;
	if (n & 1) {
		ll ans = 0;
		rep(i, 0, c0) {
			ans -= a[i] * 2;
		}
		rep(i, c2 + 1, n) {
			ans += a[i] * 2;
		}
		return ans - a[c0] + a[c2] + max(-a[c0] + a[c1], - a[c1] + a[c2]);
	}
	ll ans = - a[c0] + a[c1];
	rep(i, 0, c0) {
		ans -= a[i] * 2;
	}
	rep(i, c1 + 1, n) {
		ans += a[i] * 2;
	}
	return abs(ans);
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int H, W;
string S[100];

int cnt[26] ={};

signed main(){
	cin >> H >> W;
	rep(i, H) cin >> S[i];

	rep(i, H){
		rep(j, W){
			cnt[S[i][j]-'a']++;
		}
	}
	if(H%2 == 0 && W%2 == 0){
		rep(i, 26){
			if(cnt[i]%4 != 0){
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	if(H%2 == 1 && W%2 == 0){
		int two = 0;
		rep(i, 26){
			if(cnt[i]%4 == 2){
				two++;
			}
			if(cnt[i]%2 != 0){
				cout << "No" << endl;
				return 0;
			}
		}
		if(two <= W/2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	if(H%2 == 0 && W%2 == 1){
		int two = 0;
		rep(i, 26){
			if(cnt[i]%4 == 2){
				two++;
			}
			if(cnt[i]%2 != 0){
				cout << "No" << endl;
				return 0;
			}
		}
		if(two <= H/2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	if(H%2 == 1 && W%2 == 1){
		int one = 0;
		int two = 0;
		rep(i, 26){
			if(cnt[i]%4 == 2){
				two++;
			}
			if(cnt[i]%4 == 1){
				one++;
			}
			if(cnt[i]%4 == 3){
				one++;
				two++;
			}
		}
		if(one <= 1 && two <= H/2 + W/2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int n;
        cin >> n;

        int count = 0;
        auto process = [](int n) {
            auto s = to_string(n);
            if (s.size() == 1) {
                return n;
            }
            int max_ = 0;
            for (int j = 0; j < s.size() - 1; ++j) {
                auto l = stoi(s.substr(0, j + 1));
                auto r = stoi(s.substr(j + 1));
                max_ = max(max_, l * r);
            }
            return max_;
        };
        while (true) {
            if (0 <= n && n <= 9) {
                break;
            }
            else if (n < 0) {
                count = -1;
                break;
            }
            n = process(n);
            count += 1;
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3288
N = int(input())

L = list(map(int,input().split()))
ans = 0
for a in L:
    for b in L:
        for c in L:
            if  a not in [b,c] and b != c:
                if abs(a-b) < c and a+b >c:
                    # print("a",a,b,c)
                    ans += 1
print(ans//6)

Measured memory_bytes: 9176
import java.util.*;
 
 
class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i=0; i<A.length; i++)  A[i] = sc.nextInt();
        int flag = 0;
        //a[i-1] < a[i] == 1 a[i-1] > a[i] == -1
        int n = 1;
        for(int i=1; i<A.length; i++){
            int cmp = 0;
            if(A[i-1] < A[i]){
                cmp = 1;
            } else if(A[i-1] > A[i]) {
                cmp = -1;
            }      
            if(flag*cmp < 0){
                flag = 0;
                n++;
                continue;
            }
            if(cmp!=0) flag = cmp;
        }
       
        System.out.println(n);

    }
}

Measured memory_bytes: 50024
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
using namespace std;
typedef long long int ll;

template<class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF = 1LL << 60;

int main() {
  int N, K, h[100010];
  ll dp[100010];
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> h[i];
  for (int i = 0; i < N; i++) dp[i] = INF;
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      chmin(dp[i], dp[max(i-j, 0)] + abs(h[i] - h[max(i-j, 0)]));
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string S;
	cin >> S;

	int tmp = int(S[0] - '0') * 100 + int(S[1] - '0') * 10 + int(S[2] - '0');

	int rsl = abs(753 - tmp);
	rep(i, 0, S.length() - 3) {
		tmp -= int(S[i] - '0') * 100;
		tmp *= 10;
		tmp += int(S[i + 3] - '0');
		rsl = min(rsl, abs(753 - tmp));
	}

	cout << rsl << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main(){
    int n; cin >> n;
    cout << (n+1)/2;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const n = parseInt(input[0].split(" ")[0], 10);
  const P = input[1].split(" ").map(p => parseInt(p, 10));
  var count = 0;

  for (var i = 0; i < n; i++) {
    P[i] !== i + 1 && count++;
  }

  console.log(count <= 2 ? 'YES' : 'NO');
}

// *出力
// number
// console.log('%d', );
// string
// console.log('%s', );

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define push push_back

vector<long long> dp[12];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> k;
  dp[1].push(1);
  dp[1].push(2);
  dp[1].push(3);
  dp[1].push(4);
  dp[1].push(5);
  dp[1].push(6);
  dp[1].push(7);
  dp[1].push(8);
  dp[1].push(9);
  if (k < 10) {
    cout << k << '\n';
    return 0;
  }
  int n = 10;
  int c = 2;
  while (true) {
    for (int i = 0; i < dp[c - 1].size(); i++) {
      long long val = dp[c - 1][i];
      long long aux;
      int last = val % 10;
      if (last - 1 >= 0) {
        aux = val * 10 + (last - 1);
        dp[c].push(aux);
        if (n == k) {
          cout << aux << '\n';
          return 0;
        }
        n++;
      }
      aux = val * 10 + last;
      dp[c].push(aux);
      if (n == k) {
        cout << aux << '\n';
        return 0;
      }
      n++;
      if (last + 1 < 10) {
        aux = val * 10 + (last + 1);
        dp[c].push(aux);
        if (n == k) {
          cout << aux << '\n';
          return 0;
        }
        n++;
      }
    }
    c++;
  }
  return 0;
}


Measured memory_bytes: 4180
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  string st;
  cin>>st;
  if (st=="SUN") cout<<7<<endl;
  else if (st=="MON") cout<<6<<endl;
  else if (st=="TUE") cout<<5<<endl;
  else if (st=="WED") cout<<4<<endl;
  else if (st=="THU") cout<<3<<endl;
  else if (st=="FRI") cout<<2<<endl;
  else if (st=="SAT") cout<<1<<endl;
}

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

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

string s;
string ans;

int main() {
    cin>>s;
    if(s.substr(0,4)<"2019"){
        ans="Heisei";
    }else if(s.substr(5,2)<"04"){
        ans="Heisei";
    }else if(s.substr(5,2)=="04"&&s.substr(8,2)<="30"){
        ans="Heisei";
    }else{
        ans="TBD";
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author: kalyan       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;
 
void solve(){
    int k,n;
    cin >> k >> n;
    if(k*500 >= n) cout <<"Yes";
    else cout <<"No";
    
}
 
int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t;
    t = 1;
    // cin >> t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3560
f=lambda:map(int,input().split())
n,m=f()
l,b=[0]*n,[0]*n
if n>1: l[0]=1
for _ in range(m):
  s,c=f(); s-=1
  if b[s] and l[s]!=c or n>1 and s==c==0: print(-1); exit()
  l[s],b[s]=c,1
print(*l,sep='')

Measured memory_bytes: 9128
#include <iostream>
using namespace std;
int n, cnt = 0, flag = 0;
int num[105][2];
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> num[i][0] >> num[i][1];
    }
    for (int j = 0; j < n ; ++j) {
        if(num[j][0] == num[j][1])
        {
            cnt++;
            if(cnt == 3)
                break;
        }
        else
        {
            cnt = 0;
        }
    }
    if(cnt == 3)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

class Node:
    __slots__ = ['value', 'parent', 'left', 'right']
    def __init__(self, value: int, parent: 'Node' = None):
        self.value = value
        self.parent = parent
        self.left: Node = None
        self.right: Node = None
    def inParse(self):
        if self.value == None:
            return
        if self.left != None:
            self.left.inParse()
        print(' {}'.format(self.value), end='')
        if self.right != None:
            self.right.inParse()
    def preParse(self):
        if self.value == None:
            return
        print(' {}'.format(self.value), end='')
        if self.left != None:
            self.left.preParse()
        if self.right != None:
            self.right.preParse()

class BinarySearchTree:
    __slots__ = ['root']
    def __init__(self):
        self.root: Node = None
    def insert(self, x: int):
        if self.root == None:
            self.root = Node(x)
            return
        parent, current = None, self.root
        while current:
            parent = current
            if x < current.value:
                current = current.left
            else:
                current = current.right
        if x < parent.value:
            parent.left = Node(x, parent)
        else:
            parent.right = Node(x, parent)
    def find(self, x: int):
        y = self.root
        while y != None and y.value != x:
            if y.value > x:
                y = y.left
            else:
                y = y.right
        return y

def main():
    tree = BinarySearchTree()
    n = int(input())
    for _ in range(n):
        inp = input()
        if inp[0] == 'i':
            com, num = inp.split()
            tree.insert(int(num))
        elif inp[0] == 'f':
            com, num = inp.split()
            if tree.find(int(num)):
                print('yes')
            else:
                print('no')
        else:
            tree.root.inParse()
            print()
            tree.root.preParse()
            print()

if __name__=='__main__': main()


Measured memory_bytes: 47504
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,m,ans;
//vector<set<int> > g;
set<int> g[10];

main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		g[a].insert(b);
		g[b].insert(a);
	}
	vint v;
	rep(i,n)v.pb(i+1);
	do{
		if(v[0]!=1)break;
		bool flg=1;
		for(int i=0;i<n-1;i++){
			if(g[v[i]].count(v[i+1])==0){
				flg=0;
				break;
			}
		}
		if(flg)ans++;
	}while(next_permutation(all(v)));
	dans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 


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

    int tmp;

    tmp = n / 1.08;

    /*
    cout << tmp << endl;
    cout << tmp * 1.08 << endl;
    cout << (tmp+1) * 1.08 << endl;
    */

    if(int(tmp * 1.08) == n){
        cout << tmp << endl;
    }else if(int((tmp+1) * 1.08) == n){
        cout << tmp + 1 << endl;
    }else{
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()

{
    int a, b ;
    scanf("%d%d",&a, &b);

    if(a < b)
    {
        printf("a < b\n");
    }


  else if(a > b)
    {
        printf("a > b\n");
    }
    else
    {
        printf("a == b\n");
    }




    return 0 ;
}



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

int main(){
 long long int n,a[30]={0};
  
  string s;
  cin >> n;
  cin >> s;
  
  for(int i=0;i<n;i++){
    a[s[i]-'a']++;
    
  }
   long long int ans=1;
      
  for(int i=0;i<30;i++){
    ans *= (a[i]+1);
    ans %= 1000000007;
  }
  
  cout << ans-1 << endl;
}


Measured memory_bytes: 512