akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def f(a, x):
    return a[x]


# 二分探索 ok ng
def main():
    N = I()
    S = LI()
    Q = I()
    T = LI()
    ans = 0

    for i in range(Q):
        s = 0
        t = N
        ok = s - 1
        ng = t
        target = T[i]
        while ng - ok > 1:
            mid = (ng + ok) // 2
            # print(mid, S[mid], target)
            if f(S, mid) <= target:
                ok = mid
            else:
                ng = mid

        ans += 1 if target == S[ok] else 0

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 18172
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (
        (a - 1) * (b - 1) * (c - 1) * (d - 1) == 0 && (a - 9) * (b - 9) * (c - 9) * (d - 9) == 0 && (a - 7) * (b - 7) * (c - 7) * (d - 7) == 0 && (a - 4) * (b - 4) * (c - 4) * (d - 4) == 0) {
        cout << "YES";
    } else {
        cout << "NO";
    }   
}


Measured memory_bytes: 256
s = gets.chomp.split.map(&:to_s)
a = gets.to_i.times.map{gets.split.map(&:to_s)}

reverse = false

a.each do |_a|
  if _a[0] == '1'
    reverse = !reverse
    next
  elsif _a[1] == '1'
    if reverse
      s.push(_a[2])
    else
      s.unshift(_a[2])
    end
    next
  else _a[1] == '2'
    if reverse
      s.unshift(_a[2])
    else
      s.push(_a[2])
    end
  end
end

puts reverse ? s.join.reverse : s.join

Measured memory_bytes: 54864
#include"bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int N; cin >> N;
	vector<int> a(N);
	int sum = 0;
	rep(i, N) {
		cin >> a[i];
		sum += a[i];
	}

	double ave = (double)sum / (double)N;
	int x;
	if (ave - (double)(int)ave >= 0.5) x = (int)ave + 1;
	else x = (int)ave;

	int ans = 0;
	for (auto y : a) {
		ans += (y - x) * (y - x);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3564
#C
A,B = map(int,input().split())
def gcd(x,y):
    M = max(x,y)
    m = min(x,y)
    m2 = M%m
    if m2 == 0:
        return m
    else:
        return gcd(m2,m)
        
print(A*B//gcd(A,B))



Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String[] strA = insBR.readLine().split(" ");
			int intA = Integer.parseInt(strA[0]);
			int intB = Integer.parseInt(strA[1]);

			if(intA < intB){
				System.out.println("a < b");
			}else if(intA > intB){
				System.out.println("a > b");
			}else{
				System.out.println("a == b");
			}

		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}
}



Measured memory_bytes: 24416
n, a, b = map(int, input().split())
cnt = 0
ans = 0
l = (a+b)
if n//l <= 10**100:
    ans += a * (n//l)
    cnt += (n//l)*l
    if n - cnt >= a:
        ans += a
    else:
        ans += max(n - cnt, 0)
else:
    ans += a * 10**100
    cnt += 10**100

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,f,t,*ip,*p,*q,x,a[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,};
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d",&f,&t);
		q=&a[24];
		ip=&a[f];

		p=find(&a[f],a+24,t);
		if(f<6) q=find(a+10,a+24,t);

		if(q!=a+24)
		{
			if( q>a+15-f && (q-(a+15-f)) < (p-ip)) 
				ip=a+15-f, p=q;
		}
		x=0;
		for(;ip<=p;++ip)
			printf("%s%d",(x++?" ":""),*ip);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
int a,b,c=0;
cin>>a>>b;
c=max(a,b);
if(a==1&&b>1) cout<<"Alice"<<endl;
else if(b==1&&a>1) cout<<"Bob"<<endl;
else if(a==b) cout<<"Draw"<<endl;
else if(c==a) cout<<"Alice"<<endl;
else if(c==b) cout<<"Bob"<<endl;
return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

ii  F[1 << 18];

void upd(int i,int x)   {
    if (F[i].Y < x)
        F[i].Y = x;
    if (F[i].X < F[i].Y)
        swap(F[i].X,F[i].Y);
}

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

    int n;  cin >> n;

    for(int i = 0 ; i < (1 << n) ; ++i) {
        int x;  cin >> x;
        upd(i,x);
    }
    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < (1 << n) ; ++j) if (j >> i & 1)
        upd(j,F[j ^ (1 << i)].X),
        upd(j,F[j ^ (1 << i)].Y);

    int ans = 0;

    for(int i = 1 ; i < (1 << n) ; ++i) {
        int nxt = F[i].X + F[i].Y;
        if (ans < nxt)
            ans = nxt;

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


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

int main(void){
	int l, i=0, a[3];
	while(cin>>l){
		a[i] = l;
		i++;
	}
	
	for(int i=0; i<3 ; i++)
	{
		for(int j=i+1; j<3 ; j++)
		{
			if(a[j]<a[i])
			{
				int tmp=a[j];
				a[j]=a[i]; a[i]=tmp;
			}
		}
	}
		cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
}



Measured memory_bytes: 3072
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = Integer.valueOf(scan.next());
        // int x = 3;
        int a = x;
        for (int i=1; i<3; i++) {
            a *= x;
        }
        System.out.println(String.valueOf(a));
    }
}


Measured memory_bytes: 25996
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    r0
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    S n;
    cin >> n;
    vi a;
    rp(i,n.size()-2){
        a.pb((n.at(i)-'0')*100+(n.at(i+1)-'0')*10+n.at(i+2)-'0');
    }
    int Min=INT_MAX;
    rp(i,a.size()){
        Min=min(Min,abs(a.at(i)-753));
    }
    cout << Min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007


signed main(){

	lli n,l;
	cin>>n>>l;

	vector<lli> a(n);
	lli sum=0;
	REP(i,0,n){
		cin>>a[i];
	}

	lli pos=-1;
	for(lli i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			pos = i+1;
			break;
		}
	}

	if(pos==-1){
		cout<<"Impossible"<<endl;
		return 0;
	}
	cout<<"Possible"<<endl;

	for(lli i=1;i<pos;i++){
		cout<<i<<endl;
	}
	for(lli i=n-1;i>=pos;i--){
		cout<<i<<endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
        long long int area;
        int d;
        int x;
        while(scanf("%d", &d) != EOF) {
                for(area = 0, x = d; x <= (600 - d); x += d) {
                        area += d * x * x;
                }
                printf("%lld\n", area);
        }
        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

long long gcd(long long a, long long b) {
    for(;;) {
        if(a == 0)
            return b;
        b %= a;
        if(b == 0)
            return a;
        a %= b;
    }
}

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main() {
    string S;
    cin >> S;
    if(S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }
    map<char, int> cnt;
    REP(i, S.length()) { cnt[S[i]]++; }
    bool flag = true;
    int index = 0;
    for(int i = 'a'; i < 'z' + 1; i++) {
        if(cnt[i] == 0) {
            if(flag) {
                index = i;
            }
            flag = false;
        }
    }
    if(!flag) {
        cout << S + (char)index << endl;
        return 0;
    }
    string T = S;
    next_permutation(S.begin(), S.end());
    REP(i, S.length()) {
        cout << S[i];
        if(S[i] != T[i]) {
            break;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#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 SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int 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;
}


int main() {
	string s; cin >> s;
	unordered_map<char, int>ump;
	rep(i, s.size()) {
		ump[s[i]]++;
	}
	bool a = true;
	for (auto p : ump) {
		int b = p.second;
		if (b % 2)a = false;
	}
	cout << (a ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    ll n=5;
    ll c=0;
    while(n--)
    {
        c++;
        ll x;
        cin>>x;
        if(x==0)
            break;
    }
    cout<<c;
    return 0;
}

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

class SCC {
    void dfs(int v) {
        if (used[v]) return;
        used[v] = 1;
        for (auto &u : g[v]) dfs(u);
        ord.push_back(v);
    }

    void rdfs(int v) {
        if (~cmp[v]) return;
        cmp[v] = sz;
        for (auto &u : rg[v]) rdfs(u);
    }

public:
    int sz;
    vector<vector<int>> g, rg, dag, group;
    vector<int> cmp, ord, used;

    SCC (int n) : g(n), rg(n), cmp(n, -1), used(n, 0) {}
    SCC (vector<vector<int>> &g) : g(g), rg(g.size()), cmp(g.size(), -1), used(g.size(), 0) {
        for (int v = 0; v < (int)g.size(); ++v) for (int u : g[v]) rg[u].push_back(v);
        build();
    }

    void add_edge(int s, int t) {
        g[s].push_back(t);
        rg[t].push_back(s);
    }

    void build() {
        for (int i = 0; i < (int)g.size(); ++i) dfs(i);
        reverse(ord.begin(), ord.end());
        sz = 0;
        for (int i : ord) if (!~cmp[i]) rdfs(i), ++sz;
        dag.resize(sz); group.resize(sz);
        for (int i = 0; i < (int)g.size(); ++i) {
            for (int j : g[i]) {
                int x = cmp[i], y = cmp[j];
                if (x != y) dag[x].emplace_back(y);
            }
            group[cmp[i]].push_back(i);
        }
    }

    // number of connected components
    int size() { return sz; }

    // the number of the component to which element x belongs
    int operator[](int x) { return cmp[x]; }

    bool same(int x, int y) { return cmp[x] == cmp[y]; }
};

int main() {
    int V, E;
    cin >> V >> E;
    SCC scc(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        scc.add_edge(s, t);
    }
    scc.build();
    for (int i = 0; i < scc.ord.size(); ++i) {
        cout << scc.ord[i] << endl;
    }
}


Measured memory_bytes: 5448
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
#define MOD 1000000007

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll mod = pow(10, 9) + 7;

    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);

    for(ll i = 0; i < N; i++) cin >> A[i];

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

    ll base = 1LL;
    ll ans = 0LL;

    for(ll i = K - 1LL; i < N; i++) {
        ans += (base * A[i]) % mod;
        ans %= mod;
        ans -= (base * A[N - 1LL - i]) % mod;
        while(ans < 0LL) ans += mod;
        ans %= mod;

        base *= i + 1LL;
        base %= mod;
        base *= modpow(i - K + 2LL, mod - 2LL, mod) % mod;
        base %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3984
use std::io;

fn main() {
    loop {
        let mut input = String::new();
        let _ = io::stdin().read_line(&mut input);

        if input == "" {
            break;
        }

        let mut iter = input.split_whitespace();

        let num :i32 = iter.next().unwrap().parse::<i32>().unwrap() + iter.next().unwrap().parse::<i32>().unwrap();
        println!("{:?}", num.to_string().len());
    }
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/




typedef long long ll; 
ll N;
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    N++;
    ll ans = 1;
    while (N % 2 == 0) {
        ans *= 2;
        N /= 2;
    }
    cout << ans << endl;

}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> s[i][j];

  bool able = true;
  int di[] = {1, 0, -1, 0};
  int dj[] = {0, 1, 0, -1};
  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') continue;
    bool is_dot = true;
    rep(k, 4) {
      int ni = i + di[k];
      int nj = j + dj[k];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') is_dot = false;
    }
    if (is_dot) able = false;
  }
  if (able) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
/* ex4_2
   YSK722 */

#include <math.h>
#include <stdio.h>

int main(void){
    double short_hand, long_hand, hour, minute, ans, angle_diff;
    scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute);
    // 短針と長針のか鵜戸の差を求める
    angle_diff = 2 * M_PI * ((hour + minute/60.0) / 12 - minute / 60);
    /* 余弦定理を用いる
       cos(-x) = cos(x)より、回転角の大小は考えない */
    ans = sqrt(
              pow(short_hand, 2) + pow(long_hand, 2) \
              - 2 * short_hand * long_hand * cos(angle_diff)
          );
    printf("%.9lf\n", ans);
    return 0;
}

Measured memory_bytes: 2588
#include <iostream>

using namespace std;

int main()
{
    long long n, k, b, ans=0, p_a=0, c, d, e, f, p_v;
    cin>>n>>k;
    b=n;
    while (b>k)
    {
        p_v=ans;
        if (b==n) ans+=n-k;
        else
        {
            c=n/(b+1); d=n%(b+1);
            e=n/b; f=n%b;
            ans+=(p_a-c);
            if (c==e)
            {
                if (d<k && f>=k) ans+=(f-k+1);
                if (d>=k && f>=k) ans+=(f-d);
            }
            else
            {
                if (d<k && f<k) ans+=(b-k)*(e-c);
                if (d<k && f>=k) ans+=(b-k)*(e-c)+(f-k+1);
                if (d>=k && f<k) ans+=(b-k)*(e-c)-(d-k+1);
                if (d>=k && f>=k) ans+=(b-k)*(e-c)-(d-k+1)+(f-k+1);
            }
        }
        p_a=ans-p_v;
        b--;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    std::string S;
    std::cin >> S;
    if(S=="ABC") S="ARC";
    else S="ABC";
    cout<<S<<endl;
    return 0;
}


Measured memory_bytes: 3596
# Vacation
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]
dp_a, dp_b, dp_c = [0 for _ in range(N)], [0 for _ in range(N)], [0 for _ in range(N)]
dp_a[0], dp_b[0], dp_c[0] = abc[0][0], abc[0][1], abc[0][2]
for i in range(1, N):
    a, b, c = abc[i]
    dp_a[i] = max(dp_b[i-1] + a, dp_c[i-1] + a)
    dp_b[i] = max(dp_a[i-1] + b, dp_c[i-1] + b)
    dp_c[i] = max(dp_a[i-1] + c, dp_b[i-1] + c)
print(max(dp_a[-1], dp_b[-1], dp_c[-1]))

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

int main(int argc, char *argv[]) {
    int x;
    cin >> x;
    if(x<600) cout << "8" << endl;
    else if(x<800) cout << "7" << endl;
    else if(x<1000) cout << "6" << endl;
    else if(x<1200) cout << "5" << endl;
    else if(x<1400) cout << "4" << endl;
    else if(x<1600) cout << "3" << endl;
    else if(x<1800) cout << "2" << endl;
    else cout << "1" << endl;
    return 0;
}


Measured memory_bytes: 3640
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int a,b;
	cin>>a>>b;
	cout<<max(0LL,a-2*b)<<endl;  
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n  # 各要素の親要素の番号を格納するリスト

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


# 連結かどうかの判定->DFS, BFS, Dijkstra, UnionFindなどで解ける
N, M = map(int, input().split())
edge = []
for _ in range(M):
    u, v = map(int, input().split())
    edge.append((u-1, v-1))
cnt = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        a, b = edge[j]
        if i != j:
            uf.union(a, b)
    if uf.group_count() > 1:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
int a,b,c,i,count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(i = a;i <=b;i++){
		if(c%i == 0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

			

Measured memory_bytes: 596
#include<stdio.h>
int main(void)
{
  int  i, j, b, ans, n;
  scanf("%d", &n);
  int a[n];
  for (i=0; i<n; ++i){
    scanf("%d", &a[i]);
  }
  for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j){
      if (a[i] > a[j]){
        b = a[i];
        a[i] = a[j];
        a[j] = b;
      }
    }
  }
    ans=a[n-1]-a[0];
    printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>
#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
    struct dsu {
    public:
        dsu() : _n(0) {}
        dsu(int n) : _n(n), parent_or_size(n, -1) {}

        int merge(int a, int b) {
            assert(0 <= a && a < _n);
            assert(0 <= b && b < _n);
            int x = leader(a), y = leader(b);
            if (x == y) return x;
            if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
            parent_or_size[x] += parent_or_size[y];
            parent_or_size[y] = x;
            return x;
        }

        bool same(int a, int b) {
            assert(0 <= a && a < _n);
            assert(0 <= b && b < _n);
            return leader(a) == leader(b);
        }

        int leader(int a) {
            assert(0 <= a && a < _n);
            if (parent_or_size[a] < 0) return a;
            return parent_or_size[a] = leader(parent_or_size[a]);
        }

        int size(int a) {
            assert(0 <= a && a < _n);
            return -parent_or_size[leader(a)];
        }

        std::vector<std::vector<int>> groups() {
            std::vector<int> leader_buf(_n), group_size(_n);
            for (int i = 0; i < _n; i++) {
                leader_buf[i] = leader(i);
                group_size[leader_buf[i]]++;
            }
            std::vector<std::vector<int>> result(_n);
            for (int i = 0; i < _n; i++) {
                result[i].reserve(group_size[i]);
            }
            for (int i = 0; i < _n; i++) {
                result[leader_buf[i]].push_back(i);
            }
            result.erase(
                    std::remove_if(result.begin(), result.end(),
                                   [&](const std::vector<int>& v) { return v.empty(); }),
                    result.end());
            return result;
        }

    private:
        int _n;
        // root node: -1 * component size
        // otherwise: parent
        std::vector<int> parent_or_size;
    };

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

//#include "../library/fenwicktree.hpp"
//#include "../library/modint.hpp"
//#include "../library/segtree.hpp"

using namespace std;
using namespace atcoder;

void ADisjointSetUnion(std::istream& in, std::ostream& out) {
    int n, q;
    in >> n >> q;
    dsu d(n);
    while (q--) {
        int t, u, v;
        in >> t >> u >> v;
        if (t) out << d.same(u, v) << '\n';
        else d.merge(u, v);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    ADisjointSetUnion(in, out);
    return 0;
}

Measured memory_bytes: 3864
#標準入力を高速に
import sys 
input = sys.stdin.readline

N,M = map(int,input().split())
p = [0]*M
S = [""]*M
for i in range(M):
    p[i],S[i] = input().split()
    p[i] = int(p[i])
    p[i] -= 1

penalties=[0]*N
penalty=0
flag=[True]*N
for i in range(M):
    if flag[p[i]]:
        if S[i] == "WA":
            penalties[p[i]] += 1
        else:
            flag[p[i]] = False

corrects = 0
for i in range(N):
    if not flag[i]:
        corrects += 1
        penalty += penalties[i]

print(corrects)
print(penalty)
#print(sum(penalties))





Measured memory_bytes: 50128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;

    int s = 26;
    int t = 26;
    int cnt = 1;

    while(s < n){
        t *= 26;
        s += t;
        cnt++;
    }
    n -= s - t + 1;

    stack<int> ans;
    while(cnt > 0){
        ans.push(n % 26);
        n /= 26;
        cnt--;
    }

    while(not ans.empty()){
        int x = ans.top();
        ans.pop();
        cout << char('a' + x);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=2e5+10;
struct Edge
{
	int nx,to;
}E[MAXN<<1];
int head[MAXN],ecnt=0;
int col[MAXN],val[MAXN];
void addedge(int u,int v)
{
	++ecnt;
	E[ecnt].nx=head[u];
	E[ecnt].to=v;
	head[u]=ecnt;
}
void ins(int u,int v)
{
	addedge(u,v);
	addedge(v,u);
}
int n,m;
int dfn[MAXN],idx=0;
int dep[MAXN],fa[MAXN],top[MAXN];
int siz[MAXN],mxson[MAXN],dist[MAXN];
struct PreSegTree
{
	int nodeidx;
	struct node
	{
		int cnt,sum;
		int ls,rs;
	}Tree[MAXN*30];
	PreSegTree(){nodeidx=0;Tree[0].cnt=Tree[0].sum=0;}
#define root Tree[o]
	void upd(int &o,int pre,int l,int r,int pos,int c)
	{
		o=++nodeidx;
		root=Tree[pre];
		if(!pos)
			return;
		if(l==r)
		{
			root.cnt++;
			root.sum+=c;
			return;
		}
		int mid=(l+r)>>1;
		if(pos<=mid)
			upd(root.ls,Tree[pre].ls,l,mid,pos,c);
		else
			upd(root.rs,Tree[pre].rs,mid+1,r,pos,c);
	}
	int query_sum(int o,int l,int r,int pos)
	{
		if(!o)
			return root.sum;
		if(l==r)
			return root.sum;
		int mid=(l+r)>>1;
		if(pos<=mid)
			return query_sum(root.ls,l,mid,pos);
		else
			return query_sum(root.rs,mid+1,r,pos);
	}
	int query_cnt(int o,int l,int r,int pos)
	{
		if(!o)
			return root.cnt;
		if(l==r)
			return root.cnt;
		int mid=(l+r)>>1;
		if(pos<=mid)
			return query_cnt(root.ls,l,mid,pos);
		else
			return query_cnt(root.rs,mid+1,r,pos);
	}
}T;
int rt[MAXN];
void dfs1(int u,int Fa)
{
	fa[u]=Fa;
	dep[u]=dep[Fa]+1;
	siz[u]=1;
	T.upd(rt[u],rt[Fa],1,n,col[u],val[u]);
	for(int i=head[u];i;i=E[i].nx)
	{
		int v=E[i].to;
		if(v==Fa)
			continue;
		dist[v]=dist[u]+val[v];
		dfs1(v,u);
		siz[u]+=siz[v];
		if(siz[v]>siz[mxson[u]])
			mxson[u]=v;
	}
}
void dfs2(int u,int tp)
{
	top[u]=tp;
	if(mxson[u])
		dfs2(mxson[u],tp);
	for(int i=head[u];i;i=E[i].nx)
	{
		int v=E[i].to;
		if(v==fa[u] || v==mxson[u])
			continue;
		dfs2(v,v);
	}
}
void init()
{
	dfs1(1,0);
	dfs2(1,1);
}
int getLCA(int x,int y)
{
	while(top[x]!=top[y])
	{
		if(dep[top[x]]<dep[top[y]])
			swap(x,y);
		x=fa[top[x]];
	}
	return dep[x]<dep[y]?x:y;
}
int Solve(int c,int d,int x,int y)
{
	int LCA=getLCA(x,y);
	int cnt=0,sum=0;
	cnt+=T.query_cnt(rt[x],1,n,c);
	cnt+=T.query_cnt(rt[y],1,n,c);
	cnt-=T.query_cnt(rt[LCA],1,n,c);
	cnt-=T.query_cnt(rt[fa[LCA]],1,n,c);
	sum+=T.query_sum(rt[x],1,n,c);
	sum+=T.query_sum(rt[y],1,n,c);
	sum-=T.query_sum(rt[LCA],1,n,c);
	sum-=T.query_sum(rt[fa[LCA]],1,n,c);
	int res=dist[x]+dist[y]-2*dist[LCA];
	return res-sum+d*cnt;
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<n;++i)
	{
		int u=read(),v=read();
		col[n+i]=read(),val[n+i]=read();
		ins(u,n+i);
		ins(v,n+i);
	}
	n=2*n-1;
	init();
	while(m--)
	{
		int x=read(),y=read();
		int u=read(),v=read();
		printf("%d\n",Solve(x,y,u,v));
	}
	return 0;
}


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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string s,ans;

main() {
    cin >> s;
    rep(i,s.size()) {
        if (s[i]=='B') {
            if (!ans.empty()) ans.pop_back();
        }
        else ans.pb(s[i])
    }
    ct(ans)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a==1){
    a+=13;
  }
  if(b==1){
    b+=13;
  }
  if(a>b){
    cout << "Alice" << endl;
  }else if(a<b){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

int n,a,b,c,d,delta,whole;

double nxt,half=0.5,maxhalf,lft;

int main(){
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    nxt+=c+d;
    nxt/=2;
    half=nxt-c;
    maxhalf=half*(n-1);
    delta=abs(a-b);
    if(delta>(n-1)*nxt+maxhalf){
        printf("NO\n");
        return 0;
    }
    whole=(int)(delta/nxt);
    lft=delta-nxt*whole;
    if(n&1){
        if(whole&1){
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    else{
        if(whole&1){
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;


struct UnionFind {
    vector<int> parent; // parent[root] is the negative of the size.

    explicit UnionFind(int n) : parent(n, -1) {
    };                                       //初期化

    bool unite(int u, int v) {//ノードx,yが属する木を併合
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v];
        parent[v] = u;
        return true;
    }

    bool find(int u, int v) {//ノードx,yが同じ木に属するかどうか
        return root(u) == root(v);
    }

    int root(int u) {//ノードuが属する木の根
        return parent[u] < 0 ? u : parent[u] = root(parent[u]);
    }

    int size(int u) {//ノードiを含む木の大きさ
        return -parent[root(u)];
    }
};


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

    auto uf = UnionFind(n);
    for (int i = 0; i < q; ++i) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 0) {
            uf.unite(x, y);
        } else {
            cout << uf.find(x, y) << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main(){

int N;
string S;

cin >> N >> S;

for (int i = 0; i < S.size(); i++)
{
	if (S[i] + N <='Z')
	{
		printf("%c",(S[i] + N) );

	}
	else
	{
		printf("%c",(S[i] + N - 26));
	}

}
	


}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;

#define mygc getchar_unlocked
inline void reader(int *x) {
	int k, m = 0; *x = 0;
	while (true) {
		k = mygc();
		if (k == '-') { m = 1; break; }
		if (48 <= k && k <= 57) { *x = k - 48; break; }
	}
	while (true) {
		k = mygc();
		if (k < 48 || 57 < k) break;
		*x = (*x) * 10 + k - 48;
	}
	if (m) (*x) = -(*x);
}

int n, m, s[100009], x[100009];
int main() {
	reader(&n); reader(&m);
	for (int i = 1; i < n; i++) reader(&s[i]), s[i] += s[i - 1];
	long long ret = 0;
	for (int i = 1; i <= m; i++) {
		reader(&x[i]), x[i] += x[i - 1];
		if (x[i] < x[i - 1]) ret += s[x[i - 1]] - s[x[i]];
		else ret += s[x[i]] - s[x[i - 1]];
	}
	printf("%d\n", ret % 100000);
	return 0;
}

Measured memory_bytes: 3428
#[allow(dead_code)]
fn main() {
    let (h, w) = i::u2();
    let a = i::cmap(h);

    let mut k = Vec::new();
    for i in 0..h {
        if a[i].contains(&'#') {
            k.push(a[i].clone());
        }
    }

    let mut l = vec![Vec::new(); k.len()];
    for i in 0..w {
        let mut has = false;
        for j in 0..k.len() {
            if k[j][i] == '#' {
                has = true;
            }
        }
        if has {
            for j in 0..k.len() {
                l[j].push(k[j][i]);
            }
        }
    }
    for i in 0..l.len() {
        for j in 0..l[i].len() {
            print!("{}", l[i][j]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
const int maxint = -1u>>1;
const int maxn = 50 + 2;
const int maxm = 1000 + 10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int r, c, m;
char s[maxn][maxn];
int open[maxn][maxn], inst[maxn][maxn], cl[maxn][maxn];
pair<int, int> rec[maxm];
vector<pair<int, int> > p;
vector<int> tm[maxn][maxn];
bool used[maxn][maxn];

bool dfs(int x1, int y1, int x2, int y2) {
    if (x1 == x2 && y1 == y2) return true;
    if (used[x1][y1]) return false;
    used[x1][y1] = true;
    p.push_back(make_pair(x1, y1));
    for (int i = 0; i < 4; ++i) {
        int tx = x1 + dx[i], ty = y1 + dy[i];
        if (tx < 0 || ty < 0 || tx >= r || ty >= c || s[tx][ty] != '.') continue;
        if (dfs(tx, ty, x2, y2)) return true;
    }
    p.pop_back();
    return false;
}
int main() {
    while (scanf("%d%d%d", &r, &c, &m) == 3) {
        for (int i = 0; i < r; ++i) {
            scanf("%s", s[i]);
        }
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                tm[i][j].clear();
                scanf("%d", &inst[i][j]);
            }
        }
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                scanf("%d", &open[i][j]);
            }
        }
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                scanf("%d", &cl[i][j]);
            }
        }
        for (int i = 0; i < m; ++i) {
            scanf("%d%d", &rec[i].first, &rec[i].second);
        }
        int now = 0;
        for (int i = 1; i < m; ++i) {
            memset(used, 0, sizeof(used));
            p.clear();
            dfs(rec[i - 1].first, rec[i - 1].second, rec[i].first, rec[i].second);
            for (int j = 0; j < (int) p.size(); ++j) {
                tm[p[j].first][p[j].second].push_back(now);
                ++now;
            }
        }
        tm[rec[m - 1].first][rec[m - 1].second].push_back(now);
        int ans = 0;
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                if (tm[i][j].size() == 0) continue;
                //printf("%d %d: ", i, j);for (int k = 0; k < (int)tm[i][j].size(); ++k) printf("%d ", tm[i][j][k]); printf("\n");
                ans += open[i][j] + cl[i][j] + inst[i][j] * (tm[i][j].back() - tm[i][j].front());
                for (int k = 1; k < (int)tm[i][j].size(); ++k) {
                    if ((tm[i][j][k] - tm[i][j][k - 1]) * inst[i][j] > open[i][j] + cl[i][j]) {
                        ans -= (tm[i][j][k] - tm[i][j][k - 1]) * inst[i][j] - open[i][j] - cl[i][j];
                    }
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
N = int(input())
prime = [False]*2 + [True]*55554
for i in range(2, 55556):
  if prime[i]:
    prime[2*i::i] = [False]*(55555//i-1)

arr = []
for i in range(11, 55556):
  if prime[i] and i % 10 == 1:
    arr.append(str(i))
print(' '.join(arr[:N]))

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

double PI = acos(-1.0);

int main()
{
    int a,b,h,m; cin >> a >> b >> h >> m;

    double radianH = h * PI / 6.0 + m * PI / 360.0;
    double radianM = m * PI / 30.0;

    complex<double> hr = polar((double)a, radianH);
    complex<double> mn = polar((double)b, radianM);
    complex<double> df = hr - mn;

    printf("\n%.10f\n", abs(df));
    return 0;
}


Measured memory_bytes: 4012
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<long long> p(a,0ll),q(b,0ll),r(c,0ll);
    for(int i=0;i<a;i++)
        cin>>p[i];
    for(int i=0;i<b;i++)
        cin>>q[i];
    for(int i=0;i<c;i++)
        cin>>r[i];
    
    sort(rfull(p));
    sort(rfull(q));
    sort(rfull(r));
    priority_queue<int,vector<int>,greater<int>> pq;
    for(int i=0;i<x;i++)
        pq.push(p[i]);
    for(int i=0;i<y;i++)
        pq.push(q[i]);
    for(int i=0;i<c;i++){
        if(pq.top()<r[i]){
            pq.pop();
            pq.push(r[i]);
        }
    }

    long long ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<"\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <math.h>
#include <string.h>
using namespace std;

//typedef pair<int, int> P;
#define ll long long
//#define int ll
#define INF (1LL<<60)
#define mod 1000000007


int N, M, P[123456], Y[123456];
vector<int> year[123456];

signed main(){

	cin >> N >> M;
	for (int i = 0; i < M; i++){
		cin >> P[i] >> Y[i];
		year[P[i]].push_back(Y[i]);
	}

	for (int i = 0; i <= N; i++){
		sort(year[i].begin(), year[i].end());
	}

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

		printf("%06d%06d\n", P[i],
			(int)(lower_bound(year[P[i]].begin(), year[P[i]].end(), Y[i])
			- year[P[i]].begin() + 1 ));
	}


	return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007
#include <iomanip>

using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,w,h,x,y;
    cin >>w>>h>>x>>y;

    cout << setprecision(20) <<(double)w*(double)h/2.0<<" ";
    if((double)w/2.0==(double)x&&(double)h/2.0==(double)y)cout <<"1"<<endl;
    else cout <<"0"<<endl;

    return 0;

}

Measured memory_bytes: 256