akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================
vi g[N];
stack<int> top_order;
bool vis[N];
int dist[N];
int dp[N];

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
	}
}


void top_sort(int u = 0) {
	vis[u] = 1;
	for (int v : g[u]) {
		if (vis[v]) continue;
		top_sort(v);
	}
	top_order.push(u);
}

int longest_path(int u) {
	vis[u] = 1;
	if (dp[u] != -1) return dp[u];
	int ans = 0;
	for (int v : g[u]) {
		ans = max(ans, 1 + longest_path(v));
	}
	return dp[u] = ans;
}

void solve() {
	int i, j, n, m;
	cin >> n >> m;
	ipgraph(n, m);
	memset(vis, 0, sizeof(vis));
	fo(i, n) {
		if (!vis[i]) {
			top_sort(i);
		}
	}
	memset(dp, -1, sizeof(dp));
	// reverse(top_order.begin(),top_order.end());
	fo(i, n + 1) dist[i] = inf;
	memset(vis, 0, sizeof(vis));
	int ans = 0;
	while (top_order.size() > 0) {
		int t = top_order.top();
		top_order.pop();
		if (!vis[t]) {
			dist[t] = 0;
			ans = max(ans, longest_path(t));
		}
	}
	cout << ans << "\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}



Measured memory_bytes: 22704
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc=new Scanner(System.in);

    public static void main(String[]args){
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b % a == 0)
            System.out.println(a+b);
        else
            System.out.println(b-a);

        sc.close();
    }
}

Measured memory_bytes: 21204
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N, M;
vector<int> link[50];
int A[50];
int B[50];

bool func(int a, int b)
{
	stack<int> s;
	s.push(0);
	bool flg[50] = {};
	flg[0] = true;

	int cnt = 1;
	while (s.size() > 0)
	{
		int n = s.top();
		s.pop();
		for(int l : link[n])
		{
			if (flg[l]) continue;
			if (n == a && l == b) continue;
			if (n == b && l == a) continue;
			flg[l] = true;
			s.push(l);
			cnt++;
		}
	}

	return cnt == N;
}

signed main()
{
	cin >> N >> M;
	REP(i, M)
	{
		int a, b;
		cin >> a >> b;
		A[i] = a - 1;
		B[i] = b - 1;
		link[a - 1].push_back(b - 1);
		link[b - 1].push_back(a - 1);
	}

	int cnt = 0;
	REP(i, M)
	{
		if (!func(A[i], B[i]))
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}



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

int main(){
  int N, K;
  string S;
  cin >> N >> S >> K;
  for(int i=0; i<N; i++){
    if(S.at(i)!=S.at(K-1)){
      S.at(i)='*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import collections
N = int(input())
S = [""]*N
for i in range(N):
    S[i] = input()
    
c = collections.Counter(S)
an = sorted(c.items(), key=lambda x:x[0])
ans = sorted(an, key=lambda x:x[1], reverse=True)

print(ans[0][0])
for i in range(1, len(c)):
    if(ans[i-1][1] != ans[i][1]):
        break
    print(ans[i][0])

Measured memory_bytes: 48648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N, K;
    cin >> N >> K;
    ll mod = pow(10,9)+7;
    ll ans = 0;
    for (ll i=K; i<=N+1; i++){
        ans += (i * (N-i+1)+1);
        ans %= mod;
    }
    cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;

 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : Q - Flowers
*/

constexpr int lsb(int n) { return n & -n; }

struct max_fenwick{
  vector<ull> v;
  max_fenwick(int size) : v(size + 1, 0){}
  void set(int i, ull x){
    for(i++; i < v.size(); i += lsb(i)) v[i] = max(v[i], x);
  }
  ull prefix(int i){
    ull ans = 0;
    for(i++; i > 0; i -= lsb(i)) ans = max(ans, v[i]);
    return ans;
  }
  void print(){
    for(auto &x : v) cout << x << ' ';
    cout << '\n';
  }
};

int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vi h(n), v(n);
  for(int &i : h) cin >> i, i--;
  for(int &i : v) cin >> i;

  max_fenwick dp(n);
  
  for(int i = 0; i < n; i++) {
    // dp.print();
    // cout << "link " << v[i] << " @ " << dp.prefix(h[i] - 1) << endl;
    dp.set(h[i], dp.prefix(h[i] - 1) + v[i]);
  }

  cout << *max_element(dp.v.begin(), dp.v.end());

  return cout << endl, 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

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

    ll ans1 = a[N-1];

    ll ans2;
    ll tmp = -1;
    for(int i=0; i<N; i++){
        ll dis = min(a[i], a[N-1]-a[i]);
        if(dis > tmp){
            tmp = dis;
            ans2 = a[i];
        }
    }

    cout << ans1 << " " << ans2 << endl;

}

Measured memory_bytes: 1532
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int d;
    int c[26];
    int s[365][26];
    cin >> d;
    rep(i, 26) cin >> c[i];
    rep(i, d) rep(j, 26) cin >> s[i][j];

    int last[26] = {};
    int t[365] = {1};
    rep(i, d) {
        int max_v = - INF;
        rep(j, 26) {
            int v = 0;
            v += s[i][j];
            rep(k, 26) {
                if (k == j) continue;
                v -= c[k] * (i + 1 - last[k]);
            }
            if (v > max_v) {
                max_v = v;
                t[i] = j + 1;
            }
        }
        last[t[i]-1] = i + 1;
    }

    rep(i, d) {
        cout << t[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

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

	if (s[1] == 'B') {
		printf("ARC\n");
		return 0;
	}
	printf("ABC\n");
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    int a,b;
    cin >> a >> b;
    if(a>=1&&a<=9&&b>=1&&b<=9){
        cout << a*b <<endl;
    }else {
        cout << -1 <<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll sum(int a) {
	if (a == 0)return 0;
	return a + sum(a - 1);
}

int main() {
	init();

	int N; cin >> N;
	map<string, int>s;
	rep(i, N) {
		string a; cin >> a;
		sort(all(a));
		s[a]++;
	}
	ll ans = 0;
	for (auto p : s) {
		ans += sum(p.second - 1);
	}
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD = 1000000000+7;
ll checkbit(ll n , ll k)
{
    return (n&(1LL<<k));
}
bool comp(string a, string b)
{
  if(a.size()>=b.size())return false;
  else return true;
}
ll BIGMOD(ll x, ll y) {
    if(y == 0)
        return 1;
    ll tmp = BIGMOD(x, y/2);
    if(y%2 == 0)
        return (tmp*tmp)%MOD;
    else
        return (((tmp*tmp)%MOD)*x)%MOD;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
      int n;
      cin>>n;
      ll a[n+2];
      for(ll i=0;i<n;i++)
      {
          cin>>a[i];
      }
      ll cnt=0;
      sort(a,a+n);
       for(ll i=0;i<n;i++)
      {
          for(ll j=i+1;j<n;j++)
          {
              for(ll k=j+1;k<n;k++)
              {
                  if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] )
                 {if((a[i]+a[j])>a[k])cnt++;}
              }
          }
      }
      cout<<cnt;


}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define INF 11000000;

int main(){
  ll K, N;
  cin >> K >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  ll longest = 0, start = 0;
  for (ll i = 0; i < N - 1; i++) {
      if (!i) {
          start = (A.at(0) + (K - A.at(N - 1)) > longest ? 0 : start);
          longest = max(longest, A.at(0) + (K - A.at(N - 1)));
      } else {
          start = (A.at(i + 1) - A.at(i) > longest ? i : start);
          longest = max(longest, A.at(i + 1) - A.at(i));
      }
  }
  cout << K - longest << endl;
  return 0;
}

Measured memory_bytes: 1792
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int r, g, b;
	cin >> r >> g >> b;
	if ((100 * r + 10 * g + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 1000010;
int cnt[maxn];
int n, g;
bool pwc() {
	for (int i = 2;i < maxn;++i) {
		int c = 0;
		for (int j = i;j < maxn;j += i)
			c += cnt[j];
		if (c > 1) return false;
	}
	return true;
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	while (n--) {
		int v;
		cin >> v;
		g = __gcd(g, v);
		++cnt[v];
	}
	if (pwc())
		puts("pairwise coprime");
	else if (g == 1)
		puts("setwise coprime");
	else puts("not coprime");
}



Measured memory_bytes: 7568
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

int
main(void)
{
        int N;
        char *stone;
        int result = INT_MAX;
        int black = 0;
        int white = 0;

        scanf("%d\n", &N);
        stone = malloc(N);
        memset(stone, 0, sizeof(char) * N);

        for (int i = 0; i < N; i++) {
                char c;
                scanf("%c", &c);

                if (c == '.')
                        white++;
                else
                        stone[i] = 1;
        }

        for (int i = 0; i <= N; i++) {
                if(white + black < result)
                        result = white + black;

                if (i == N)
                        break;

                if (stone[i] == 1)
                        black++;
                else
                        white--;
        }

        printf("%d", result);

        return 0;
}


Measured memory_bytes: 384
n,m = [int(i) for i in input().split()]

l =[]
r =[]
for i in range(m):
    l1, r1 = [int(i) for i in input().split()]
    l.append(l1)
    r.append(r1)

min = 1
max = n
for i in range(m):
    temp = l[i]
    min = min if min>temp else temp
    temp = r[i]
    max = max if max<temp else temp
    #print(min, max)

#print(min,max)
ans = max-min+1
if min>max:
    print(0)
else:
    print(ans)

Measured memory_bytes: 11120
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n+1)
dp[1]=0
dp[2]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i+1]=min(dp[i]+abs(h[i]-h[i-1]),dp[i-1]+abs(h[i]-h[i-2]))
print(dp[n])


Measured memory_bytes: 52336
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#define _USE_MATH_DEFINES
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    double theta = atan(2 * (a * a * b - x) * 1.0 / (a * a * a * 1.0));
    if (x * 1.0 < a * a * b * 1.0 / 2.0) {
        theta = atan((a * b * b * 1.0) / (2.0 * x));
    }
    cout << setprecision(8) << theta * 180 / M_PI << endl;
    return 0;
}


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

int a[4];
int c(int f, int o, int b){
    if(o==0) return f+b;
    else if(o==1) return f-b;
    else return f*b;
}

char conv(int o){
    if(o==0) return '+';
    else if(o==1) return '-';
    else return '*';
}

int make(int w, int x, int y, int z){
    int p=0;
    int i, j, k;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(c(c(w, i, x), k, c(y, j, z)) == 10){
                    p=1;
                    break;
                }else if(c(c(c(w, i, x), j, y), k, z) == 10){ 
                    p=2;
                    break;
                }
            }
            if(p) break;
        }
        if(p) break;
    }
    if(p){
        if(p==1){
            cout << "((" << w << ' ' << conv(i) << ' ' << x << ')';
            cout << ' ' << conv(k) << ' ';
            cout << '(' << y << ' ' << conv(j) << ' ' << z << "))";
            cout << endl;
            return 0;
        }
        else if(p==2){
            cout << "(((" << w << ' ' << conv(i) << ' ' << x << ')';
            cout << ' ' << conv(j) << ' ' << y << ')';
            cout << ' ' << conv(k) << ' ' << z << ')';
            cout << endl;
            return 0;
        }
    }
    return 1;
}

int solve(){
    for(int w=0;w<4;w++){
        for(int x=0;x<4;x++){
            if(x==w) continue;
            for(int y=0;y<4;y++){
                if(y==w || y==x) continue;
                for(int z=0;z<4;z++){
                    if(z==w || z==x || z==y) continue;
                    if(!make(a[w], a[x], a[y], a[z])) return 0;
                }
            }
        }
    }
    cout << 0 << endl;
}

int main(){
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    while(a[0]||a[1]||a[2]||a[3]){
        solve();
        cin >> a[0] >> a[1] >> a[2] >> a[3];
    }
}

Measured memory_bytes: 1164
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
ans=0

for i in range(n):
    b[a[i]-1]+=1
for i in range(n):
    ans+=(b[i]*(b[i]-1))//2
for i in range(n):
    print(ans-b[a[i]-1]+1)

Measured memory_bytes: 24996
#include <iostream>
#include <algorithm>
using namespace std;
#define NMAX 100
int N;
int A,B,C;
int topping[NMAX+1];
int main(){
	cin>>N;
	cin>>A>>B;
	cin>>C;
	for(int i=0;i<N;i++){
		cin>>topping[i];
	}
	sort(topping,topping+N);
	int kalory=C;
	int money=A;
	for(int i=N-1;i>=0;i--){
		if((kalory+topping[i])/(money+B)>=kalory/money){
			kalory+=topping[i];
			money+=B;
		}
		else break;
	}
	cout<<kalory/money<<endl;
	return 0;
}

Measured memory_bytes: 0
score = []
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
    score.append([m, f, r])

for mc, fc, rc in score:
    if mc == -1 or fc == -1:
        print('F')
    elif mc + fc >= 80:
        print('A')
    elif mc + fc >= 65:
        print('B')
    elif mc + fc >= 50 or rc >= 50:
        print('C')
    elif mc + fc >= 30:
        print('D')
    else:
        print('F')

Measured memory_bytes: 6724
//2020.3.28 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define lowbit(x) (x&-x)
#define gc getchar
#define kcz 998244353
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
// }
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
// char sr[1<<21],z[20];
// int C=-1,Z=0;
// inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
// inline void print(res x){
//    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
//    while(z[++Z]=x%10+48,x/=10);
//    while(sr[++C]=z[Z],--Z);
// }
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
//inline void swap(res &x,res &y) {
//    x^=y^=x^=y;
//}
//inline void add(res &x,const res &y){
//    x+=y,x>=kcz?x-=kcz:(x<0?x+=kcz:1);
//}
//inline int Add(const res &x,const res &y){
//    return x+y>=kcz?x+y-kcz:(x+y<0?x+y+kcz:x+y);
//}
//inline int mul(const res &x,const res &y){
//    return int(1LL*x*y%kcz);
//}
//inline int mul(const res &x,const res &y,const res &d){
//    return int(1LL*x*y/d%kcz);
//}
//inline int qpow(res x,res y){
//    res ret=1;
//    while(y){
//        if(y&1)ret=mul(ret,x);
//        x=mul(x,x),y>>=1;
//    }
//    return ret;
//}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    inline void MAIN(){
        res x=read();
        res ans=0;
        res t=x/500;
        ans=t*1000;
        x=x-t*500;
        t=x/5;
        ans+=t*5;
        printf("%d\n",ans);
    }
}
int main(){
//    srand(19260817);
    // freopen("tracing.in","r",stdin);
    // freopen("tracing.out","w",stdout);
    MAIN::MAIN();
//    Ot();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),A[]=new int[n];

		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());

		int stdIndex=partition(A,n,A[n-1]);

		for(int i=0;i<n-1;i++) {
			if(i==stdIndex) {
				System.out.print("["+A[i]+"] ");
			}
			else System.out.print(A[i]+" ");
		}
		if(n-1==stdIndex) {
			System.out.println("["+A[n-1]+"]");
		}
		else System.out.println(A[n-1]);
	}

	static int partition(int A[],int n,int std) {
		int i=0;
		do {
			while(i<n && A[i]<=std)i++;
			if(i==n)return i-1;

			int j=i;
			while(j<n && A[j]>std)j++;

			int tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;

			if(j==n-1)return i;
		}while(true);
	}

}



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

int main(){
  int a,b,c,d,e;
  cin >> a;
 b=a%2;
   c=a-b;
   c=c/10;
   d=c%2;
   e=c-d;
   e=c/10;
   e=e%2;
   
   
  cout << b+d+e << endl;
}

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    rep(i, 3){
        if(s[i] == '1'){
            s[i] += 8;
            continue;
        }
        if(s[i] == '9'){
            s[i] -= 8;
            continue;
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,D,A=map(int,input().split())
s=[tuple(map(int, input().split())) for i in range(N)]
s.sort()
d=2*D+1
t=0
p=0
l=[0]*N
a=0
for n,i in enumerate(s):
    while 1:
        if t<N and s[t][0]<i[0]+d:
            t+=1
        else:
            break
    h=i[1]-p*A
    if h>0:
        k=-(-h//A)
        a+=k
        p+=k
        l[t-1]+=k
    p-=l[n]
print(a)

Measured memory_bytes: 73692
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long K){
    if(K % 2 == 0) {cout<<-1<<endl; return;}
    ll X = 0;
    for(ll i = 1; i <= 2000000; i++){
        X = X*10 + 7;
        X = (X % K);
        if(X == 0) {cout << i << endl; return;}
    }
    cout << -1 << endl;
}
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3672
ab = input()
a = int(ab.split(' ')[0])
b = int(ab.split(' ')[1])

apb = a+b
amb = a-b
akb = a*b

if apb > amb:
    if apb > akb:
        print(apb)
    else:
        print(akb)
else:
    if amb > akb:
        print(amb)
    else:
        print(akb)

Measured memory_bytes: 3060
def BubbleSortChar(c,n):
    num = [int(s[1]) for s in c]
    for i in range(n):
        # n-1からiまでさかのぼっていく
        for j in range(n-1,i,-1):
            # 順番を入れ替える条件
            if num[j-1] > num[j]:
                # 数字のみの入れ替え
                tmp = num[j-1]
                num[j-1] = num[j]
                num[j] = tmp
                # 本物の入れ替え
                tmp = c[j-1]
                c[j-1] = c[j]
                c[j] = tmp
    return " ".join(c)

def SelectionSortChar(c,n):
    num = [int(s[1]) for s in c]
    for i in range(n):
        # print(c)
        minj = i
        for j in range(i,n):
            if num[j] < num[minj]:
                minj = j
        # origin
        tmp = c[minj]
        c[minj] = c[i]
        c[i] = tmp
        #num
        tmp = num[minj]
        num[minj] = num[i]
        num[i] = tmp

    return " ".join(c)




# バブルソートは常に安定ソート
# バブルソートと違う -> Not Stable
N = int(input())
S1 = input().split(" ")
S2 = [s for s in S1]
# Bubble Sort
C1 = BubbleSortChar(S1,N)
print(C1)
print("Stable")

# Selection Sort
C2 = SelectionSortChar(S2,N)
print(C2)
if C1==C2:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5612
n = int(input())
a = list(map(int, input().split()))

def kouyakusuu(x, y):
    if x < y:
        tmp = y
        y = x
        x = tmp
    elif x == y:
        return x

    while True:
        tmp1 = x // y
        tmp2 = x % y
        if tmp2 == 0:
            return y
        x = y
        y = tmp2

ans = a[0]
for i in range(1, len(a)):
    ans = kouyakusuu(ans, a[i])
print(ans)



Measured memory_bytes: 14252
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  string s; cin >>s;
  vector<int> lcp=atcoder::lcp_array(s,atcoder::suffix_array(s));
  li n=s.size();
  li ans=n*(n+1)/2;
  for(int x:lcp) ans-=x;
  print(ans);
}


Measured memory_bytes: 15604
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000

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



Measured memory_bytes: 256
using System;

namespace A___Ferris_Wheel
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var A = read[0];
            var B = read[1];

            int result;

            if(A < 6){
                result = 0;
            }else if (A <= 12){
                result = B/2;
            }else{
                result = B;
            }

            Console.WriteLine(result);
        }
    }
}


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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  cin >> N;
  cout << fixed << setprecision(20) << 2 * M_PI * N;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=309;
	int mod;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*ret%mod,y>>=1;
		}
		return ret;
	}

	int f[N][N],n,K,C[N][N],sum[N][N];
	int main(){
		n=read<int>(),K=read<int>(),mod=read<int>();
		C[0][0]=1;
		for(int i=1;i<=n+1;i++){
			C[i][0]=1;
			for(int j=1;j<=i;j++) C[i][j]=add(C[i-1][j],C[i-1][j-1]);
		}

		for(int j=0;j<=K;j++) f[j][1]=1;
		sum[K][1]=1;
		for(int j=K-1;~j;j--){
			for(int i=1;i<=n+1;i++)
				for(int k=1;k<i;k++)
					f[j][i]=(1LL*f[j][i-k]*C[i-2][k-1]%mod*sum[j+1][k]+f[j][i])%mod;
			for(int k=0;k<=n+1;k++) sum[j][k]=add(sum[j+1][k],f[j][k]);
		}
		printf("%d\n",f[0][n+1]);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 4848
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005][3],dp[100005][3];
int solve(int i,int x){
  if(i>=n)
    return 0;
  int ans=0;
  if(x==0)
    ans += max(a[i][1]+solve(i+1,1),a[i][2]+solve(i+1,2));
  else if(x==1)
    ans += max(a[i][0]+solve(i+1,0),a[i][2]+solve(i+1,2));
  else if(x==2)
    ans += max(a[i][1]+solve(i+1,1),a[i][0]+solve(i+1,0));
  return ans;
}
int main() {
  int k;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  dp[n-1][0]=a[n-1][0];
  dp[n-1][1]=a[n-1][1];
  dp[n-1][2]=a[n-1][2];
  for(int i=n-2;i>=0;i--){
    dp[i][0]=a[i][0]+max(dp[i+1][2],dp[i+1][1]);
    dp[i][1]=a[i][1]+max(dp[i+1][0],dp[i+1][2]);
    dp[i][2]=a[i][2]+max(dp[i+1][0],dp[i+1][1]);
  }
  cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));
}   

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

using namespace std;

#define Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define MOD 998244353
#define fi first
#define se second

const int NR = 2e5 + 10;

ifstream in ("date.in");
ofstream out ("date.out");

ll n,k,sol,i;
int main()	{
    Speed;
    cin >> n >> k;
    cout << min ( n % k , k - n% k ) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

const ll max_size = 200010;
ll H, W, A, B;
ll fact[max_size];
ll ifact[max_size];

void init(ll size) {
    fact[0] = 1;
    FOR(i, 1, size)
        fact[i] = i*fact[i-1]%MOD;
    ifact[size] = modpow(fact[size], MOD-2);
    DOWN(i, size-1, 0)
        ifact[i] = ifact[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll k) {
    ll res = fact[n]*ifact[k]%MOD;
    return res*ifact[n-k]%MOD;
}

int main() {
    cin >> H >> W >> A >> B;
    init(H+W);
    ll ans = 0;
    ll a = H-A-1;
    ll c = A-1;
    REP(i, W-B) {
        ll b = B+i;
        ll d = W-B-1-i;
        ll t = comb(a+b,a)*comb(c+d,c)%MOD;
        ans = (ans + t)%MOD;
    }
    cout << ans << endl;
	return 0;
}

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

long long P[] =
{
1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,134217727,268435455,536870911,1073741823,2147483647,4294967295,8589934591,17179869183,34359738367,68719476735,137438953471,274877906943,549755813887,1099511627775,2199023255551,4398046511103,8796093022207,17592186044415,35184372088831,70368744177663,140737488355327,281474976710655,562949953421311,1125899906842623,2251799813685247
};

long long H[] =
{
1,5,13,29,61,125,253,509,1021,2045,4093,8189,16381,32765,65533,131069,262141,524285,1048573,2097149,4194301,8388605,16777213,33554429,67108861,134217725,268435453,536870909,1073741821,2147483645,4294967293,8589934589,17179869181,34359738365,68719476733,137438953469,274877906941,549755813885,1099511627773,2199023255549,4398046511101,8796093022205,17592186044413,35184372088829,70368744177661,140737488355325,281474976710653,562949953421309,1125899906842621,2251799813685245,4503599627370493
};


long long Val( long long n, long long x )
{
int i;
long long a;
long long b;

	if( x >= H[ n ] ) return P[ n ];
	if( n == 0 ) return 0;

	a = H[ n - 1 ];
	b = P[ n - 1 ];
	if( x == a + 2 ) return b + 1;
	else if( x == a + 1 ) return b;
	else if( x <= a ) return Val( n - 1, x - 1 );
	else return b + 1 + Val( n - 1, x - a - 2 );

}


int main()
{
long long N;
long long X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> X;

	cout << Val( N, X ) << endl;

	return 0;
}


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

int main(void)
{
    int x;
    cin >> x;
    
    int ans = 0;
    if(400 <= x && x <= 599) ans = 8;
    if(600 <= x && x <= 799) ans = 7;
    if(800 <= x && x <= 999) ans = 6;
    if(1000 <= x && x <= 1199) ans = 5;
    if(1200 <= x && x <= 1399) ans = 4;
    if(1400 <= x && x <= 1599) ans = 3;
    if(1600 <= x && x <= 1799) ans = 2;
    if(1800 <= x && x <= 1999) ans = 1;
    
    cout << ans << endl;
}


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;
int xf[N] , yf[N];
int x[N] , y[N];
set<int> st[N];		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n,m,k;
		cin>>n>>m>>k;
		
		int maxx = 0,maxy = 0;
		for(int i=0,xx,yy;i<k;++i)
		{
			cin>>xx>>yy;
			st[yy].insert(xx);
			xf[xx]++;
			yf[yy]++;
			maxx = max(maxx,xf[xx]);
			maxy = max(maxy,yf[yy]);
			x[i] = xx;
			y[i] = yy;
		}
		set<int> tempx,tempy;
		for(int i=1;i<=n;++i)
		{
			if(xf[i]==maxx)
			tempx.insert(i);
		}
		for(int i=1;i<=m;++i)
		{
			if(yf[i]==maxy)
			{
				tempy.insert(i);
			}
		}
		int ans = maxx;
		for(auto it:tempy)
		{
			for(auto it1:tempx)
			{
				if(!st[it].count(it1))
				{
					cout<<ans+maxy;
					return 0;
				}
			}
		}
		cout<<ans+maxy-1;
		
		
    }
    return 0;
}


Measured memory_bytes: 69244
#include<stdio.h>

int main(void){

	int i,j,k,l,i2,j2;
	int a[101][101]={0};
	int r,c,d;

	scanf("%d %d ",&r,&c);
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
		}
	}

	for(k=0;k<r;k++){
		for(l=0;l<c;l++){
			printf("%d ",a[k][l]);
			a[k][c]=a[k][c]+a[k][l];
		}
		printf("%d\n",a[k][c]);
	}
	for(j2=0;j2<=c;j2++){
		for(i2=0;i2<r;i2++){
			d=d+a[i2][j2];
		}
		if(j2 != c){	
			printf("%d ",d);
			d=0;
		}
		else{
			printf("%d\n",d);
		}
	}
	return 0;
}

Measured memory_bytes: 648
#include <stdio.h>
int main(){
  int a,b,c,d,e,f,g,h;
char s[15];
scanf ("%s",s);
a=s[0]-'0';
b=s[1]-'0';
c=s[2]-'0';
 d=s[3]-'0';
 e=s[5]-'0';
 f=s[6]-'0';
 g=s[8]-'0';
 h=s[9]-'0';
if ((a*10000000)+(b*1000000)+(c*100000)+(d*10000)+(e*1000)+(f*100)+(g*10)+h < 20190431){
printf ("Heisei");
}
  else {
  printf ("TBD");
  }
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    if(1<=N&&N<2){printf("1");}
    else if(2<=N&&N<4){printf("2");}
    else if(4<=N&&N<8){printf("4");}
    else if(8<=N&&N<16){printf("8");}
    else if(16<=N&&N<32){printf("16");}
    else if(32<=N&&N<64){printf("32");}
    else if(64<=N&&N<=100){printf("64");}
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

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

bool compare_pair(pair<int, int> a, pair<int, int> b){
    if(a.first == b.first){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

int main(){
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, n){
        int tmp;
        cin >> tmp;
        a[i].first = tmp;
        a[i].second = i+1;
    }
    
    sort(a.begin(), a.end(), compare_pair);

    int hw[h*w];
    int p = 0;
    rep(i, n){
        rep(j, a[i].first)hw[p++]=a[i].second;
    }
    
    rep(i, h){
        bool s = i%2;
        rep(j, w){
            if(s==0)cout << hw[i*w + j] << " ";
            else cout << hw[i*w + w-j-1] << " ";
        }cout << endl;
    }

}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  string ans = "NO";

  for (int i = 0; i < B; i++) {
    if (A * i % B == C) ans = "YES";
  }

  cout << ans << "\n";
}

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

int main(){
    //棒の数
    int n; cin >> n;

    //棒の長さ
    vector<long long int> L(n);
    for(int i=0; i<n; i++) cin >> L[i];

    //answer
    long long int ans = 0;

    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(abs(L[j]-L[k]) < L[i] && L[i] < L[j] + L[k]){
                    if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if (n<1200) {
        cout<<"ABC"<<endl;
    } else if (n<2800) {
        cout<<"ARC"<<endl;
    } else {
        cout<<"AGC"<<endl;
    }
}


Measured memory_bytes: 256
a = [0] *9

a[0], a[1], a[2] = list(map(int, input().split()))
a[3], a[4], a[5] = list(map(int, input().split()))
a[6], a[7], a[8] = list(map(int, input().split()))

n = int(input())

b = [0]*9

for i in range(n):
    c = int(input())
    for j in range(9):
        if a[j] == c:
            b[j] = 1

if (b[0] == 1 and b[1] == 1 and b[2] == 1) or \
    (b[3] == 1 and b[4] == 1 and b[5] == 1) or \
    (b[6] == 1 and b[7] == 1 and b[8] == 1) or \
    (b[0] == 1 and b[3] == 1 and b[6] == 1) or \
    (b[1] == 1 and b[4] == 1 and b[7] == 1) or \
    (b[2] == 1 and b[5] == 1 and b[8] == 1) or \
    (b[0] == 1 and b[4] == 1 and b[8] == 1) or \
    (b[2] == 1 and b[4] == 1 and b[6] == 1):
    print('Yes')
else:
    print('No')

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int main() {
	int N, K, Q; cin >> N >> K >> Q;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = INT_MAX;
    for (int x: a) {
        vector<int> vs;
        vs.pb(-1);
        rep(i, N) if (a[i] < x) vs.pb(i);
        vs.pb(N);
        int lb = x - 1, ub = 1000000001;
        while (ub - lb > 1) {
            int mid = (lb + ub) / 2;
            int sum = 0;
            rep(j, vs.size() - 1) {
                int l = vs[j] + 1, r = vs[j + 1];
                if (r - l < K) continue;
                int cnt = 0;
                for (int i = l; i < r; i++) if (a[i] <= mid) cnt++;
                sum += min(r - l - K + 1, cnt);
            }
            if (sum >= Q) ub = mid;
            else lb = mid;
        }
        if (ub < 1000000001) ans = min(ans, ub - x);
    }
    cout << ans << endl;
}


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

D=[list(map(int,input().split())) for i in range(C)]
grid=[list(map(int,input().split())) for i in range(N)]

a=[[0]*C for i in range(3)]


for i in range(N):
    for j in range(N):
        a[(i+j)%3][grid[i][j]-1]+=1

b=[[0]*C for i in range(3)]
for i in range(3):
    for j in range(C):
        b[i][j]=[ sum([ D[k][j] * a[i][k] for k in range(C)]), j]

b=[ sorted(b[i]) for i in range(3)]

ans=10**10
for i in range(3):
    for j in range(3):
        for k in range(3):
            if b[0][i][1]!=b[1][j][1] and b[1][j][1]!=b[2][k][1] and b[2][k][1]!=b[0][i][1]:
                ans=min(ans,b[0][i][0]+b[1][j][0]+b[2][k][0])

print(ans)

Measured memory_bytes: 5620
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int a,b,c,d,n;
  scanf("%d %d %d %d",&a,&b,&c,&n);
  d=MAX(a,MAX(b,c));
  a=a+b+c-d;
  while(n--)d*=2;
  printf("%d\n",a+d);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if(abs(a-b)%2==0){
    cout<<abs(a-b)/2<<endl;
  }else{
    cout<<min(abs(a-1)+1+abs(abs(a-b)-1)/2,abs(n-b)+1+abs(abs(a-b)-1)/2)<<endl;
  }
  return 0;
}


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

int main(){

  int n;
  cin >> n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin >> arr[i] ;
  
  if(n<2)
    return 0;
  
  int a=0;
  int b=abs(arr[1]-arr[0]);
  
  for(int i=2;i<n;i++){
    int val=min(b+abs(arr[i]-arr[i-1]),a+abs(arr[i]-arr[i-2]));
    a=b;
    b=val;
  }
  
  cout<<b;
  
  return 0;
}


Measured memory_bytes: 4012