akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lec11C
{
    class Element
    {
        public int id;
        public int degree;
        public int[] next_list;
        public int state;
        public int d;
        //public int f;

        public void Setting(int n)
        {
            next_list = new int[n];
            state = 0;
        }

    }
    class Program
    {
        //static int time = 0;
        const int Inf = 10000000;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Element[] arr = new Element[n];

            for (int i = 0; i < n; i++)
            {
                string[] input = (Console.ReadLine()).Split(' ');

                arr[int.Parse(input[0]) - 1] = new Element();
                arr[int.Parse(input[0]) - 1].id = int.Parse(input[0]);
                arr[int.Parse(input[0]) - 1].Setting(int.Parse(input[1]));
                arr[int.Parse(input[0]) - 1].degree = int.Parse(input[1]);

                for (int j = 0; j < int.Parse(input[1]); j++)
                {
                    arr[int.Parse(input[0]) - 1].next_list[j] = int.Parse(input[j + 2]);
                }

            }

            BFS(arr,1);
            //DFS(arr);

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(arr[i].id + " " + arr[i].d );
            }

            Console.ReadLine();
        }

        static void BFS(Element [] g ,int s)
        {

            for (int i = 1; i < g.Length; i++)
            {
                g[i].d = -1; 
            }
            Queue<int> q = new Queue<int>();
            g[0].state = 1;
            g[0].d = 0;
            q.Enqueue(s);
            while (q.Count > 0)
            {
                int u = q.Dequeue();
                foreach (int v in g[u-1].next_list)
                {
                    if (g[v-1].state == 0)
                    {
                        g[v-1].state = 1;
                        g[v-1].d = g[u-1].d + 1;
                        q.Enqueue(v);
                    }
                }
                g[u-1].state = 2;
            }

        }

        /*
        static void DFS(Element[] g)
        {
            for (int i = 1; i <= g.Length; i++)
            {
                if (g[i - 1].state == 0)
                {
                    Visit(g, i);
                }
            }

        }

        static void Visit(Element[] u, int i)
        {
            u[i - 1].state = 1;
            time++;
            u[i - 1].d = time;

            foreach (int j in u[i - 1].next_list)
            {
                if (u[j - 1].state == 0)
                {
                    Visit(u, j);
                }
            }
            u[i - 1].state += 1;
            time++;
            u[i - 1].f = time;

        }*/
    }
}



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

#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    string s;
    cin>>s;
    int i,cnt=0;
    int ans=0;
    rep(i,0,sz(s))
    {
        if(s[i]=='R')
        {
            cnt=0;
            while(s[i]=='R'&&i<sz(s))
            {
                i++;
                cnt++;
            }
        }
        amax(ans,cnt);
    }
    cout<<ans;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3612
# D - Maximum Average Sets

N, A, B = map(int, input().split())
v = sorted(list(map(int, input().split())), reverse = True)

factorial_memo = [1]
for i in range(1,N+1):
    factorial_memo.append(factorial_memo[-1] * i)

def comb(n, r):
    return factorial_memo[n]//(factorial_memo[n-r] * factorial_memo[r])

print(sum(v[:A]) / A)
for i in reversed(range(A, N)):
    if v[i] == v[0]:
        print(sum([comb(i+1, x) for x in range(A, B+1)]))
        break
else:
    print(comb(v.count(v[A]), v[:A].count(v[A])))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
string S;
void input() {
	cin >> n;
	cin >> S;
}
void solve() {
	if (n % 2 == 1)ans = 1;
	rep(i, n/2) {
		if (S[i] != S[i + n / 2])ans = 1;
	}

	if (ans == 1) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
}

int main() {
	input();
	solve();
}

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

int main(){
	string s;cin>>s;
	int cnt=1e9;
	if(s.size()==1){
		cout<<0;
		return 0;
	}
	set<char>hnhn;
	for(char u:s)hnhn.insert(u);
	if(hnhn.size()==1){
		cout<<0;
		return 0;
	}
	string tmp;
	for(char c='a';c<='z';c++){
		tmp=s;
		int now=0;
		string t="";
		while(true){
			now++;
			for(int i=0;i<tmp.size()-1;i++){
				if(tmp[i]==c||tmp[i+1]==c){
					t+=c;
				}else{
					t+=tmp[i];
				}
			}
			set<char>ss;
			for(char u:t){
				ss.insert(u);
			}
			//cout<<t<<endl;
			//cout<<ss.size()<<endl;
			if(now>110)break;
			if(ss.size()==1){
				cnt=min(now,cnt);
				break;
			}
			tmp=t;
			t="";
			//cout<<111<<endl;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
def mod_exp(b,e,mod):
    r = 1
    while e > 0:
        if (e&1) == 1:
            r = (r*b)%mod
        b = (b*b)%mod
        e >>= 1

    return r

# get degree of p in n! (exponent of p in the factorization of n!)
def fact_exp(n,p):
    e = 0
    u = p
    t = n
    while u <= t:
        e += t//u
        u *= p
    return e

# convert given number n into array of its base b representation
# most significant digit is at rightmost position in array
def get_base_digits(n,b):
    d = []
    while n > 0:
        d.append(n % b)
        n  = n // b
    return d

# Using Fermat's little theorem to compute nCk mod p
# considering cancelation of p in numerator and denominator
# Note: p must be prime
def fermat_binom_advanced(n,k,p):
    # check if degrees work out
    num_degree = fact_exp(n,p) - fact_exp(n-k,p)
    den_degree = fact_exp(k,p)
    if num_degree > den_degree:
        return 0
    if k > n:
        return 0
    # calculate numerator and cancel out occurrences of p
    num = 1
    for i in range(n,n-k,-1):
        cur = i
        while cur%p == 0:
            cur //= p
        num = (num*cur)%p
    # calculate denominator and cancel out occurrences of p
    denom = 1
    for i in range(1,k+1):
        cur = i
        while cur%p == 0:
            cur //= p
        denom = (denom*cur)%p
    # numerator * denominator^(p-2) (mod p)
    return (num * mod_exp(denom,p-2,p))%p

# Using Lucas' theorem to split the problem into smaller sub-problems
# In this version assuming p is prime
def lucas_binom(n,k,p):
    # get n and k in base p representation
    np = get_base_digits(n,p)
    kp = get_base_digits(k,p)
    # calculate (nCk) = (n0 choose k0)*(n1 choose k1) ... (ni choose ki) (mod p)
    binom = 1
    for i in range(len(np)-1,-1,-1):
        ni = np[i]
        ki = 0
        if i < len(kp):
            ki = kp[i]
        binom = (binom * fermat_binom_advanced(ni,ki,p)) % p
    return binom

mod = 10**9+7

n,m,k = map(int,input().split())
temp = 0
for d in range(1,m):
	temp += d*n*n*(m-d)
for d in range(1,n):
	temp += d*m*m*(n-d)
l = lucas_binom(n*m-2,k-2,mod)
print(temp*l%mod)

Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
 
using namespace std;
typedef long long ll ;
int main(){
  ll n;
  ll m;
  cin >> m;
  cin >> n;
  vector<int> tmp(n);
  for(int i=0;i<n;i++){
    cin >> tmp[i];
  }
  for(int i=m;1;i++){
    int buf = i;
    bool flag=true;
    while(buf){
      for(int j=0;j<n;j++){
        if(buf%10==tmp[j])flag=false;
      }
      buf/=10;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n;
lint C, x[MAX], v[MAX], ans = 0;

void solve(){
    lint vsum[n+3], dmax[n+3];
    vsum[0] = dmax[0] = 0;
    copy(v, v+n+2, vsum+1);
    partial_sum(vsum, vsum+n+3, vsum);
    rep(i, n+2) dmax[i+1] = vsum[i+1] - x[i];
    partial_sum(dmax, dmax+n+3, dmax, [](lint a, lint b){return max(a, b);});

    rep(i, n+2){
        lint L = vsum[n+1] - vsum[i] - (C-x[i])*2;
        lint R = dmax[i];
        chmax(ans, L + R);
    }
}

int main(){
    scanf("%d%lld", &n, &C);
    x[0] = v[0] = 0;
    x[n+1] = C; v[n+1] = 0;
    For(i, 1, n+1) scanf("%lld%lld", &x[i], &v[i]);
    solve();
    For(i, 1, n+1) x[i] = C - x[i];
    reverse(x+1, x+n+1);
    reverse(v+1, v+n+1);
    solve();
    printf("%lld\n", ans);
}

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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

	// ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	int n, w;
	scanf("%d %d", &n, &w);

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

	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &a[i], &b[i]); //w v
	}

	std::vector<LL> dp(w + 1);
	// dp[0] = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = w; j >= a[i]; --j) {
			dp[j] = max (dp[j], b[i] + dp[j-a[i]]);
		}
	}

	printf("%lld\n", dp[w]);




	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>

using namespace std;

int main(){
  string S,T;
  cin >> S >> T;

  vector<int> c1(26,-1);
  vector<int> c2(26,-1);
  for(int i=0;i<S.size();i++){
    if(c1.at(S.at(i)-'a')!=-1 || c2.at(T.at(i)-'a')!=-1){
      if(c1.at(S.at(i)-'a')!=T.at(i)-'a' || c2.at(T.at(i)-'a')!=S.at(i)-'a'){
        cout << "No" << endl;
        return 0;
      }
    }
    c1.at(S.at(i)-'a')=T.at(i)-'a';
    c2.at(T.at(i)-'a')=S.at(i)-'a';
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
void rec(ll n) {
    if(n==0 || n==1) {
        cout << (n?1:0);
        return;
    }
    int res = n/(-2);
    if(n < 0 && abs(n)&1) res++;
    rec(res);
    int r = 0;
    if(abs(n)&1) r = 1;
    cout << r;
}
int main() {
    ll n; cin >> n;
    rec(n);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
  int A,B,K,k;
  scanf("%d %d",&A,&B);
  k=abs(A+B);
  if(k%2==1){
    printf("IMPOSSIBLE\n" );
  }else{
    K=(k/2);
    printf("%d\n",K );
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

vector<ll> pow, sum;

int depth(ll n){
    for(int i = 0; i < sum.size(); i++){
        if(sum[i] >= n) return i;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N, Q; cin >> N >> Q;
    if( N == 1){
        for(int i = 0; i < Q; i++){
            ll v, w; cin >> v >> w;
            cout << v << endl;
        }
        return 0;
    }
    ll cur = 1;
    ll tmp = 1;
    pow.push_back(1);
    sum.push_back(1);
    while(tmp <= 2e9){
        cur *= N;
        tmp += cur;
        pow.push_back(cur);
        sum.push_back(tmp);
    }
    
    for(int i = 0; i < Q; i++){
        ll v, w; cin >> v >> w;
        set<ll> st; st.insert(v);
        int d = depth(v);
        while(v != 1){
            ll m = (v-sum[d-1]+N-1)/N;
            if(d >= 2) v = sum[d-2]+m;
            else v = 1;
            st.insert(v);
            d--;
        }
        if(st.count(w) != 0){
            cout << w << endl;
            continue;
        }
        d = depth(w);
        while(w != 1){
            ll m = (w-sum[d-1]+N-1)/N;
            if(d >= 2) w = sum[d-2]+m;
            else w = 1;
            if(st.count(w) != 0) {
                cout << w << endl;
                break;
            }
            d--;
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	bool flag=0;
	getline (cin,s);
	for(int i=0;i<s.length();i++){
		if(s[i]=='C')flag=1;
		if(flag&&s[i]=='F'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
ll MOD = 1e9 + 7;

using vc = vector<char>;
using vi = vector<int>;

string L;
vector<vector<ll>> dp;

ll get_count(int sIndex, bool isUnder) {
    if (sIndex == L.size()) return 1;

    if (dp[sIndex][isUnder] != -1) return dp[sIndex][isUnder];
    
    ll ways = 0;
    // add 0
    ways += get_count(sIndex + 1, isUnder | (L[sIndex] == '1'));
    
    // add 1
    if (isUnder) {
        ways += 2 * get_count(sIndex + 1, isUnder);
    } else if (L[sIndex] == '1') {
        ways += 2 * get_count(sIndex + 1, false);
    }
    ways %= MOD;
    dp[sIndex][isUnder] = ways;
    return ways;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> L;
    dp = vector<vector<ll>> (L.length(), vector<ll>(2, -1));
    cout << get_count(0, false) << endl;
}

Measured memory_bytes: 12112
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b, ll cmod) {ll res=1;a%=cmod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%cmod;a=a*a%cmod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int get_ans(ll val) {
    int cnt = 0;
    while (val > 0)
        val = val%((ll)__builtin_popcount(val)), cnt++;
    return cnt;
}

void solve() {
    int n;
    cin >> n;
    string b;
    cin >> b;

    int ones = 0;
    for (auto x : b)
        ones += (x == '1');

    vi ans(n);
    FOR (d, -1, 2) {
        int cnt = ones + d;
        ll val = 0, mul = 1;
        if (cnt == 0)
            val = 0;
        else {
            RFOR (i, 0, n)
                val += mul*(b[i ]== '1'), val %= (ll)cnt, mul *= 2, mul %= (ll)cnt;
        }

        FOR (j, 0, n) {
            int ccnt = ones;
            if (b[j] == '1')
                ccnt--;
            else
                ccnt++;
            if (ccnt == cnt) {
                if (ccnt == 0)
                    ans[j] = 0;
                else {
                    ll cval = val;

                    if (b[j] == '1')
                        cval -= powmod(2, n-j-1, cnt);
                    else
                        cval += powmod(2, n-j-1, cnt);

                    cval = (cval%cnt + cnt)%cnt;
                    ans[j] = 1 + get_ans(cval);
                }
            }
        }
    }

    for (auto x : ans)
        cout << x << "\n";

}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 4380
// https://atcoder.jp/contests/abc161/tasks/abc161_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    int t1 = N % K;
    int t2 = min(t1, abs(t1 - K));
    cout << t2 << endl;

    return 0;
}


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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
 
using namespace std;

signed main(){
    
    int  n,m;
    cin >> n >> m;

    int s[n+1] = {0};
    REP(i,n){
        int a;
        cin >> a;
        s[i+1] = s[i] + a;
    }

    int ans = 0;
    
    map<int,int> mp;
    REP(i,n+1){
        int x = s[i]%m;
        auto itr = mp.find(x);
        if(itr != mp.end()){
            mp[x]++;
        }else{
            mp[x] = 1;
        }
    }
    for(auto x : mp){
        ans += x.se * (x.se - 1)/2;
    }

    cout << ans << endl;
    
    return 0;
}
//g++ -std=c++14 code1.cpp



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

points = []

def dist(x, y):
    if x == 0:
        return R * 2 + C + (C - y)
    if x == R:
        return R + y
    if y == 0:
        return x
    if y == C:
        return R + C + (R - x)

for i in range(N):
    x1, y1, x2, y2 = map(int, input().split())
    if ((x1 == 0 or x1 == R) or (y1 == 0 or y1 == C)) and ((x2 == 0 or x2 == R) or (y2 == 0 or y2 == C)):
        points.append((i + 1, dist(x1, y1)))
        points.append((i + 1, dist(x2, y2)))
points.sort(key=lambda p: p[1])
l = []
for point in points:
    if len(l) == 0:
        l.append(point[0])
        continue
    if point[0] == l[-1]:
        l.pop()
    else:
        l.append(point[0])
if len(l) == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 33436
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long power(long long N, long long expo)
{
	long long ans = 1;
	while(expo)
	{
		if(expo % 2)
			ans = ans * N % MOD;
		N = N * N % MOD;
		expo /= 2;
	}
	return ans;
}

int main()
{
	long long a,b,h;
	cin>>a>>b>>h;
	cout<<((a+b)*h)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,m,ans=0,sum=0;
  cin >> n >> m;
  vector<pair<int64_t,int64_t>> a(n);
  for(int64_t i=0;i<n;i++)cin >> a[i].first >> a[i].second;
  sort(a.begin(),a.end());
  for(int64_t i=0;i<n;i++){
    if(sum+a[i].second>=m){
      ans+=a[i].first*(m-sum);
      break;
    }else{
      sum+=a[i].second;
      ans+=a[i].first*a[i].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4848
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let a = (0..n).map(|_| read_vec::<usize>()).collect::<Vec<Vec<_>>>();
    let big_int = 1000_000_000 + 7;
    let mut dp = vec![0u64; 1 << n];

    let mut bits = vec![vec![]; n + 1];
    for bp in 0..(1 << n) {
        let k = (bp as u32).count_ones();
        bits[k as usize].push(bp);
    }
    // println!("bits {:?}", bits);
    for i in 0..n {
        if a[0][i] == 1 {
            dp[1 << i] = 1;
        }
    }
    for i in 1..n {
        for j in 0..n {
            if a[i][j] == 0 {
                continue;
            }
            for &k in bits[i].iter() {
                if k & 1 << j != 0 {
                    continue;
                }
                // println!("{:?}", (k, 1 << j, k ^ (1 << j), 1 << n));
                dp[k ^ (1 << j)] += dp[k];
                dp[k ^ (1 << j)] %= big_int;
            }
        }
    }
    println!("{:?}", dp[(1 << n) - 1]);
}


Measured memory_bytes: 48728
#include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
     
    int main(){
        int N,K;
        cin >> N >> K;
        int ans=1;
        for(int i=0;i<N;i++){
            ans=min(ans*2,ans+K);
        }
        cout << ans << endl;
        return 0;
    }

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

using namespace std;

int main(){
	int N, L; cin >> N >> L;
	string S[N];
	for(int i = 0; i < N; ++i) cin >> S[i];
	sort(S, S + N);
	for(int i = 0; i < N; ++i) cout << S[i];
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair
long long gcd(long long a, long long b){
    if(a==0) return b;
    if(b==0) return a;
    if(a>b) return gcd(b, a%b);
    return gcd(a,b%a);
}
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
//#endif
    int n;
    int k;
    scanf("%d %d", &n, &k);
    int d = 0;
    int x;
    int mx = 0;
    forn(i,0,n) {
        scanf("%d", &x);
        d=gcd(d,x);
        mx = max(mx,x);
    }
    if(k%d == 0 && k<=mx) cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";
    
}



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

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++){
        cin >> p[i];
    }
    
    ll mini = n+1;
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        if (p[i] <= mini){
            mini = p[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
#define point complex<double>
const int N = 3e5 + 5;
const int OO = 1e9 + 7;
using namespace std;
int main() {
    IO;
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> mp;
    forr(i,1,n)
    {
        ll x;
        cin >> x;
        ans += mp[i-x];
        mp[i+x]++;
    }

    cout << ans;



}

Measured memory_bytes: 26244
a, b, c = map(int, raw_input().split())
s = a + b + c
if a % 2 == 1 or b % 2 == 1or c % 2 == 1:
    print 0
    exit()

mem = set()
ans = 0
while True:
    a, b, c = sorted((a, b, c))
    if a % 2 == 1 or b % 2 == 1or c % 2 == 1:
        break
    if (a, b, c) in mem:
        print -1
        exit()
    mem.add((a, b, c))
    na = b / 2 + c / 2
    nb = a / 2 + c / 2
    nc = a / 2 + b / 2
    a, b, c = na, nb, nc
    ans += 1
print ans


Measured memory_bytes: 28396
#include <stdio.h>
int main(void) {
	
	// ?????????????????\???
	int a,b;
	scanf("%d" "%d",&a,&b);

	// ?????¶??????????????????
	if (a > b) {
		
		printf("a > b\n");
		
	} else if (a < b) {
		
		printf("a < b\n");
		
	} else {
		
		printf("a == b\n");
		
	}
	return 0;
}

Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int a[maxn];
int n;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	ll sum=0;
	if(n==2) sum=a[1];
	else
	{
		sum=a[1];
		for(int i=3;i<=n;++i) sum+=a[(i+1)/2];
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	ll ans = 1001001001001001;
	rep(i,n) cin >> v[i];
	for (int i = 0; i < n - k + 1; i++) {
		int l = v[i];
		int r = v[i + k - 1];
		if (0 <= l) {
			ans = min(ans,(ll) r);
		} else if (r <= 0) {
			ans = min(ans, (ll)abs(l));
		} else {
			ll t = (ll)abs(l) + abs(r) + min(abs(l), abs(r));
			ans = min(ans, t);
		}
	}
	cout << ans << endl;
}

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

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

int n, d, frec[110], lay = 0;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> d;
        frec[d] = 1;
    }
    for (int i = 1; i <= 105; i++)
    {
        if (frec[i] > 0)
        {
            lay++;
        }
        
    }
    cout << lay << endl;
    
    cin.get();
    return 0;
}

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

int main(){
    vector <int> intV;

    int N;
    cin >> N;

    intV.reserve(N+1);
    for(int i=0;i<N;i++){
        int temp =0;
        cin>>temp;
        intV.push_back(temp);
    }
    std::sort(intV.begin(), intV.end());

    int retval = intV[N/2] - intV[N/2 -1];

    cout<<retval<<endl;

}



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


int main () {

    int H,W;
    cin >> H >> W;
    string S[H];
    for(int i = 0; i < H; i++) {
        cin >> S[i];
        cout << S[i] << endl << S[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;




signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll ans = 0;
    ll div = 2;   
    ll init = n;
    bool prime = true;
    while(n > 0)
    {
        ll mult = 0;
        if(init < div * div)
            break;
        while(n % div == 0 && n > 0)
        {
            prime = false;
            mult += 1;
            n = n / div;
        }
        div += 1;
        if(mult == 0)
            continue;
        ll sum = mult;
        ll temp = 0;
        if(mult == 1)
        {
            ans += 1;
            continue;
        }
        for(ll j = 1; j <= mult; j++)
        {
            if(sum < j)
                break;
            temp += 1;
            sum -= j;
        }
        ans += temp;
    }
    if(n != 1)
    {
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int a,b,c = 0,d;

	cin >> a >> b;
	if (a > b ||a == b)
	{
		c += a;
		a--;
		c += max(a,b);
	}
	else
	{
		c += b;
		b--;
		c += max(a,b);
	}

	cout << c;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Union_Find_Tree{
	public:
	vi p,r,s,a;
	Union_Find_Tree(int n){
		p=r=a=vi(n);
		s=vi(n,1);
		for(int i=0;i<n;i++) p[i]=i;
	}
	int Par(int x){
		if(p[x]==x) return x;
		return p[x]=Par(p[x]);
	}
	int Size(int x){return s[Par(x)];}
	bool Unite(int x,int y){
		x=Par(x);
		y=Par(y);
		if(x==y) return 0;
		if(r[x]<r[y]){
			p[x]=y;
			s[y]+=s[x];
		}
		else{
			p[y]=x;
			s[x]+=s[y];
			if(r[x]==r[y]) r[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){return Par(x)==Par(y);}
};

int m,h,w;
vip e;

int main(){
	cin>>m>>h>>w;
	int n=h+w;
	for(int i=0;i<m;i++){
		int x,y,w;
		cin>>x>>y>>w;
		e.push_back({w,{x-1,y+h-1}});
	}
	sort(e.rbegin(),e.rend());
	Union_Find_Tree uft(n);
	ll res=0;
	for(auto p:e){
		int u=p.second.first,v=p.second.second;
		u=uft.Par(u),v=uft.Par(v);
		if(u==v&&!uft.a[u]||u!=v&&uft.a[u]+uft.a[v]<2){
			res+=p.first;
			uft.Unite(u,v);
			if(u==v||uft.a[u]||uft.a[v]){
				u=uft.Par(u);
				uft.a[u]=1;
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 4724
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());
		int i = 0;
		int[][] ar;
		ar = new int[2][];
		while (sc.hasNextLine()) {
		    String s = sc.nextLine();
		    String[] sr = s.split(" ");
		    int[] sri = new int[sr.length];
		    for(int j = 0; j<n ; j++) {
			    sri[j] = Integer.parseInt(sr[j]);
		    }
		    ar[i] = sri;
		    i++;
		}

		ArrayList<Integer> arrayList = new ArrayList<Integer>();

		for(int ii = 0; ii < ar[0].length ; ii++) {
			int count = 0;
			for(int j = 0; j<ar[0].length ; j++) {
				if(ii == j) {
					count += ar[0][j] + ar[1][j];
				} else if (ii > j) {
					count += ar[0][j];
				} else if (ii < j) {
					count += ar[1][j];
				}
			}
			arrayList.add(count);
//			System.out.println(count);
		}

		int result = (Collections.max(arrayList)<0)? 0 : Collections.max(arrayList);
		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 22868
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i] >> B[i];
  vector<pair<long long, long long>> C(N);
  for (int i = 0; i < N; ++i)
    C[i] = make_pair(A[i], B[i]);
  sort(C.begin(), C.end());
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    if (C[i].second >= M)
      ans += C[i].first * M, M = 0;
    else
      ans += C[i].first * C[i].second, M -= C[i].second;
    if (M == 0)
      break;
  }
  cout << ans << endl;
}

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

int main(void){
    int n, t, a, ans;
    double diff = pow(10, 6), tmp;
    cin >> n >> t >> a;
    int h[n];
    for (int i=0; i<n; i++) cin >> h[i];
    for (int i=0; i<n; i++){
        tmp = abs((t - h[i] * 0.006) - a);
        if (tmp < diff){
            diff = tmp;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair <int,int> ii ;
typedef vector < ii > vii ;
typedef vector < vii > viii ;
#define rep(i,n)                   for( ll i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++) 
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define db double 
#define fi first
#define se second

//int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
ll knapSack(int W, ll wt[], ll val[], int n) 
{ 
   int i, w; 
   ll K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 

bool comp(pair<ll,ll> &a, pair<ll,ll> &b) {
	return a.se>b.se;
}

int main() {
   ll n,w; cin>>n>>w;
  ll val[n], wt[n];
   rep(i,n) {
   	cin>>wt[i]>>val[i];
   }
   //sort()
   cout<<knapSack(w, wt, val, n);
}

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

int main(){

	int r;
	cin >> r;
	if (r < 1200) cout << "ABC" << endl;
	if (r >= 1200 && r < 2800) cout << "ARC" << endl;
	if (r >= 2800) cout << "AGC" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**7
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    ans = []

    max_a = max(A)
    min_a = min(A)

    if max_a * min_a < 0:
        p = max_a if abs(max_a) > abs(min_a) else min_a
        q = A.index(p)
        for i in range(N):
            ans.append((q+1,i+1))
            A[i] += p
        min_a = min(A)

    if min_a >= 0:
        for i in range(1,N):
            ans.append((i,i+1))
    else:
        for i in range(N,1,-1):
            ans.append((i,i-1))

    print(len(ans))
    for x in ans:
        print(x[0],x[1])

if __name__ == '__main__':
    main()

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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	if (n == 1 && a != b) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = (b - a) * (n - 2) + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],vis[5001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


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

    ll n;
    cin>>n;
    cout<<((modPow(10,n,mod)-modPow(9,n,mod)+mod)%mod-(modPow(9,n,mod)-modPow(8,n,mod)+mod)%mod+mod)%mod<<endl;;

    return 0;
}


Measured memory_bytes: 3584
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

x = sum(A2) + A1[0]
ans = x
for i in range(N-1):
    x += A1[i+1] - A2[i]
    ans = max(ans, x)
print(ans)


Measured memory_bytes: 3060
# include <stdio.h>
int main()
{
	int a[100];
	int n;
	int flag = 1;
	int num = 0;
	scanf("%d",&n);
	for(int i = 0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int j = 0;j<n-1&&flag==1;j++)
	{
		flag = 0;
		for(int i = 0; i<n-1-j;i++)
		{
			if(a[i]>a[i+1])
			{
				num++;
				int tem;
				tem = a[i];
				a[i] = a[i+1];
				a[i+1] =tem;
				flag = 1;
			}
		}
		
	}
	for(int i = 0;i<n-1;i++)
	printf("%d ",a[i]);
	printf("%d",a[n-1]);
	printf("\n%d\n",num);
	
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 2e5+5;
ll n, q;
bool vis[nax];
unordered_map<ll, ll>val;
vector<ll>arr[nax];

void dfs(ll a, ll b){
		vis[b]=1;
		val[b]+=val[a];
		for(auto x:arr[b]){
			if(!vis[x]){
				dfs(b, x);
			}
		}
	}

int main(){
	IOS
	cin >> n >> q;
	for(int i=0;i<n-1;i++){
		ll a, b;
		cin >> a >> b;
		arr[a].push_back(b);
		arr[b].push_back(a);
	}
	while(q--){
		ll node, nilai;
		cin >> node >> nilai;
		val[node]+=nilai;
	}
	for(int i=1;i<=n;i++){
		vis[i]=1;
		for(auto x:arr[i]){
			if(!vis[x]){
				dfs(i, x);
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout << val[i];
		if(i!=n){
			cout << ' ';
		}
	}
	cout << '\n';
}


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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}

int main() {
	int P, Q, R; cin >> P >> Q >> R;
	int ans = min(P+Q, Q+R);
	cout << min(ans, R+P);
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

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

    int ans = count_if(A.begin(), A.end(), [](const int &a) {
        return a % 2 == 0;
    });

    cout << ans << endl;

}












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

const int MAX_N=101;

int n,j;
vector<int> keys(MAX_N);
string s,alp="";

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i=0;i<26;++i) alp+='a'+i;
    for (int i=0;i<26;++i) alp+='A'+i;
    while(cin >> n,n){
        for (int i=0;i<n;++i) cin >> keys[i];
        cin >> s;
        for (int i=0;i<s.size();++i){
            for (j=0;j<52;++j) if (s[i]==alp[j]) break;
            j=(j+52-keys[i%n])%52;
            s[i]=alp[j];
        }
        cout << s << '\n';
    }
}


Measured memory_bytes: 3228
//     nohomo    //
//  Brankonymous //
//     nohomo    //

#include <bits/stdc++.h>

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
#define mod 1000000007
#define random_jbt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int main(){
    int a,b,t;
    cin>>a>>b>>t;
    int ans=0;
    for (int i=a;i<=t;i+=a){
        ans+=b;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};
use std::fmt::{Display, Formatter};
use std::ops::{Add, Sub, Mul, Div};

const INF: i32 = 1001001001;
const LNF: i64 = 1001001001001001001;
const MOD: u32 = 1000000007;

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
  }
  let mc = ModCalc::new(500000);
  let all = (mc.facc[m] / mc.facc[m - n]).pow(2);
  let mut acc = ModInt(0);
  for i in 1..(n + 1) {
    let a = mc.facc[m] / mc.facc[m - i];
    let b = (mc.facc[m - i] / mc.facc[m - n]).pow(2);
    if i % 2 == 1 {
      acc = acc + mc.com(n, i) * a * b;
    } else {
      acc = acc - mc.com(n, i) * a * b;
    }
  }
  let ans = all - acc;
  println!("{}", ans);
}

trait Monoid {
  fn one() -> Self;
}

trait Powerable: Mul<Output = Self> + Monoid + Copy {
  fn pow(self, mut n: u64) -> Self {
    let mut r = Self::one();
    let mut x = self;
    while n > 0 { if n & 1 == 1 { r = r * x; } x = x * x; n >>= 1; }
    r
  }
}

#[derive(Clone, Copy)]
struct ModInt(u32);

impl Monoid for ModInt {
  fn one() -> Self { Self(1) }
}

impl Powerable for ModInt {}

impl Display for ModInt {
  fn fmt<'a>(&self, f: &mut Formatter<'a>) -> std::fmt::Result {
    write!(f, "{}", self.0)
  }
}

impl Add for ModInt {
  type Output = Self;
  fn add(self, rhs: Self) -> Self {
    let x = self.0 + rhs.0;
    Self(if x >= MOD { x - MOD } else { x })
  }
}

impl Sub for ModInt {
  type Output = Self;
  fn sub(self, rhs: Self) -> Self {
    let x = self.0 + MOD - rhs.0;
    Self(if x >= MOD { x - MOD } else { x })
  }
}

impl Mul for ModInt {
  type Output = Self;
  fn mul(self, rhs: Self) -> Self {
    let x = self.0 as u64 * rhs.0 as u64;
    Self(if x >= MOD as u64 { x % MOD as u64 } else { x } as u32)
  }
}

impl Div for ModInt {
  type Output = Self;
  fn div(self, rhs: Self) -> Self {
    self * rhs.inv()
  }
}

impl ModInt {
  fn new(x: u32) -> Self {
    Self(x % MOD)
  }
  fn inv(self) -> Self {
    self.pow((MOD - 2) as u64)
  }
}

struct ModCalc {
  facc: Vec<ModInt>,
  finv: Vec<ModInt>,
}

impl ModCalc {
  fn new(n: usize) -> Self {
    let mut facc = vec![ModInt(0); n + 1];
    let mut finv = vec![ModInt(0); n + 1];
    facc[0] = ModInt::one();
    for i in 0..n {
      facc[i + 1] = facc[i] * ModInt((i + 1) as u32);
    }
    finv[n] = ModInt::one() / facc[n];
    for i in (0..n).rev() {
      finv[i] = finv[i + 1] * ModInt((i + 1) as u32);
    }
    ModCalc { facc, finv }
  }
  fn com(&self, a: usize, b: usize) -> ModInt {
    if b > a {
      return ModInt(0);
    }
    self.facc[a] * self.finv[a - b] * self.finv[b]
  }
}

Measured memory_bytes: 6036
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC\n";
	} else {
		cout << "ABC\n";
	}
 	return 0;
}

Measured memory_bytes: 3628