akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-                                                         
def main():
  # input
  N = int(raw_input())
  s = raw_input()
  a = map(int, s.split())
  count = 0 
  for i in range(0, N): 
    if a[a[i]-1]-1 == i:
      count = count + 1 

  # output
  print count/2

main()

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

#define MX 100050
int a[MX], c[MX];
pair<int, int> p[MX], b[MX];
bool vis[MX];

int main() {
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		p[i] = make_pair(a[i], i);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%d", &b[i].first);
		b[i].second = i;
	}
	sort(b + 1, b + n + 1);
	sort(p + 1, p + n + 1);
	bool ans = true;
	for(int i = 1; i <= n; i++)
		if(p[i].first > b[i].first) {
			ans = false;
			break;
		}
	if(!ans) {
		puts("No");
		return 0;
	}
	bool flag = false;
	for(int i = 1; i < n; i++) {
		if(b[i].first >= p[i + 1].first) flag = true;
	}
	if(flag) {
		puts("Yes");
		return 0;
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) c[p[i].second] = b[i].second;
	for(int i = 1; i <= n; i++) {
		if(vis[i]) continue;
		int cur = i;
		do {
			vis[cur] = true;
			cur = c[cur];
		} while(!vis[cur]);
		cnt++;
	}
	puts(cnt != 1 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
const int maxn=1e5+100;
const int mod=1e9+7;
const int inf=123456789;
const int p=1e4;
using namespace std;
ll n,t,k,br[maxn];
char str[maxn];
map<string ,int >mp;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>str>>k;
        br[i]=br[i-1]+k;
        mp[str]=i;
    }
    cin>>str;
    cout<<br[n]-br[mp[str]]<<'\n';
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int a = 999999999;
        int b = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            a = Math.min(a, A[i]);
            b = Math.max(b, A[i]);
        }
        System.out.println(b - a);
    }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		/*int count = 0;*/
		
		Scanner scan = new Scanner(System.in);
	

		while (true) {
			
			int count = 0;
			
			int n = scan.nextInt();
			int x = scan.nextInt();

			if ((n == 0) && (x == 0)) {
				break;
			} 
			else {
				for (int i = 1; i <= n - 2; i++) {

					for (int j = i + 1; j <= n - 1; j++) {

						for (int k = j + 1; k <= n; k++) {

							if (i + j + k == x) {
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26664
long gcd(a,b)long a,b;{return b?gcd(b,a%b):a;}
const long mod=1e9+7;
struct X{long A,B;int f}A[2<<17];
O=mod-1;
cmp(a,b)struct X*a,*b;{
	long dA=a->A-b->A,dB=a->B-b->B;
	return dA?dA<0?-1:1:dB?dB<0?-1:1:0;
}
main(N)
{
	scanf("%d",&N);
	int sz=0;
	for(int i=0;i<N;i++)
	{
		long a,b;scanf("%ld%ld",&a,&b);
		if(!a&&!b)O++;
		else
		{
			long g=gcd(a,b);
			a/=g;b/=g;
			if(a<0)
			{
				a=-a;
				b=-b;
			}
			int f=0;
			if(a==0)
			{
				a=1;
				b=0;
				f=1;
			}
			else if(b<0)
			{
				long t=a;
				a=-b;
				b=t;
				f=1;
			}
			A[sz].A=a;
			A[sz].B=b;
			A[sz].f=f;
			sz++;
		}
	}
	qsort(A,sz,sizeof(struct X),cmp);
	long ans=1;
	for(int i=0;i<sz;)
	{
		int c[2]={1,1};
		int j=i;
		while(i<sz&&A[i].A==A[j].A&&A[i].B==A[j].B)
		{
			c[A[i].f]=c[A[i].f]*2%mod;
			i++;
		}
		ans=ans*(c[0]+c[1]-1)%mod;
	}
	printf("%d\n",(ans+O)%mod);
}


Measured memory_bytes: 10712
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<stdio.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++){
		string s;
		ll ans=0;
		cin>>s;
		while(true){
			if(s.length()==1)break;
			else{
				ans++;
				vector<ll>num;
				for(ll i=0;i<s.length()-1;i++){
					string t=s.substr(0,i+1);
					string u=s.substr(i+1,s.length()-i-1);
					ll x=0,y=0;
					for(ll j=t.length()-1;j>=0;j--){
						ll digit=t[j]-'0';
						x+=digit*pow(10,t.length()-1-j);
					}
					for(ll j=u.length()-1;j>=0;j--){
						ll digit=u[j]-'0';
						y+=digit*pow(10,u.length()-1-j);
					}
					num.push_back(x*y);
				}
				sort(num.begin(),num.end());
				ll m=num[num.size()-1];
				s=to_string(m);
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 3432
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])

v = input()
k = int(v)

max_index = 0

array = []
array.append(a)
array.append(b)
array.append(c)


for i in range(k):
    array.sort()
    x = array.pop()
    x *= 2
    array.append(x)


answer = 0
for i in range(len(array)):
    answer += array[i]

print(answer)



Measured memory_bytes: 9184
import statistics
N = int(input())
*A, = map(int, input().split())
B = [a - (i+1) for i, a in enumerate(A)]
B.sort()
# b = statistics.median(B)
b = B[len(B) // 2]
ans = 0
for i, a in enumerate(A):
    ans += abs(a - (b + (i+1)))
print(ans)


Measured memory_bytes: 27356
#include <bits/stdc++.h>
#define fname "LCS"
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<"]\n";}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<"]\n";}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define ers erase
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << "}\n";}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}\n";}
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll, ii> lii;
const int M = 5005, N = 1000001;
string A, B;
int nextPos[N][26], n, m, dp[M][M];

int main()
{
	//freopen(fname".INP", "r", stdin);
    //freopen(fname".OUT", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> A >> B;
    n = A.size(); m = B.size();
    A = ' ' + A;
    B = ' ' + B;
    for(char c = 'a'; c <= 'z'; ++c)
        nextPos[n + 2][c - 'a'] = nextPos[n + 1][c - 'a'] = n + 1;
    REPB1(i, n) {
        for(char c = 'a'; c <= 'z'; ++c) {
            if(A[i] == c) nextPos[i][c - 'a'] = i;
            else nextPos[i][c - 'a'] = nextPos[i + 1][c - 'a'];
        }
    }
    fill(&dp[0][0], &dp[0][0] + sizeof(dp)/sizeof(int), n + 1);
    REP0(i, m+1) dp[i][0] = 0;
    REP1(j, m)
        REP1(k, m)
            dp[j][k] = min(dp[j - 1][k], nextPos[dp[j - 1][k - 1] + 1][B[j] - 'a']);
    int ans;
    REPB0(k, m+1) {
        if(dp[m][k] != n + 1) {
            ans = k;
            break;
        }
    }
    if(ans) {
        string res;
        int val = dp[m][ans];
        REPB0(j, m) {
            if(!ans) break;
            if(dp[j][ans] != val) {
                res.pb(B[j + 1]);
                --ans;
                val = dp[j][ans];
                ++j;
            }
        }
        reverse(res.begin(), res.end());
        cout << res;
    }
	return 0;
}


Measured memory_bytes: 98688
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<set>
#include<map>
using namespace std;

int main() {
	int n, a[200001] = {};
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int b[200001] = {};
	for (int i = n; i > 0; i--) {
		int s = 0;
		for (int j = 2; j <= n / i; j++) {
			s += b[i * j];
		}
		b[i] = (s+a[i]) % 2;
		
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		cnt += b[i];
	}
	cout << cnt << endl;
	for (int i = 1; i <=n; i++) {
		if (b[i]==1) cout << i << " ";
	}
	cout << endl;
}


Measured memory_bytes: 2688
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T>map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
//------------------------------------------------------
ll n; string s;
void input(){
    cin>>n>>s;
}
void src(){
    auto m=count_same_elements(string_to_vector_char(s));
    ll sum=1;
    for(auto k:m){
        sum *= k.se+1;
        sum %= MOD;
    }
    cout<<sum-1;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string.h>
using namespace std;
typedef long long ll;
ll n, k;
struct node{
	ll x, y;
	friend bool operator < (node a, node b){
		return a.x < b.x;
	}
}a[100005];
int main()
{
	scanf("%lld%lld", &n, &k);
	for (ll i = 0; i < n; i++)
		scanf("%lld%lld", &a[i].x, &a[i].y);
	sort(a, a + n);
	ll sum = 0;
	for (ll i = 0; i < n; i++)
	{
		sum += a[i].y;
		if (sum >= k)
		{
			sum = a[i].x;
			break;
		}
	}
	printf("%lld\n", sum);	
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}
const int dx[4] = {1,0,0,-1};
const int dy[4] = { 0,1,-1,0 };

int main() {
    ll H, W;
    cin >> H >> W;//tate h yoko w
    vector<vector<char>> moji(H, vector<char>(W));
    vector<vector<bool>> visit(H, vector<bool>(W,true));
    rep(i, H) {
        rep(j, W) {
            cin >> moji[i][j];
            if (moji[i][j] == '#')visit[i][j] = false;
        }
    }
/*
3 3
.#.
###
.#.
*/
    bool ans = true;
    rep(i, H) {
        rep(j, W) {
            if (!(visit[i][j])) {
                bool ok = false;
                rep(d, 4) {
                    ll dh = i + dx[d]; ll dw = j + dy[d];
                    if (dh >= 0 && dw >= 0 && dh < H && dw < W) {
                        if (moji[dh][dw] == '#') {
                            ok = true;
                            visit[i][j] = true;
                        }
                    }
                }
                if (!(ok)) {
                    ans = false;
                }
            }
        }
    }
    if (ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll f(ll b,ll n){
  ll ans=0;
  while(n){
    ans+=n%b;
    n/=b;
  }
  return ans;
}

int main(){
  ll n,s,k=2,b;
  cin>>n>>s;
  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }
  for(b=2;b*b<=n;b++){
    k=b;
    if(f(b,n)==s){
      cout<<b<<endl;
      return 0;
    }
  }
  if(k*k==n) k--;
  for(ll a=k;a>0;a--){
    b=(n-s+a)/a;
    if(b<2) continue;
    if(f(b,n)==s){
      cout<<b<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

using namespace std;

typedef pair<int, int> p;
#define INF 1e9+1

int main(){
  int n, m;
  cin >> n >> m;
  vector< vector< pair<int, int> > > e(n);
  for(int i = 0; i < m; i++){
    int l,r,d;
    cin >> l >> r >> d;
    l--;
    r--;
    e[l].push_back(make_pair(r,d));
    e[r].push_back(make_pair(l,-1*d));
  }
  vector<int> v(n, INF);

  for(int k  = 0 ; k < n; k++){
    if(v[k] != INF) continue;
    v[k] = 0;
    queue<int> q;
    q.push(k);
    while(!q.empty()){
      int now = q.front();
      q.pop();
      for(auto human : e[now]){
        if(v[human.first] != INF){
          if(v[human.first] != v[now] + human.second){
            cout << "No" << endl;
            return 0;
          }
        }else{
          v[human.first] = v[now] + human.second;
          q.push(human.first);
        }
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 9344
N=int(input())
S=input()
if len(S)%2==1:
  print('No')
else:
  flag=0
  for i in range(0,N//2):
    if not(S[i]==S[i+N//2]):
      flag=1
      break
  if flag==0:
    print('Yes')
  else:
    print('No')

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

int main() {
  int k;
  for (int i=1; i<=5; i++){
    int a;
    cin >> a;
    if (a==0){
      k=i;
      break;
    }
  }

    cout << k << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    if( N==3 ){
        printf ("%d %d %d\n", 2, 5, 63 );
        return 0;
    }

    const int K = 30000;

    vi a,b,c,d;

    Repe(i,K+1,1){
        if( i%6 == 0 ) d.push_back(i);
        else if( i%3 == 0 ) c.push_back(i);
        else if( i%2 == 0 ){
            if( i%3 == 1 ) b.push_back(i);
            else a.push_back(i);
        }
    }

    vi ans;
    int ai=0,bi=0,ci=0,di=0,M=N;
    if( N%2 ) ans.push_back(d[di++]), M--;
    Rep(i,M){
        if( i%4 == 0 ) ans.push_back(a[ai++]);
        else if( i%4 == 1 ) ans.push_back(b[bi++]);
        else if( i%4 >= 2 ){
            if( ci < 5000 ) ans.push_back(c[ci++]);
            else ans.push_back(d[di++]);
        }
    }

    int sum = 0;
    Rep(i,N) printf ("%d%s", ans[i], i==N-1?"\n":" " );

    return 0;
}



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

int main(void) {
    long h, w, k;
    cin >> h >> w >> k;

    vector<string> a(h);
    for(auto &e: a) cin >> e;

    long si, sj;
    for(long i=0; i<h; i++)
        for(long j=0; j<w; j++)
            if(a[i][j] == 'S')
                si = i, sj = j;

    long dxy[] = {-1, 0, 1, 0, -1};
    set<pair<long,long>> s;
    {
        queue<tuple<long, long, long>> q;

        q.push(make_tuple(0, si, sj));
        s.insert({si, sj});

        while(!q.empty()) {
            long d, y, x;
            tie(d, y, x) = q.front(); q.pop();
            if(d == k) continue;

            for(long di=0; di<4; di++) {
                long dx = dxy[di], dy = dxy[di+1];
                long nx = x + dx, ny = y + dy;
                if(!(0 <= nx && nx < w && 0 <= ny && ny < h)) continue;
                if(s.count({ny, nx})) continue;
                if(a[ny][nx] == '#') continue;
                s.insert({ny, nx});
                q.push(make_tuple(d+1, ny, nx));
            }
        }
    }

    auto f = [&](pair<long,long> t) {
        long y, x;
        tie(y, x) = t;
        return min(min(x, y), min(w-1-x, h-1-y));
    };

    long r = 1e9;
    for(auto &t: s) {
        long u = (f(t) + k-1) / k;
        r = min(r, u);
    }
    cout << 1+r << endl;
}


Measured memory_bytes: 40320
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
long long moduloMultiplication(long long a,
                               long long b,
                               long long mod)
{
    long long res = 0; // Initialize result

    // Update a if it is more than
    // or equal to mod
    a %= mod;

    while (b)
    {
        // If b is odd, add a with result
        if (b & 1)
            res = (res + a) % mod;

        // Here we assume that doing 2*a
        // doesn't cause overflow
        a = (2 * a) % mod;

        b >>= 1; // b = b / 2
    }

    return res;
}
int main()
{
    double d, t, s;
    cin >> d >> t >> s;
    if (d / s <= t)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 3716
N = int(input())
W = list(map(int,input().split()))
ml = [0]*(N-1)
a = 0
for i in range(0,N-1):
    a = 0
    for j in range(0,i+1):
        a += W[j]
    ml[i] = abs(sum(W) - a*2)
print(min(ml))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    string S,T;
    int n,a;
    a=0;
    cin>>S>>T;
    n=S.length();
    for(int i=0;i<n;i++)
    {
        if(S[i]!=T[i])
        {
            a=a+1;
        }

    }
    cout<<a;
    return 0;

}


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

int main()
{
    ll x; cin >> x;
    ll a = 0;
    a = x/500;
    ll b = (x - 500*a)/5;
    a = a*1000 + b*5;
    

    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


string padding( string s, int L ) {
    string res = string( L, '0' );
    return res.substr( 0, L - s.size() ) + s;
}

int getMin( string s ) {
    sort( s.begin(), s.end() );
    ISS iss(s);
    int res;
    iss >> res;
    return res;
}

int getMax( string s ) {
    sort( s.rbegin(), s.rend() );
    ISS iss(s);
    int res;
    iss >> res;
    return res;
}

string getNext( string s, int L ) {
    int mins = getMin(s);
    int maxs = getMax(s);
    int next = maxs - mins;
    OSS oss;
    oss << next;
    return padding( oss.str(), L );
}

int toInt( string s ) {
    ISS iss(s);
    int res;
    iss >> res;
    return res;
}

map <string, int> M;
void solve( string s, int L ) {
    s = padding(s, L);
    M.clear();
    M[s] = 0;
    for ( int i = 1; ; ++ i ) {
        s = getNext(s, L);
        if ( M.find(s) == M.end() ) {
            M[s] = i;
            continue;
        }
        cout << M[s] << " " << toInt(s) << " " << i - M[s] << endl;
        break;
    }
}

int main() {
    string s;
    int L;
    while ( cin >> s >> L ) {
        if ( s == "0" && L == 0 ) break;
        solve( s, L );
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define y1 y3278
#define sz(v) int(v.size())
#define y2 y4368
#define y y4368232
#define x x43682322
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define tm tm3278
#define left left3278
#define right right3278
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <class T> using Pair_indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long INF = 2000000000000000000;
const long long Maxll = 9223372036854775807;
const long long MOD = 1000000000000037;
const int MOD2 = 1100000009;
const int inf = 1000000000;
const long long q0 = 31;
const int differ = 'a' - 'A';

/// Actual code starts here
ll t, n, m, k, x , y, sz;

void VOLK() {
    cin >> n;
    cout << n + n * n + n * n * n;

}
int main() {
    ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    t = 1;
    //cin >> t;
    while (t--)
        VOLK();
}


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

using namespace std;

int n, m, k;

int main() {
	bool flag = false;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i * m + n * j - 2 * i * j == k) {
				flag = true;
			}
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
sys.setrecursionlimit(2*2*10**5)

def dfs(i,p,edges,num):
    
    for j in edges[i]:
        if(j!=p):
            
            num[j] += num[i]
            
            dfs(j,i,edges,num)
    


N,Q = map(int,input().split())


#隣接リスト
edges = [ [] for i in range(N)]
num = [0]*N


for i in range(N-1):
    a0,b0 = map(int,input().split())

    edges[a0-1].append(b0-1)
    edges[b0-1].append(a0-1)
    
for i in range(Q):
    p0,x0 = map(int,input().split())

    num[p0-1] += x0
    
dfs(0,-1, edges, num)
    
for i in range(N):
    print(num[i], end=" ")


Measured memory_bytes: 231180
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.buffer.readline
from bisect import bisect_left
n=int(input())
*a,=map(int,input().split())
dp=[float("inf")]*n
con=[[] for _ in range(n)]
for _ in range(n-1):
	s,t=map(int,input().split())
	con[s-1].append(t-1)
	con[t-1].append(s-1)

ans=[0]*n
def dfs(cur,pre):
	idx=bisect_left(dp,a[cur])
	bef=dp[idx]
	dp[idx]=min(bef,a[cur])
	ans[cur]=bisect_left(dp,float("inf"))
	for nxt in con[cur]:
		if pre!=nxt:
			dfs(nxt,cur)
	dp[idx]=bef
dfs(0,-1)
print("\n".join(map(str,ans)))

Measured memory_bytes: 225432
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
long long f[N], a[N], A[N], NI[N];
int B, W;
long long calc(long long x, long long y)
{
    long long z = 1;
    while (y)
    {
        if (y & 1) (z *= x) %= mod;
        (x *= x) %= mod, y /= 2;
    }
    return z;
}
long long C(int x, int y)
{
    if (x < y) return 0;
    return A[x] * NI[y] % mod * NI[x - y] % mod;
}
void work(long long &v, int x, int y)
{
    v = a[x + y] * C(x + y, x) % mod;
}
int main()
{
    scanf("%d %d", &B, &W);
    a[0] = 1;
    a[1] = calc(2, mod - 2);
    for (int i = 2 ; i <= B + W ; i ++)
        a[i] = a[i - 1] * a[1] % mod;
    A[0] = 1;
    for (int i = 1 ; i <= B + W ; i ++)
        A[i] = A[i - 1] * i % mod;
    NI[B + W] = calc(A[B + W], mod - 2);
    for (int i = B + W - 1 ; i >= 0 ; i --)
        NI[i] = NI[i + 1] * (i + 1) % mod;
    for (int i = W ; i <= B + W; i ++)
    {
        work(f[i], W - 1, i - W);
        f[i] = f[i] * a[1] % mod;
        (f[i] += f[i - 1]) %= mod;
    }
    long long lv = 0, rv = 0;
    int lastl = -1, lastr = -1;
    for (int i = 1; i <= W + B; i ++)
    {
        long long ans = 0, ans1 = 0;
        if (i >= W)
            ans = f[i - 1];
        if (lastl != -1)
        {
             lv = (lv * 2 - C(i - 2, lastl) + mod) % mod;
        }
        if (lastr != -1)
        rv = (rv * 2 - C(i - 2, lastr) + mod) % mod;
        int nowl = max(0, i - B) - 1;
        int nowr = min(W - 1, i - 1);
        if (nowl != lastl)
        {
            lv = (lv + C(i - 1, nowl)) % mod;
            lastl = nowl;
        }
        if (nowr != lastr)
        {
            rv = (rv + C(i - 1, nowr)) % mod;
            lastr = nowr;
        }
        if (lastr >= lastl)
            ans1 = (rv - lv + mod) % mod;
        printf("%lld\n", (ans + ans1 * a[i]) % mod);
    }
    return 0;
}

Measured memory_bytes: 8448
include Math
n = gets.to_i
n.times do
	xa,ya,ra,xb,yb,rb = gets.chomp.split.map { |i| i.to_f }
	oa_ob = sqrt((xa-xb)**2 + (ya-yb)**2)
	if oa_ob < ra-rb
		puts 2
	elsif oa_ob < rb-ra
		puts (-2)
	elsif oa_ob > ra+rb
		puts 0
	else
		puts 1
	end
end
		

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] A = new int[n];
        Arrays.setAll(A, i -> Integer.parseInt(sc.next()));
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++)
            ans = Math.min(ans,
                    Math.min(i==0 ? A[n-1] - A[i] : k - (A[i] - A[i-1]),
                             i==n-1 ? A[i] - A[0] : A[i] + (k - A[i+1])));
        System.out.println(ans);
    }
}


Measured memory_bytes: 63816
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  if((a%2)&&(b%2)) cout<<"Yes";
  else cout<<"No";
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	char o[51], e[51]; scanf("%s %s", o, e);
	int l = strlen(o);
	for(int i = 0; i < l; i++){
		if(e[i] != '\0') printf("%c%c", o[i], e[i]);
		else putchar(o[i]);
	}
	puts("");
	return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(void){
	int N, K;
	cin >> N >> K;
	ll Neg[N];
	ll Pos[N];
	int Nn, Np;
	Nn = 0;
	Np = 0;
	ll tmp;
	rep(i,N){
		cin >> tmp;
		if (tmp>=0){
			Pos[Np] = tmp;
			Np++;
		}
		else{
			Neg[Nn] = tmp;
			Nn++;
		}
	}

	tmp = 1;
	if (N == K){
		rep(i,Nn) tmp = (tmp*Neg[i])%Nmax;
		rep(i,Np) tmp = (tmp*Pos[i])%Nmax;
		cout << (Nmax+tmp)%Nmax << endl;
		return 0;
	}

	tmp = 1;
	if ((Np == 0 && K%2 == 1)){
		sort(Neg, Neg+Nn, greater<>());
		rep(i,K) tmp = (tmp*Neg[i])%Nmax; 
		cout << (Nmax+tmp)%Nmax << endl;
		return 0;
	}

	/*
	sort(Neg, Neg+Nn);
	sort(Pos, Pos+Np, greater<>());
	
	ll ans;
	vector<ll> pairs;
	for (int i = 0; i <= Nn-2; i+=2) {
		pairs.push_back(Neg[i]*Neg[i+1]);	
	}
	if (K%2 == 0){
		ans = 1;
		for (int i = 0; i <= Np-2; i+=2) {
			pairs.push_back(Pos[i]*Pos[i+1]);
		}
	}
	else {
		ans = Pos[0];
		for (int i = 1; i <= Np-2; i+=2) {
			pairs.push_back(Pos[i]*Pos[i+1]);
		}
	}

	sort(pairs.rbegin(), pairs.rend());
	rep(i,K/2) {
		ans *= pairs[i];
		ans %= Nmax;
	}
	*/
	mint ans = 1;
	vector<ll> s(Pos, Pos+Np);
	vector<ll> t(Neg, Neg+Nn);
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (K%2 == 1) {
		ans *= s.back();
		s.pop_back();
	}
	vector<ll> p;
	while (s.size() >= 2) {
		ll x = s.back(); s.pop_back();
		x *= s.back(); s.pop_back();
		p.push_back(x);
	}
	while (t.size() >= 2) {
		ll x = t.back(); t.pop_back();
		x *= t.back(); t.pop_back();
		p.push_back(x);
	}
	sort(p.rbegin(), p.rend());
	rep(i,K/2) {
		ans *= p[i];
	}
	cout << ans << endl;

return 0;
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b;
    else cout<<b-a;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

ll MOD = 1000000007;
ll n;

ll Pow(ll m){ //m^nを返す
  ll ret = 1;
  rep(i,n){
    ret *= m;
    ret %= MOD;
  }
  ret %= MOD;
  //cout << "m=" << m << ",ret = " << ret << endl;
  return ret;
}

vector<pair<ll, ll>> Prime_Factorize(ll n){
  vector<pair<ll, ll>> ans;
  for (ll a=2; a*a<=n; a++){
    if (n%a != 0) continue;
    ll ex = 0; //指数
    while(n%a == 0){
      ex++;
      n /= a;
    }
  ans.push_back({a, ex});
  }
  if (n != 1) ans.push_back({n,1});
  return ans;
}

int main(){
  ll n; cin >> n;
  const auto res = Prime_Factorize(n);
  ll ans = 0;
  for (auto p:res){
    ll exp = p.second;
    //cout << exp << "," << endl;
    ll lim = 0;
    for (int i=1; i<=exp; i++){
      lim += i;
      if (exp == 1){
        ans += 1;
        break;
      }
      if (lim > exp){
        ans += i-1;
        break;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3544
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    int n=in,k=in,i=0;
    while(n>0){
        n/=k;
        i++;
    }
    out(i);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main{
	static long memo[][];
	static int n;
	static int m;
	static char[][]a;
	static long dp(int k,int l) {
	for(int i=1;i<n;i++) {
		for(int j=1;j<m;j++) {
			if(a[i][j]=='#')memo[i][j]=0;
			else
			memo[i][j]=memo[i-1][j]%(1000000000+7)+memo[i][j-1]%(1000000000+7);
		}
	}
	return memo[n-1][m-1]%(1000000000+7);
   
    }
    
	public static void main(String []args) throws IOException {
 		PrintWriter pw =new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st =new StringTokenizer(br.readLine());
		 n=Integer.parseInt(st.nextToken());
	     m=Integer.parseInt(st.nextToken()); 
		memo=new long [n][m];
		a=new char[n][m];
		for(int i=0;i<n;i++) {
			StringBuilder sb=new StringBuilder(br.readLine());
			for(int j=0;j<m;j++)a[i][j]=sb.charAt(j);
		}int pos1=n,pos2=m;
		for(int i=0;i<n;i++)if(a[i][0]=='#'){memo[i][0]=0;pos1=i;break;}else memo[i][0]=1;
		for(int i=pos1+1;i<n;i++)memo[i][0]=0;
		for(int i=0;i<m;i++)if(a[0][i]=='#'){memo[0][i]=0;pos2=i;break;}else memo[0][i]=1;
		for(int i=pos2+1;i<m;i++)memo[0][i]=0;
		pw.println(dp(1,1));
        pw.flush();
}
}

Measured memory_bytes: 38352
#include<iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b)      cout << "a" << " > " << "b" << endl;
    else if(a < b) cout << "a" << " < " << "b" << endl;
    else           cout << "a" << " == " << "b" << endl;
    return 0;
}


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

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

    double out = 0;
    for (int i = 0; i < n; i++) {
        double a; cin >> a;
        out += 1 / a;
    }

    cout << setprecision(10);
    cout << 1 / out << endl;

}


Measured memory_bytes: 256
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;
    var height = fieldInfo[1] - 0;
          
    if(!width && !height){
      break;
    }
          
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    var c;
    for(var y = height; y--;){
      i++;
      var ni = input[i];
      for(var x = 0; x < width; x++){
        c = ni[x];
        
        if(c === '.'){
        }else if(c === '1' || c === '2' || c === '3' || c === '4' || c === '5'){
          var e = elem[c - 1];
          e[e.length] = pos(x, y);
        }else if(c === 'S'){
          start = pos(x, y);
        }else{
          goal = pos(x, y);
        }
          
      }
    }
          
    var INF = 1 << 30;
    var bestElement = -1;
    var distance = INF;
    
    for (var startElem = 0; startElem < 5; startElem++) {
      
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        var initdph = dp[h];
        initdph.length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          initdph[hidx] = INF;
        }
      }
      
      var first = (startElem + 1) % 5;
      var firstLength = elem[first].length;
      var dpf = dp[first];
      var elemf = elem[first];
      for (var j = 0; j < firstLength; j++) {
        dpf[j] = dist(start, elemf[j]);
      }
      
      for (var e = 0; e < 3; e++) {
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var dpnw = dp[now];
        var dpnx = dp[next];
        var elnw = elem[now];
        var elnx = elem[next];
        var nowLength = elnw.length;
        var nextLength = elnx.length;
        for (var j = 0; j < nowLength; j++) {
          var dpnwj = dpnw[j];
          var elnwj = elnw[j];
          for (var k = 0; k < nextLength; k++) {
            dpnx[k] = min(
              dpnx[k],
              dpnwj + 
                  dist(elnwj, elnx[k]));
          }
        }
      }

      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      var dpl = dp[last];
      var ell = elem[last];
      for (var j = 0; j < lastLength; j++) {
        var d = dpl[j] + dist(ell[j], goal);
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
                  
      }
                
    }
              
    if (distance == INF) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
          
    i++;
  }
            
          
}
          
function dist(from, to){
  return abs((from >> 11) - (to >> 11)) + abs((from & 2047) - (to & 2047));
}
          
function min(a, b){
  var t = a - b;
 return b + (t & (t >> 31));
}
          
function pos(a, b){
  return (a << 11) + b;
}
         
function abs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
          
var
input = '';
          
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

int main() {

  while(1) {
  int n;
  cin >> n;
  if(n == 0) break;
  
  string str[51];
  int p,a,b,c,d,e,f,s,m;
  double money[51];
  for(int i=0;i<n;i++){
    cin >> str[i] >> p  >> a >> b >> c >> d >> e >> f >> s >> m;
    money[i] = ((double)f*s*m - p) / (a + b + c +(d + e)*m);
    //   cout <<str[i] <<" " << money[i] << endl;
  }
  
    double t;
    string ts;

    for(int i=0;i<n;i++) {
      for(int j=n-1;j>i;j--) {
	if(money[j] > money[j-1]){
	  t = money[j];
	  money[j] = money[j-1];
	  money[j-1] = t;

	  ts = str[j];
	  str[j] = str[j-1];
	  str[j-1] = ts;
	}
	if(money[j] == money[j-1] && str[j] < str[j-1]) {
	  ts = str[j];
	  str[j] = str[j-1];
	  str[j-1] = ts;
	}
      }
    }

    
    
    for(int i=0;i<n;i++) cout << str[i] << endl;
    cout <<"#"<< endl;

        
  }
  
  return 0;
  
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

int32_t main()
{
    IOS
    int n;
    cin>>n;
    vector<int>v;
    int arr[n];
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        arr[i]=x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        auto itr=upper_bound(v.begin(),v.end(),arr[i]);
        auto itl=lower_bound(v.begin(),v.end(),arr[i]);
        if(itr==v.end()&&itr-itl==1){
            cout<<*(--itl)<<'\n';
        }
        else cout<<v[v.size()-1]<<'\n';
    }
    return 0;
}
        

Measured memory_bytes: 4848
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

int main(){
	string s;
	while(getline(cin,s)){
		if(s==".") break;
		stack<char> st;
		bool flag = true;
		for(char c : s){
			if(c == '(' || c == '[') st.push(c);
			else if(c ==')') {
				if(st.empty() || st.top() != '(') {
					flag =false;
					break;
				}
				st.pop();
			} 
			else if(c ==']') {
				if(st.empty() || st.top() != '[') {
					flag =false;
					break;
				}
				st.pop();
			} 
		}
		if(!st.empty()) flag = false;
		cout<<(flag?"yes":"no")<<endl;
	}
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<int>
#define  pb push_back
int func(vector<vi> &mat,int n){
    for(int i=1;i<n;i++){
        mat[i][0]+=max(mat[i-1][1],mat[i-1][2]);
        mat[i][1]+=max(mat[i-1][0],mat[i-1][2]);
        mat[i][2]+=max(mat[i-1][0],mat[i-1][1]);
    }
    return max(mat[n-1][0],max(mat[n-1][1],mat[n-1][2]));
}
int main(){
        int n;
        cin>>n;
        vector<vi> mat(n,vi(3));
        for(int i=0;i<n;i++){
            cin>>mat[i][0];
            cin>>mat[i][1];
            cin>>mat[i][2];
        }
        cout<<func(mat,n)<<endl;
        return 0;
    }

Measured memory_bytes: 8764
import itertools

n, m, x = map(int, input().split())
cost = 10**9
a = [list(map(int, input().split()))]

for i in range(n - 1):
    a.append(list(map(int, input().split())))

for i in range(1, n + 1): #購入する参考書の数
    for j in itertools.combinations(range(n), i): #購入する参考書の組合せ
        l = [0]*(m + 1)
        for k in j: #購入する参考書の種類をロード
            for o in range(m + 1): #1冊の参考書の情報を代入
                l[o] += a[k][o]
        cnt = 0
        for p in range(1, m + 1):
            if l[p] < x:
                break
            else:
                cnt += 1
        if cnt == m:
            cost = min(cost, l[0])


if cost < 10**9:
    print(cost)
else:
    print(-1)

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

int findSumOfDigits(int n) {
    int sum = 0;
    while (n) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n, ans = 1e9;
    cin >> n;
    REP(a, 1, n) {
        int b = n - a;
        ans = min(ans, findSumOfDigits(a) + findSumOfDigits(b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256