akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ABC154
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split().ToArray();
            string S = input[0];
            string T = input[1];
            int[] input2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input2[0];
            int B = input2[1];
            string U = Console.ReadLine();

            if (U == S) A--;
            else B--;

            Console.WriteLine("{0} {1}", A, B);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, ac=0, wa=0, tle=0, re=0;
    cin >> n;
    vector<string> s(n);
    rep(i, n)cin >> s[i];
    rep(i, n){
        if(s[i] == "AC")ac++;
        if(s[i] == "WA")wa++;
        if(s[i] == "TLE")tle++;
        if(s[i] == "RE")re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    OP(min(b / a, c));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define BIG 10e18
#define ll long long
int  a,b,c;
long long k;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    scanf("%lld",&k);

    if(BIG-a-b<0)
        {
             printf("Unfair");
             return 0;
        }
    if(k%2==0)
        k=a-b;
    else
    {
        k=b-a;

    }
    printf("%lld",k);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define max2(a,b) ((a)>(b)?(a):(b))   
#define min2(a,b) ((a)<(b)?(a):(b)) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef pair<ll,ll>     pll;
typedef pair<int,int>   pii;
typedef vector<ll>      vll;
typedef vector<int>      vi;
typedef vector< pll >  vpll;
typedef vector< pii >  vpii;
typedef set<ll>         sll;
typedef set<int>         si;
typedef set< pll >     spll;
typedef set< pii >     spii;
clock_t clk=clock();       

ll i,j,k;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
// #define cerr if(0)cerr

void solve()
{
   ll n; cin>>n;
   ll a[n];
   rep(i,0,n-1) cin>>a[i];
   sort(a,a+n);

   int ct=0;
   rep(i,0,100000)
     {
     	int pos=lower_bound(a,a+n,i)-a;
     	--pos;
     	if(pos+1==n-pos-1) ++ct;
     }	
     cout<<ct<<'\n';
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int y1,m1,d1,y2,m2,d2;
	int i;
	int y1day,y2day;
	while(1){
		scanf("%d %d %d %d %d %d",&y1,&m1,&d1,&y2,&m2,&d2);
		y1day=y2day=0;
		if(y1==-1 || m1==-1 || d1==-1 || y2==-1 || m2==-1  || d2==-1) break;
		y1day=y2day=0;
		for(i=1;i<y1;i++){
			y1day+=365;
			if((i%4==0 && i%100!=0) || i%400==0) y1day++;
		}
		for(i=1;i<m1;i++){
			y1day+=31;
			if(i==4 || i==6 || i==9 || i==11) y1day-=1;
			if(i==2){
				y1day-=3;
				if((y1%4==0 && y1%100!=0) || y1%400==0) y1day++;
			}
		}
		y1day+=d1;
		for(i=1;i<y2;i++){
			y2day+=365;
			if((i%4==0 && i%100!=0) || i%400==0) y2day++;
		}
		for(i=1;i<m2;i++)	{
			y2day+=31;
			if(i==4 || i==6 || i==9 || i==11) y2day--;
			if(i==2){
				y2day-=3;
				if((y2%4==0 && y2%100!=0) || y2%400==0) y2day++;
			}
	//		printf("y2d==%d\n",y2day);
		}
		y2day+=d2;
	//	printf("%d %d\n",y1day,y2day);
		printf("%d\n",y2day-y1day);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int cnt = 0;
  for (int i = 0; i <= n; i += r)
  {
    for (int j = 0; j <= n; j += g)
    {
      int k = n - (i + j);
      if (k >= 0 && k % b == 0)
        cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


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

int main() 
{
	int n,k=0;
	string a;
	cin>>n>>a;
	for(int i=0;i<n-2;i++)
	{
		if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C')
		{
			k++;
		}
	}
	cout<<k;
}

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

int main() {
    int k;
    string s;
    cin >> k;
    cin >> s;

    if (s.length() <= k) {
        cout << s << endl;
    } else {
        string s2 = s.substr(0, k) + "...";
        cout << s2 << endl;
    }
}


Measured memory_bytes: 3632
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;
void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {
  vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);
} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  nl                     printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 500 + 5;
const int N1            = 3e5 + 5;
int visit[N][N];
string s[505];

int solve()
{
	//happy coding
	ll n,a,b;
	cin>>n>>a>>b;
		ll x = n%(a+b);
		cout<<a*(n/(a+b))+min(x,a)<<endl;
	//error()
	return 0;
}

int main(){
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--)solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
bool visited[100005];
const int max_N=1e5+10;
ll K;
string s;
int main(void)
{
  cin >> s;
  cin >> K;
  for(int i=0;i<int(s.size());i++)
    {
      if(i!=int(s.size())-1)
	{
	  if(s[i]=='a') continue;
	  if(K>=int('z'-s[i])+1)
	    {
	      //cout << int('z'-s[i])+1 << endl;
	      K-=(int('z'-s[i])+1);
	      s[i]='a';
	      //cout << K << endl;
	    }
	}
      else if(i==int(s.size())-1)
	{
	  K+=int(s[i]-'a');
	  K%=26;
	  s[i]=char('a'+K);
	  break;
	}
    }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
def main():
  S = input()
  L = ['A', 'C', 'G', 'T']
  res = 0
  
  count = 0
  for i in range(len(S)):
    if S[i] in L:
      count += 1
    else:
      if (res < count):
        res = count
      count = 0

  if (res < count):
    res = count
  print(res)
main()


Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    cout<<setprecision(16);
    ll n;
    cin>>n;
    ll n2 = (n+1)/2;

    double ans = double(n2)/double(n);
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    int A,B;
    cin >> A >> B;
    if(A<= B*2){
        cout << 0 << endl;
    }else{
        cout << A-B*2 << endl;
    }

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    ll sum=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        sum+=a[i];
        a[i]*=2;
    }
    vector<ll>ans(n,0);
    ans[0]+=sum;
    for (int i = 0; i <n/2; ++i) {
        ans[0]-=a[1+i*2];
    }
    for (int i = 0; i < n - 1; ++i) {
//        cout <<a[i]<<" "<<ans[i]<<endl;
        ans[i+1]=a[i]-ans[i];
    }
    for (int i = 0; i < n; ++i) {
        cout <<ans[i]<<" ";
    }
    cout <<endl;
    return 0;
}



Measured memory_bytes: 2944
S = set(list(input()))

if len(S) == 4:
    ans = "Yes"
elif len(S) == 3 or len(S) == 1:
    ans = "No"
else:
    # print(list(S))
    if ("N" in S and "S" in S) or ("E" in S and "W" in S):
        ans = "Yes"
    else:
        ans = "No"

print(ans)


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

min_val_list = []
max_val_list = []
for i in range(M):
    min_id_range, max_id_range = map(int, input().split())
    min_val_list.append(min_id_range)
    max_val_list.append(max_id_range)

min_val_id = max(min_val_list)
max_val_id = min(max_val_list)


if min_val_id > max_val_id:
    print(0)
else:
    print(max_val_id - min_val_id + 1)


Measured memory_bytes: 11016
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};
#define pb push_back 

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i];
        a[i] -= (i+1);
        b[i] = a[i];
    }
    sort(b.begin(),b.end());

    ll m = b[n/2], ans = 0;
    rep(i,n){
        ans += abs(a[i] - m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define MOD 1000000007
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
ll calc(int t){
	ll res=1;
	while(t>1){
		res=res*(t--)%MOD;
	}
	return res;
}
int main(void)
{
	int n,m,i;
	ll t,x,y,z;
	scanf("%d%d",&n,&m);
	if(n<m) swap(int,n,m);
	if(n>m+1){
		puts("0");
		return 0;
	}
	if(n==m+1) printf("%lld\n",calc(n)*calc(m)%MOD);
	else printf("%lld\n",calc(n)*calc(m)*2%MOD);
	return 0;
}
    
    

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
int product,i=1,j=1;
int p[31];
int x,maxnumber = 0;
scanf("%d",&x);
p[0] = 1;
for (i = 2;i <= 31;i++){
    product = i;
    if(product*i<=x){
    while(product*i <= x){
        product = product*i;
    }    
    }    
    else{
        product = 1;
    }
    p[i-1] = product;
}
for(j=0;j<31;j++){
    if(maxnumber <= p[j]){
    maxnumber = p[j];
    }
}

if(x == 1){
    printf("%d\n",p[0]);
}
else if(x > 1){
    printf("%d\n",maxnumber);
}
return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;


bool ** v;
int ** dp;
int *a, *b, *c;
int solve(int n, const int& max, char last){
	if (n == max)
		return 0;

	if (v[n][last]) return dp[n][last];
	
	int score_a = last == 'a' ? 0 : solve(n+1, max, 'a') + a[n];
	int score_b = last == 'b' ? 0 : solve(n+1, max, 'b') + b[n];
	int score_c = last == 'c' ? 0 : solve(n+1, max, 'c') + c[n];

	dp[n][last] = std::max({score_a, score_b, score_c});
	v[n][last] = 1;

	return dp[n][last];


	
}

int main(){
	int N;
	cin >> N;
	v = new bool*[N];
	a = new int[N];
	b = new int[N];
	c = new int[N];
	dp = new int*[N];


	for(int i = 0;i < N;i++){
		v[i] = new bool[3];
		dp[i] = new int[3];
		cin  >> a[i];
		cin >> b[i];
		cin >> c[i];
	}


	//fill(&dp[0][0], &dp[0][0] + sizeof(dp), 0);
	//fill(&v[0][0], &v[0][0] + sizeof(v), 0);

	cout << solve(0, N, 0) << endl;
	return 0;
}


Measured memory_bytes: 20356
def fib(n, broken):
    a = 1
    b = 1
    for i in range(n-2):
        # if i in broken:

        a, b = b, a + b
    print(b)


# t = int(input())
t = 1

for _ in range(t):
    n, m = [int(x) for x in input().split()]
    broken = set()
    for _ in range(m):
        broken.add(int(input()))

    x = 0
    y = 1
    i = 1
    impossible = False
    c = 0
    while i <= n:
        # print(f'degrau: {i}')
        # print(f'main loop: i: {i}')
        if i in broken:
            # print('broken')
            x = y
            if i + 1 in broken:
                impossible = True
                break
            while not ((i + 1) not in broken and (i + 2) not in broken and (i + 3) not in broken):

                if i + 1 in broken and i + 2 in broken:
                    impossible = True
                if i + 2 in broken and i + 3 in broken:
                    impossible = True

                i += 1
            i += 2
            # while True:
            #     print('entrei')

            #     if not ((i + 1) not in broken and (i + 2) not in broken and (i + 3) not in broken):
            #         print('aqui')

            #         i += 1
            #         print(f'i: {i}')
            #         break
            #     i += 3
            #     break

            #     c = 0
            #     for x in range(i + 1, i + 4):
            #         if x in broken:
            #             c += 1
            #     if c >= 2:
            #         impossible = True

            #     print(f'i: {i}')
            # if i + 1 not in broken and i + 2 not in broken and i + 3 not in broken:
            #     i += 1

            # print('broken')
            # x = y
            # # y = x
            # print(f'x: {x}, y: {y}')
            # previous_broken = False
            # while i not in broken and (i + 1) not in broken and (i + 2) not in broken:
            #     i += 1
            # while c < 2:
            #     i += 1
            #     if i in broken:
            #         if previous_broken:
            #             impossible = True
            #         previous_broken = True
            #         continue
            #     else:
            #         previous_broken = False
            #         c += 1
            # i += 2
            # c = 0
        else:
            y, x = (x + y) % 1000000007, y % 1000000007
            # print(f'x: {x}, y: {y}')
            c = 0
        i += 1
        # print(y)
    print(0) if impossible else print(y % 1000000007)


Measured memory_bytes: 11884
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		Set<String> s_set = new HashSet<>();
		for(int i=0; i<N; i++) {
			String s = sc.next();
			s_set.add(s);
		}

		System.out.println(s_set.size());
	}
}


Measured memory_bytes: 77088
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 998244353;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

string solve(int A, string B) {
    string ret = "error";
    int max_sum = 0;
    for (int i = 0; i < (1 << (B.length() - 1)); i++) {
        int bits = i;
        int sum = 0;
        int num = 0;
        string shredded;
        for (int j = 0; j < B.length(); j++) {
            num += B[j] - '0';
            shredded += B[j];
            if (bits & (1 << j) || j == B.length() - 1) {
                sum += num;
                num = 0;
                if (j != B.length() - 1) shredded += ' ';
            }
            num *= 10;
        }
        if (sum > max_sum && A >= sum) {
            ret = to_string(sum) + ' ' + shredded;
            max_sum = sum;
        } else if (sum == max_sum) {
            ret = "rejected";
        }
    }
    return ret;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> cd;
    for (int i = 0; i < M; i++) {
        int c, d; cin >> c >> d;
        if (c > d) continue;
        cd.push_back({c, d});
    }
    if (cd.size() == 0) {
        cout << N+1 << endl;
        return 0;
    }

    sort(cd.begin(), cd.end());
    vector<pair<int, int>> merged_cd;
    merged_cd.push_back(cd[0]);
    for (int i = 1; i < cd.size(); i++) {
        if (cd[i].first <= merged_cd[merged_cd.size() - 1].second) {
            merged_cd[merged_cd.size() - 1].second = max(merged_cd[merged_cd.size() - 1].second, cd[i].second);
        } else {
            merged_cd.push_back(cd[i]);
        }
    }
    int ans = 0;
    for (int i = 0; i < merged_cd.size(); i++) {
        ans += (merged_cd[i].second - merged_cd[i].first) * 2;
    }
    ans += N+1;
    cout << ans << endl;
}



Measured memory_bytes: 3100
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<algorithm>

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

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }

int main(){
	for(int n;scanf("%d",&n),n;){
		static ll b[32000];
		int m=n*(n+1)/2;
		rep(i,m) scanf("%lld",b+i);

		int n_ev=0,n_od=0;
		static ll b_ev[250],b_od[32000];
		rep(i,m){
			if(b[i]%2==0) b_ev[n_ev++]=b[i];
			else          b_od[n_od++]=b[i];
		}

		sort(b_ev,b_ev+n_ev);
		sort(b_od,b_od+n_od);

		vector<ll> a0_cand;
		rep(j,n_ev) rep(i,j) {
			ll x=b_ev[i],y=b_ev[j],z=b_od[0],g;
			g=gcd(x,z); x/=g; z/=g;
			g=gcd(y,z); y/=g; z/=g;
			if(z==1){
				ll a0=(ll)(sqrt(x)*sqrt(y)+0.5);
				for(ll t=max(a0-7,2LL);t<=a0+7;t++){
					if(t%2==0 && t*t==x*y) a0_cand.push_back(t);
				}
			}
		}
// puts("cand");
// rep(i,a0_cand.size()) printf("%lld ",a0_cand[i]); puts("");
		ll a0;
		static ll a_od[250];
		rep(i,a0_cand.size()){
			a0=a0_cand[i];

			rep(j,n) a_od[j]=b_ev[j]/a0;

			int n_od2=0;
			static ll b_od2[32000];
			rep(k,n_ev) rep(j,k) b_od2[n_od2++]=a_od[j]*a_od[k];
			sort(b_od2,b_od2+n_od2);

			bool ok=true;
			rep(j,n_od) if(b_od[j]!=b_od2[j]) { ok=false; break; }
			if(ok) break;

			// bool ok=true;
			// rep(j,300){
				// int k1=rand()%n;
				// int k2=rand()%n;
				// if(k1>=k2){ j--; continue; }
				// ll b_rnd=a_od[k1]*a_od[k2];
				// if(!binary_search(b_od,b_od+n_od,b_rnd)) ok=false;
			// }
			// if(ok) break;
		}

		printf("%lld\n",a0);
		rep(i,n_ev) printf("%lld%c",a_od[i],i<n_ev-1?' ':'\n');
	}

	return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll a(N);
        map<ll, ll> mp;
        rep(i, 0, N) {
                ll a;
                cin >> a;
                mp[a]++;
        }
        ll ans = 0;
        for (auto el : mp) {
                ll n = el.first;
                ll c = el.second;
                if (n < c) {
                        ans += c - n;
                } else if (n > c) {
                        ans += c;
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 7040
function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = input[0];
  var B = input[1];
  var ans  = "";
  if(A < B.length){
    ans += B.slice(0,A) + "...";
  }else{
    ans=B;
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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



int x;
cin>>x;
int a=x/100;
int b=x%100;

bool c1=0,c2=0;

if(a<=12&&a>=1)
c1=true;

if(b<=12&&b>=1)
c2=true;
if(c1&&c2)
{
  cout<<"AMBIGUOUS\n";
}
else if(c1)cout<<"MMYY\n";
else if(c2)cout<<"YYMM\n";
else cout<<"NA";



  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ll;
typedef std::pair<int, int> P;
 
#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back
 
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 200010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	string s, t; cin >> s >> t;
	rrep(i, s.size()){
		bool flag = true;
		if(s[i] == t[t.size()-1] || s[i] == '?'){
			string ss = s;
			rrep(j, t.size()){
				int k = i - t.size() + 1 + j;
				if(t[j] != s[k] && s[k] != '?'){
					flag = false;
				}else{
					ss[k] = t[j];
				}
			}
			if(flag){
				rep(i, ss.size()){
					if(ss[i] == '?') cout << 'a';
					else cout << ss[i];
				}
				cout << END;
				return;
			}
		}
	}
	cout << "UNRESTORABLE" << END;
}
 
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 256
/*   --------------------
    |       MAGIC        |
    |       ~KIRI~       |
     --------------------
*/
#pragma comment(linker, "/stack:200000000")
#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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define inl(x) scanf("%lld",&x)
#define in(x) scanf("%d",&x)
#define ll long long
#define mp(x,y) make_pair(x,y)
#define mxx 100000000000000000
#define pi 2*acos(0.0)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
ll prime = 1000000000+7;
int main()
{

    int n;
    in(n);
    string s;
    cin >> s;
    map <char,int> m;
    m.clear();
    map <char,int> :: iterator it;
    for(int i=0;i<s.size();i++)
    {
        m[s[i]]++;
    }
    ll ans=1,p,q;
    for(it=m.begin();it!=m.end();it++)
    {
//        cout << it->second<<endl;
        p = it->second;
        ans*=(p+1);
        ans %= prime;
    }
    ans--;
    printf("%lld\n",ans%prime);
    return 0;
}


Measured memory_bytes: 512
N,M = map(int,input().split())
I = set()
n = set()
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        I.add(b)
    if b == N:
        n.add(a)
if  I & n == set():
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/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; }



int main(){
  int n;
  cin >> n;
  V<string> s(n);
  rep(i,n) cin >> s[i];
  V<map<char, int>> mp(n);
  rep(i,n) {
    rep(j,sz(s[i])) {
      mp[i][s[i][j]]++;
    }
  }
  for(char c = 'a'; c <= 'z'; c++) {
    int cnt = inf;
    rep(i,n) chmin(cnt, mp[i][c]);
    rep(i,cnt) cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i,n) {
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i,m) {
    int a = q.top(); q.pop();
    q.push(a/2);
  }
  ll ans = 0;
  rep(i,n) {
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
    cout << "No" << endl;
    return 0;
  }
  else{
    if (S.substr(0,N/2)==S.substr(N/2,N/2)){
      cout << "Yes" << endl;
      return 0;
    }
    else{
      cout << "No" << endl;
    }
  }
}
  

Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let abc = readn::<usize>(" ");
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];

    if a + b >= c {
        println!("No");
    } else {
        let r = (c - a - b) * (c - a - b);
        let l = 4 * a * b;
        if l < r {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int a, b, c;

void solve() {
	cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust";
	else cout << "win";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3616
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

std::unordered_map<ll, ll> f_memo;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll mod = 1000000000+7;
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll inv_mul(ll x, ll y){
    return (x % mod* modpow(y,mod-2,mod))%mod;
}
ll b,w;
ll f(ll i,ll c){
    ll bw;
    if(c == b){
        bw = 0;
    }else{
        bw = 1;
    }
    if(i== c+1){
        return inv_mul(COM(i-2,c-1), modpow(2,i-1,mod));
    }
    if(f_memo[i*10 + bw]!=0){
        return f_memo[i*10 + bw];
    }else{
        ll ans = f( (i-1), c) + inv_mul(COM(i-2,c-1), modpow(2,i-1,mod));
        ans %= mod;
        return f_memo[i*10 + bw] = ans;
    }
}

int main() {
    COMinit();
    std::cin >> b>>w;
    for (int i = 1; i <= b+w; i++) {
        ll result = 0;
        if(i<=b){
            if(i<=w){
                result =  inv_mul(1,2)%mod ;
            }else{
                result =  inv_mul(1,2)%mod  + inv_mul(1,2) %mod * f(i,w) %mod;
            }
        }else{
            if(i<=w){
                result = inv_mul(1,2) %mod * (( 1 - f(i,b) + mod)%mod)%mod;
            }else{
                result = inv_mul(1,2) %mod * (( 1 - f(i,b) + mod)%mod)%mod+ inv_mul(1,2) %mod * f(i,w) %mod;
            }
        }
        std::cout << result %mod<< std::endl;
    }
    
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string S;		cin>>S;
	if(S=="SUN")	cout<<"7"<<endl;
	else if(S=="MON")	cout<<"6"<<endl;
	else if(S=="TUE")	cout<<"5"<<endl;
	else if(S=="WED")	cout<<"4"<<endl;
	else if(S=="THU")	cout<<"3"<<endl;
	else if(S=="FRI")	cout<<"2"<<endl;
	else cout<<"1"<<endl;


    return 0;
}



Measured memory_bytes: 256
from collections import deque
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
q = deque()
q.append([1])
while q:
  A = q.pop()
  if len(A) == N+1:
    ans = max(ans, sum([d if A[b]-A[a] == c else 0 for a, b, c, d in ABCD]))
  else:
    for i in range(A[-1], M+1):
      q.append(A+[i])
print(ans)

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

signed main() {
    string s;
    int K;
    cin >> s >> K;

    string ans = s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        int t = 'z' - s[i] + 1;
        if (cnt + t <= K) {
            ans[i] = 'a';
            cnt += t % 26;
        }
    }
    char& c = ans.back();
    c = 'a' + (c - 'a' + K - cnt) % 26;
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), Q = sc.nextInt();
		int A[] = new int[Q], B[] = new int[N];
		for(int i = 0; i < Q; i++) A[i] = sc.nextInt();
		for(int i = 0; i < Q; i++) {
			for(int j = 0; j < N; j++) {
				int r = sc.nextInt();
				if(A[i] == r) B[j]++;
				else B[A[i] - 1]++;
			}
		}
		for(int i = 0; i < N; i++) System.out.println(B[i]);
	}
}

Measured memory_bytes: 38140
#include<stdio.h>
#include<math.h>
int f(int a){return a*a;}
int main(){
  int n,m,l,s,i,j,k,c=0,d[110][110];
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++)scanf("%d",&d[i][j]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=l=0;k<m;k++)l+=f(d[i][k]-d[j][k]);
      s=sqrt(l);
      if(l==s*s)c++;
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;

bool isPrime(int n){
    if(n < 2) return false;
    else if(n == 2) return true;
    else if(n % 2 == 0) return false;
    
    double s = sqrt(n);
    for(int i=3; i<=s; i+=2){
        if(n % i == 0) return false;
    }

    return true;
}


int main() {
    int N;
    cin >> N;
    
    int cnt=0, n=11;
    while(cnt < N){
        if(isPrime(n) && (n % 5 == 1)) {
            cout << n << " ";
            cnt++;
        }
        n+=2;
    }
    cout << endl;
}


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

const int MAXV = 100010;
const long long INF = 0xfffffffffffff;

bool cmp(long long a, long long b){return a < b;}

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long N, M, K;
    
    cin >> N >> M >> K;
    
    vector<long long> A(N), B(M);
    
    cin >> A[0];
    for (long long i = 1; i < N; i++) {
        cin >> A[i];
        A[i] += A[i - 1];
    }
    
    cin >> B[0];
    for (long long i = 1; i < M; i++) {
        cin >> B[i];
        B[i] += B[i - 1];
    }
    
    
    auto upa = A.begin();
    auto upb = B.begin();
    upa = upper_bound(A.begin(), A.end(), K);
    
    int max_cnt = 0;
    for (auto it = A.begin(); it <= upa; it++) {
        if (it == A.begin()) {
            upb = upper_bound(B.begin(), B.end(), K);
        } else {
            upb = upper_bound(B.begin(), B.end(), K - A[it - A.begin() -1]);
        }
        int cnt = it - A.begin() + upb - B.begin();
        max_cnt = max(max_cnt, cnt);
    }
    
    
    
    cout << max_cnt << endl;
    
    
    return 0;
}


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

int main() {
	char x, y;
	cin >> x >> y;
	char ans;
	if (x - y == 0) {
		ans = '=';
	} else if (x - y > 0) {
		ans = '>';
	} else {
		ans ='<';
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int A = ni(), B = ni(), C = ni(), K = ni();
		if(A >= K) {
			out.println(K);
			return;
		}
		else {
			K -= A;
		}
		if(B >= K) {
			out.println(A);
			return;
		}
		else K-= B;
		A -= K;
		out.println(A);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

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

  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i < 10) {
      ans++;
    }
    else if (i < 100) {
      if (i / 10 == i % 10)
        ans += 3;
      else if (i % 10 && i / 10 > i % 10)
        ans += 2;
    }
    else {
      string s = to_string(i);
      if (s.back() == '0') continue;

      ans += (static_cast<long long>(exp((s.length() - 2) * log(10))) - 1) / 9 * 2;
      if (s.front() >= s.back()) {
        if (s.front() == s.back())
          ans += stoi(s.substr(1, s.length() - 2)) * 2 + 3;
        else
          ans += static_cast<long long>(exp((s.length() - 2) * log(10)) * 2);
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for (int i=0;i<n;i++) cin>> a[i];
	for (int i=n-1;i>=0;i--){
		cout << a[i];
		if (i != 0) cout << ' ';
	}
	cout << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    string s = to_string(n);
    string ans="No";
    if(s[0]=='7') ans="Yes";
    if(s[1]=='7') ans="Yes";
    if(s[2]=='7') ans="Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[100000];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i&&a[i - 1] < a[i])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3872
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n){cin>>a[i];a[i]--;}
  int id=0,cnt=0;
  rep(i,n)
  {
    id=a[id];cnt++;
    if(id==1){
      cout<<cnt<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  

  return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

double QR,RP,PQ;

struct point{
    double x,y,z;
    point(){}
    point(double _x, double _y, double _z) {
        x = _x;
        y = _y;
        z = _z;
    }
};

double dbl(double num) {
    return num * num;
}

double dist(point a, point b) {
    return sqrt(dbl(a.x - b.x) + dbl(a.y - b.y) + dbl(a.z - b.z));
}

double diff(double a, double b) {
    return abs(a - b);
}

bool f1(double qr, double rp) {
    return diff(QR/RP, qr/rp) < 0.0005;
}

bool f2(double qr, double pq) {
    return diff(QR/PQ, qr/pq) < 0.0005;
}

bool f3(double rp, double pq) {
    return diff(RP/PQ, rp/pq) < 0.0005;
}

void solve() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int test_case;
    cin >> test_case;
    while (test_case--) {

        cin >> QR >> RP >> PQ;

        // cout << fixed << setprecision(5) << QR << " " << RP << " " << PQ << endl;

        int n;
        cin >> n;
        point P[n];
        REP(i,n) cin >> P[i].x >> P[i].y >> P[i].z;

        // cout << n << endl;
        // REP(i,n) {
        //     cout << fixed << setprecision(5) << P[i].x << " " << P[i].y << " " << P[i].z << endl;
        // }


        bool f = 0;
        REP(p,n) {
            REP(q,n) {
                if (p == q) continue;
                REP(r,n) {
                    if (r == p || r == q) continue;

                    double qr = dist(P[q], P[r]);
                    double rp = dist(P[r], P[p]);
                    double pq = dist(P[p], P[q]);

                    if (f1(qr,rp) && f2(qr,pq) && f3(rp,pq)) {
                        cout << p + 1 << " " << q + 1 << " " << r + 1 << endl;
                        f = 1;
                    }

                }
                if (f) break;
            }
            if (f) break;
        }

    }

}


int main(int argc, char *argv[]){

    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }

    /* AOJ */
    solve();

    return 0;
}


Measured memory_bytes: 3196