akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define WMAX 10000
#define HMAX 10000
#define NMAX 50
#define MMAX 50

//コメントアウトするとdebug()を実行しない
#define DEBUG

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

typedef pair<int ,int > P;

int C,N,M,W,H,ans,dp[HMAX][WMAX];
char A[NMAX][NMAX],B[MMAX][MMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
bool check(int a,int b){
	for (int i = 0; i < M; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			if(A[a+i][b+j] != B[i][j]){
				return false;
			}
		}
	}
	return true;
}

bool solve(){
	for (int i = 0; i < N-M+1; ++i)
	{
		for (int j = 0; j < N-M+1; ++j)
		{
			if(check(i,j)){
				return true;
			}
		}
	}
	return false;
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < M; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			cin >> B[i][j];
		}
	}
	if(solve()){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (((0 <= (x - r))&&((x + r) <= w)) && ((0 <= (y - r))&&((y + r) <= h)))cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3116
h, w = map(int, input().split())
table = [list(input()) for _ in range(h)]

mx = [0, 1, 0, -1]#yとの兼ね合いで片方は0にして上下左右判定
my = [1, 0, -1, 0]#xとの兼ね合いで片方は0にして上下左右判定
for i in range(h):
    for j in range(w):
        if table[i][j] == "#":
            for k in range(4):
                tx = j + mx[k]#左右判定
                ty = i + my[k]#上下判定
                if 0 <= tx < w and 0 <= ty < h and table[ty][tx] == "#":#添え字に使えるか判定している
                    break
            else:#breakされなかった時実行される、上下左右に#がなかった時になる
                print("No")
                exit(0)
print("Yes")



Measured memory_bytes: 9148
#include<iostream>
#include<sstream>
#include<algorithm>
using namespace std;
#define INF 1000000002

int func(){
  string s;
  cin>>s;
  if(s=="x")return INF;
  stringstream ss;
  ss<<s;
  int res;
  ss>>res;
  return res;
}

int N;
int t[2000];

string solve(){
  for(int i=0;i+1<N;i++)if(t[i]==INF&&t[i+1]==INF)return "none";
  int l=-INF,r=INF;
  for(int i=0;i<N;i++){
    if(t[i]!=INF){
      if(i%2==0){
	if(i-1>=0&&t[i-1]!=INF&&t[i-1]<=t[i])return "none";
	if(i+1<N&&t[i+1]!=INF&&t[i]>=t[i+1])return "none";
      }else{
	if(i-1>=0&&t[i-1]!=INF&&t[i-1]>=t[i])return "none";
	if(i+1<N&&t[i+1]!=INF&&t[i]<=t[i+1])return "none";
      }
      continue;
    }
    if(i%2==0){
      if(i-1>=0)r=min(r,t[i-1]-1);
      if(i+1<N)r=min(r,t[i+1]-1);
    }else{
      if(i-1>=0)l=max(l,t[i-1]+1);
      if(i+1<N)l=max(l,t[i+1]+1);
    }
  }
  if(l==r){
    stringstream ss;
    ss<<l;
    string res;
    ss>>res;
    return res;
  }else if(r<l){
    return "none";
  }else{
    return "ambiguous";
  }
}

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    for(int i=0;i<N;i++)t[i]=func();
    cout<<solve()<<endl;
  }
  return 0;
}

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

int main()
{
    int N, count = 0;
    cin >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    while (1)
    {
        rep(i, N)
        {
            if (A[i] % 2 == 0)
            {
                A[i] /= 2;
            }
            else
            {
                cout << count << endl;
                return 0;
            }
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=3e3+7;
map<ll,ll> counter;
int dp[L][L], n, m;
string s, t;
pii nxt[L][L];
int solve(int i, int j)
{
	if(i>=n || j>=m)return 0;
	if(dp[i][j] != -1)return dp[i][j];
	int &ret = dp[i][j];
	ret = 0;
	if(s[i] == t[j])
	{
		ret = 1 + solve(i+1,j+1);
		nxt[i][j] = {i+1,j+1};
	}
	int ret1 = solve(i+1,j);
	if(ret1 > ret)
	{
		ret = ret1;
		nxt[i][j] = {i+1,j};
	}
	ret1 = solve(i,j+1);
	if(ret1 > ret)
	{
		ret = ret1;
		nxt[i][j] = {i,j+1};
	}
	return ret;
}
void fff()
{
	init(dp, -1);
	cin >> s >> t;
	n = s.length();
	m = t.length();
	FOR(i,0,n)FOR(j,0,m)nxt[i][j] = {n,m};
	solve(0,0);
	pii x;
	while(x.F<n&&x.S<m)
	{
		// debug(x.F,x.S);
		if(s[x.F] == t[x.S])cout<<s[x.F];
		x = nxt[x.F][x.S];
	}	
	cout<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 180320
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}


void solve()
{
	set<int> ms;
	ms.insert(1);
	ms.insert(2);
	ms.insert(3);
	int a,b;
	cin >> a >> b;
	ms.erase(a);
	ms.erase(b);
	cout << *ms.begin() << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	clock_t start,stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for(int tc = 1;tc < t + 1;tc++) solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
S = input()
Q = int(input())
flip = 0
head = []
tail = []
for i in range(Q):
  Query = input().split()
  if len(Query) == 3:
    T,F,C = Query
    F = int(F)-1
    if F^flip == 1:
      tail.append(C)
    else:
      head.append(C)
  else:
    flip ^= 1
if flip:
  head, tail = tail, head
  S = S[::-1]
head = ''.join(head[::-1])
tail = ''.join(tail)
print(head+S+tail)

Measured memory_bytes: 12024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N;
  string s;

  cin >> N >> s;

  int x = 0, y = 0;

  for(int i=0; i<N; i++) {
    if ('A' <= s[i] && s[i] <= 'M') y--;
    if ('N' <= s[i] && s[i] <= 'Z') y++;
    if ('a' <= s[i] && s[i] <= 'm') x++;
    if ('n' <= s[i] && s[i] <= 'z') x--;
  }

  string ans;

  for(int i=0; i<abs(y); i++) {
    if (y < 0) ans += "A";
    else ans += "Z";
  }

  for(int i=0; i<abs(x); i++) {
    if (x > 0) ans += "a";
    else ans += "z";
  }

  cout << ans.size() << endl;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3340
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P>  PP;
typedef pair<int,PP> PPP;
ll a,b;
int ans;
int used[100006];
vector<ll> yaku;
ll gcd(ll x, ll y)
{
    if(y==0)return x;
    else return gcd(y,x%y);
}
int main()
{
    cin>>a>>b;
    ll q=gcd(a,b);
    for(int i=1;i<=sqrt(q);i++)
    {
        if(q%i==0)
        {
            if(i*i==q)
            {
                yaku.push_back(i);
            }
            else{
                yaku.push_back(i);
                yaku.push_back(q/i);
            }
        }
    }
    int t=yaku.size();
    sort(yaku.begin(),yaku.end());
    //rep(i,t)cout<<yaku[i]<<"fffd"<<endl;
    rep(i,t)used[i]=1;
    rep(i,t)
    {
        rep2(j,1,i)
        {
            ll ds=gcd(yaku[i],yaku[j]);
            //cout<<ds<<"ds"<<endl;
            if(ds!=1)
            {
                used[i]=0;
            }
        }
    }
    //rep(i,t)cout<<used[i]<<"fffd"<<endl;
    rep(i,t)
    {
        ans+=used[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#define MOD 1000000007ll

char s(int i)
{
    char c[] = "ACGT";
    return c[i];
}

bool ok(int i, int j, int k, int l)
{
    return !((s(j) == 'A' && s(k) == 'G' && s(l) == 'C') ||
             (s(j) == 'G' && s(k) == 'A' && s(l) == 'C') ||
             (s(j) == 'A' && s(k) == 'C' && s(l) == 'G') ||
             (s(i) == 'A' && s(k) == 'G' && s(l) == 'C') ||
             (s(i) == 'A' && s(j) == 'G' && s(l) == 'C'));
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    ll ans = 0;
    ll dp[n + 100][4][4][4] = {};
    rep(i, 4) rep(j, 4) rep(k, 4)
    {
        dp[0][i][j][k] = 1;
    }
    dp[0][0][2][1] = 0;
    dp[0][0][1][2] = 0;
    dp[0][2][0][1] = 0;

    rep(step, 3, n)
    {
        rep(i, 4) rep(j, 4) rep(k, 4) rep(l, 4)
        {
            if (ok(i, j, k, l))
            {
                dp[step - 2][j][k][l] += dp[step - 3][i][j][k];
                dp[step - 2][j][k][l] %= MOD;
            }
            else
                cerr << s(i) << s(j) << s(k) << s(l) << endl;
        }
    }
    rep(i, 4) rep(j, 4) rep(k, 4)
    {
        ans += dp[n - 3][i][j][k];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    long long x;
    cin >> x;

    if (x % 11 == 0)
    {
        cout << (x / 11 * 2) << endl;
    }
    else if (x % 11 <= 6)
    {
        cout << (x / 11 * 2) + 1 << endl;
    }
    else
    {
        cout << (x / 11 * 2) + 2 << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,y;
    cin>>x>>y;
    if(x==y || x%y==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    if(y==1)
    {
        cout<<-1<<endl;
        return 0;
    }
    if(x==1)
    {
        cout<<y+1<<endl;
        return 0;
    }
    long long ans=2*x*y-x;
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
  int a,b,c,d,count=-1;
  cin >> a >> b >> c >> d;
  for(int i=min(a,c);i<=max(b,d);i++){
    if(a<=i&&i<=b&&c<=i&&i<=d) count++;
  }
  cout << max(count,0) << endl;
}

Measured memory_bytes: 256
n = gets.chomp.split(' ').map(&:to_i)
strs = gets.chomp.split(' ').map(&:to_i)

# 左から順に見ていく
# Index+1と違う値が2個より大きければ、NO
more_big_cnt = 0
strs.each_with_index do |str, idx|
  more_big_cnt += 1 if str != idx+1
  if more_big_cnt > 2
    puts 'NO'
    exit
  end
end
puts 'YES'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
 
 
 
 
int n,k,x,y;
 
signed main(){
    cin>>n>>k>>x>>y;
    int ans=0;
    repe(i,1,n){
        if(i<=k)ans+=x;
        else ans+=y;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
<?php
// スペース区切りの整数の入力
fscanf(STDIN, "%d %d %d %d", $n, $m, $x, $y);

//n個の整数の入力
$format = "%d";
for ($i = 1; $i < $n; $i++) {
  $format .= " %d";
}
  //n個を配列に格納
$x_data = fscanf(STDIN, $format);

//m個の整数の入力
$format = "%d";
for ($i = 1; $i < $m; $i++) {
  $format .= " %d";
}
  //m個を配列に格納
$y_data = fscanf(STDIN, $format);

//xの最大値がyの最小値より小さければNoWar
$x_max = $x;
foreach($x_data as $d) {
  if ($x_max < $d) {
    $x_max = $d;
  }
}

$y_min = $y;
foreach($y_data as $d) {
  if ($y_min > $d) {
    $y_min = $d;
  }
}

if ($x_max < $y_min) {
  echo "No War";
} else {
  echo "War";
}
?>


Measured memory_bytes: 3576
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		Integer[] a = new Integer[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
		}
		Arrays.sort(a, Comparator.reverseOrder());
		long ans = a[0];
		int count = 0;
		int now = 1;
		for(int i = 0;i < n-2;i++){
			ans += a[now];
			count++;
			if(count == 2){
				now++;
				count = 0;
			}
			
		}

		System.out.println(ans);
		
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

ll n, k;
ll a[2 * 100000];
const ll tens = 1e9;

template <typename T>
T BinarySearch(T lo, T hi, std::function<bool(T)> pred) {
  while (lo + 1 < hi) {
    T mid = (hi - lo) / 2 + lo;
    if (pred(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo;
}

// Returns the number of pairs whose values are equal to or less than x.
ll count(ll x) {
  ll cnt = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] < 0) {
      if (a[i-1] * a[i] <= x) {
        if (a[0] * a[i] <= x) {
          cnt += i;
          continue;
        }
        int j = BinarySearch<int>(0, i, [&](int idx) { return a[i] * a[idx] > x; });
        cnt += i - (j + 1);
      }
    } else {
      if (a[0] * a[i] <= x) {
        int j = BinarySearch<int>(0, i, [&](int idx) { return a[i] * a[idx] <= x; });
        cnt += j + 1;
      }
    }
  }
  return cnt;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);

  ll x = BinarySearch<ll>(-tens * tens - 1, tens * tens + 1, [&](ll x) {
    return count(x) < k;
  });
  dbg(x, count(x - 1), count(x), count(x + 1));
  out(x + 1);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    int N; cin >> N;
    vector<vector<int>> V(N);
    for(int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b; a--;b--;
        V[a].push_back(b);
        V[b].push_back(a);
    } 

    bool grid[N];
    memset(grid, false, sizeof(grid));
    grid[0] = true;

    queue<pair<int,int>> Q;
    Q.push(make_pair(0, 0));
    vector<int> dB(N), dW(N);

    while(!Q.empty()){
        int v = Q.front().first;
        int cnt = Q.front().second;
        Q.pop();
        //cout << v << endl;
        for(auto u : V[v]){
            //cout << " " << u << endl;
            if(!grid[u]){
                grid[u] = true;
                Q.push(make_pair(u, cnt+1));
                dB[u] = cnt+1;
            }
        }
    }

    memset(grid, false, sizeof(grid));
    grid[N-1] = true;
    Q.push(make_pair(N-1, 0));


    while(!Q.empty()){
        int v = Q.front().first;
        int cnt = Q.front().second;
        Q.pop();
        //cout << v << endl;
        for(auto u : V[v]){
            //cout << " " << u << endl;
            if(!grid[u]){
                grid[u] = true;
                Q.push(make_pair(u, cnt+1));
                dW[u] = cnt+1;
            }
        }
    }
    int b = 0, w = 0;
    for(int i = 0; i < N; i++) {
        if(dB[i] <= dW[i]) b++;
        else w++;
    }

    if(b > w) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

}

Measured memory_bytes: 6656
#include<stdio.h>

int main(){
	
	int A,B,C,D,i,ans=0;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	
	for(i=0;i<=100;i++){
	if(A<=i&&i<=B&&C<=i&&i<=D){
		ans++;
	}
	}
	
	if(ans>0){
		printf("%d",ans-1);
	}else {
		printf("0");
	}
	
	return 0;
}

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

using namespace std;

constexpr int N = 1e5 + 10;
constexpr int LG = 20;
constexpr int MOD = 1e9 + 7;
constexpr int MOD2 = 1e9 + 9;

long long n, u, v, who = -1, mxh, p[N], dp[N], ans;
vector <int> node[N];

void dfs (int v, int h = 0) {
    if ((int)node[v].size() >= 3 && h >= mxh) {
        mxh = h;
        who = v;
    }
    for (auto i : node[v])
        if (i != p[v])
            p[i] = v, dfs (i, h + 1);
}

void dfs2 (int v, int par = -1) {
    int cnt = 0;
    for (auto i : node[v]) {
        if (i != par) {
            dfs2 (i, v);
            dp[v] += dp[i];
            if (!dp[i])
                cnt++;
        }
    }
    dp[v] += max (cnt - 1, 0);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        node[u].push_back (v);
        node[v].push_back (u);
    }
    p[0] = -1;
    dfs (0);
    if (who == -1) {
        cout << 1 << '\n';
        return 0;
    }
    int cnt = 0;
    for (auto i : node[who]) {
        if (cnt == 2)
            break;
        if (i != p[who]) {
            cnt++;
            memset (dp, 0, sizeof (dp));
            dfs2 (i);
            ans = max (ans, dp[i] + 1);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std ;
const int MAXN = 5*1e5 ;
vector<int> adj[MAXN] ;
int st[MAXN] , ed[MAXN] ;
vector<int> dfsPath ;
bool v[MAXN] ;
void dfs(int s){
  
  v[s] = true ;
  st[s] = (int)dfsPath.size() ;
  dfsPath.push_back(s) ;
  for(int i =0 ;i < adj[s].size() ;i++)
    if(v[adj[s][i]] == false)
      dfs(adj[s][i]) ;
  ed[s] = (int)dfsPath.size() ;
}
int main () {
  
  int N , Q ;
  cin >> N >> Q ;
  for(int i=0 ;i<=N;i++)
    v[i] = false; 
  for(int i = 1 ; i < N ;i++){
    
    int u , v ;
    cin >> u >> v ;
    adj[u].push_back(v) ;
    adj[v].push_back(u) ;
  }
  dfs(1) ;
  int pre[(int)dfsPath.size() + 10] ;
  for(int i =0 ; i < (int)dfsPath.size() + 10 ;i++)
    pre[i] =0 ;
  while(Q--) {
    
    int p , x ;
    cin >> p >> x ;
    pre[st[p]]+=x ;
    pre[ed[p]]-=x;
  }
  for(int i=1 ; i < dfsPath.size() ;i++)
    pre[i] = pre[i - 1] + pre[i] ;
  for(int i = 1 ; i <= N ;i++)
    cout<<pre[st[i]]<<" ";
  cout<<endl;
 return 0 ; 
  
}
  
  
  

Measured memory_bytes: 30840
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second


void solve()
{
	char al;
	cin >> al;
	if (al >= 65 and al <= 90)
		cout << "A\n";
	else
		cout << "a\n";

}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }

	return 0;
}

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

int main(){
	int x, y, z;

	cin >> x >> y >> z;

	x -= z;

	int cnt = 0;

	while(1){
		if(x>=(y+z)){
			cnt++;
			x -= (y + z);
		}else{
			break;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
S = input()

X = [0]*2019
X[0] = 1
d = 1
a = 0

for s in reversed(S):
    a = ((ord(s) - ord('0'))*d + a)%2019
    d = d*10%2019
    X[a] += 1

ans = sum(x*(x-1)//2 for x in X)
print(ans)

    


Measured memory_bytes: 9284
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
    string ans;
    if(x/10==9||x%10==9)ans="Yes";
    else ans = "No";
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a,a+3);
int cnt = 1;
int old = a[0];
if(old != a[1]){
cnt++;
old = a[1];
}
if(old != a[2]){
cnt++;
}
cout << cnt << endl;
}

Measured memory_bytes: 256
#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>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline 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);
  ll n;
  string ss,s;
  cin>>ss;
  n=ss.length();
  vector<ll>cnt;
  ll x=0;
  rep(i,n){
    if(ss[i]!='x'){
      cnt.push_back(x);
      s.push_back(ss[i]);
      x=0;
    }
    else {
      x++;
    }
  }
  cnt.push_back(x);
  auto t=s;
  auto rc=cnt;
  reverse(all(t));
  reverse(all(rc));
  ll f=1;
  ll res=0;
  rep(i,s.size()){
    if(s[i]!=t[i])f=0;
  }
  rep(i,cnt.size()){
    res+=max(cnt[i],rc[i])*2-cnt[i]-rc[i];
  }
  if(!f)res=-2;
  cout<<res/2<<endl;
  return 0;

}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
vector<int> edges[100005];
bool visitor[100005];
void dfs(int s)
{
    visitor[s]=true;
    for(int x: edges[s])
    {
        if(!visitor[x])
        {
            dfs(x);
        }
    }
}
int main()
{
   int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int count=-1;
    for(int i=1;i<=n;i++)
    {
        if(!visitor[i])
        {
            dfs(i);
            count++;
        }
    }
    cout<<count<<endl;
}

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

int main() {
  int a , b ;
  cin >> a >> b;
  
  double x = (a + b) / 2.0;
  
  if(a%2 == b%2){
    cout << x << endl;
  }else{
  	cout << x+0.5 << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long LL;
LL a[200055];
const int MX=1e9;
const LL MAX=1e18;
inline LL mul(LL a,LL b,LL mod){
	return
	(a*b-(LL)((long double)a/mod*b)*mod+mod)%mod;
}
int n;
void brute(){
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(mul(a[i],a[j],MAX)==0)ans++;//,cout<<i<<' '<<j<<endl;
		}
	}
	cout<<ans<<endl;
	exit(0);
}
struct num{int two,fiv,id;}y[200055];
bool cmp1(num a,num b){return a.two<b.two;}
struct ques{int l,w;}q[200055];
bool cmp2(num a,num b){return a.fiv>b.fiv;}
bool cmp3(ques a,ques b){return a.w>b.w;}

struct TreeArry{
#define lowbit(i) ((i)&(-(i)))
	LL tree[200055],n;
	inline void add(int a,LL b)
		{for(;a<=n;a+=lowbit(a))tree[a]+=b;}
	inline int sum(int l,int r){
		int res=0;l--;
		while(r>l)res+=tree[r],r-=lowbit(r);
		while(l>r)res-=tree[l],l-=lowbit(l);
		return res;
	}
}S;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		double t;
		cin>>t;
		a[i]=round((long double)t*MX);
	}
	//for(int i=1;i<=n;i++)cout<<a[i]<<' ';cout<<endl;
	//brute();
	for(int i=1;i<=n;i++){
		while(a[i]%2==0)y[i].two++,a[i]/=2;
		while(a[i]%5==0)y[i].fiv++,a[i]/=5;
	}
	LL ans=0;
	//for(int i=1;i<=n;i++)cout<<y[i].two<<' ';cout<<endl;//
	//for(int i=1;i<=n;i++)cout<<y[i].fiv<<' ';cout<<endl;//
	//cout<<"_____\n";//
	sort(y+1,y+n+1,cmp1);
	//for(int i=1;i<=n;i++)cout<<y[i].two<<' ';cout<<endl;//
	//for(int i=1;i<=n;i++)cout<<y[i].fiv<<' ';cout<<endl;//
	for(int i=1;i<=n;i++){
		q[i].l=lower_bound(y+1,y+n+1,(num){max(0,18-y[i].two),0,-1},cmp1)-y;
		q[i].w=max(0,18-y[i].fiv);
		if(max(0,18-y[i].two)<=y[i].two&&max(0,18-y[i].fiv)<=y[i].fiv)ans--;//,cout<<i<<',';//
	}//cout<<endl;
	//for(int i=1;i<=n;i++)cout<<q[i].l<<' ';cout<<endl;//
	//for(int i=1;i<=n;i++)cout<<q[i].w<<' ';cout<<endl;//
	//cout<<ans<<endl;
	for(int i=1;i<=n;i++)y[i].id=i;
	sort(y+1,y+n+1,cmp2);
	sort(q+1,q+n+1,cmp3);
	S.n=n;
	for(int i=1,l=1;i<=n;i++){
		while(y[l].fiv>=q[i].w&&l<=n)S.add(y[l].id,1),l++;
		ans+=S.sum(q[i].l,n);//cout<<ans<<endl;
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 10780
#include <iostream>
#include <iomanip>

using namespace std;

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (int array[], int l, int r) {
    int pivot = array[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array[j] <= pivot) {
            i++;
            swap(&array[i], &array[j]);
        }
    }
    swap(&array[i + 1], &array[r]);
    return (i + 1);
}

void quickSort(int array[], int l, int r) {
    if (l < r) {
        int pivot = partition(array, l, r);
        quickSort(array, l, pivot - 1);
        quickSort(array, pivot + 1, r);
    }
}

int main(void)
{
    int N, i, v[60];
    double x[60];

    cin >> N;

    for(i=1; i<=N; i++){
	cin >> v[i];
    }

    quickSort(v, 1, N);

    x[1] = (double)(v[1] + v[2]) / 2.0;

    for(i=2; i<=N-1; i++){
	x[i] = (double)(x[i-1] + v[i+1]) / 2.0;
    }

    cout << setprecision(10) << x[N-1] << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import math

g = 9.8

while True:
    try:
        s = raw_input()
        vd = float(s)
        #N = int(math.ceil((vd * vd / (10 * g)) + 1))
        #N = int(math.ceil((vd * vd / (9.8 * 2) + 5) / 5))
        N  = int(math.ceil((vd * vd / (9.8 * 2) + 5) / 5))
        print N
    except EOFError:
        break

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

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

    int x = 0, y = 0, t = 0;
    bool flg = true;

    while (N--) {
        int t2, x2, y2;
        cin >> t2 >> x2 >> y2;
        int time = abs(t2 - t);
        int dist = abs(x2 - x) + abs(y2 - y);

        if (time % 2 != dist % 2) flg = false;
        if (time < dist) flg = false;

        t = t2;
        x = x2, y = y2;
    }

    if (flg) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	bool jdg = false;
	int num;
	for (int i = 2; i <= 9; i++) {
		num = N % i;
		if (num == 0) {
			num = N / i;
			if (num <= 9) {
				jdg = true;
				break;
			}
		}
	}

	if (N == 1) {
		cout << "Yes" << endl;
	}
	else if (jdg == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
    }
    int min = l[0], max = r[0];
    bool z= true;
    for(int i = 1; i < m; i++){
        min = std::max(min, l[i]);
        max = std::min(max, r[i]);
        if(min > max){
            z = false;
            break;
        }
    }
    if(z) cout << max - min + 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
const int maxN = 3e5+5;
typedef long long i64;
typedef std::pair<int,int> pii;
int N;
i64 pre[maxN];
i64 suf[maxN];
int a[maxN];
int b[maxN];

int cnt[maxN*4];
i64 sum[maxN*4];

#define lc (u << 1)
#define rc (lc | 1)
#define MID ((l + r) >> 1)
void modify(int u,int l,int r,i64 v) {
  ++cnt[u]; sum[u] += v;
  if(l != r) {
    if(v <= b[MID]) modify(lc, l, MID, v);
    else modify(rc, MID + 1, r, v);
  }
}

i64 get(int u,int l,int r,int k) {
  if(cnt[u] <= k) return sum[u];
  if(l == r) return sum[u] / cnt[u] * k;
  else {
    if(cnt[lc] >= k) return get(lc, l, MID, k);
    return sum[lc] + get(rc, MID + 1, r, k - cnt[lc]);
  }
}

i64 get0(int u,int l,int r,int k) {
  if(cnt[u] <= k) return sum[u];
  if(l == r) return sum[u] / cnt[u] * k;
  else {
    if(cnt[rc] >= k) return get0(rc, MID+1, r, k);
    return sum[rc] + get0(lc, l, MID, k - cnt[rc]);
  }
}

int main() {
  if(fopen("input.txt","r")) {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  }

  scanf("%d", &N);
  for(int i = 1;i <= 3*N; ++i) {
    scanf("%d", a + i), b[i] = a[i];
    pre[i] = pre[i - 1] + a[i];
  }

  int tot = N * 3;
  for(int i = tot; i; --i)
    suf[i] = suf[i+1] + a[i];
  
  std::sort(b + 1, b + tot + 1);
  tot = std::unique(b + 1, b + tot + 1)-b-1;
  
  for(int i = 1;i <= N; ++i) modify(1, 1, tot, a[i]);
  for(int i = N+1; i <= N*2; ++i) {
    modify(1, 1, tot, a[i]);
    pre[i] -= get(1, 1, tot, i - N);
  }

  memset(cnt, 0, sizeof cnt);
  memset(sum, 0, sizeof sum);

  for(int i = 2*N+1;i <= 3*N; ++i)
    modify(1, 1, tot, a[i]);
  i64 ans = pre[2*N]-suf[2*N+1];
  for(int i = 2*N;i > N; --i) {
    modify(1, 1, tot, a[i]);
    suf[i] -= get0(1, 1, tot, 2*N+1-i);
    ans = std::max(ans, pre[i-1]-suf[i]);
  }

  get0(1, 1, tot, N);
  printf("%lld", ans);
  
  return 0;
}


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

using namespace std;

const double pi=acos(-1.0);

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

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

	double h=c*30+(d*0.5);
	double m=d*6;
	double theta=fabs(h-m);
	double ans=sqrt(a*a+b*b-(2*a*b)*cos(pi*theta/180.0));
	cout<<setprecision(10)<<fixed<<ans<<'\n';
}


Measured memory_bytes: 4176
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=100002;

 
void solve(){
	set<int>st;
	int a,b;
	cin>>a>>b;
	st.insert(a);
	st.insert(b);
	for(int i=1;i<=3;i++){
		if(st.find(i)==st.end()){
			cout<<i;
			return;
		}
	}
	
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

int main() {
	ll n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;
	ll flg = min({a, b, c, d, e});
	if(flg==1){
		cout<< n/flg+4 <<endl;
	} else {
		cout<< n/flg+5 <<endl;
	}
	
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	ll n;cin >> n;
	ll ans = 10000000000;
	
	for(ll i = 1;i <= 101000;i++){
		ll tmp = 0;
		ll j = n - i;
		if(i > 0 && j > 0){
			ll hoge = i;
			while(hoge > 0){
				tmp += hoge % 10;
				hoge /= 10;
			}
			hoge = j;
			while(hoge > 0){
				tmp += hoge % 10;
				hoge /= 10;
			}
			ans = min(ans,tmp);
		}
	}
	
	cout << ans << endl;
		
	
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        ArrayList<Integer> A = new ArrayList<Integer>();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
 
        for(int i=0;i<N;i++){
            A.add(scanner.nextInt());
        }
        printList(A,N);
        insertionSort(A,N);
    }
     
    static void insertionSort(ArrayList<Integer> A,int N){
        for(int i=1;i<N;i++){
            int v = A.get(i);
            int j=i-1;
            while(j>=0 && (v < A.get(j))){
                A.set(j+1,A.get(j));
                j--;
            }
            A.set(j+1, v);
            printList(A,N);
        }
    }
    static void printList(ArrayList<Integer> A,int N){
        StringBuilder builder = new StringBuilder();
        for(int i=0;i<N;i++){
            if(i>0){
                builder.append(" ");
            }
            builder.append(A.get(i));
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 29508
using System;
using System.Linq;
 
class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if(s[1]==100) Console.WriteLine(101 * Math.Pow(100, s[0]));
        else Console.WriteLine(s[1] * Math.Pow(100,s[0]));
    }
}

Measured memory_bytes: 13268
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
def search(pros,tgt,g,d):
    tmp = 0
    cnt = 0
    rest = []
    for i in range(d):
        if tgt % 2 == 1:
            tmp += 100 * (i+1) * pros[i][0] + pros[i][1]
            cnt += pros[i][0]
        else:
            rest.append((i+1,pros[i][0]-1))
        tgt //= 2
    # print(tmp)
    if tmp >= g:
        return cnt
    for ap, ac in rest[::-1]:
        if tmp + 100 * ap * ac >= g:
            cnt += math.ceil((g - tmp)/(100 * ap))
            return cnt
        else:
            cnt += ac
            tmp += 100 * ac * ap

    return INF

def main():
    d,g = getList()
    pros = []
    for i in range(d):
        pros.append(getList())
    ans = INF
    tgt = 2 ** d
    for i in range(tgt):
        tmp = search(pros, i,g, d)
        # print(i, tmp)
        if tmp < ans:
            ans = tmp

    print(ans)
    return


 
if __name__ == "__main__":
    main()
   

Measured memory_bytes: 74068
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <vector>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <ctime>
#include <numeric>
using namespace std;

#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(unique(all(x)) - (x).begin())
#define ld long double
#define int long long

void SOLVE() {
	string s;
	cin >> s;
	set <char> st;
	for (char c : s) {
		st.insert(c);
	}
	if (st.size() == 1) cout << "No\n";
	else cout << "Yes\n";
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(10);
	int Q = 1;
	//cin >> Q;
	while (Q--) {
		SOLVE();
	}

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(){
    long long a,b,sum=0;
    cin>>a;
    b=0;
    while(a>=10){
       b++;
       sum+=a%10;
       a/=10;
    }
    sum+=a;
    if(sum<a+b*9-1) sum=a+b*9-1;
    cout<<sum<<endl;
    return 0;

}

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

int main(){


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

    if(a+b == c+d){
        cout << "Balanced" << endl;
    }else if(a+b < c+d){
        cout << "Right" << endl;
    }else{
        cout << "Left" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int a[50],ans[100];
int main(){
	long long n;
	scanf("%lld",&n);n++;
	int m=0,t=0;
	for (;n>1;n>>=1) m+=(a[++t]=n&1);
	int l=m+1,r=m;
	for (int i=t,j=0;i;i--){
		ans[++r]=++j;
		if (a[i]) ans[--l]=++j;
	}
	printf("%d\n",r*2);
	for (int i=1;i<=r;i++) printf("%d ",ans[i]);
	for (int i=1;i<=r;i++) printf("%d ",i);
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var total = line[2] / line[0] * line[1];
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5+5;

int arr[maxn];
ll qs[maxn];

pair<ll, ll> ask(ll a, ll b, ll c, ll d)
{
	return make_pair(min(min(a, b), min(c, d)), max(max(a, b), max(c, d)));
}
int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i<= n; i++)
		scanf("%d", arr+i);
	for(int i = 1; i<= n; i++)
		qs[i] = qs[i-1] + arr[i];
	
	int p1 = 1, p2 = 3;
	ll best = 2e18;
	for(int mid = 2; mid<= n-2; mid++)
	{
		ll left = qs[mid];
		ll right = qs[n]-qs[mid];
		while(p1< mid && 2LL*qs[p1]<= left) p1++;
		while(p2< n && 2LL*(qs[p2]-qs[mid])<= right) p2++;
		ll a1 = qs[p1];
		ll a2 = qs[mid]-qs[p1];
		ll a3 = qs[p2]-qs[mid];
		ll a4 = qs[n]-qs[p2];
		ll b1 = qs[p1-1];
		ll b2 = qs[mid]-qs[p1-1];
		ll b3 = qs[p2-1]-qs[mid];
		ll b4 = qs[n]-qs[p2-1];
		auto x1 = ask(a1, a2, a3, a4);
		auto x2 = ask(a1, a2, b3, b4);
		auto x3 = ask(b1, b2, a3, a4);
		auto x4 = ask(b1, b2, b3, b4);
		ll r1 = x1.Y-x1.X, r2 = x2.Y-x2.X, r3 = x3.Y-x3.X, r4 = x4.Y-x4.X;
		best = min(best, r1); best = min(best, r2); best = min(best, r3); best = min(best, r4);
	}
	printf("%lld\n", best);
}

Measured memory_bytes: 2688
n = int(input())
evidences = [[] for _ in range(n)]
for i in range(n):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x-1, y))
result = 0
for i in range(1, 2**n):
    consistent = True 
    for j in range(n):
        if (i>>j) & 1 == 0:
            continue 
        for x, y in evidences[j]:
            if (i>>x)&1 != y:
                consistent = False 
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)



Measured memory_bytes: 9156
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n, m;
  string str;
  
  while(cin >> n,n){
    cin >> m >> str;
    
    int cnt = 0;
    int IO[m];
    memset(IO, 0, sizeof(IO));
    
    for(int i = 2 ; i < m ; i++){
      if(str[i-2] == 'I' && str[i-1] == 'O' && str[i] == 'I'){
	IO[i] += IO[i-2] + 1;
      }
    }
    
    for(int i = 2 ; i < m ; i++){
      if(IO[i] >= n) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
  string s;
  cin >>s;
  
  sort(s.begin(), s.end());
  if(s.at(0)=='a' && s.at(1)=='b' && s.at(2)=='c') cout <<"Yes";
  else cout <<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    float n,d,a,b,s=0;
    cin>>n>>d;
    for(float i=0;i<n;i++)
    {
        cin>>a>>b;
        if(pow(d,2)>=pow(a,2)+pow(b,2))
        {
            s++;
        }
    }
    cout<<s<<endl;
}



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

const int nmax = 250000;

int main()
{
	int pr[nmax];
	pr[0]=pr[1]=0;
	for(int i=2; i<nmax; i++)
	{
		pr[i]=1;
	}

	for(int i=2; i*i<nmax; i++)
	{
		if(!pr[i]) continue;
		for(int j=i*2; j<nmax; j+=i)
		{
			pr[j]=0;
		}
	}

	for(int i=1; i<nmax; i++)
	{
		pr[i]+=pr[i-1];
	}

	int N;
	while(cin >> N, N)
	{
		cout << pr[N*2]-pr[N] << endl;;
	}
}

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

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

Measured memory_bytes: 3632