akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n; scan(n);
  string s; scan(s);
  vi accum(n+1, 0);
  rep (i, n) {
    accum[i+1] = accum[i];
    if (s[i] == '.') {
      accum[i+1] += 1;
    }
  }
  int ans = INT_MAX;
  rep (i, n+1) {
    int cost = i - accum[i] + accum[n] - accum[i];
    ans = min(ans, cost);
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> prime(0);//i番目の素数
vector<bool> is_prime(0);//iは素数か
//n以下の素数の数
int hurui(int n){
    is_prime.resize(n+1,true);
    is_prime[0]=0; is_prime[1]=0;
    int p=0;
    REP(i,2,n+1){
        if(is_prime[i]){
            prime.emplace_back(i);
            p ++;
            for(int j=2*i; j<=n; j +=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
  hurui(1e7);
  int n;
  while(cin>>n){
      cout<<upper_bound(all(prime),n)-prime.begin()<<endl;
  }
}


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

namespace B.AcCepted
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            bool flg1, flg2, flg3;

            flg1 = str[0] == 'A';
            flg2 = str.Skip(2).Take(str.Length - 3).Contains('C');
            flg3 = str.Count(x => char.IsUpper(x)) == 2;
            
            if (flg1 && flg2 && flg3)
                Console.WriteLine("AC");
            else
                Console.WriteLine("WA");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
const int MOD(1e9 + 7);
inline int Powlog(int a, int b) {
    int res(1);
    while (b) {
        if (b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}
int x, y, n, k, f1, f2, f3, res;
int32_t main() {
    DAU
    cin >> x >> y;
    if ((x + y) % 3) {
        cout << 0;
        PLEC
    }
    n = (x + y) / 3;
    k = min(x, y) - (x + y) / 3;
 	if (k < 0) {
    	cout << 0;
      	PLEC
    }
    f1 = f2 = f3 = 1;
    for (int i = 1; i <= n; ++i)
        f1 = (f1 * i) % MOD;
    for (int i = 1; i <= k; ++i)
        f2 = (f2 * i) % MOD;
    for (int i = 1; i <= n - k; ++i)
        f3 = (f3 * i) % MOD;
    res = ((f1 * Powlog(f2, MOD - 2)) % MOD * Powlog(f3, MOD - 2)) % MOD;
    cout << res;
    PLEC
}

Measured memory_bytes: 3616
N,M = map(int,input().split())
adjacent = [[] for i in range(N)]
for i in range(M):
  A,B = map(int,input().split())
  adjacent[A-1].append(B-1)
  adjacent[B-1].append(A-1)
Michi = [0 for i in range(N)]
visited = set()
frontier = set()
visited.add(0)
frontier.add(0)
while len(frontier) > 0:
  newfrontier = set()
  for v in frontier:
    for next in adjacent[v]:
      if next not in visited:
        Michi[next] = v
        visited.add(next)
        newfrontier.add(next)
  frontier = newfrontier
print('Yes')
for i in range(1,N):
  print(Michi[i]+1)

Measured memory_bytes: 41616
#pragma warning(disable:4996) 

#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

vector<ll> prime_factor(ll n);

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

	 ll n, p, result = 1;
	 cin >> n >> p;
	 vector<ll> v = ::prime_factor(p);

	 map<ll, ll> counter;
	 for (const ll prime : v) {
		 counter[prime]++;
	 }

	 for (const auto& x : counter) {
		 if (x.second >= n) {
			 int times = lldiv(x.second, n).quot;
			 for (int i = 0; i < times; i++) {
				 result *= x.first;
			 }
		 }
	 }

	 cout << result << endl;
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}

vector<ll> prime_factor(ll n) {
	if (n <= 1) {
		return { n };
	}

	vector<ll> v;

	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			v.push_back(i);
		}
	}

	if (n > 1) {
		v.push_back(n);
	}

	return v;
}

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

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

    int A[n];
    rep(i,n) A[i] = 0;

    rep(i,k) {
        int d;
        cin >> d;

        rep(j,d) {
            int a;
            cin >> a;
            a--;
            A[a]++;
        }
    }

    int ans = 0;
    rep(i,n) if (A[i] == 0) ans++;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
if __name__ == '__main__':
  a,b,k=(int(x) for x in input().split())
  
  if(a<k):
    k-=a
    a=0
    if(b<k):
      b=0
    else:
      b-=k
  else:
    a-=k
  print(str(a)+" "+str(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  for (ll i = 0; i < N; ++i) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  ll ans = 0;
  for (ll i = 0; i < K; ++i) {
    ans += p.at(i);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll n;
  cin>>n;
  double ans=0.0;
  double z=380000.0;
  double x;
  string u;
  for(ll i=0;i<n;i++){
    cin>>x>>u;
    if(u=="JPY"){
      ans+=(double)x;
    }
    else{
      ans+=(double)z*x;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    int H[1001] = {},W[1001] = {};
    
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(H[i] < w-a){
                if(W[j] < h-b){
                    cout << 0;
                    H[i]++,W[j]++;
                }
                else cout << 1;
            } else cout << 1;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#116C
n = int(input())
h = list(map(int,input().split()))
s = set([])

for i in range(n):
    s.add(h[i])
s = list(s)
s.append(0)
s.sort()

m = len(s)
    
flag = [0] * (n+1)
flag[0] = 1
ans = 0

for i in range(m-1):
    a = 0
    b = s[i+1]-s[i]
    
    for j in range(n):
        if flag[j+1] == 0 and flag[j] == 1:
            a += 1
    
    for j in range(n):
        if h[j] == s[i+1]:
            flag[j+1] = 1
    ans += (a * b)
    
print(ans)

Measured memory_bytes: 39024
#include<stdio.h>

int main()
{
  int  n, a, i, j, c, d;

  scanf("%d", &n);
  c = 0;
  for( i = 0; i < n; i++){
    scanf("%d", &a);
    for( d = 0; a%2==0; d++){
       a /= 2;
    }
    c += d;
  }
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int d, n;
  cin >> d >> n;

  int ans = n;
  if (n == 100) ans++;
  for (int i = 0; i < d; i++) ans *= 100;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(ll i =0;i < n;i++)cin >> a[i];

	if(k >= 200){
		for(ll i = 0;i < n;i++)cout << n << endl;
		return 0;
	}

	vector<ll> sum(n+1,0);
	for(ll i = 0;i < k;i++){
		for(ll j = 0;j <= n;j++)sum[j] = 0;
		for(ll j = 0;j < n;j++){
		   ll l = max(0LL,j-a[j]);
		   ll r = min(n,a[j]+j)+1;
		   sum[l] += 1;
		   sum[r] -= 1;
		}
		ll now = 0;
		for(ll j = 0;j < n;j++){
			now += sum[j];
			a[j] = now;
		}
	}

	for(ll i = 0;i < n;i++)cout << a[i] << " ";
	cout << endl;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char a[2];
cin >> a;
if(a[0]=='9'||a[1]=='9') {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

apples = [0] * (N + 1)
applepie = 0
eaten = 100 + 200

for i in range(1, N + 1):
    apples[i] = L + i - 1
    applepie += apples[i]

    if eaten**2 > apples[i]**2:
        eaten = apples[i]

print(applepie - eaten)


Measured memory_bytes: 2940
//Areas on the Cross-Section Diagram
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

struct Area {
    int pos;
    int number;
    Area(int pos, int number): pos(pos), number(number) {};
};

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

    stack<int> st1;
    stack<Area> st2;
    int sum = 0;
    
    for(int i=0; i<s.length(); i++) {
        if(s[i] == '_') continue;
        else if(s[i] == '\\') st1.push(i);
        else {
            if(st1.empty()) continue;
            int j = st1.top(); st1.pop();
            int area = (i - j);
            sum += area;

            while(!st2.empty() && st2.top().pos > j) {
                area += st2.top().number;
                st2.pop();
            }

            st2.push(Area(j, area));
        }
    }

    vector<int> ans;
    while(!st2.empty()) {
        ans.insert(ans.begin(), st2.top().number);
        st2.pop();
    }

    cout << sum << endl;
    int k = ans.size();
    cout << k;
    if(k > 0) for (int i=0; i<k; i++) cout << " " << ans[i];
    cout << endl;
    return 0;
}


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


int main(){
    ll a,b;cin>>a>>b;
    ll ans=0;
    rep(i,b+1,a+1){
        ans+=(a/i)*(i-b)+max((ll)0,(a%i-b+1));
    }
    if(b==0)ans=a*a;
    cout<<ans<<endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    ll n;
    cin >> n;
    ll ans=n*(n+1)/2+(n-n/2)*(2*(n/2+1)+(n-n/2-1))/2;
    repr(i,2,n/2+1) {
        ll tans=(n/i)*(2*i+(n/i-1)*i)/2;
        ans+=tans;
    }
    if (n==1) ans=1;
    cout << ans << endl;
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;
#define M 1000000007

typedef long long int ll;

ll modMult(ll a, ll b) {
	return (a*b) % M;
}

ll modPow(ll base, ll exp) {
	ll res = 1;
	
	while (exp > 0) {
		if (exp & 1)
			res = modMult(res, base);

		exp >>= 1;
		base = modMult(base, base);
	}

	return res;
}

ll modSub(ll a, ll b) {
	return (a - b + M) % M;
}

ll modAdd(ll a, ll b) {
	return (a + b) % M;
}

int main() {

	IOS

	ll n, k;
	cin >> n >> k;

	ll c[k+1];

	for (int i = k; i > 0; i--) {
		ll count_multiples = k / i;
		ll arrangement_with_multiples = modPow(count_multiples, n);

		for (int j = 2*i; j <= k; j += i)
			arrangement_with_multiples = modSub(arrangement_with_multiples, c[j]);

		c[i] = arrangement_with_multiples;
	}

	ll ans = 0;
	for (int i = 1; i <= k; i++)
		ans = modAdd(ans, modMult(i, c[i]));

	cout << ans;

	return 0;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
lli gcd(lli a, lli b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main() 
{
    
    lli n, k, c;
    cin >> n >> k;
    c = gcd(n, k);
    cout << (n*k)/c;
    return 0;
    
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

struct T{
	bool a, b, c;
	T():a(false),b(false),c(false){}
};

signed main(){
	int n; cin >> n;
	vector<T> arr(n);
	int x, y, z; cin >> x;
	for(int i = 0; i < x; i++){
		int tmp; cin >> tmp;tmp--;
		arr[tmp].a = true;
	}
	cin >> y;
	for(int i = 0; i < y; i++){
		int tmp; cin >> tmp;tmp--;
		arr[tmp].b = true;
	}
	cin >> z;
	for(int i = 0; i < z; i++){
		int tmp; cin >> tmp;tmp--;
		arr[tmp].c = true;
	}
	int ans = 0;
	for(auto e : arr){
		if((!e.a && e.c) || (e.b && e.c))ans++;
	}
	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 3100
fun main(args: Array<String>) {
    val mod = 1000000007
    val (x1,y1,x2,y2) = readIntList()


    val x3 = y1-y2+x2
    val y3 = x2-x1+y2
    val x4 = y1-y2+x1
    val y4 = x2-x1+y1



    println("$x3 $y3 $x4 $y4")
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 37912
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N, M, X; cin >> N >> M >> X;
	vector<int> A(M);
	REP(i,M) cin >> A[i];


	int L = 0;
	int R = 0;
	REP(i,M){
		if(A[i] < X) L++;
		else R++;
	}
	
	int ans = min(L,R);
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b;
    cin >> a >> b;
    if(a+b>=10)cout << "error" << endl;
    else cout << a+b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
  std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
  }
}

using namespace std;

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

  int count = 0;

  if(b > a){
    swap(a,b);
  }

  int mini = b, result = 0;

  // cout << mini<< endl;

  for(int i = mini; (i > 0) && (count != k) ; i--){
    if( (a % i)  == 0 && (b % i) == 0){
      count++;
      result = i;
      continue;
    }
  }

  cout << result << endl;

  return 0;
}

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

n, m = map(int,input().split())
L = []
R = []

for i in range(m):
  l, r = map(int,input().split())
  L.append(l)
  R.append(r)
  
if min(R)-max(L) >= 0:
  print(min(R)-max(L)+1)
else:
  print(0)

Measured memory_bytes: 11016
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()

d.sort()
print(d[N//2]-d[N//2-1])

Measured memory_bytes: 15948
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

//#include <windows.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	string ans = "NO";
	int n;
	vector<int> v;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}

	vector<int> v2;
	v2 = v;
	sort(v2.begin(), v2.end());

	int a = 0;
	int b = 0;

	bool flg = false;
	for (int i = 1; i < n; i++) {
		if (v[i] < v[i - 1] && !flg) {
			a = i - 1;
			flg = true;
			continue;
		}
		if (v[i] < v[i - 1]) {
			b = i;
		}
	}
	if (a != 0 || b != 0) {
		int tmp = v[a];
		v[a] = v[b];
		v[b] = tmp;
	}
	
	if (v == v2) {
		ans = "YES";
	}

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A, B, K, cnt=0, ans;

void solve(){
    for(int i = min(A,B); i > 0; i--){
        if(A % i == 0 && B % i == 0) cnt++;
        if(cnt == K) {
            ans = i;
            break;
            }
    }
    cout << ans << endl;
}

int main(){
    cin >> A >> B >> K;

    solve();
}


Measured memory_bytes: 256
def main():
    import heapq
    from sys import stdin
    input=stdin.readline
    xs,ys,xt,yt=map(int,input().split())
    n=int(input())
    xyr=[[xs,ys,0],[xt,yt,0]]+[list(map(int,input().split())) for _ in [0]*n]
    g=[[] for _ in [0]*(n+2)]
    for i in range(n+1):
        x1,y1,r1=xyr[i]
        for j in range(i+1,n+2):
            x2,y2,r2=xyr[j]
            d_temp=max(0,((x1-x2)**2+(y1-y2)**2)**0.5-r1-r2)
            g[i].append((j,d_temp))
            g[j].append((i,d_temp))
    d=[0]*(n+2)
    visit=[False]*(n+2)
    visit[0]=True
    h=[]
    for i,j in g[0]:
        h.append((j,i))
    heapq.heapify(h)
    while h:
        i,j=heapq.heappop(h)
        if visit[j]==True:
            continue
        visit[j]=True
        d[j]=i
        for k,l in g[j]:
            if visit[k]==False:
                heapq.heappush(h,(l+i,k))
    print(d[1])
main()

Measured memory_bytes: 142600
A,B,C,D,E,F=map(int,input().split())
x=1
y=-1
for a in range(0,F+1,100*A):
    for b in range(0,F-a+1,100*B):
        m=min(F-a-b,(a+b)*E//100)
        if a+b==0:
            continue
        for c in range(0,m+1,C):
            for d in range(0,m-c+1,D):
                if y/x<(c+d)/(a+b):
                    x=a+b
                    y=c+d
print(x+y,y)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long n,m,p,j[65000],i,s;
while(cin>>n,n){
m=1;
for(s=i=0;i<n;i++){cin>>p;s+=p;}
for(i=0;i<n-1;i++){cin>>j[i];s+=j[i];}
sort(j,j+n-1);
for(;;){
if((m+1)*(s-j[m-1])>s*m){s-=j[m-1];m++;}else break;
if(m==n)break;
}
cout<<s*m<<endl;
}
return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,i; cin>>n>>i; cout << n+1-i << endl;
	return 0;
}


Measured memory_bytes: 256
try:
    a = int(input().strip())
    b = int(input().strip())
    c = int(input().strip())
    d = int(input().strip())
    sum = 0
    if a > b:
        sum = b
    else:
        sum = a
    if c > d:
        sum += d
    else:
        sum += c
    print(sum)
except EOFError:
    pass


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int x;

int main() {
	cin >> x;
	if (x < 1200)cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
*/
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int father[maxn],cnt[maxn];
int findFather(int x) {return x==father[x]?x:father[x] = findFather(father[x]);}
int main()
{
    fastio();
    int n,m; cin>>n>>m;
    rep(i,1,n) father[i] = i;
    rep(i,1,m){
        int u,v; cin>>u>>v;
        int fu = findFather(u),fv = findFather(v);
        if(fu != fv) father[fu] = fv;
    }
    int ans = 0;
    rep(i,1,n){
        int f = findFather(i);
        cnt[f]++;
        ans = max(cnt[f],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10600
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    a=list(map(int, input().split()))
    ans = 0
    for i in range(n-2):
        if a[i] <= a[i+1] < a[i+2]:
            ans += 1
        if a[i+2] <= a[i+1] < a[i]:
            ans += 1
    print(ans)
        
main()


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  if (N <= 999) {
    cout << "ABC" << endl;
  } else {
    cout << "ABD" << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;
int max_point = 0;
bool ok_flag = false;

void recursive(int sum, int pos, vector<int>& card)
{
	if(sum > 21)
	{
		return;
	}
	if(pos == card.size())
	{
		if(max_point < sum)
		{
			ok_flag = true;
			max_point = sum;
			return;
		}
	}
	recursive(sum + 1, pos + 1, card);
	recursive(sum + 11, pos + 1, card);
}

void solve()
{
	string str;
	while(getline(cin, str))
	{
		if(str == "0")
		{
			break;
		}
		max_point = 0;
		stringstream ss(str);
		string temp;
		vector<int> card;
		while(ss >> temp)
		{
			card.push_back(atoi(temp.c_str()));
		}
		sort(card.begin(), card.end(), greater<int>());
		int sum = 0;
		int one_pos = -1;
		for(int i = 0; i < card.size(); ++i)
		{
			if(card[i] >= 10)
			{
				sum += 10;
			}
			else if(card[i] >= 2)
			{
				sum += card[i];
			}
			else
			{
				one_pos = i;
				break;
			}
		}
		if(sum > 21)
		{
			cout << 0 << endl;
			continue;
		}
		if(max_point < sum && one_pos == -1)
		{
			max_point = sum;
			cout << max_point << endl;
			continue;
		}
		
		ok_flag = false;
		recursive(sum, one_pos, card);
		if(ok_flag)
		{
			cout << max_point << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}

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

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=205;
const int mod=998244353;
struct point{
	int x,y;
}c[maxn];
int n;
LL _2[maxn],ans;
int main(){
	scanf("%d",&n);
	_2[0]=1;
	for(int i=1;i<=n;i++) _2[i]=_2[i-1]*2%mod;
	ans=_2[n]-n-1;
	for(int i=1;i<=n;i++) scanf("%d%d",&c[i].x,&c[i].y);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(i==j) continue;
			int cnt=0;
			for(int k=j+1;k<=n;k++){
				if((c[i].x-c[k].x)*(c[j].y-c[k].y)==(c[j].x-c[k].x)*(c[i].y-c[k].y)) cnt++;
			}
			ans=(ans-_2[cnt]+mod)%mod;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int d, n, q, a[200009], x;
int main() {
	while (reader(&d), d) {
		reader(&n); reader(&q);
		for (int i = 1; i < n; i++) reader(&a[i]);
		sort(a, a + n);
		for (int i = 0; i < n; i++) a[i + n] = a[i] + d; a[n * 2] = a[0] + d * 2;
		long long ret = 0;
		while (q--) {
			reader(&x);
			int ptr = lower_bound(a, a + n * 2, x) - a;
			ret += min(a[ptr] - x, x - a[ptr + n - 1] + d);
		}
		printf("%lld\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3496
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

const mod int = 1e9 + 7

func main() {
	s := readString()
	n := len(s)

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, 13)
	}
	dp[0][0] = 1

	for i := 1; i < n+1; i++ {
		c := s[i-1 : i]
		cnum, _ := strconv.Atoi(c)
		for j := 0; j < 10; j++ {
			if c != "?" && j != cnum {
				continue
			}
			for k := 0; k < 13; k++ {
				dp[i][(k*10+j)%13] += dp[i-1][k]
			}
		}

		for k := 0; k < 13; k++ {
			dp[i][k] %= mod
		}
	}

	fmt.Println(dp[n][5])
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  repc(x, k) repc(y, k) {
    int z = s - x - y;
    if (z < 0 || z > k) continue;
    if (x + y + z == s) ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }


int main(){
  int n; cin >> n;
  vector<pair<ll, ll>> v(n);
  rep(i, n){
    ll a, b; cin >> a >> b;
    v[i] = mp(b, a);
  }

  sort(ALL(v));
  ll timesum = 0;
  bool flag = true;
  rep(i, n){
    timesum += v[i].second;
    if(timesum > v[i].first) flag = false;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 6368
#include <stdio.h>

int main(){
    int m, f, r;
    while(1){
        scanf("%d %d %d ", &m, &f, &r);
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65){
            printf("B\n");
        }else if(m+f>=50){
            printf("C\n");
        }else if(m+f>=30){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  string a, b;
  cin >> a >> b;
  a += b;
  int c = stoi(a);
  REP(i, (int)sqrt(c) + 1){
    if(i*i == c){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main(int argc, char** argv) {
  unsigned long N, K;
  std::cin >> N >> K;
  std::vector<unsigned long> H(N);
  for (auto& e : H) std::cin >> e;
  std::sort(H.begin(), H.end(), std::greater<unsigned long>());
  unsigned long long sum {};
  for (auto i = 0;i < N;++i) {
    if (i < K) {
      ;
    } else {
      sum += H[i];
    }
  }
  std::cout << sum << '\n';
}


Measured memory_bytes: 2424
#include<iostream>
#include<map>

using namespace std;

int main(void)
{
  int n; cin>>n;
  string s;
  map<string,int> m;
  for(int i=0;i<n;i++){
    cin>>s;
    m[s]++;
  }
  
  int count=0;
  map<string,int>::iterator it;
  for(it=m.begin();it!=m.end();it++){
    count++;
  }
  
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 19252
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int N;
char buf[SIZE];

int main(){

	scanf("%d",&N);

	scanf("%s",buf);

	int row = 0,col = 0;

	for(int i = 0; i < N; i++){

		if(buf[i] >= 'A' && buf[i] <= 'M'){

			row++;

		}else if(buf[i] >= 'N' && buf[i] <= 'Z'){

			row--;

		}else if(buf[i] >= 'a' && buf[i] <= 'm'){

			col++;

		}else{

			col--;
		}
	}

	printf("%d\n",abs(row)+abs(col));

	if(row > 0){

		for(int i = 0; i < row; i++){

			printf("A");
		}

	}else if(row < 0){

		for(int i = 0; i < abs(row); i++){

			printf("N");
		}
	}

	if(col > 0){

		for(int i = 0; i < col; i++){

			printf("a");
		}

	}else if(col < 0){

		for(int i = 0; i < abs(col); i++){

			printf("n");
		}
	}

	printf("\n");

	return 0;
}



Measured memory_bytes: 3324
#include <stdio.h>

int main(void)
{
  int h, n, a, s=0;
  
  scanf("%d%d", &h, &n);

  for (int i=0; i<n; i++) {
    scanf("%d", &a);
    s+=a;
  }
  
  if (h<=s)
    printf("Yes\n");
  else
    printf("No\n");
    
  return 0;
}

Measured memory_bytes: 256
input = input()
output = ""

for i in range(len(input)):
    if input[i] == "0":
        output += "0"
    elif input[i] == "1":
        output += "1"
    elif input[i] == "B":
        output = output[0:len(output)-1]
    else:
        pass

print(output)

Measured memory_bytes: 9044
#include<stdio.h>
#include<string.h>
int main(){
    char num[1005];
    int sum = 0,i,len;
    while(1){
        scanf("%s",num);
        if(num[0] == '0')break;
        sum=0;
        len = strlen(num);
        for(i = 0;i < len;i++){
            sum += num[i] - '0';
        }
        printf("%d\n",sum);
    }
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  vector<int> Hs(N);
  for (int i = 0; i < N; i++){
    cin >> Hs.at(i);
  }
  
  int Ans = 1;
  bool judge = 1;
  for (int i = 1; i < N; i++){
    for (int j = 0; j < i; j++){
      if ( Hs.at(i) < Hs.at(j) ){
        judge = 0;
      }     
    }
    if (judge){
      Ans += 1;
    }
    else{
      judge = 1;
    }
  }
  cout << Ans << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define rpe(i,r,l) for(int i=(r);i>=(l);--i)
#define rpp(i,x,e,head) for(int i=head[x];~i;i=e[i].next)
#define dyes cerr<<"yes"<<endl
#define dbg(x) cerr<<#x<<"="<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pts puts("")
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
inline ll readll(){
    ll f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template <class T> inline void chmax(T &a,T b){if(a<b) a=b;}
template <class T> inline void chmin(T &a,T b){if(a>b) a=b;}
inline void swap(int &a,int &b){int c=a;a=b;b=c;}
using namespace std;
#define mst(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >
#define mp(i,j) make_pair(i,j)
#define fi first
#define sc second
#define inf (0x3f3f3f3f)
#define infl (0x3f3f3f3f3f3f3f3fLL)
#define forvec(i,j) for(vector<int>::iterator i=j.begin();i!=j.end();++i)
#define forvecv(i,j) for(vector<int>::iterator i=--j.end();i>=j.begin();--i)
//=====================head end======================//
const int N=3e3+10;
const int M=2e5+10;
vector<pii> e[N];
inline void add(int u,int v,int id){e[u].push_back(mp(v,id));}
int n,m;
int rea[N][N],vis[N];
inline void dfs1(int x,int frm){
    vis[x]=1;rea[frm][x]=1;
    for(auto k:e[x]){
	int v=k.fi;if(vis[v]) continue;
	dfs1(v,frm);
    }
}
int p[N][N],q[N][N],col;
inline void dfs2(int x,int frm){
    p[frm][x]=col;vis[x]=1;
    for(auto k:e[x]){
	int v=k.fi;if(vis[v]) continue;
	dfs2(v,frm);
    }
}
inline void dfs3(int x,int frm){
    q[frm][x]=col;vis[x]=1;
    for(auto k:e[x]){
	int v=k.fi;if(vis[v]) continue;
	dfs3(v,frm);
    }
}
struct edge{int u,v,id;}E[M];
int main(){
    n=read();m=read();
    rep(i,1,m){
	int u=read(),v=read();
	add(u,v,i);E[i].id=i;E[i].u=u;E[i].v=v;
    }
    rep(i,1,n){rep(j,1,n) vis[j]=0;dfs1(i,i);}
    rep(x,1,n){
	rep(j,1,n) vis[j]=0;vis[x]=1;
	for(auto k:e[x]){
	    col=k.sc;
	    int v=k.fi;if(vis[v]) continue;
	    dfs2(v,x);
	}
	rep(j,1,n) vis[j]=0;vis[x]=1;
	int sz=(int)e[x].size()-1;
	rpe(j,sz,0){
	    pii k=e[x][j];
	    col=k.sc;
	    int v=k.fi;if(vis[v]) continue;
	    dfs3(v,x);
	}
    }
    rep(i,1,m){
	int u=E[i].u,v=E[i].v;
	int k=rea[v][u];
	k^=(p[u][v]!=i||q[u][v]!=i);
	if(k){puts("diff");}
	else puts("same");
    }
    return 0;
}


Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int K;
    cin >> K;
    vector<int>A(K);
    for(int i = 0; i < K; i++) {
        cin >> A[i];
    }
    bool ok = false;
    int l = 1,r = INF;
    while (l+1 < r) {
        int mid = (l+r)/2;
        int X = mid;
        for(int i = 0; i < K; i++) {
            X-=X%A[i];
        }
        if(X == 2) {
            ok = true;
        }
        if(X >= 2) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    if(!ok) {
        cout << -1 << endl;
        return 0;
    }
    cout << l+1 << " ";
    l = 1;r = INF;
    while (l+1 < r) {
        int mid = (l+r)/2;
        int X = mid;
        for(int i = 0; i < K; i++) {
            X-=X%A[i];
        }
        if(X > 2) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r-1 << endl;
}

Measured memory_bytes: 4032
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret ++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[101010];

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	int maxl = 0, minl = INF;
	REP(i, n) {
		maxl = max(a[i], maxl);
		minl = min(a[i], minl);
	}
	cout << maxl - minl << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    if(n%2==0) printf("0.50000000\n");
    else {
        double ans = (double)(n/2+1) / n;
        printf("%.10f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256