akhauriyash/Code-Regression huggingface dataset:
D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())

num = []
# 完全に解くか解かないかを選ぶ
for i in range(2**D):
    score = 0
    num_tmp = 0  # 解いた問題数
    not_comp = []  # 解いていないもの
    for j in range(D):
        if i >> j & 1:
            score += p[j] * 100 * (j + 1) + c[j]
            num_tmp += p[j]
        else:
            not_comp.append(j)

    for j in not_comp[::-1]:
        if score < G:
            num_j = min(p[j] - 1, (G - score - 1) // (100 * (j + 1)) + 1)
            score += num_j * 100 * (j + 1)
            num_tmp += num_j

    if score >= G:
        num.append(num_tmp)

ans = min(num)
print(ans)

Measured memory_bytes: 3192
while True:
  H,W = map(int,input().split())
  if H == 0 and W == 0: break
  
  for x in range(H):
    for y in range(W):
      if x == 0 or y == 0 or y == W-1 or x == H-1:
        print("#",end="")
      else:
        print(".",end="")
    print("")
  print("")


Measured memory_bytes: 7012
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
const int INF = (1<<30);
struct node{
	int pos, key;
	node(int _p=0, int _k=0):pos(_p), key(_k){}
}a[MAXN + 5], b[MAXN + 5];
bool cmp_pos(node a, node b) {
	return a.pos < b.pos;
}
bool cmp_key(node a, node b) {
	return a.key < b.key;
}
int siz[MAXN + 5], fa[MAXN + 5];
int N;long long x;
int Find(int x) {
	if( fa[x] == x ) return x;
	else return fa[x] = Find(fa[x]);
}
void Union(int x, int y) {
	int fx = Find(x), fy = Find(y);
	if( fx != fy ) {
		siz[fy] += siz[fx];
		fa[fx] = fy;
	}
}
int solve1() {
	for(int i=1;i<=N;i++) {
		fa[i] = i;
		siz[i] = 1;
	}
	for(int i=1;i<=N;i++)
		Union(a[i].pos, b[i].pos);
	for(int i=1;i<N;i++)
		if( a[i].key == a[i+1].key ) Union(a[i].pos, a[i+1].pos);
	sort(a+1, a+N+1, cmp_pos); sort(b+1, b+N+1, cmp_pos);
	for(int i=1;i<=N;i++)
		if( a[i].key == b[i].key )
			siz[Find(a[i].pos)]--;
	int ret = 0;
	for(int i=1;i<=N;i++)
		if( fa[i] == i && siz[i] ) ret += (siz[i] + 1);
	return ret;
}
int solve2(int p, int q) {
	sort(a+1, a+N+1, cmp_key);
	int temp = a[p].key; p = a[p].pos;
	sort(a+1, a+N+1, cmp_pos);
	sort(b+1, b+N+1, cmp_pos);
	for(int i=1;i<=N;i++) {
		if( a[i].key == temp && b[i].key != temp) {
			p = i;
			break;
		}
	}
	sort(a+1, a+N+1, cmp_key);
	for(int i=1;i<=N;i++)
		if( a[i].pos == p ) a[i].key = x;
	sort(a+1, a+N+1, cmp_key); sort(b+1, b+N+1, cmp_key);
	for(int i=1;i<=N;i++) {
		fa[i] = i;
		siz[i] = 1;
	}
	for(int i=1;i<=N;i++)
		Union(a[i].pos, b[i].pos);
	for(int i=1;i<N;i++)
		if( a[i].key == a[i+1].key ) Union(a[i].pos, a[i+1].pos);
	sort(a+1, a+N+1, cmp_pos); sort(b+1, b+N+1, cmp_pos);
	int ret = -1;
	for(int i=1;i<=N;i++)
		if( a[i].key == b[i].key )
			siz[Find(a[i].pos)]--;
	if( siz[Find(p)] == 0 )
		ret = 1;
	for(int i=1;i<=N;i++)
		if( fa[i] == i && siz[i] ) ret += (siz[i] + 1);
	return ret;
}
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%d", &a[i].key);
		a[i].pos = i;
		x ^= a[i].key;
	}
	for(int i=1;i<=N;i++) {
		scanf("%d", &b[i].key);
		b[i].pos = i;
	}
	bool f1 = true, f2 = true;
	sort(a+1, a+N+1, cmp_key); sort(b+1, b+N+1, cmp_key);
	for(int i=1;i<=N;i++)
		f1 = f1 && (a[i].key == b[i].key);
	int p = -1, q;
	for(int i=1;i<=N;i++)
		if( b[i].key == x ) p = i;
	if( p == -1 ) f2 = false;
	else {
		bool f3 = true;
		int i = 1, j = 1;
		while( i <= N && j <= N ) {
			if( j == p ) {
				j++;
				continue;
			}
			if( a[i].key != b[j].key ) {
				if( f3 ) {
					q = i;
					f3 = false, i++;
					continue;
				}
				else {
					f2 = false;
					break;
				}
			}
			i++, j++;
		}
		if( f3 ) q = N;
	}
	int ans = INF;
	if( (!f1) && (!f2) ) {
		puts("-1");
		return 0;
	}
	if( f1 ) ans = min(ans, solve1());
	if( f2 ) ans = min(ans, solve2(q, p));
	printf("%d\n", ans);
}

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

int main() {
	int a, b; cin >> a >> b;
	int c;
	if( b < 10 ) c = a * 10 + b;
	else if( b < 100 ) c = a * 100 + b;
	else if( b == 100 ) c = a * 1000 + b;
	
	int i = 0;
	while( i * i <= c ){
		if( i * i == c ){
			cout << "Yes" << endl;
			return 0;
		}
		++i;
	}
	
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define calc(a,b) ((a+=b)%=mo)
using namespace std;
const int N=200050,mo=1e9+7,ni=(mo+1)/2;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int fap(int a,int b){
    int s=1;
    for (; b; b>>=1,a=1ll*a*a%mo)
	if (b&1) s=1ll*s*a%mo;
    return s;
}
int n,ans,num[N],a[N],d[N],cnt[N],w[N],L[N],R[N];
struct bit{
    int f[N];
    void ins(int x,int s){
	while(x<=n) (f[x]+=s)%=mo,x+=x&-x;
	return;
    }
    int query(int x){
	int s=0;
	while(x) (s+=f[x])%=mo,x-=x&-x;
	return s;
    }
}A,B,C;
int main(){
    cin>>n;
    for (int i=1; i<=n; ++i) a[i]=gi(),++cnt[a[i]];
    for (int i=n-1; i; --i) cnt[i]+=cnt[i+1]-1;
    for (int i=1; i<=n; ++i)
	if (cnt[i]<=0)
	    return puts("0"),0;
    int sum=1; d[0]=1;
    for (int i=1; i<=n; ++i){
	num[i]=num[i-1],d[i]=d[i-1],sum=1ll*sum*cnt[i]%mo;
	if (cnt[i]==1) ++num[i];
	else d[i]=1ll*d[i]*(cnt[i]-1)%mo*fap(cnt[i],mo-2)%mo;
	w[i]=fap(d[i],mo-2);
    }
    for (int i=1; i<=n; ++i)
	if (num[i]==num[i-1]) L[i]=L[i-1];
	else L[i]=i;
    R[n+1]=n;
    for (int i=n; i>=1; --i)
	if (cnt[i]==1) R[i]=i-1;
	else R[i]=R[i+1];
    int s,v;
    for (int i=1; i<=n; ++i){
	s=(mo+A.query(a[i])-A.query(L[a[i]]))%mo;
	(ans+=1ll*s*d[a[i]]%mo*sum%mo*ni%mo)%=mo;
	if (a[i]<n){
	    s=(mo+B.query(R[a[i]+1])-B.query(a[i]))%mo;
	    v=(mo+C.query(n)-C.query(a[i]))%mo;
	    (ans+=1ll*sum*v%mo)%=mo;
	    (ans+=mo-1ll*s*w[a[i]]%mo*ni%mo*sum%mo)%=mo;
	}
	A.ins(a[i],w[a[i]]),B.ins(a[i],d[a[i]]),C.ins(a[i],1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8064
import sys
sys.setrecursionlimit(100000000)
 
N, A, B, C, D = map(int, input().split())
s = list(input())
 
A -= 1
B -= 1
C -= 1
D -= 1
 

if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and B <= i + 1 <= D:
                tmp = 1
    if tmp != 1:
        print("No")
        exit()
 
 
 
def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans
 
ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (n % 2 == 0) {
        ll r = 0, s = 0;

        for (int i = 0; i < n; i += 2) {
            s += a[i];
            r += a[i + 1];
            r = max(r, s);
        }
        cout << r << endl;

    } else {
        ll r = 0, s = 0, t = 0;

        for (int i = 2; i < n; i += 2) {
            t += a[i];
        }
        ll u = t;

        for (int i = 2; i < n; i += 2) {
            t -= a[i];
            s += a[i - 2];
            r += a[i - 1];
            r = max(r, s);
            u = max(u, r + t);
        }
        cout << u << endl;
    }

    return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <numeric>

using namespace std;

vector<unordered_set<int>> graph;
vector<int> visited;
vector<int> component;

void dfs(int v, int c) {
  visited[v] = 1;
  for(auto& u: graph[v]) {
    if(!visited[u]) {
      dfs(u, c);
    }
  }
  component[v] = c;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int n, m, a, b;
  cin >> n >> m;
  graph = vector<unordered_set<int>>(n);
  visited = vector<int>(n, 0);
  component = vector<int>(n, 0);

  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--; b--;
    graph[a].insert(b);
    graph[b].insert(a);
  }
  int cur_component = 0;
  for(int i = 0; i < n; ++i) {
    if(!visited[i]) {
      component[i] = cur_component;
      dfs(i, cur_component);
      ++cur_component;
    }
  }
  unordered_map<int, int> mp;
  for(auto& c: component) {
    mp[c]++;
  }
  int result = 0;
  while(mp.size()) {
    int cur_min = 10000000;
    for(auto& p: mp) {
      if(p.second < cur_min) cur_min = p.second;
    }
    result += cur_min;
    vector<int> to_delete;
    for(auto iter = begin(mp); iter != end(mp); ++iter) {
      iter->second -= cur_min;
      if(iter->second == 0) to_delete.push_back(iter->first);
    }
    for(auto& el: to_delete) mp.erase(el);
  }
  cout << result << "\n";
	return 0;
}


Measured memory_bytes: 37236
#include <iostream>
#include <cstdlib>
#include <string>
#include <map>

using namespace std;
typedef pair<int, int> P;
void solve()
{
	map<int, int> Map1;
	map<int, int> Map2;
	string str;
	while(getline(cin, str))
	{
		if(str.size() == 0)
		{
			break;
		}
		
		string temp;
		int n = str.size();
		for(int i = 0; i < n; ++i)
		{
			if(str[i] == ',')
			{
				int a = temp.size();
				char* c = new char[a];
				for(int j = 0; j < a; ++j)
				{
					c[j] = temp[j];
				}
				int b = atoi(c);
				++Map1[b];
				temp.clear();
			}
			else
			{
				temp += str[i];
			}
		}
	}

	while(cin >> str)
	{
		string temp;
		int n = str.size();
		for(int i = 0; i < n; ++i)
		{
			if(str[i] == ',')
			{
				int a = temp.size();
				char* c = new char[a];
				for(int j = 0; j < a; ++j)
				{
					c[j] = temp[j];
				}
				int b = atoi(c);
				++Map2[b];
				temp.clear();
			}
			else
			{
				temp += str[i];
			}
		}
	}
	for(map<int, int>::iterator Ite = Map2.begin(); Ite != Map2.end(); ++Ite)
	{
		if(Map1[Ite->first] > 0)
		{
			cout << Ite->first << " " << Map1[Ite->first] + Ite->second << endl;
		}
	}	
}

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

Measured memory_bytes: 0
import Control.Applicative
import qualified Data.IntMap.Strict as I
import Data.List
import Data.Function (on)

main = do
    nums <- foldl' (flip (flip (I.insertWith (+)) 1)) I.empty
        . map read . lines <$> getContents
    let ns = sortBy (flip compare `on` snd) . I.toAscList $ nums
        maxFreq = snd . head $ ns
    mapM_ (print . fst) . takeWhile ((maxFreq ==) . snd) $ ns

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int k, x;
    cin >> k >> x;
    cout << x - k + 1;
    if(k != 1){
        for(int i = x - k + 2; i <= x + k - 1; ++i){
            cout << " " << i;
        }
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int i;
  int cnt=0;
  int score[200005];
  score[0]=0;
  for(i=0;i<n;i++){
    if(s[i]=='#') cnt++;
    score[i+1]=cnt;
  }
  int ans=n;
  for(i=0;i<=n;i++){
    int tmp=0;
    tmp+=score[i];
    tmp+=(n-i)-(score[n]-score[i]);
    ans=min(ans,tmp);
  }
  //cout<<score<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    LL n,n1;
    cin >> n;
    n1 = n%10;

    vector<string>  ans(10);
    ans[0] = ans[1] = ans[6] = ans[8] = "pon";
	ans[3] = "bon";
	ans[2] = ans[4] = ans[5] = ans[7] = ans[9] = "hon";
	cout << ans[n1] << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
  int N;
  int A[10][2];
  int i;
  int result_odd, result_total, result;
  scanf("%d", &N);
  for(i = 0; i < N; ++i){
    scanf("%d", &A[i][0]);
    /* 奇数の数 */
    if(A[i][0] % 2 == 1)
      A[i][1] = 1;
    else
      A[i][1] = 2;
  }
  result_odd	= A[0][1];
  result_total	= 3;
  for(i = 1; i < N; ++i){
    result_total	*= 3;
    result_odd		*= A[i][1];
  }
  result = result_total - result_odd;
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<string>
#include <time.h>
#include<map>
#include<set>
#include<algorithm>
#include<vector>
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;

ll MOD=1e9+7;
int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        
        ll before_me=0;
        for(int j=0;j<i;j++)
        {
            if(arr[j]>arr[i])
                before_me++;
        }
        ll all=0;
        for(int j=0;j<n;j++)
        {
            if(arr[j]>arr[i])
                all++;
        }
        ll cur=before_me*k;
        cur%=MOD;
        ll side=(k*(k-1))/2;
        side%=MOD;
        side*=all;
        side%=MOD;
        cur=(cur+side)%MOD;
        ans+=cur;
        ans%=MOD;
    }
    cout<<ans;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x1,x2, y1, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (x2 - x1);
    y4 = y3 - (y2 - y1);

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << '\n';

    return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max(A*B, C*D) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

int main()
{
    fastio;
    int n, maxn = 0;
    cin >> n;

    map<string, int> mp;
    set<string> st;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
        st.insert(s);
        maxn = max(maxn, mp[s]);
    }

    vector<string> ans;
    for (auto &p : st)
    {
        if (mp[p] == maxn)
            ans.push_back(p);
    }

    sort(ans.begin(), ans.end());

    for (auto &p : ans)
        cout << p << "\n";
    
    return 0;
}

Measured memory_bytes: 35056
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N = 0;
    int A[1000] = {};
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    for (int i = 0; i < N ; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 == 0 || A[i] % 5 == 0) {
                continue;
            }else{
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    
    return 0;
}


Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
n, m = ri_()
print((n-1)*(m-1))

Measured memory_bytes: 63200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int digit(int N)
{
  int count=0;
  while (N>0)
  {
    N/=10;
    count++;
  }
  return (count);
}

int main()
{
  int N;cin>>N;
  int d = digit(N);
  
  int G[10][10];
  for (int i=0;i<=9;i++)
  {
    for (int j=0;j<=9;j++)
      G[i][j]=0; 
  }
  
  for (int i=1;i<=N;i++)
  {
    int dd = digit(i);
    int head = i/pow(10,dd-1);
    int foot = i % 10;
    //cout<<i<<" "<<head<<" "<<foot<<endl;
    G[head][foot]++;
  }
  
  int count=0;
  for (int i=0;i<=9;i++)
  {
    for (int j=0;j<=9;j++)
    {
      count += G[i][j]*G[j][i];  
    }
  }
  cout<<count<<endl;  
}

Measured memory_bytes: 256
$dice = gets.split(" ").map(&:to_i)
commands = gets.chomp!.split("")

def turn_north(dice)
  new_dice = [dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]]
  new_dice
end

def turn_south(dice)
  new_dice = [dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]]
  new_dice
end

def turn_east(dice)
  new_dice = [dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]]
  new_dice
end

def turn_west(dice)
  new_dice = [dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]]
  new_dice
end

commands.each do |c|
  case c
  when "N"
    $dice = turn_north($dice)
  when "S"
    $dice = turn_south($dice)
  when "W"
    $dice = turn_west($dice)
  when "E"
    $dice = turn_east($dice)
  end
end

puts $dice.first



Measured memory_bytes: 8888
h, w = map(lambda x: int(x)+2, input().split())
MOD = 10**9+7
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

route = [[0]*w for _ in range(h)]
route[1][1] = 1
for i in range(1, h-1):
    for j in range(1, w-1):
        for x, y in [(i+1, j), (i, j+1)]:
            if MAZE[x][y] == '#':
                continue
            route[x][y] += route[i][j]

print(route[-2][-2] % MOD)

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

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

    a = N % 10;

    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon" << endl;
    if (a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    if (a == 3) cout << "bon" << endl;

}

Measured memory_bytes: 3620
import java.math.BigInteger;
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final BigInteger A = new BigInteger(sc.next());
        final BigInteger B = new BigInteger(sc.next());
        sc.close();

        BigInteger C = A.gcd(B);
        long ans = A.multiply(B).divide(C).longValue();
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;

vector<int> g[MAXN];
int d[MAXN],c[MAXN],pa[MAXN];
set<pair<int,int>> s;

void dfs(int a,int p){
	pa[a] = p;
	for(int i:g[a]) if(i != p) dfs(i,a);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	for(int i=0;i<n-1;i++){
		int a,b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
		d[a]++;
		d[b]++;
	}
	dfs(n,0);
	for(int i=1;i<=n;i++) s.insert({d[i],i});
	while(!s.empty()){
		auto t = *s.begin(); s.erase(s.begin());
		int a = t.second;
		if(a == n){
			c[a] = 1; break;
		}
		if(c[pa[a]] != 0){
			cout << "First\n"; return 0;
		}
		c[a] = 2; c[pa[a]] = 1;
		s.erase({d[pa[a]],pa[a]});
		int grand = pa[pa[a]];
		if(grand == 0 || c[grand] != 0) continue;
		s.erase({d[grand],grand});
		d[grand]--;
		s.insert({d[grand],grand});
	}
	for(int i=1;i<=n;i++) if(c[i] == 1){
		int f = 0;
		for(int j:g[i]) if(c[j] == 2){
			f = 1; break;
		}
		if(f == 0){
			cout << "First\n"; return 0;
		}
	}
	cout << "Second\n";
	return 0;
}


Measured memory_bytes: 14336
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	ll X,Y;
	cin>>X>>Y;
	ll Z=X;
	for(int i=0;i<1000000;i++){
		if(Z%Y!=0){
			cout<<Z<<endl;
			return 0;
		}
		Z+=X;
	}
	cout<<-1<<endl;
	return 0;
}

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

int strtoint(string s) {
	stringstream t2(s);
	int m = 0;
	t2 >> m;
	return m;
}

int main() {
	string s;
	cin >> s;
	string t = s.substr(0, 2);
	int fo = strtoint(t);
	t = s.substr(2, 2);
	int back = strtoint(t);

	if(0 < fo && fo < 13) {
		if(0 < back && back < 13) {
			cout << "AMBIGUOUS" << endl;
		} else {
			cout << "MMYY" << endl;
		}
	} else if(0 < back && back < 13) {
		cout << "YYMM" << endl;
	} else {
		cout << "NA" << endl;
	}
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += a[n - 1 - i];
		}
		System.out.println(sum);
	}
}


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

int main() {
  int x; cin >>x;
  int max = 0;
  int buf;
  for (int b=1; b<=35; b++){
    buf = b;
    for (int p=2; p<=9; p++){
      buf *= b;
      if (buf > x) break;
      else if (buf > max) max = buf;
    }
  }
  cout <<max <<endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    rep(i, n) cin >> a.at(i);
    vector<string> b(m);
    rep(i, m) cin >> b.at(i);

    bool tflag = false;

    if(n == m) {
        rep(i, n) {
            if(a.at(i) != b.at(i)) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }

    if(n != m) {
        rep(i, n-m) {
            rep(j, n-m) {

                bool flag = false;

                rep(k, m) {
                    rep(l, m) {
                        if(a.at(i+k)[j+l] != b.at(k)[l]) {
                            flag = true;
                            break;
                        }
                        if(l==m-1 && k == m-1) {
                            cout << "Yes" << endl;
                            return 0;
                        }
                    }
                    if(flag == true) break;
                }

            }
        }
    }
    
    cout << "No" << endl;

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n)
	{
		cin >> a[i];
	}
	sort(ALL(a),greater<int>());
int ans=0;
rep(i,n)
{
	if(i)ans+=a[i];
	else ans += a[i]/2;
}
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int A, B, C;
    cin >> A >> B >> C;
    int X;
    cin >> X;
    int cnt = 0;
    REP(i, A+1){
        REP(j, B+1){
            REP(k, C+1){
                if(500*i+100*j+50*k==X){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << el;
}



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

int main()
{
    int N;
    int K, P;
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        int K, P;
        cin >> K >> P;
        if ( K % P == 0 ) {
            cout << P << endl;
        } else {
            cout << K % P << endl;
        }
    }
    return ( 0 );
}




Measured memory_bytes: 3112
import java.util.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int max_l = 0;
        int min_r = Integer.MAX_VALUE;

        for(int i = 0; i<m; i++){
            // if(m==1)
            int l = sc.nextInt();
            int r = sc.nextInt();
            max_l = max(l,max_l);
            min_r = min(r,min_r);
        }
        int ans =0;
        for(int i=1; i<=n; i++){
            if(i>=max_l && i<=min_r){
                ans++;
            }
        }
        System.out.println(ans);
    }
}
    

Measured memory_bytes: 62988
N,X,M=map(int,input().split())
l=[-1]*M
a=0
t=X
l[X]=0
if t**2%M==t:
    print(N*t)
    exit()
for i in range(1,M+1):
    t=t**2%M
    if l[t]==-1:
        l[t]=i
    else:
        s,g=l[t],i
        break
if N<=s+1:
    t=X
    a=X
    for i in range(N-1):
        t=t**2%M
        a+=t
    print(a)
else:
    t=X
    a=0
    if s!=0:
        a=X
    for i in range(s-1):
        t=t**2%M
        a+=t
    t2=t
    c=0
    for i in range(g-s):
        t=t**2%M
        c+=t
    if s==0:
        for i in range(N%(g-s)):
            a+=t2
            t2=t2**2%M
    else:
        for i in range((N-s)%(g-s)):
            t2=t2**2%M
            a+=t2
    a+=c*((N-s)//(g-s))
    print(a)

Measured memory_bytes: 66352
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;

 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 500 + 10;
const ll N = 100 * 1000 + 10;

vector <int> adj[N], t, k;
bool vis[N];
ll p[N];

void dfs(int v)
{
	t.push_back(p[v]);
	k.push_back(v);
	vis[v] = 1;
	for (auto u : adj[v])
	{
		if(!vis[u])	
			dfs(u);
	}
}

int main()	
{
	faster();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
		p[i]--;
	}
	for (int i = 0; i < m; i++)
	{
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if(!vis[i])
		{
			dfs(i);
			sort(t.begin(), t.end());
			sort(k.begin(), k.end());
			for (int j = 0; j < t.size(); j++)
			{
				ans += binary_search(k.begin(), k.end(), t[j]);
			}
			t.clear();
			k.clear();
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 11564
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	int res=inf;
	for(int i=0;i<n;i++){
		int A,t=0;
		cin>>A;
		while(A%2==0){
			A/=2;
			t++;
		}
		res=min(res,t);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <string>
#define _USE_MATH_DEFINES
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define fors(i, a, b) for(int i = a; i < b; i++)
#define for(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<string, int> > vpsi;
typedef map<string, int> msi;
int main()
{
    ios::sync_with_stdio(false);
    double n;
    cin >> n;
    cout << 2.0 * n * M_PI << endl;
}

Measured memory_bytes: 3804
import static java.lang.Math.pow;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int a = scanner.nextInt();
    final int b = scanner.nextInt();
    final int c = scanner.nextInt();

    if((a == b && a != c) || (b == c && b != a) || (c == a && c != b)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int H = scanner.nextInt();
		int N = scanner.nextInt();
		
		//決まった回数繰り返す
		for (int i = 0; i < N; i++) {
          
			int A = scanner.nextInt();
			H -= A;
		}
      	
		String ans = H <= 0 ? "Yes" : "No";
		System.out.println(ans);


		scanner.close();
	}
}


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll X, A;
    cin >> X >> A;

    if(X < A) _PR(0);
    else _PR(10);

    return 0;
}

/*



*/

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

int main(){
    int n,k,x=1;

    cin >> n >> k;

    for(int i=0; i<n; i++){
        if(x < k){
            x *=2;
        }else{
            x += k;
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC133
//
//  Created by didi on 2020/1/17.
//  Copyright © 2020年 didi. All rights reserved.
//
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cassert>
#include <queue>
#include <list>
using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> sum(N+1);
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        int flag = (i&1) ? 1 : (-1);
        sum[i] = sum[i-1] + flag * A[i];
    }
    for (int i = 1; i <= N; ++i) {
        int t = sum[N] - 2 * sum[i-1];
        int flag = (i&1) ? 1 : (-1);
        int ans = flag * t;
        if (i > 1) cout << " ";
        cout << ans;
    }
    return 0;
}


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

unsigned long N,res;

void DFS(unsigned long n){
	if(n <= N){
		bool seven = 0,five = 0,three = 0;
		unsigned long num = n;
		while(num > 0){
			if(num % 10 == 7)seven = 1;
			else if(num % 10 == 5)five = 1;
			else if(num % 10 == 3)three = 1;
			else{
				goto label;
			}
			num /= 10;
		}
		if(seven == 1 && five == 1 && three == 1){
			res++;
		}
		label:;
		DFS(10 * n + 7);
		DFS(10 * n + 5);
		DFS(10 * n + 3);
	}
}

int main(){
	cin >> N;
	DFS(0);
	cout << res << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, raw_input().split())
if    a <= b <= c:
    print"%d %d %d" % (a, b, c)
elif b <= a <= c:
    print"%d %d %d" % (b, a, c)
elif a <= c <= b:
    print"%d %d %d" % (a, c, b)
elif c <= a <= b:
    print"%d %d %d" % (c, a, b)
elif b <= c <= a:
    print"%d %d %d" % (b, c, a)
elif c <= b <= a:
    print"%d %d %d" % (c, b, a)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int k;
  string s;
  cin >> k >> s;

  if(k >= s.size()) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;

  return 0;
}


Measured memory_bytes: 3628
import sys
N = int(input())
s = []

for i in range(N):
    s.append(int(input()))

ans = sum(s)

if ans % 10 != 0:
    print(ans)
else:
    s.sort()
    for i in range(N):
        if (ans - s[i]) % 10 != 0:
            print(ans-s[i])
            sys.exit()

    print(0)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  long long int A,B,C;
  scanf("%lld%lld%lld",&A,&B,&C);
  if(A+B+1>=C){
    printf("%lld\n",B+C);
  }else{
    printf("%lld\n",A+2*B+1);
  }

  return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  string ans;

  if (a == 0 || b == 0)
    ans = "Zero";
  else if ((a < 0 && 0 < b) || (b < 0 && 0 < a))
    ans = "Zero";
  else if (a > 0 || (b - a) % 2 != 0)
    ans = "Positive";
  else
    ans = "Negative";

  cout << ans << endl;
}


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

using namespace std;

//#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int RES[N];

int Ask(int i) {
	if (RES[i] != -1) return RES[i];
	cout << i << endl;
	string s; cin >> s;
	if (s == "Male") return RES[i] = 1;
	if (s == "Female") return RES[i] = 2;
	exit(0);
	return RES[i] = 0;
}

int Find(int l, int r) {
	if (Ask(l) == 0) return l;
	if (Ask(r) == 0) return r;
	int md = (l + r) >> 1;
	if (Ask(l) == Ask(md) && (md - l) % 2 == 1) return Find(l, md);
	if (Ask(l) != Ask(md) && (md - l) % 2 == 0) return Find(l, md);
	if (Ask(md) == Ask(r) && (r - md) % 2 == 1) return Find(md, r);
	if (Ask(md) != Ask(r) && (r - md) % 2 == 0) return Find(md, r);
	return -1;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) RES[i] = -1;
	Find(0, n - 1);

	return 0;
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll ans;

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

    ans += (x / 11) * 2;
    x = x % 11;

    if (x != 0)
        ans++;

    if (x > 6)
        ans++;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  998244353ll
#define N    3000000
using namespace std;
int n,m;
ll jc[N+5],njc[N+5],ans;
ll fp(ll x,int k=998244351){
    ll ans=1;
    while(k){
        if(k&1)ans=ans*x%orz;
        k>>=1,x=x*x%orz;
    }
    return ans;
}
ll c(int x,int y){return jc[x]*njc[y]%orz*njc[x-y]%orz;}
ll cal(int x){
    if(x<0) return 0;
    x/=2;
    return c(x+n-1,n-1);
}
int main(){
    scanf("%d%d",&n,&m);
    jc[0]=1;
    for(int i=1;i<=N;++i)jc[i]=jc[i-1]*i%orz;
    njc[N]=fp(jc[N]);
    for(int i=N;i;--i)njc[i-1]=njc[i]*i%orz;
    for(int i=0;i<=m&&i<=n;++i){
        if((m-i)&1) continue;
        ll o=0;
        o+=cal(m*3-i);
        o-=cal(m-i)*i%orz;
        o-=cal(m-i-2)*(n-i)%orz;
        o=(o%orz+orz)%orz;
        o=o*c(n,i)%orz;
        ans+=o;
    }
    ans=(ans%orz+orz)%orz;
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b != c)
    {
        cout << "Yes" << endl;
    }
    else if (a != b && b == c)
    {
        cout << "Yes" << endl;
    }
    else if (c == a && a != b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// AOJ 1175: And Then. How Many Are There?
// 2017.12.21 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int s, del, m; } Q;
Q q[1000]; int top;
typedef struct { int x, y, r; } T;
T d[25];
int col[4][6], clen[4]; char f[5];
int up[25][25], ulen[25];		// ?????????????????????????????°??¨??????
char visited[16777216];

int main()
{
	int n, i, j, k, a, c, cmax, l, p, r, s, del, m, ans;

	while (scanf("%d", &n) && n > 0) {
		memset(clen, 0, sizeof(clen)), memset(f, -1, sizeof(f)), cmax = 0;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d%d", &d[i].x, &d[i].y, &d[i].r, &c);
			if  (f[c] >= 0)     c = f[c];
			else f[c] = cmax++, c = cmax-1;
			col[c][clen[c]++] = i;
		}

		memset(ulen, 0, sizeof(ulen));
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			int dx = d[i].x - d[j].x, dy = d[i].y - d[j].y, rr = d[i].r+d[j].r;
			if (dx*dx + dy*dy < rr*rr) up[j][ulen[j]++] = i;
		}

		ans = 0;
		memset(visited, 0, 1 << n);
		q[0].s = 0, q[0].del = 0, q[0].m = n, top = 1;
		while (top) {
			s = q[--top].s, del = q[top].del, m = q[top].m;
			if (m <= 1) break;
			if (visited[s]) continue;
			visited[s] = 1;
			for (c = 0; c < cmax; c++)if ((l = clen[c]) >= 2) for (p = 0; p < l; p++) {
				i = col[c][p];
				if (s & (1<<i)) continue;
				for (k = 0; k < ulen[i]; k++) {
					a = up[i][k];
					if (!(s & (1<<a))) goto next;
				}

				for (r = p+1; r < l; r++) {
					j = col[c][r];
					if (s & (1<<j)) continue;
					for (k = 0; ; k++) {
						if (k == ulen[j]) {
							if (del+2 > ans) ans = del+2;
							q[top].s = s|(1<<i) | (1<<j), q[top].del = del+2, q[top++].m = m-2;
							break;
						}
						a = up[j][k];
						if (!(s & (1<<a))) break;
					}
				}
				next:;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18252
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  s <- BS.getLine
  t <- BS.getLine

  let n = BS.length s
      m = BS.length t

      getdiff i j res | j >= m = res
                      | otherwise = let c1 = s `BS.index` (i + j)
                                        c2 = t `BS.index` j
                                        res' = if c1 /= c2
                                               then res + 1
                                               else res
                                    in getdiff i (j+1) res'

      solve i res | i > n - m = res
                  | otherwise =
                    let res' = min res (getdiff i 0 0)
                    in solve (i+1) res'

  print $ solve 0 inf


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	ll n; cin >> n;
	ll ans=1;
	for(ll i=1;i<=n;i++) {
		ans=ans*i%mod;
	}
  	ans%=mod;
	cout << ans << endl;
}

Measured memory_bytes: 3604