akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

const int MAX_ROW = 635; // to be set appropriately
const int MAX_COL = 635; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) { return val[i]; }
};

int GaussJordan(BitMatrix & A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> & res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

void solve(int h, int w, int d)
{
	int n = h * w;
	vector<int> bits(n);
	FOR_LT(i, 0, n) {
        cin >> bits[i];
	}

    BitMatrix A(n, n);
    FOR_LT(i, 0, n) {
        FOR_LT(j, 0, n) {
            int x0 = i % w;
            int y0 = i / w;
            int x1 = j % w;
            int y1 = j / w;
            if (abs(x0 - x1) + abs(y0 - y1) == d || i == j) {
                A[i][j] = 1;
            }
        }
    }

    vector<int> res(n);
    int r = linear_equation(A, bits, res);
    if (r == -1) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	while (true) {
		int w, h, d; cin >> w >> h >> d;
		if (w + h + d == 0) break;

		solve(h, w, d);
	}

	return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll m[4];
    m[0] = a * c;
    m[1] = a * d;
    m[2] = b * c;
    m[3] = b * d;
    sort(m, m + 4);
    cout << m[3];
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  
  int j, k = 0;
  
  while(j < n){
    if(v.at(j) != j + 1){
      k++;
    }
    j++;
  }
  
  if((k == 0) || (k == 2)){
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
}

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

using namespace std;
int a[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	long long ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i]/2;
		a[i]=a[i]%2;
		if(a[i]&&a[i+1]!=0){
			a[i]--;
			a[i+1]--;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string S;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  rep(i, (int)S.length()-8) cout << S[i];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s[3] [3],n;
		int b[10];
	for(int i=0;i<3;i++) {
		for(int j=0;j<3;j++){
			cin>>s[i] [j];
		}
	}
	cin>>n;
	for(int a=0;a<n;a++) cin>>b[a];
	for(int i=0;i<3;i++) {
		for(int j=0;j<3;j++){
			for(int a=0;a<n;a++){
				if(s[i] [j]==b[a]) s[i] [j]=0;
			}
		}
	}
	if(s[0] [0]==0&&s[0] [1]==0&&s[0] [2]==0) cout<<"Yes";
	else if(s[1] [0]==0&&s[1] [1]==0&&s[1] [2]==0) cout<<"Yes";
	else if(s[2] [0]==0&&s[2] [1]==0&&s[2] [2]==0) cout<<"Yes";
	else if(s[0] [0]==0&&s[1] [0]==0&&s[2] [0]==0) cout<<"Yes";
	else if(s[0] [1]==0&&s[1] [1]==0&&s[2] [1]==0) cout<<"Yes";
	else if(s[0] [2]==0&&s[1] [2]==0&&s[2] [2]==0) cout<<"Yes";
	else if(s[0] [2]==0&&s[1] [1]==0&&s[3] [0]==0) cout<<"Yes";
	else if(s[0] [0]==0&&s[1] [1]==0&&s[2] [2]==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int count;
  
  rep(i, N) {
    if(A[i]%2!=0) count++;
  }
  if(count%2==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for ia in range(A+1):
    for ib in range(B+1):
        for ic in range(C+1):
            if 500*ia+100*ib+50*ic == X:
                ans +=1
print(ans)


Measured memory_bytes: 9120
#include<cstdio>
#include<algorithm>
using std::min;
using std::max;
using std::distance;
using std::lower_bound;
using std::reverse;
using std::sort;
#define reg register
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg int res=0;
	while(ch<'0'||'9'<ch)f|=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')res=10*res+ch-'0',ch=getchar();
	return f?-res:res;
}

const int MAXN=300000+5;
const int MAXA=MAXN;

int n,Max;
int a[MAXN];
int T[MAXA];
int C[MAXA];
int C2[MAXA];

int main(void){
	reg int i,j;
	n=read();
	for(i=0;i<n;++i)
		a[i]=read();
	sort(a,a+n);
	for(i=0;i<n;++i){
		++T[a[i]-1];
		Max=max(Max,T[a[i]-1]);
	}
	for(i=0;i<n;++i)
		for(j=1;j<=T[i];++j)
			++C[j-1];
	for(i=1;i<Max;++i)
		C[i]+=C[i-1];
	for(i=1;i<=n;++i)
		C2[i-1]=C[min((int)i,Max)-1]/i;
	reverse(C2,C2+n);
	for(i=1;i<=n;++i)
		printf("%d\n",(int)(C2+n-lower_bound(C2,C2+n,(int)i)));
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int s, w;
    cin >> s >> w;
    string ans = "safe";
    if (w >= s) ans = "unsafe";
    cout << ans << endl;
}

Measured memory_bytes: 3628
from collections import deque

S=input()
Q=int(input())

t=deque(S)
flag_r=0
for _ in range(Q):
    Query=input().split()
    if int(Query[0])==1:
        flag_r=(flag_r+1)%2
    elif int(Query[1])==1+flag_r:
        t.appendleft(Query[2])
    else:
        t.append(Query[2])
result=''.join(t)
if flag_r:# reverseは最後にやる
    result=result[::-1]
print(result)

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

int main() {
	
	int k, s; cin >> k >> s;
	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

x,n,*p = map(int,read().split())

p = set(p)

v = x
for i in range(1000):
    if v+i not in p:
        break
v = v+i

w = x
for i in range(1000):
    if w-i not in p:
        break
w = w-i

if abs(v-x) < abs(w-x):
    print(v)
else:
    print(w)



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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int n,K;
int a[300000];

int C(int d){
	ll sum=0;
	rep(i,n){
		sum+=max(0,(a[i]+d-1)/d-1);
	}
	return sum<=K;
}

int main(){
	cin>>n>>K;
	rep(i,n)scanf("%d",&a[i]);
	int ok=1e9,ng=0;
	while(ok-ng>1){
		int t=(ok+ng)/2;
		if(C(t))ok=t;
		else ng=t;
	}
	cout<<ok<<endl;
}

Measured memory_bytes: 4440
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/24
Solved on 2019/3/
@author: shinjisu
"""


# ABC 056 C - Go Home
def getInt(): return int(input())
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替
class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    X = getInt()
    d.dmp((X), 'X')
    sm = 0
    for i in range(1, 10**9+1):
        sm += i
        if X <= sm:
            break
    return i


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
// it is a tree, so no cycles
// I think basically from the root node 
vector<vl> adj;
void solve()
{
    ll n;
    cin>>n;
    adj.resize(n);
    vector<pl> num;
    forr(i, n-1)
    {
    	ll a, b;
    	cin>>a>>b;
    	--a, --b;
    	adj[a].pb(b);
    	adj[b].pb(a);
    	num.pb({a, b});
    }
    ll k=0;
    map<pl, ll> fish;
    vl cs(n, 0);
    queue<ll> q;
    vector<bool> visit(n, false);
    q.push(0);
    visit[0]=true;
    vl be_careful(n, 0);
    while(!q.empty())
    {
    	ll ele=q.front();
    	//cout<<ele<<endl;
    	q.pop();
    	k=max(k, (ll)adj[ele].size());
    	ll cur=1;
    	for(auto x:adj[ele])
    	{
    		if(visit[x])
    			continue;
    		visit[x]=true;
    		if(cur==be_careful[ele])
    			cur++;
    		be_careful[x]=cur;
    		fish[{ele, x}]=cur, fish[{x, ele}]=cur++;
    		q.push(x);
    	}
    }
    cout<<k<<endl;
    for(auto x:num)
    	cout<<fish[x]<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 24872
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int):
    if (A-2) % 14 < (B-2) % 14:
        print("Bob")
    elif (A-2) % 14 > (B-2) % 14:
        print("Alice")
    else:
        print("Draw")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define ll    long long
#define pb    push_back
#define mk    make_pair
#define f     first
#define s     second
#define pii   pair<int, int>
#define fuck  return 0;

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


int main()
{
   string a[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"} ;
   int sum = 0, day[12]={31,29,31,30,31,30,31,31,30,31,30,31};

   int m, d;

   while((cin >>m >>d) && (m!=0 && d!=0))
   {
       for(int i=0; i<=m-2; i++) sum+= day[i];


       sum += d;
       int ans = sum % 7;
       cout <<a[ans] << endl;
     sum=0;
   }
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	set<string>ch;
	for(ll i=0;i<n;i++){
		string now;
		cin>>now;
		ch.insert(now);
	}
	cout << ch.size();
	// your code goes here
	return 0;
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int n;

    std::cin >> n;

    std::vector<int> a(n);

    int sum = 0;

    rep(i, n)
    {
        std::cin >>
            a[i];
        sum = sum ^ a[i];
    }

    rep(i, n)
    {
        std::cout << (sum ^ a[i]) << ' ';
    }
    std::cout << std::endl;

    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(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) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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

template <typename T> void max_self(T& a,T b)
{
  a = max(a,b);
}

vector<int> dp;
vector<int> vis;

int dfs(int id,vector<vector<int>>& adj)
{
  //cout<<" called "<<id<<endl;
    if(vis[id])
  {
    return dp[id];
  }

  for(int i=0;i<adj[id].size();i++)
  {
    dp[id] = max(dp[id],dfs(adj[id][i],adj)+1);
  }
  vis[id] = true;
  return dp[id];
}

int main() 
{

// #ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
// #endif

int n,e;
cin>>n>>e;
vector<vector<int>> adj(n);

for(int i=0;i<e;i++)
{
  int a,b;
  cin>>a>>b;
  //cout<<a<<" "<<b<<endl;
  adj[a-1].push_back(b-1);
}
//cout<<" adj done"<<endl;
dp.assign(n,0);
vis.assign(n,false);

for(int i=0;i<n;i++)
{
  if(!vis[i])
  {
    dfs(i,adj);
  }
}

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

}


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

int n , m , a , b , c , p , d[2501] , us[2501] , from_st[2501];
vector <pair <pair <int , int> , int> > ed;
vector <int> v[2501];
bool can = false;

void _dfs(int x){
    from_st[x] = 1;
    for (auto u: v[x])
        if (!from_st[u]) _dfs(u);
}

void dfs(int x){
    if (x == n - 1) can = true;
    us[x] = 1;
    for (auto u: v[x])
        if (!us[u]) dfs(u);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> p;
    for (int i = 0; i < m; i++){
        cin >> a >> b >> c;
        c -= p; a--; b--;
        ed.push_back({{a , b} , -c});
        v[a].push_back(b);
    }
    for (int i = 1; i < n; i++) d[i] = inf;
    vector <int> was;
    for (int i = 0; i < n; i++){
        was.clear();
        for (int j = 0; j < m; j++){
            if (d[ed[j].first.first] != inf &&
                d[ed[j].first.first] + ed[j].second < d[ed[j].first.second]){
                    was.push_back(ed[j].first.second);
                    d[ed[j].first.second] = d[ed[j].first.first] + ed[j].second;
                }
        }
    }
    _dfs(0);
    for (auto u: was) if (from_st[u] && !us[u]) dfs(u);
    if (can || d[n - 1] == inf){
        cout << -1;
        return 0;
    }
    cout << max(0 , -d[n - 1]);
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	vll A(N), B(N);
	priority_queue<pair<ll, ll>> pq;

	rep(i, 0, N) {
		std::cin >> A[i] >> B[i];
		pq.push({ A[i] + B[i],i });
	}

	
	ll ans = 0;
	bool isTakahashisTurn = true;

	while (!pq.empty()) {
		if (isTakahashisTurn) {
			ans += A[pq.top().second];
		}
		else {
			ans -= B[pq.top().second];
		}
		isTakahashisTurn = !isTakahashisTurn;
		pq.pop();
	}

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3956
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  get(N);
  vector<int> mxs(N, -1);
  int ans = 0;
  FOR(i, N) {
    int A;
    get(A);
    int j = 0;
    while (mxs[j] >= A)
      ++j;
    if (mxs[j] < 0)
      ans++;
    mxs[j] = A;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;



main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,x,y;
cin>>n>>x>>y;
vector<vector<ll> > d(n+1,vector<ll> (n+1,(ll)0));
vector<ll> f(n,0);
for(ll i=1;i<=n;i++)
{
	for(ll j=i+1;j<=n;j++)
	{
		d[i][j]=min(j-i,min(abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1));
		f[d[i][j]]++;
	}
} 
for(ll i=1;i<n;i++)
cout<<f[i]<<el;
}

Measured memory_bytes: 31616
s = input()
q = int(input())
h, t = [], []
p = 0
for i in range(q):
	c = input().split()
	if c[0] == '1':
		h, t = t, h
		p = 1 - p
	else:
		if c[1] == '1':
			h.append(c[2])
		else:
			t.append(c[2])
if p == 1:
	s = s[::-1]
print("".join(h[::-1]) + s + "".join(t))

Measured memory_bytes: 6252
object Q20200817 {
  case class Answer(
                     numberOfLikeFood: Int,
                     likeFoodIndexes: Seq[Int],
              )


  class AllHumanLikeKindFoodCount(val value: Int) extends AnyVal {
    override def toString: String = value.toString
  }

  object AllHumanLikeKindFoodCount {
    def apply(numberOfKindOfFood: Int, answers: Seq[Answer]): AllHumanLikeKindFoodCount = {
      new AllHumanLikeKindFoodCount((1 to numberOfKindOfFood)
        .count { foodIndex =>
          answers.forall(_.likeFoodIndexes.contains(foodIndex))
        })
    }
  }
}

object Main extends App {
  import Q20200817._

  import io.StdIn._
  val Array(numberOfHuman, numberOfKindOfFood) = readLine().split(' ').map(_.toInt)
  val stringToAnswer = (line: String) => {
    val numbers = line.split(' ')
    Answer(numbers.head.toInt, numbers.tail.map(_.toInt))
  }

  val inputs = (0 until numberOfHuman).map(_ => readLine()).map(stringToAnswer)
  println(AllHumanLikeKindFoodCount(numberOfKindOfFood, inputs))
}

Measured memory_bytes: 55020
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int a[200005];
int ans[200005];
vector<int> g[200005];
multiset<pii> cur;
multiset<pii>::iterator its;
void dfs(int u, int p){
    its = cur.lower_bound(pii(a[u], -1));
 
    pii x = pii(-1, -1);
    if(its != cur.end()){
        x = *its;
        cur.erase(its);
    }
    ans[u] = cur.size()+1;
    cur.insert(pii(a[u], ans[u]));
 
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(v == p) continue;
        dfs(v, u);
    }
 
    if(cur.find(pii(a[u], ans[u])) != cur.end()) cur.erase(cur.find(pii(a[u], ans[u])));
    if(x.first != -1) cur.insert(x);
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    for(int i=1;i<=n-1;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs(1, 0);
    for(int i=1;i<=n;i++){
        printf("%d\n", ans[i]);
    }   
}

Measured memory_bytes: 39180
#include <iostream>
//#include <algorithm>
//#include <cmath>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int r, d;
    int x;
    cin >> r >> d >> x;

    for(int i=0; i<10; i++){
        x = r*x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

int main(){
	ll n, k; cin >> n >> k;
	vector<ll> a(n); REP(i,n) cin >> a.at(i);
	ll ans = 100000000000;
	REP(i,(1<<n)){
		ll maxh = 0; ll cntcolor = 0; ll cnt = 0;
		REP(j,n){
			if ((i>>j)%2==1){
				cntcolor++;
				if (a.at(j)>maxh){
					maxh = a.at(j);
				}
				else {
					maxh++;
					cnt += maxh-a.at(j);
				}
			}
			else{
				if (a.at(j)>maxh) maxh = a.at(j);
			}
		}
		if (cntcolor==k){
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))

for i in range(1, N):
    print(' '.join((str(x) for x in A)))
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
print(' '.join((str(x) for x in A)))

Measured memory_bytes: 6724
import sys
sys.setrecursionlimit(10**6)
# 解法 累積和とdfsを使うと探索が減ってなんかうまくいく．
N,Q = map(int,input().split())
E=[[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    E[a-1].append(b)
    E[b-1].append(a)
dic = {}
for _ in range(Q):
    p,x = map(int,input().split())
    if not p-1 in dic:
        dic[p-1] = x
        continue
    dic[p-1] += x

res = [0 for _ in range(N)]
def dfs(p,s,ans):
    global res
    # 終わり条件　最後まで行ったら，つまりE[k] = []になったら.
    # 再帰 累積和を計算して，自分がつながっているノードに接続している
    if s-1 in dic:
        ans += dic[s-1]

    res[s-1] = str(ans)
    if E[s-1] == [p]:
        return
    for e in E[s-1]:
        if e == p:
            continue
        dfs(s,e,ans)
dfs(1,1,0)
print(' '.join(res))





Measured memory_bytes: 267560
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
def iter_value_and_unit():
    for line in lines:
        value, unit = line.split(" ")
        value = float(value)
        if unit == "BTC":
            yield 380000.0 * value
        else:
            yield value

print(sum(iter_value_and_unit()))


Measured memory_bytes: 9164
IDENTIFICATION DIVISION.
PROGRAM-ID. 158B.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(100).
01 N          PIC 9(19).
01 A          PIC 9(18).
01 B          PIC 9(18).
01 SUM-A      PIC 9(19).
01 SUM-B      PIC 9(19).
01 CNT        PIC 9(18).
01 BK-CNT     PIC 9(19).

01 OUT-CNT    PIC Z(18)9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO N A B.
    
  EVALUATE TRUE
    WHEN A = 0
      MOVE 0 TO OUT-CNT
    WHEN B = 0
      MOVE N TO OUT-CNT
    WHEN OTHER
      COMPUTE CNT = N / (A + B) 
      EVALUATE TRUE
        WHEN (N - (A + B) * CNT = 0)
          COMPUTE OUT-CNT = A * CNT
        WHEN (N - (A + B) * CNT >= A)
          COMPUTE OUT-CNT = A * CNT + A
        WHEN OTHER
          COMPUTE OUT-CNT = N - B * CNT
      END-EVALUATE
  END-EVALUATE.

  DISPLAY OUT-CNT.
 
MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 764
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	h,w,n = readline() |> split |> parseMap
	y,x = readline() |> split |> parseMap
	s = chomp(readline())
	t = chomp(readline())
	flg = 0
	pl = x
	pr = x
	pu = y
	pd = y
	for i in 1:n
		if s[i] == 'L'
			pl -= 1
		elseif s[i] == 'R'
			pr += 1
		elseif s[i] == 'U'
			pu -=1
		else
			pd += 1
		end
		if pl<1||pr>w||pu<1||pd>h
			flg = 1
			break
		else
			if t[i] == 'L'
				pr = max(pr-1,1)
			elseif t[i] == 'R'
				pl = min(pl+1,w)
			elseif t[i] == 'U'
				pd = max(pd-1,1)
			else
				pu = min(pu+1,h)
			end
		end
	end
	println(flg==1?"NO":"YES")
end
main()


Measured memory_bytes: 168228
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vector<vector<ll>> a(N, vector<ll>(3));
    Rep (i, N) Rep (j, 3) cin >> a[i][j];

    vector<vector<ll>> dp(N+1, vector<ll>(3, 0));
    Rep (i, N) {
        Rep (j, 3) {
            Rep (k, 3) {
                if (j != k) {
                    chmax(dp[i+1][j], dp[i][k] + a[i][j]);
                }
            }
        }
    }

    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << "\n";
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, sum = 0,x,y;
    char c;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<k;i++){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

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

int A[100001];

int main(void) {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	long long Bm = -A[1], Bp = A[1];

	for (int i = 2; i < N; i++) {
		long long TmpBm = Bm, TmpBp = Bp;
		// 反転する
		Bm = max(TmpBm+A[i], TmpBp-A[i]);
		// 反転しない
		Bp = max(TmpBm-A[i], TmpBp+A[i]);
	}
	// 最後のAnを足す
	Bm += -A[N];
	Bp += +A[N];
	cout << max(Bm, Bp) << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define F first
#define S second
const int N = 9;
vector<pii> v;
int n, m;
string S[9];
int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++) cin >> S[i];
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) if(S[i][j]=='#') v.push_back({i, j});
    for(pii x:v) for(pii y:v) if(x.F>y.F && x.S<y.S) { cout << "Impossible"; return(0); }
    cout << "Possible";
}

Measured memory_bytes: 256
import itertools
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]
ans=-10**9
for i in list(itertools.product(range(2),repeat=10)):
  if sum(i)==0:
    continue
  bns=0
  for j in range(N):
    b=0
    for k in range(10):
      if i[k]*F[j][k]==1:
        b+=1
    bns+=P[j][b]
  ans=max(ans,bns)
print(ans)

Measured memory_bytes: 9336
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();

        int K = nextInt();

        int count = 0;
        for(int i=0; i<N; i++){
            if(nextInt() >= K){
                count++;
            }
        }

        println(count);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

const int N = 2010;

std::vector <int> e[N];
int dis[N];

void dfs(int u, int fa){
	for (auto v : e[u]){
		if (v == fa) continue;
		dis[v] = dis[u] + 1;
		dfs(v, u);
	}
}

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0, u, v; i < n - 1; ++ i){
		scanf("%d%d", &u, &v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	int min = INT_MAX;
	if (k & 1){
		for (int i = 1; i <= n; ++ i){
			for (auto u : e[i]){
				memset(dis, 0, sizeof(dis));
				dfs(u, i);
				dfs(i, u);
				int cnt = 0;
				for (int j = 1; j <= n; ++ j){
					cnt += dis[j] > k - 1 >> 1;
				}
				min = std::min(min, cnt);
			}
		}
	}
	else{
		for (int i = 1; i <= n; ++ i){
			memset(dis, 0, sizeof(dis));
			dfs(i, 0);
			int cnt = 0;
			for (int j = 1; j <= n; ++ j){
				cnt += dis[j] > k >> 1;
			}
			min = std::min(min, cnt);
		}
	}
	printf("%d\n", min);
	return 0;
}

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

using namespace std;

int main() {
	int n,x;
	cin >> n >> x;
	vector<int> arr;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		arr.push_back(a);
	}
	sort(arr.begin(),arr.end());
	int ans = 0;
	for(int a : arr) {
		x-=a;
		if(x>=0) ans++;
		if(x<=0) break;
	}
	if(x>0) ans--;
	if(ans<0) ans=0;
	cout << ans << endl;
}


Measured memory_bytes: 256
L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(L[k-1])

Measured memory_bytes: 3316
def main():
    """
    Aの空でない連続する部分列であって、
    その総和が 0になるものの個数を求めてください。
    ただし、ここで数えるのは 部分列の取り出し方 であることに注意してください。
    つまり、ある2つの部分列が列として同じでも、
    取り出した位置が異なるならば、それらは別々に数えるものとします。

    制約
        1 ≤ N ≤ 2×10^5
        −10^9 ≤ Ai ≤ 10^9
    """
    N = int(input())
    *A, = map(int, input().split())

    f2(N, A)


def f1(N, A):
    """
    愚直にやる場合: O(N^2),TLE
    0-0,0-1,0-2,...0-N_1
        1-1,1-2,...1-N_1
                ...
                   N_2-N_1
                   N_1-N_1
    """
    ans = 0
    for i in range(N):
        s = 0
        for j in range(i, N):
            s += A[j]
            print(i, j, s, sep="\t")
            if s == 0:
                ans += 1

    print(ans)


def f2(N, A):
    """
    累積和をとるだけではO(N^2)
    i=0,ループ
    i=1,ループs[i]-A[0]

    i=0,s[i]-0    ->          0の個数
    i=1,s[i]-s[0] -> -A[0]     の個数
    i=2,s[i]-s[1] -> -A[0]+A[1]の個数

    i=0
        A:0,1,-1
        s:0,1,0
    i=1
        A:1,-1,1
        s0:1,0,1
        s1:x,-1,0

        →自身が含まれるので-1してカウント
        →本来は、ずらしながらカウントするので消費したら-1
        Nループだけ,O(N)
    """
    s = [None] * N
    s[0] = A[0]
    for i in range(1, N):
        s[i] = s[i-1] + A[i]

    from collections import Counter
    c = Counter(s)
    ans = c[0]
    for i in range(1, N):
        ans += c[s[i]] - 1
        c[s[i]] -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41696
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
string S;
int main() {
	int cnt=0,n,type=0;
	cin>>n>>S;
	for(int i=0;i<S.length();i++) {
		if(S[i]=='A')
			type=1;
		else if(S[i]=='B' && type==1)
			type=2;
		else if(S[i]=='C' && type==2)
			type=0, cnt++;
		else
			type=0;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

vector<int> f(45);

int fib(int n)
{
	if (n <= 1)
	{
		f.at(n) = 1;
		return 1;
	}
	else if (f.at(n) > 0)
	{
		return f.at(n);
	}
	else
	{
		f.at(n) = fib(n - 1) + fib(n - 2);
		return f.at(n);
	}
}

int main()
{
	int n;
	cin >> n;
	cout << fib(n) << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define pip pair<ll,pii>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M           100011
#define N           20
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}



int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    vii a,b,c;
    for(i=0;i<n;++i)cin>>x,a.pb(x-1);
    for(i=0;i<n;++i)cin>>x,b.pb(x);
    for(i=0;i<n-1;++i)cin>>x,c.pb(x);
    p=0;
    for(i=0;i<n;++i){
    	p+=b[i];

    	if(i+1>=0&&a[i]+1==a[i+1]){

    		p+=c[a[i]];
    	}
    }
    cout<<p<<"\n";










}



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

int main()
{
	int n;
	double x1,y1,x2,y2,x3,y3;
	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double a1 = 2*(x2 - x1);
		double b1 = 2*(y2 - y1);
		double c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;

		double a2 = 2*(x3 -x1);
		double b2 = 2*(y3 - y1);
		double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;

		double x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
		double y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);

		double r_2 = (x1 - x)*(x1 - x) + (y1 - y)*(y1 - y);
		double r = sqrt(r_2);

		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

const int INF = 1e9;

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    int ans[h][w] = {};
    for (int cx = 0; cx < h; cx++) {
        for (int cy = 0; cy < w; cy++) {
            if (s[cx][cy] == '#') {
                ans[cx][cy] = INF;
                continue;
            }
            for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
                    int nx = cx + dx, ny = cy + dy;
                    if ((0 <= nx && nx < h) && (0 <= ny && ny < w) && s[nx][ny] == '#') {
                        ans[cx][cy]++;
                    }
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ans[i][j] != INF) cout << ans[i][j];
            else cout << '#';
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;
deque<char> deq,ans;
int k;
void ins(){
	while(deq.size()>=2){
		int x = deq.size();
		if(deq[x-2]=='B' && deq[x-1]=='A'){
			ans.push_back('B'); ans.push_back('A');
			deq.pop_back(); deq.pop_back();
		}else{
			break;
		}
	}
}

void simple(){
	int i;
	k--;
	for(i=0;i<deq.size();i++){
		if(i==0 && deq[0]=='A'){
			deq[0] = 'B';
			break;
		}
		if(i!=deq.size() - 1){
			if(deq[i]=='B' && deq[i+1]=='B') deq[i] = 'A';
			if(deq[i]=='A' && deq[i+1]=='A') deq[i] = 'B';
		}else{
			deq[i] = 'A';
		}
	}
	ins();
}

void solve(){
	if(deq[0]=='A'){
		deq[0] = 'B';
		k--;
	}else{
		if(deq[1]=='B') k -= 3;
		else k -= 2;
		deq.pop_front(); deq.pop_front();
		ans.push_back('B'); ans.push_back('A');
	}
	ins();
}

int main(){
	int i,n;
	cin >> n >> k;
	for(i=0;i<n;i++){
		char c; cin >> c;
		deq.push_back(c);
	}
	for(i=0;i<2;i++){
		if(deq.back()=='B') simple();
	}
	while(deq.size()>=2 && k>0){
		if(k>=3) solve();
		else simple();
	}
	if(k==0){
		for(i=0;i<deq.size();i++){
			cout << deq[i];
		}
		for(i=0;i<ans.size();i++){
			cout << ans[i];
		}
	}else{
		if(deq.size()){
			if(k&1){
				if(deq[0]=='A') cout << 'B';
				else cout << 'A';
			}else{
				cout << deq[0];
			}
		}
		for(i=0;i<ans.size();i++){
			cout << ans[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int x[9],i,f;
	while(1){
		scanf("%d",&x[0]);
		if(x[0]==0)break;
		for(i=1;i<5;i++)
			scanf("%d",&x[i]);
		f=0;
		for(i=0;i<5;i++){
			if(x[i]==1 && f%10==0)f+=1;
			if(x[i]==2 && (f%100-f%10)==0)f+=10;
			if(x[i]==3 && (f%1000-f%100)==0)f+=100;
		}
		//printf("%d\n",f);
		if(f==111)for(i=0;i<5;i++)printf("3\n");
		else if(f==1 || f==10 || f==100)
			for(i=0;i<5;i++)printf("3\n");
		else{
			if(f==11){
				for(i=0;i<5;i++)printf("%d\n",x[i]);
			}else if(f==110){
				for(i=0;i<5;i++)printf("%d\n",x[i]-1);
			}else{
				for(i=0;i<5;i++)printf("%d\n",x[i]%3+1);
			}
		}
	}
	return 0;
}

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

int d,ans[365],c[26],s[365][26],last[26],tlast[26],S[365][26];
const int INF=1e9;

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

void FIN(int a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]<<"\n";
    fout.close();
    return;
  }
  REP(i,d)cout<<ans[i]<<"\n";
  return;
}

int score(){
  int res=0;
  memset(tlast,-1,sizeof(tlast));
  REP(day,d){
    res+=S[day][ans[day]-1];
    tlast[ans[day]-1]=day;
    REP(i,26)res-=c[i]*(day-tlast[i]);
  }
  return res;
}

signed main(){
  memset(last,-1,sizeof(last));
  cin>>d;
  REP(i,26)cin>>c[i];
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(i,d)REP(j,26)S[i][j]=s[i][j];
  REP(j,26){
    int now=-INF;
    for(int i=364;i>=0;i--){
      if(now>15000)s[i][j]-=(now-15000);
      if(now<s[i][j])now=s[i][j];
      now-=c[j];
    }
  }
  REP(day,d){
    vector<int> minus(26);
    REP(j,26)minus[j]=c[j]*(day-last[j]);
    int A=-INF,idx=0;
    REP(j,26){
      int tmp=s[day][j]+minus[j];
      if(A<tmp)A=tmp,idx=j;
    }
    ans[day]=idx+1;
    last[idx]=day;
  }
  /*
  REP(_,480){
    int day1=rand()%365,day2=rand()%365;
    if(day1==day2)day2++;if(day2==365)day2=0;
    int Sc=-INF,now1=ans[day1],now2=ans[day2];
    REP(i,26){
      REP(j,26){
        ans[day1]=i+1;
        ans[day2]=j+1;
        int R=score();
        if(Sc<R)Sc=R,now1=i+1,now2=j+1;
        else ans[day1]=now1,ans[day2]=now2;
      }
    }
  }
  */
  /*
  REP(_,1000){
    int day1=_%360;
    int now[5],Sc=-INF;
    vector<int> v(5);
    REP(i,5)v[i]=ans[day1+i];
    sort(v.begin(),v.end());
    do{
      REP(i,5)ans[day1+i]=v[i];
      int R=score();
      if(Sc<R){
        REP(i,5)now[i]=v[i];
        Sc=R;
      }
      else REP(i,5)ans[day1+i]=now[i];
    }while(next_permutation(v.begin(),v.end()));
  }
  */
  REP(__,5){
    REP(_,1000){
      int day=rand()%365,Sc=-INF,now=ans[day];
      REP(i,26){
        ans[day]=i+1;
        int R=score();
        if(Sc<R)now=i+1,Sc=R;
        else ans[day]=now;
      }
    }
    REP(_,1000){
      int day1=rand()%360;
      int day2=day1+rand()%5;
      int R=score();
      swap(ans[day1],ans[day2]);
      if(R>score())swap(ans[day1],ans[day2]);
    }
  }

  FIN(0);
}


Measured memory_bytes: 3692
from collections import deque
que = deque()
K = int(input())

for a in range(1,10):
    que.append(a)
nums = []
while len(nums) <= 1000000:
    if que:
        num = que.popleft()
    nums.append(num)
    for i in range(-1,2):
        plus = (num % 10) + i
        if 0 <= plus < 10:
            new = num*10 + plus
            if new <= 3234566667:
                que.append(new)
            else:
                continue

nums.sort
print(nums[K-1])

Measured memory_bytes: 109144
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int A, B; cin >> A >> B; A--, B--;
	vector<vector<char>> gr(100, vector<char>(100));
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) 
			gr[i][j] = (i < 50 ? '.' : '#');
	}
	bool flag = true;
	for (int i = 0; i < 49 && flag; i+=2) {
		for (int j = (i % 2 ? 1 : 0); j < 100; j+=2) {
			if (B <= 0) {
				flag = false; break;
			}
			gr[i][j] = '#';
			B--;		
		}
	}

	flag = true;
	for (int i = 99; i > 50 && flag; i-=2) {
		for (int j = (i % 2 ? 1 : 0); j < 100; j += 2) {
			if (A <= 0) {
				flag = false; break;
			}
			gr[i][j] = '.';
			A--;			
		}
	}
	cout << 100 << " " << 100 << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++)
			cout<<gr[i][j];
		cout << endl;
	}

}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=2e3+10;
typedef long long LL;
int dis[MR][MR],cnt[MR]={};
int main() {
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dis[i][j]=abs(i-j);
		}
	} 
	for(int i=1;i<=n;i++){
		dis[i][y]=min(dis[i][y],dis[i][x]+1);
		dis[y][i]=dis[y][i];
	}
	for(int i=1;i<=n;i++){
		dis[i][x]=min(dis[i][x],dis[i][y]+1);
		dis[x][i]=dis[x][i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dis[i][j]=min(dis[i][j],dis[i][x]+dis[x][j]);
			dis[i][j]=min(dis[i][j],dis[i][y]+dis[y][j]);
			cnt[dis[i][j]]++;
		}
	}
	for(int i=1;i<=n-1;i++){
		printf("%d\n",cnt[i]/2);
	}
    return 0;
}

Measured memory_bytes: 16000
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan=new Scanner(System.in);
    		
    		int x=Integer.parseInt(scan.next());
    		
    		System.out.print(x<1200? "ABC":"ARC");
    				
    	}
     
    }

Measured memory_bytes: 20820
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int a, b, c;
   cin >> a >> b >> c;
   if (a == b)
   {
      cout << c << endl;
   }
   else if (b == c)
   {
      cout << a << endl;
   }
   else if (a == c)
   {
      cout << b << endl;
   }

   return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())
a = list(map(int, input().split()))

# 求解処理


def get_divisible_count(x: int) -> int:
    divisible_count = 0
    while x % 2 == 0:
        divisible_count += 1
        x /= 2
    return divisible_count


ans = 0
for n in range(N):
    ans += get_divisible_count(a[n])

# 結果出力
print(ans)


Measured memory_bytes: 10060