akhauriyash/Code-Regression huggingface dataset:
var
    s1,s2:string;
begin
    readln(s1);
    readln(s2);
    if(s2[1]<>s1[3])then
    begin
        writeln('NO');
        exit;
    end;
    if(s2[2]<>s1[2])then
    begin
        writeln('NO');
        exit;
    end;
    if(s2[3]<>s1[1])then
    begin
        writeln('NO');
        exit;
    end;
    writeln('YES'); 
end.


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

int main()
{
	int n,m,i;
	int ave[1000]={0};

	m=0;
	while(1){
		int point[100]={0};
		int min=1000;
		int max=0;
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>point[i];
			if(point[i]>max) max=point[i];
			if(point[i]<min) min=point[i];
			ave[m]+=point[i];
		}
//		cout<<"debug "<<ave[m]<<endl;
//		cout<<max<<" "<<min<<endl;
		ave[m]=(ave[m]-max-min)/(n-2);
		m++;
	}
	for(i=0;i<m;i++){
		cout<<ave[i]<<endl;
	}
}

Measured memory_bytes: 1160
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int x;in(x);
	cout<<(!x)<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  int s1, s2, s3;
  
  cin >> s;

  s1 = s / 100;
  s2 = (s - 100 * s1) / 10;
  s3 = s - 100 * s1 - 10 * s2;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define free 0
#define notfree 1
#define N 8
#define NIL -1

int col[50],dpos[50],dneg[50],row[50];
int A[50];

void printBoard(void){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j){
	printf("Q");
      }else{
	printf(".");
      }
    }
    printf("\n");
  }
}


int putqueen(int i){
  int j;
  if(i == N){
    printBoard();
    return 1;
  }

  if(A[i] == notfree){
    if(putqueen(i+1)){return 1;}
    return 0;
  }

  for(j=0;j<N;j++){
    if(col[j] == notfree || dpos[i+j] == notfree || dneg[i-j+N-1] == notfree){
      continue;
    }
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = notfree;
    if(putqueen(i+1)){return 1;}
    col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
  return 0;
}


int main(){
  int n,r,c,i,j;
  scanf("%d",&n);

  for(i=0;i<N;i++){
    A[i] = NIL;
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      col[i] = dpos[i+j] = dneg[i-j+N-1] = free;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&r,&c);
    row[r] = c;
    A[r] = notfree;
    col[c] = notfree;
    dpos[r+c] = notfree;
    dneg[r-c+N-1] = notfree;
  }
  
  putqueen(0);
  
  return 0;
}



Measured memory_bytes: 2108
import sys, random
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20

#    t = int(input())
    # t, a, b = map(int, input().split())
    t = 1
    
    
    for _ in range(1, t+1):
        # print("Case #{}: ".format(_), end = '')
        
        a, b = [input().strip() for i in range(2)]
        
        if(a == b[:len(a)]):
            print("Yes")
        else:
            print("No")
        
        
main()

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

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

    if (A == 5 && B == 5 && C == 7)
    {
        cout << "YES" << endl;
    }
    else if (A == 7 && B == 5 && C == 5)
    {
        cout << "YES" << endl;
    }
    else if (A == 5 && B == 7 && C == 5)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(s);

		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += s[i];
		}

		if (sum % 10 == 0) {
			for (int i = 0; i < n; i++) {
				if (s[i] % 10 != 0) {
					System.out.println(sum - s[i]);
					return;
				}
			}
			System.out.println(0);
		} else {
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 23764
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>

using namespace std;

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



const int PS = 1000000;
int prime[PS];
int set_prime(){
	rep(i,PS)prime[i]=1;
	prime[0]=prime[1]=0;
	rep(i,PS){
		if(prime[i]==0)continue;
		for(int j=i*2;j<PS;j+=i)prime[j]=0;
	}
}


int sum[PS];
int set_sum(){
	set_prime();
	rep(i,PS)sum[i]=0;
	reps(i,1,PS)sum[i]=sum[i-1]+prime[i];
}
int main(){
	set_sum();
	
	int a;
	while(scanf("%d",&a)!=EOF){
		printf("%d\n",sum[a]);
	}
}

Measured memory_bytes: 8984
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

struct train
{	
	int c,s,f;
};
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	int n,yy;

	scanf("%d %d",&n,&yy);

	for(int x = 0 ;x<=n;x++){
		for(int y=0;y<=n-x;y++){
			int z = n - x - y;
			if((x*10000 + y*5000 + z*1000) == yy){
				return !printf("%d %d %d\n",x,y,z);
			}
		}
	} 

	printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
import math
MOD = 1000000000+7
X, Y = map(int, input().split())
 
if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
elif 2 *Y == X or 2 * X == Y:
    print(1)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]
 
    fac_list[0] = 1
    for i in range(1, x+y+2):
        fac_list[i] = i * fac_list[i-1] % MOD
 
    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD
 
    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)

Measured memory_bytes: 91912
#include <stdio.h>

int main(void) {
  char s[7];
  scanf("%s", s);
  int bool = 0;
  for(int i = 2; i < 6; i += 2) {
    if(s[i] == s[i + 1]) {
      bool += 1;
    }
  }
  if(bool == 2) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, h, w; cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << '\n';
}

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

one_list = set()
n_list = set()

for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        one_list.add(b)
    if b == 1:
        one_list.add(a)
    if a == n:
        n_list.add(b)
    if b == n:
        n_list.add(a)

print('IMPOSSIBLE' if (one_list & n_list) == set() else 'POSSIBLE')


Measured memory_bytes: 19024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int
main(int argc, char *argv[])
{
  int n;
  char s[310][310];
  scanf("%d", &n);
  rep(i, n) scanf("%s", s[i]);

  int ans = 0;
  for (int d = 0; d < n; d++) {
    int c = n - d;
    bool f1 = true, f2 = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
	if (s[(i + d) % n][j] != s[(j + d) % n][i]) f1 = false;
	if (s[i][(j + d) % n] != s[j][(i + d) % n]) f2 = false;
      }
    }
    if (d == 0) {
      if (f1) ans += c;
    } else {
      if (f1) ans += c;
      if (f2) ans += c;
    }
  }

  printf("%d\n", ans);

  return 0;
}
      
    
    


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int isPrime(int x){
	int i;
	if(x<2) return 0;
	else if(x==2) return 1;
	if(x%2==0) return 0;
	for(i=3;i*i<=x;i+=2){
		if(x%i==0) return 0;
	}
	return 1;
}
int p,cnt,cnt2,food;
int n,d=0,g,kakaku[31],flag,youso[1000002]={0};
int main()
{
	scanf("%d %d",&n,&p);
	while(1){
		//memset(youso, 0, sizeof(youso));
	
		if(n==0&&p==0){
			break;
		}
		for(cnt=1;cnt<=n;cnt++){
			scanf("%d",&food);
			youso[food]=1;
			kakaku[cnt]=food;
		}
		for(cnt=0;cnt<=p;cnt++){
			if(youso[cnt]==1){
				for(cnt2=1;cnt2<=n;cnt2++){
					if(cnt+kakaku[cnt2]<=p){
						youso[cnt+kakaku[cnt2]]=1;
					}
				}
			}
		}
		flag=0;
		for(cnt=p;cnt>=0;cnt--){
			if(youso[cnt]==1){
				g=cnt;
				d=isPrime(g);
				if(d==1){
					flag=1;
					d=cnt;
					printf("%d\n",d);
					break;
				}
			}
		}
		if(flag==0){
			printf("NA\n");
		}
		d=0;
		flag=0;
		
		scanf("%d %d",&n,&p);
			for(int i=0;i<p+1;i++){
			youso[i]=0;
		}
	}
	return 0;
}

Measured memory_bytes: 6588
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
        int k=i;
		int cnt = 0;
		while (k > 0) {
			cnt += k % 10;
			k /= 10;
		}
		if (cnt >= a && cnt <= b) ans+=i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
int main() {
	string s; int n;
	cin >> s >> n;
	int len = s.length();
	vector<int> t;
	rep(i, len) {
		if (s[i] == '+' || s[i] == '*')t.push_back(0);
		else t.push_back(s[i] - '0');
	}
	int m, l; m = 0; l = t[0];
	rep(i, len) {
		if (s[i] == '+') {
			m += t[i - 1];
			l += t[i + 1];
		}
		else if(s[i]=='*'){
			l *= t[i + 1];
			t[i + 1] *= t[i-1];
		}
	}
	m += t[len - 1];
	if (m == n && l == n) {
		cout << "U" << endl;
	}
	else if (m == n) {
		cout << "M" << endl;
	}
	else if (l == n) {
		cout << "L" << endl;
	}
	else {
		cout << "I" << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
k,x = map(int, input().split())

kazu = k-1

if x-kazu<=-1000000:
    min = -1000000
else:
    min = x-kazu

if x+kazu>=1000000:
    max=1000000
else:
    max=x+kazu

[print(i) for i in range(min,max+1)]

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

int main(){
    char a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a==b){
        cout << "Bad" << endl;
    }
    else if(b==c){
        cout << "Bad" << endl;
    }
    else if(c==d){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<complex>
using namespace std;
typedef long long ll;
ll n,z,w,a[2010];
int main(){
  cin>>n>>z>>w;
  for(int i=0;i<n;i++)cin>>a[i];
  if(n==1){
      cout<<abs(a[0]-w)<<endl;
  }
  else{
      ll vl=abs(a[n-2]-a[n-1]);
      ll vr=abs(a[n-1]-w);
      cout<<max(vl,vr)<<endl;
  }
  return 0;
}


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

#define INF 0x7fffffff
#define ll  long long

int main() {
  int n;
  cin >> n ;
  vector<ll> dp(n+2 , 0x7fffffffffffffffll);
  vector<ll> h(n+2);

  for(int i=0;i<n;i++) {
    cin >> h[i+1]; 
  }
  dp[1] = 0;
  for(int i=1;i<n;i++) {
    ll t = h[i] - h[i+1];
    if (t<0) t*=-1;
    dp[i+1] = min(dp[i+1], dp[i]+t);
    t = h[i] - h[i+2];
    if (t<0) t*=-1;
    dp[i+2] = min(dp[i+2], dp[i]+t);    
  }

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


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

int main() {
    double a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        double x=(c*e-b*f)/(a*e-b*d)+1e-10;
        double y=(a*f-c*d)/(a*e-b*d)+1e-10;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

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

int main() {
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll mod=1e9+7;
    for(ll i=k;i<=n+1;i++){
        ll s=((i-1)*i)/2;
        ll e=((2*n-i+1)*i)/2;
        ans+=e-s+1;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int cnt = 0;
        int kari = 0;
        for(int i=A;i<=B;i++){
          kari = i - 10001*(i%10) - 101*((i%100)-(i%10)) - ((i%1000)-(i%100));
//          System.out.println(cnt);
          if(kari == 0){
            cnt++;
          }
        }

        System.out.println(cnt);  
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    string s;
    cin>>s;
    auto r=s;
    reverse(all(r));
    rep(i,r.size()){
        if(abs(s[i]-r[i])>2 || abs(s[i]-r[i])==0){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

vector<vector<int>> G(100005);
vector<int> dist_A(100005), dist_T(100005);

void dfs(vector<int> &dist, int now, int p, int p_num) {
  dist[now] = p_num + 1;
  if (G[now].size() == 1 && p != -1) return;
  for (int i = 0; i < G[now].size(); i++) {
    if (G[now][i] == p) continue;
    dfs(dist, G[now][i], now, p_num + 1);
  }
}

int main(void) {
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  int a[n], b[n];
  rep (i, n - 1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  dfs(dist_A, v, -1, -1);
  dfs(dist_T, u, -1, -1);

  //rep (i, n) cout << dist_A[i] << " " << dist_T[i] << endl;
  int gole, maxd = -1;
  rep (i, n) {
    if (dist_A[i] < dist_T[i]) continue;
    maxd = max(maxd, dist_A[i]);
  }
  cout << maxd - 1 << endl;
  return 0;
}

Measured memory_bytes: 12416
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int length;
	char word[1024];

	fgets(word, sizeof(word), stdin);
	length = 0;
	while(word[length] != '\n' && word[length != '\0']) {
		length += 1;
	}

	word[length] = '\0';
	if(word[length - 1] == 's') {
		printf("%ses\n", word);
	} else {
		printf("%ss\n", word);
	}

	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int x,t;
  
  cin >> x;
  
  t=0;
  while (1){
    if (x<t*100){
      cout << 0 << endl;
      return 0;
    }
    if (x-t*100 <= t*5){
      cout << 1 << endl;
      return 0;
    }
    t++;
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

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

  string A, B, C;
  cin >> A >> B >> C;
  if(A[A.length()-1] == B[0] && B[B.length()-1] == C[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


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

int main() {
 
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double x = m * 6;
  double y = h * 30 + 0.5 * m;
  
  double z = x-y;
  
  
  double ans = pow(a*a + b*b - 2*a*b*cos(z*M_PI/180),0.5);

  cout << fixed << setprecision(10) << ans << endl;
  
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = (n - 1); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(k>0){
    if(a<b) break;
    b*=2;
    k--;
  }
  while(k>0){
    if(b<c) break;
    c*=2;
    k--;
  }
  if(a<b && b<c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++) // repマクロ

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep (i, 0, n)
    cin >> l.at(i);
  int ans = 0;
  
  sort(l.begin(), l.end());
  
  rep (i, 0, n-2) {
    rep (j, i+1, n-1) {
      rep (k, j+1, n) {
        if (l.at(i) + l.at(j) - l.at(k) > 0)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int x, y, c, surplus;
    
    scanf("%d %d", &x, &y);
    
    if(x < y){
        c = x;
        x = y;
        y = c;
    }
    
    while(1){
        surplus = x % y;
        if(surplus == 0){
            break;
        }
        x = y;
        y = surplus;
    }
    
    printf("%d\n", y);
}


Measured memory_bytes: 2060
/*
    Created by 10_months
    Tag:
    Link:
*/

#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

const long long inf = 1e17;
const int INF = 1e9 + 7;
const int N = 1234567;
const int M = 123456;

int n;

int main() {
    #ifdef home
        freopen("in", "r", stdin);
        freopen("out", "w", stdout);
    #endif       
    while (cin >> n) {
       long long ans = 1;
       for (int i = 2; i <= n; i++) {
            ans = (ans * i) % INF;;
       }
       cout << ans << endl;
    }
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		
		int A = Integer.parseInt(st.nextToken());
		int B = Integer.parseInt(st.nextToken());
		int C = Integer.parseInt(st.nextToken());
		int D = Integer.parseInt(st.nextToken());
		
		int t1 = (int) Math.ceil((double) C / B);
		int t2 = (int) Math.ceil((double) A / D);
		
		if (t1 <= t2)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    long long int h;
    long long int count=1;
    long long int counts=1;
    cin >> h;

    while(1){
        h /= 2;
        if(h == 0) break;
        if(h <= 0) break;
        counts += pow(2, count);
        count++;
    }

    cout << counts << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for(int i = 8; i >= 0; --i)
    {
        if(N & (1 << i))
        {
            cout << (N & (1 << i)) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline())

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
dp = [[0 for i in range(3)] for j in range(n)]
for col in range(3):
    dp[0][col] = L[0][col]
#print(dp)

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + L[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + L[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + L[i][2]

print(max(dp[-1]))

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

#define ll long long
#define pb push_back

const int maxn = 3e3 + 20;

int match[maxn * 2];

string s[maxn] , dp[maxn];

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

	int n;
	cin >> n >> s[0];

	for(int i = 1; i < n; i++)
	{
		s[i] = s[i - 1];
		for(int j = 0; j < (int)s[i].size(); j++)
			if(s[i][j] == 'a')
			{
				s[i].erase(s[i].begin() + j);
				break;
			}

		for(int j = 0; j < (int)s[i].size(); j++)
			if(s[i][j] == 'b')
			{
				s[i].erase(s[i].begin() + j);
				break;
			}
	}

	for(int i = n - 1; i >= 0; i--)
	{
		dp[i] = dp[i + 1];
		int sz = s[i].size();
		vector<int> A , B;
		for(int j = 0; j < sz; j++)
		{
			if(s[i][j] == 'a')
				A.pb(j);
			else
				B.pb(j);
		}

		for(int j = 0; j < sz / 2; j++)
			match[A[j]] = B[j] , match[B[j]] = A[j];

		if(s[i][0] == 'b')
		{
			int mx = 0;
			for(int k = 0; k < sz; k++)
			{
				mx = max(mx , match[k]);
				if(mx <= k)
				{
					dp[i] = max(dp[i] , s[i].substr(0 , k + 1) + dp[i + (k + 1) / 2]);
					break;
				}
			}
		}
		else
			dp[i] = max(dp[i] , "ab" + dp[i + match[0]]);
	}

	cout << dp[0] << endl;
}
























Measured memory_bytes: 18304
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 100005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll n;
     cin >> n;
     ld third = n/3.0;
     ld ans = third * third * third;
     cout<<fixed<<setprecision(12)<<ans;       
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 256
S = list(input())
K = int(input())

N = len(S)

if len(set(S)) == 1: #種類が１つ
    tmp = K * N // 2
    print (tmp)
    exit()

if S[0] != S[-1]:
    count = 0
    for i in range(N - 1):
        if S[i] == S[i + 1]:
            S[i + 1] = '*'
            count += 1
    print (count * K)
else:
    i = 1
    while i < N:
        if S[i - 1] != S[i]:
            break
        i += 1
    
    j = 1
    while j < N:
        if S[N - j] != S[N - j - 1]:
            break
        j += 1
    
    ans = 0
    tmp = 1
    for k in range(i, N - j):
        if S[k] != S[k + 1]:
            ans += K * (tmp // 2)
            tmp = 1
        else:
            tmp += 1
    ans += K * (tmp // 2)
    ans += (K - 1) * ((i + j) // 2)
    ans += i // 2
    ans += j // 2
    print (ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
        var a = Console.ReadLine().Split().Select(long.Parse).ToList();
        long currentCost = a.Take(nk[1]).Where(x => x < 0).Sum();
        long costMax = currentCost;

        long currentDump = a.Take(nk[1]).Where(x => x > 0).Sum();
        long dumpMin = currentDump;
        for (int i = nk[1]; i < nk[0]; i++)
        {
            if (a[i - nk[1]] < 0) currentCost -= a[i - nk[1]];
            else currentDump -= a[i - nk[1]];

            if (a[i] < 0) currentCost += a[i];
            else currentDump += a[i];

            costMax = Max(costMax, currentCost);
            dumpMin = Min(dumpMin, currentDump);
        }
        long greedyScore = a.Where(x => x >= 0).Sum();
        Console.WriteLine(Max(greedyScore + costMax, greedyScore - dumpMin));
    }
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, a, b);
  OUTL((b % a == 0) ? a + b : b - a);
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define g(i,a,b) for(ll i=a;i>=b;i--)
#define F first
#define vv vector
#define S second
#define mp make_pair
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
using namespace std;


int main()
{

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin>>n;
string s;
cin>>s;
s+="?";
ll c=0;
f(i,0,s.length()-2) if(s[i]!=s[i+1]) c++;
cout<<c;

}







Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] h = new int[n];
        for (int i=0;i<n;i++){
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
            h[i]=sc.nextInt();
        }
        int count=0;
        String ans="";
        for (int i=0;i<=100;i++){
            for (int j=0;j<=100;j++){
                count++;
                int instance=0;
                boolean b = true;
                for (int k=0;k<n-1;k++){
                    if (h[k]!=0&&h[k+1]!=0){
                        int p = Math.abs(i-x[k])+Math.abs(j-y[k])+h[k];
                        int q = Math.abs(i-x[k+1])+Math.abs(j-y[k+1])+h[k+1];
                        if (h[k]!=0)instance=k;
                        if (h[k+1]!=0)instance=k+1;
                        if (p!=q)b=false;
                    }
                }
                if (b){
                    ans = i+" "+j+" "+(Math.abs(i-x[instance])+Math.abs(j-y[instance])+h[instance]);
                }
            }
        }
        int a=0;
        int b=0;
        for (int i=0;i<n;i++){
            if (h[i]==1){
                a=x[i];
                b=y[i];
            }
        }
        Arrays.sort(h);
        if (h[n-2]==0) {
            System.out.println(a+" "+b+" "+1);
        }else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 40792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int n;cin>>n;
    int ans=INF;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0)chmin(ans,i+n/i-2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

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

int main()
{
   int A;
   float B;
   cin >> A;
   cin >> B;
   if (int(B) == 1)
   {
       cout << 0;
   }
   else
   {
    cout << ceil((B - A)/ (A - 1)) + 1;
   }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr ll P = 998244353;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

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

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

    ll k;
    cin >> k;

    init(n + 1);

    ll x = 0, y = 0;
    for (x = 0; x < n; x++) {
        if (a * x >= k) break;
    }
    for (y = 0; y < n; y++) {
        if (a * x + b * y >= k) break;
    }
    if (a * x + b * y < k) {
        cout << 0 << endl;
        return 0;
    }

    ll r = 0;
    for (;;) {
        if (a * x + b * y == k) {
            r += comb(n, x) * comb(n, y);
            r %= P;
        }
        do {
            if (a * x + b * y >= k) {
                if (x == 0) goto exit;
                x--;
            } else {
                if (y == n) goto exit;
                y++;
            }
        } while (a * x + b * y != k);
    }

exit:
    cout << r << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define MP make_pair

constexpr int INF = 1LL << 60;
constexpr int MOD = 998244353;
constexpr double EPS = 1.0e-9;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(16);

    int a, b, n;
    cin >> a >> b >> n;
    int x = min(n, b - 1);
    cout << a * x / b - a * (x / b) << endl;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>

char a[205], b[205];

int main(){
	int k, ans;
	char *p, *q, *wp, *wq;
	char *s[3] = { "IDENTICAL", "CLOSE", "DIFFERENT" };

	while (scanf("%s", a) && a[0] != '.') {
		scanf("%s", b); p = a, q = b; ans = -1, k = 0;
		while (*p && *q) {
			if (*p != *q) { ans = 2; break; }
			if (*p == '"') {
			    wp = ++p, wq = ++q;
				while (*p != '"'){
				    p++;
				}while (*q != '"'){
				    q++;
				}
				*p = *q = 0;
				k += 1 - (strcmp(wp, wq) == 0);
				if (k > 1) {
				    ans = 2; break;
				    }
			}
			p++, q++;
		}
		if (ans < 0) if (*p == *q) ans = k; else ans = 2;
		puts(s[ans]);
	}
	return 0;
}


Measured memory_bytes: 2044
N, M = map(int, input().split())

import numpy as np
a = np.zeros(N)
flag = np.zeros(N)

for i in range(M):
  p, S = map(str, input().split())
  p = int(p)
  if flag[p-1] == 0 and S == "WA":
    a[p-1] += 1
  if S == "AC":
    flag[p-1] = 1
a = [int(np.sum(flag)), int(np.sum(flag * a))]
print(*a)

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, A, B;
  cin >> N >> A >> B;
  cout<<min(A*N, B) << endl;

  return 0;
}


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

const long MAX_N=100100;
long h[MAX_N];
long a[MAX_N];
long dp[MAX_N];
const long INF = 10^10;

int main() 
{ 
    long N;
    cin >> N;
    for (long i=0; i<N; i++){
        cin >> h[i];
        a[N-1-i] = h[i];
    }

    long res = 0;
    for (long i=0; i<N; i++) {
        dp[i] = 0;
        if (i > 0)
            if (a[i-1]<=a[i])
                dp[i] = max(dp[i], dp[i-1]+1);
        res = max(res,dp[i]);
    }

    cout << res << endl;

    return 0; 
} 


Measured memory_bytes: 2560
n,m=map(int,input().split())
c=[]
for i in range(m):
  a,b=map(int,input().split())
  c.append([a,b])
c.sort()
bridge=0
key=1
for i in range(m):
  if c[i][1]<=key:
    key=c[i][1]
  if c[i][0]>=key:
    bridge+=1
    key=c[i][1]
print(bridge)

Measured memory_bytes: 20068
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

int main(){
    int N, L;
    while(std::cin >> N >> L, N || L){
        int a[21];
        a[0] = N;

        P res = mp(-1, -1);
        for(int i=1;!~res.first;i++){
            std::string s = std::to_string(N);

            while(s.size() < L){
                s += "0";
            }
        
            int min, max;
            std::sort(s.begin(), s.end());
            min = std::stoi(s);
            std::reverse(s.begin(), s.end());
            max = std::stoi(s);

            N = max - min;
            if(i <= 20){a[i] = N;}
            
            for(int j=0;j<=std::min(20,i-1);j++){
                if(N == a[j]){res = mp(j, i); break;}
            }
        }

        printf("%d %d %d\n", res.first, a[res.first], res.second-res.first);
    }
}

Measured memory_bytes: 1224
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Strings
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[128], t[128];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);
  printf("%s%s\n", t, s);
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		System.out.println(str.toUpperCase());
	}

}

Measured memory_bytes: 24264
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

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

int W, H, N;
int wall[4][50][50];
int step[50][50];
int visit[50][50];

int search(int ix, int iy, int ox, int oy){
	memset(step, -1, sizeof(step));
	step[ix][iy] = 0;
	queue< pair<int,int> > qu; qu.push(make_pair(ix, iy));
	while(!qu.empty()){
		pair<int,int> pr = qu.front(); qu.pop();
		int x = pr.first, y = pr.second;
		for(int i=0;i<4;i++){
			if(wall[i][x][y]) continue;
			int nx = x+dx[i], ny = y+dy[i];
			if(nx<0 || W<=nx || ny<0 || H<=ny) continue;
			if(step[nx][ny]!=-1) continue;
			step[nx][ny] = step[x][y]+1;
			qu.push(make_pair(nx,ny));
		}
	}
	return step[ox][oy];
}

int main(){
	while(cin >> W >> H >> N && W){
		memset(wall, 0, sizeof(wall));
		for(int i=0;i<N;i++){
			int sx, sy, gx, gy;
			cin >> sx >> sy >> gx >> gy;
			if(sx == gx){
				if(0 < sx && sx < W){
					if(sy > gy) swap(sy, gy);
					for(int i=sy;i<gy;i++){
						wall[0][sx-1][i] = wall[2][sx][i] = 1;
					}
				}
			} else {
				if(0 < sy && sy < H){
					if(sx > gx) swap(sx, gx);
					for(int i=sx;i<gx;i++){
						wall[1][i][sy-1] = wall[3][i][sy] = 1;
					}
				}
			}
		}
		int ix, iy, ox, oy;
		cin >> ix >> iy >> ox >> oy;
		int cur = search(ix, iy, ox, oy);
		int best = cur;
		for(int i=0;i<W;i++){
			for(int j=0;j<H;j++){
				if(i+1<W && !wall[0][i][j]){
					wall[0][i][j] = wall[2][i+1][j] = 1;
					best = max(best, search(ix, iy, ox, oy));
					wall[0][i][j] = wall[2][i+1][j] = 0;
				}
				if(j+1<H && !wall[1][i][j]){
					wall[1][i][j] = wall[3][i][j+1] = 1;
					best = max(best, search(ix, iy, ox, oy));
					wall[1][i][j] = wall[3][i][j+1] = 0;
				}
			}
		}
		cout << best-cur << endl;
	}
}

Measured memory_bytes: 1272
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
int main() {
  int k, s, cunt = 0;
  cin >> k >> s;
  rep(x, k + 1) {
    rep(y, k + 1) {
      int z = s - x - y;
      if (z >= 0 && z <= k) {
        cunt++;
      }
    }
  }
  cout << cunt << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int result = 0;
        int min = 10;
        for (int i = 0; i < 5; i++) {
            final int a = scanner.nextInt();
            if (a % 10 != 0 && a % 10 < min) {
                min = a % 10;
            }
            result += Math.ceil((float) a / 10) * 10;
        }

        if (min != 10) {
            result -= 10 - min;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
a,b,h,m=list(map(int,input().split()))
hun=h*60+m
kakudo=min((5.5*hun)%360,360-(5.5*hun)%360)
import math
cos=math.cos(math.radians(kakudo))
print(math.sqrt(a*a+b*b-2*a*b*cos))



Measured memory_bytes: 9556
import java.math.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	//初期フィールド・メソッド---------------------------------------------
	static Scanner sc = new Scanner(System.in);
	static int min(int... ar) {Arrays.sort(ar); return ar[0];}
	static int max(int... ar) {Arrays.sort(ar); return ar[ar.length-1];}
	//------------------------------------------------------------


	//フィールド追加場所-----------------------------------------------
	//------------------------------------------------------------


	//メソッド追加場所------------------------------------------------
	//------------------------------------------------------------


	//mainメソッド---------------------------------------------------
	public static void main(String[] args) {
		Map<String,List<Integer>> map = new TreeMap<>();
		
		while (sc.hasNext()) {
			String word = sc.next();
			int page = sc.nextInt();
			
			if (word.equals("end")) break;
			
			if (!map.containsKey(word)) map.put(word, new ArrayList<>());
			map.get(word).add(page);
		}
		
		map.forEach((k,v)-> {
			out.println(k);
			Collections.sort(v);
			for (int i=0; i<v.size(); i++) {
				out.print((i==0?"":" ")+v.get(i));
			}
			out.println();
		});
	}
	//------------------------------------------------------------
}


Measured memory_bytes: 31852
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;

using namespace std;

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

	cin>>n>>m;
	if (n == m) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  int n,a;cin>>n>>a;int x[50];rep(i,n)cin>>x[i];int dp[51][51][2600];rep(i,51)rep(j,51)rep(k,2600)dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  repd(i,1,n + 1){
    rep(j,i+1){
      repd(k,0,2600){
        if(k < x[i-1])dp[i][j][k] = dp[i - 1][j][k];
        else dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i-1]] ;
      }
    }
  }
  int ans = 0;
  repd(i,1,n+1){
    ans += dp[n][i][a * i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 53120
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(a, i, n) for (int i = a; i <= n; ++i)

int main() {
    int N;
    scanf("%d", &N);

    vector<string> v;
    REP(1, i, N) {
        string str;
        cin >> str;
        v.push_back(str);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    long M, A, R, C, H;
    M = A = R = C = H = 0;
    vector<string>::iterator it;
    for (it = v.begin(); it != v.end(); ++it) {
        if ((*it)[0] == 'M') M++;
        else if ((*it)[0] == 'A') A++;
        else if ((*it)[0] == 'R') R++;
        else if ((*it)[0] == 'C') C++;
        else if ((*it)[0] == 'H') H++;
        else {}
    }

    long ans = M * A * (R + C + H) +
               A * R * (C + H) +
               M * R * (C + H) +
               (A + M + R) * C * H;

    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 6132
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b = LS()
    a = int(a)
    if b == '0':
        print(0)
        return
    s = ''
    for c in b:
        if c == '.':
            continue
        s += c
    s = int(s)
    print(a * s//100)


main()



Measured memory_bytes: 10952