akhauriyash/Code-Regression huggingface dataset:
class DisjointSetUnion:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n

    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a

    def union(self, a, b):
        a, b = self.find(a), self.find(b)
        if a != b:
            if self.size[a] < self.size[b]:
                a, b = b, a

            self.num_sets -= 1
            self.parent[b] = a
            self.size[a] += self.size[b]

    def set_size(self, a):
        return self.size[self.find(a)]

    def __len__(self):
        return self.num_sets

N, M = map(int, input().split())
UF = DisjointSetUnion(N)
for _ in range(M):
    a, b = map(int, input().split())
    UF.union(a-1,b-1)

best = 0
for i in range(N):
    best = max(best,UF.set_size(i))
print(best)


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);

    ll sum=0;
    vector<ll> a(2*n);
    rep(i,n)
    {
        scanf(" %lld", &a[i]);
        a[i+n]=a[i];
        sum+=a[i];
    }

    vector<ll> presum(2*n+1,0);
    for(int i=1; i<=2*n; ++i) presum[i] = presum[i-1]+a[i-1];

    ll ans=0;
    rep(i,n)
    {
        int x = lower_bound(all(presum),presum[i]+sum/3)-presum.begin();
        int y = lower_bound(all(presum),presum[i]+sum*2/3)-presum.begin();
        for(int j=x-1; j<=x+1; ++j)for(int k=y-1; k<=y+1; ++k)
        {
            if(i<j && j<k && j<i+n && k<i+n)
            {
                ll p = presum[j]-presum[i];
                ll q = presum[k]-presum[j];
                ll r = presum[i+n]-presum[k];

                ans = max(ans, min({p,q,r}));
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    int n, k, w[100000], max =1, sum = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> w[i];
        if (max < w[i]) max = w[i];
        sum += w[i];
    }
    int ave = sum/k;
    int t;
    //tは平均値と要素の最大値のうちの大きいほう
    if(ave < max) t = max;
    else t = ave;
    int P = t;
    while(1){
        //Pは許容量、numは必要なトラック数
        int s = 0, num = 1;
        for(int j = 0; j < n; j++){
            s += w[j];
            //sが許容量を超えたらnumを増やし、sの初期値を積めなかった荷物にする
            if(s > P){
                num++;
                s = w[j];
            }
        }
        // もしトラックの数が足りたら
        if (num <= k){
            cout << P << endl;
            break;
        }
        //足りなければ
        else{
            P++;
        }

    }

}


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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<pair<int, int>> blue(n), red(n);
    rep(i, n) cin >> red.at(i).first >> red.at(i).second;
    rep(i, n) cin >> blue.at(i).first >> blue.at(i).second;
    sort(blue.begin(), blue.end());
    sort(red.begin(), red.end());
    rep(i, n) {
        int f = blue.at(i).first;
        int s = blue.at(i).second;
        int temp = -1, maximum = -1;
        rep(j, n) if(red.at(j).first < f) {
            if(maximum < red.at(j).second && red.at(j).second < s) {
                temp = j;
                maximum = red.at(j).second;
            }
        }
        if(temp != -1) {
            red.at(temp) = make_pair(INT_MAX, INT_MAX);
            ans++;
        }

    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

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

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


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vector<pair<ll, int>> a(n);
  REP(i, n) {
    int _a;
    cin >> _a;
    a[i] = {_a, i + 1};
  }
  sort(a.rbegin(), a.rend());
  vector<vl> dp(n + 1, vl(n + 1, 0));
  FOR(i, 1, n + 1) {
    REP(j, i + 1) {
      if (j <= i - 1)
        chmax(dp[i][j], dp[i - 1][j] + abs(n - (i - 1 - j) - a[i - 1].second) * a[i - 1].first);
      if (j > 0) {
        chmax(dp[i][j], dp[i - 1][j - 1] + (ll)abs(j - a[i - 1].second) * a[i - 1].first);
      }
    }
  }
  ll ans = 0;
  REP(i, n + 1) { chmax(ans, dp[n][i]); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34600
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


int n, x, y;
map<int,int> m;

int fun(int a, int b){
    if(b <= x || a >= y)return (b - a);
    if(a >= x && b <= y)return min((b - a),(y - b + a - x + 1));
    else{
        if(a <= x && b >= y)return (x - a + b - y + 1);
        else if(a <= x && b <= y)return min((b - a),(x - a + 1 + y - b));
        else if(a >= x && b >= y)return min((b - a),(b - y + 1 + a - x));
    }
    return (b - a);
}

void solve(){
    cin>>n>>x>>y;
    for(int i = 1; i < n; i++)for(int j = i + 1; j <= n; j++)m[fun(i,j)]++;
    for(int i = 1; i<= n - 1; i++)cout<<m[i]<<endl;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

class DisjSet { 
    int *rank, *parent, n; 
  
public: 
    // Constructor to create and 
    // initialize sets of n items 
    DisjSet(int n) 
    { 
        rank = new int[n]; 
        parent = new int[n]; 
        this->n = n; 
        makeSet(); 
    } 
  
    // Creates n single item sets 
    void makeSet() 
    { 
        for (int i = 0; i < n; i++) { 
            parent[i] = i; 
        } 
    } 
  
    // Finds set of given item x 
    int find(int x) 
    { 
        // Finds the representative of the set 
        // that x is an element of 
        if (parent[x] != x) { 
  
            // if x is not the parent of itself 
            // Then x is not the representative of 
            // his set, 
            parent[x] = find(parent[x]); 
  
            // so we recursively call Find on its parent 
            // and move i's node directly under the 
            // representative of this set 
        } 
  
        return parent[x]; 
    } 
  
    // Do union of two sets represented 
    // by x and y. 
    void Union(int x, int y) 
    { 
        // Find current sets of x and y 
        int xset = find(x); 
        int yset = find(y); 
  
        // If they are already in same set 
        if (xset == yset) 
            return; 
  
        // Put smaller ranked item under 
        // bigger ranked item if ranks are 
        // different 
        if (rank[xset] < rank[yset]) { 
            parent[xset] = yset; 
        } 
        else if (rank[xset] > rank[yset]) { 
            parent[yset] = xset; 
        } 
  
        // If ranks are same, then increment 
        // rank. 
        else { 
            parent[yset] = xset; 
            rank[xset] = rank[xset] + 1; 
        } 
    } 
    ll ans(){
        unordered_map<int, int> hMap;
        for(int i=1; i<this->n; ++i){
            int parent = find(i);
            if(hMap.find(parent)!=hMap.end()) hMap[parent]++;
            else hMap[parent] = 1;
        }
        ll a = INT_MIN;
        for(auto x: hMap){
            a = max((int)a, (int)x.second);
        }
        return a;
    }
}; 
  

int main(){
    FASTIO
    int testCases = 1;
    // cin>>testCases;
    while(testCases--){
        ll N, M; cin>>N>>M;
        DisjSet ds(N+1);
        for(int i=0; i<M; ++i){
            int a, b; cin>>a>>b;
            ds.Union(a, b);
        }
        cout<<ds.ans()<<endl;
    }
}

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

using namespace std;
 
int main(){
    int r;
    cin >> r;
    if(r < 1200)
        cout << "ABC" << endl;
    else if( r < 2800)
        cout << "ARC" << endl;
    else 
        cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int S,h,m,s,i;
    scanf("%d",&S);
    h=S/3600;
    i=S%3600;
    m=i/60;
    s=i%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2120
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;

  int ans = n * n * n;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <string>
#include <iomanip>
using namespace std;
#define int long long
int mas[1000000];
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	int t;
	cin >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> mas[i];
	}
	int ans = 0;
	int end = mas[1] + t - 1;
	for (int i = 2; i <= n; ++i) {
		if (end >= mas[i] - 1) {
			ans += mas[i] - mas[i - 1];
		}
		else {
			ans += end - mas[i - 1] + 1;
		}
		end = mas[i] + t - 1;
	}
	ans += end - mas[n] + 1;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;




#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);

ll N, A[100005], B[100005], C[100005];
ll best[100005][3];
int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		cin >> N;

		F0R(i, N) cin >> A[i] >> B[i] >> C[i];

		best[1][0] = A[0];
		best[1][1] = B[0];
		best[1][2] = C[0];
		for (int i = 2; i <= N; i++) {
				best[i][0] = MAX(best[i - 1][1], best[i - 1][2]) + A[i - 1];
				best[i][1] = MAX(best[i - 1][0], best[i - 1][2]) + B[i - 1];
				best[i][2] = MAX(best[i - 1][1], best[i - 1][0]) + C[i - 1];
		}
		cout << MAX(best[N][0], MAX(best[N][1], best[N][2])) << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define L long long

using namespace std;

L n,m,k;


void E(){
	puts("Yes");
	exit(0);
}

int main()
{
	scanf("%lld %lld %lld",&n,&m,&k);
	L i,j;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i*j+(n-i)*(m-j)==k) E();
		}
	}
	puts("No");
}

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

int main()
{
    size_t k;
    string s;

    cin >> k;
    cin >> s;

    if (s.length() <= k) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, 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 = 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):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, 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())
N, M = map(int,input().split())
uf = UnionFind(N)
B = []
for k in range(M):
    B.append(list(map(int,input().split())))
B = B[::-1]

ans = []
a = N*(N-1)//2
for e in B:
    ans.append(a)
    if uf.same(e[0]-1,e[1]-1) == False:
        s, t = uf.size(e[0]-1), uf.size(e[1]-1)
        a -= (s+t)*(s+t-1)//2 - s*(s-1)//2 - t*(t-1)//2
        uf.union(e[0]-1,e[1]-1)
    else:
        pass

print(*ans[::-1], sep = "\n")


Measured memory_bytes: 37164
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <sstream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iterator>
#include <stdio.h>
#include <memory.h>

using namespace std;

//#define DEBUG_MODE

#ifdef DEBUG_MODE
#include <fstream>
//#include "prettyprint.hpp"
#endif // DEBUG_MODE

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<PII> VII;

#define A1D(T)              vector<T>
#define A2D(T)              vector<vector<T> >
#define sz(x)               ((int)(x).size())
#define maxof(x)            numeric_limits<x>::max()
#define minof(x)            numeric_limits<x>::min()
#define lowbit(x)           ((x)&-(x))
#define log2(x)             (log((double)x)/log(2.0))
#define _FORu(T,i,l,h,k)    for(T i=(l);i<=(h);i+=(k))
#define _FORd(T,i,h,l,k)    for(T i=(h);i>=(l);i-=(k))
#define FOR(i,n)            _FORu(int,i,0,n,1)
#define FORu1(i,l,h)        _FORu(int,i,l,h,1)
#define FORuk(i,l,h,k)      _FORu(int,i,l,h,k)
#define FORd1(i,h,l)        _FORd(int,i,h,l,1)
#define FORdk(i,l,h,k)      _FORd(int,i,h,l,k)
#define FOREACH(e,s)        for(__typeof__((s).begin()) e=(s).begin();e!=(s).end();++e)
#define IO_OPT              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef DEBUG_MODE
#define debug(...)          fprintf(stderr, __VA_ARGS__)
#define DEBUG(x)            cerr << '>' << #x << ':' << x << endl << flush;
#else
#define debug(...)
#define DEBUG(x)
#endif // DEBUG_MODE

const double PI      = acos(-1.0);
const double E       = exp(1.0);
const double EPS     = 1e-8;
const int HALF_INF   = 0x3f3f3f3f;

class Solver
{
public:
    void Solve()
    {
        int n;
        scanf("%d", &n);
        printf("%d", n * 800 - (n / 15) * 200);
    }
};

int main()
{
#ifdef DEBUG_MODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w+", stdout);
#endif // DEBUG_MODE

    Solver * solver = new Solver();
    solver->Solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int i,c,n;
 c=0;
 cin >> n;
 int a[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 for(i=1;i<(n-1);i++)
 {
  if((a[i]<a[i-1] && a[i]>a[i+1]) || (a[i]>a[i-1] && a[i]<a[i+1]))
  c++;
 }
 cout << c;
 return 0;
}

Measured memory_bytes: 256
require 'set'

n, k = gets.split.map(&:to_i)
as = [0] + gets.split.map(&:to_i)

visited = Set.new
current = 1

c1 = 0

# find loop
while !visited.include?(current)
  visited << current
  current = as[current]
  c1 += 1
end

endpoint = current
cycle = 0

while true
  current = as[current]
  cycle += 1

  break if current == endpoint
end

travel = c1 - cycle


l = 0
if k <= travel
  l = k
else
  l = (k - travel) % cycle + travel
end

current = 1
l.times do |i|
  current = as[current]
end

p current


Measured memory_bytes: 38512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s:chars,
        p:chars,
        q:chars,
    }
    print!("A");
    print!("{}", (p[0].to_string()).to_uppercase());
    print!("C");
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define iter(name) decltype(name)::iterator
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}



ll A;
string S;

void input() {
	cin>>A>>S;
}

void solve() {
	if(S.length()<=A) {
		cout<<S<<endl;
		return;
	}

	cout<<string(S.begin(),S.begin()+A)<<"..."<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


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

long long dp[3010];

int main(){
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	dp[0] = 1;
	for (int i = r; i <= n; i++){
		dp[i] += dp[i - r];
	}
	for (int i = b; i <= n; i++){
		dp[i] += dp[i - b];
	}
	for (int i = g; i <= n; i++){
		dp[i] += dp[i - g];
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 256
/*
  B - Checkpoints
  <http://abc057.contest.atcoder.jp/tasks/abc057_b>
  [Tips]
  ・typedef long int int32_tとするとstdlib.hに怒られる。
  ・stdintという環境によらず同じ大きさの整数型を扱うことができるヘッダファイルがある。
*/

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int32_t DiffAbs( int32_t x, int32_t y ){
  int32_t ret = x - y;
  if( ret < 0 ){
    ret = -ret;
  }
  return ret;
}

int32_t ManhattanDistance( int32_t x0, int32_t y0, int32_t x1, int32_t y1 ){
  return DiffAbs(x0,x1) + DiffAbs(y0,y1);
}

int main(int argc, char const *argv[]) {

  int N,M;
  int32_t *a,*b,*c,*d;
  int i,j;
  int minId;
  int32_t tmpDist,minDist;

  scanf("%d %d", &N,&M);
  a = (int32_t *)calloc(N, sizeof(int32_t));
  b = (int32_t *)calloc(N, sizeof(int32_t));
  c = (int32_t *)calloc(M, sizeof(int32_t));
  d = (int32_t *)calloc(M, sizeof(int32_t));

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

  for( i=0; i<N; i++ ){
    minDist = INT32_MAX;
    minId = 0;
    for( j=0; j<M; j++ ){
      tmpDist = ManhattanDistance( a[i], b[i], c[j], d[j] );
      if( tmpDist < minDist ){
        minDist = tmpDist;
        minId = j+1;
      }
    }
    printf("%d\n", minId);
  }

  free(a);
  free(b);
  free(c);
  free(d);

  return 0;
}


Measured memory_bytes: 128
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
#include <cstdio>
#include <queue>
 
using namespace std;
 
int main(){
 int N;
 int M;
 cin >> N >> M;
 int A[N];
 int i;
 int tmp;
priority_queue<int> q;
 for(i=0;i<N;++i){
   cin >> A[i];
   q.push(A[i]);}

for(i=0;i<M;++i){
    tmp = q.top()/2;
    q.pop();
    q.push(tmp);
}
 long long int count = 0;
 while(!q.empty()){
    count += q.top();
    q.pop();
 }
 cout << count << endl;
  return 0;
}

Measured memory_bytes: 1148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    static double dp[21][200000];
    rep(i,21)rep(j,200000)dp[i][j]=INF;
    dp[0][1] = 0;
    
    rep(item,n){
        for(int val = 1;val<200000;val++){
            for(int k=1;val*k<200000;k++){
                dp[item+1][val*k] = min(dp[item+1][val*k], max(dp[item][val],(double)abs(val*k-v[item])/v[item]));
            }
        }
    }
    double ans = INF;
    rep(i,200000)ans = min(dp[n][i],ans);
    
    printf("%.20lf\n",ans);
}



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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ll long long

int main() {
    int a, b;
    cin >> a >> b;
    if ( a >= 10 || b >= 10 ) {
        cout << -1 << endl;
    } else {
        cout << a*b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
A = []
for _ in range(H):
    a = input()
    if "#" in a:
        A.append(a)
A_ = ["" for _ in range(len(A))]
for x in range(W):
    f = False
    for a in A:
        if a[x] == "#":
            f = True
            break
    if f:
        for y, a in enumerate(A):
            A_[y] += a[x]
for a in A_:
    print(a)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int d;cin >> d;
    int c[26];
    rep(i,26)cin >> c[i];
    rep(i,d){
        P mx = P(0,0);
        rep(j,26){
            int a;cin >> a ;
            mx = max(mx,P(a,j));
        }
        
        cout << mx.second +1 << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3612
import math

a, b, x = map(int, input().split())

if x >= a*a*b/2:
    l = 2*(b - (x/a**2))
    theta = math.atan(l/a)
else:
    l = (2*x) / (a*b)
    theta = math.atan(b/l)

print(math.degrees(theta))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define N 500010
#define lowbit(x) x&-x
using namespace std;
int a[N],pos[N],ans[N],fwt[N];
vector<pair<int,int> > v[N];
void update(int x,int p)
{
	for(int i=x;i<N;i+=lowbit(i)) fwt[i]+=p;
}
int sum(int x)
{
	int ss=0;
	for(int i=x;i>0;i-=lowbit(i)) ss+=fwt[i];
	return ss;
}
int main()
{
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=q;i++)
	{
		int l,r;
		cin>>l>>r;
		v[r].push_back({l,i});
	}
	memset(pos,-1,sizeof(pos));
	for(int i=1;i<=n;i++)
	{
		if(pos[a[i]]==-1)
		{
			update(i,1);
			pos[a[i]]=i;
		}
		else
		{
			update(pos[a[i]],-1);
			update(i,1);
			pos[a[i]]=i;
		}
		for(int j=0;j<v[i].size();j++) ans[v[i][j].second]=sum(i)-sum(v[i][j].first-1);
	}
	for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 33140
def examA():
    R = I()
    if R<1200:
        ans = "ABC"
    elif R<2800:
        ans = "ARC"
    else:
        ans = "AGC"
    print(ans)
    return

def examB():
    return

def examC():
    return

def examD():
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()


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

int main(){
	int n,k;
	cin >> n >> k;
	int mask = 0;
	for(int i = 0; i < k; i ++) {
		int p;
		cin >> p;
		mask |= (1 << p);
	}

	for(int i = n; ; i ++) {
		int t = i, m = 0;
		while(t) m |= (1 << (t % 10)), t /= 10;
		if((mask & m) == 0) {
			cout << i << endl;
			break;
		}
	}

}


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

typedef long long ll;

ll comb2(ll n) {
    if (n < 2) return 0;
    else if ((n & 1) == 0) return n / 2 * (n - 1);
    else return (n - 1) / 2 * n;
}

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

    int N, M; cin >> N >> M;
    map<ll, ll> sum_modM_idx;
    
    int sum_modM = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        sum_modM += a;
        sum_modM %= M;
        if (sum_modM_idx.count(sum_modM) <= 0) sum_modM_idx[sum_modM] = 0;
        ++sum_modM_idx[sum_modM];
    }

    ll ans = sum_modM_idx.count(0) > 0 ? sum_modM_idx[0] : 0;
    for (auto it : sum_modM_idx) {
        ans += comb2(it.second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(lis[int(input()) - 1])

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

int main() {
	char b;
	cin >> b;
  
	if(b=='A'){
		cout << 'T';
	}
	if(b=='T'){
		cout << 'A';
	}
	if(b=='C'){
		cout << 'G';
	}
	if(b=='G'){
		cout << 'C';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
ll ans=0,v[200005];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k;
    memset(v,0,sizeof(v));
    cin>>n>>k;
    for (int i=1;i<=n;i++) {
    	v[i%k]++;
    }
    ans = (v[0]*v[0]*v[0]);
    if (k%2==0) {
        v[0] = v[k/2];
  		ans += (v[0]*v[0]*v[0]);
    }
  	cout<<ans;
}


Measured memory_bytes: 1792
import java.awt.*;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int l = scanner.nextInt();
        UnionFind road = new UnionFind(n);
        UnionFind rail = new UnionFind(n);
        for (int i = 0; i < k; i++) {
            road.unite(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }
        for (int i = 0; i < l; i++) {
            rail.unite(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }

        Point[] keys = new Point[n];
        Map<Point, Integer> count = new HashMap<>();
        for (int i = 0; i < n; i++) {
            keys[i] = new Point(road.root(i), rail.root(i));
            count.compute(keys[i], (key, value) -> value == null ? 1 : value + 1);
        }

        System.out.println(Arrays.stream(keys).map(count::get).map(String::valueOf).collect(Collectors.joining(" ")));
    }

    static class UnionFind {
        private int[] parent;

        public UnionFind(int n) {
            parent = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
            }
        }

        public int root(int n) {
            while (parent[n] != n) {
                n = parent[n] = parent[parent[n]];
            }
            return n;
        }

        public void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
                parent[x] = y;
            }
        }

        public boolean same(int x, int y) {
            return root(x) == root(y);
        }
    }
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

typedef unsigned long long ll;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll lcm(ll const& a, ll const& b) {
	return a * (b / __gcd(a, b));
}

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	ll n, m; cin >> n >> m;
	vector<ll> a(n);

	ll l = 1;
	for (ll& i : a) {
		cin >> i;
		i /= 2;
		l = lcm(l, i);
		if (l > m) break;
	}

	if (l <= m) for (ll& i : a) if ((l/i)%2 == 0) {
		cout << 0 << '\n';
		return 0;
	}

	ll lo = 0, hi = m, mi;
	while(lo < hi) {
		mi = (lo + hi + 1) / 2;
		if (l + 2ull * l * mi <= m) lo = mi;
		else hi = mi-1;
	}

	cout << ((l <= m) + lo) << '\n';

	return 0;
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	map<string , int> mp;
	string s;
	for(int i=0;i<n;i++){
		cin >> s;
		mp[s]++;
	}
	// keisan
	int sum=0;
	for(auto x:mp){
		if(x.second > 0){
			sum++;
		}
	}
	cout << sum;
	// syutsuryoku
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;

vector <int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int32_t main()
{
    int k; cin >> k; cout << v[k-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//データ型名 配列名[要素数] = {要素1, 要素2, …...};
int main (){
 string s;
 cin>>s;
cout <<s.at(0)<<s.size()-2<<s.at(s.size()-1)<<endl;
}


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

int dp[100010][3];

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3, 0));
    rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(k==j) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    int ans = 0;
    rep(i,3) ans = max(dp[n][i], ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    cin>>N;

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(N==i*j){
                cout <<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

    return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Algo
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine();
            var ans = 0L;
            for (var i = 1; i < s?.Length; i++)
            {
                if (s[i - 1] != s[i]) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
	int a[5];
  	for(int i=0;i<5;i++){
    	cin>>a[i];
    }
  for(int i=0;i<5;i++){
  	if(a[i]==0){
    	cout<<i+1<<endl;
      break;
    }
 }
}
  

Measured memory_bytes: 3528
#include<iostream>
using namespace std;
int X,Y,S;
int tax(int a,int b)
{
    return b*(100+a)/100;
}
int solve()
{
    int maximum=0;
    for(int i=1;i<S;i++)
        for(int j=1;j<S;j++)
            if(tax(X,i)+tax(X,j)==S)
                maximum=max(maximum,tax(Y,i)+tax(Y,j));
    return maximum;
}
int main()
{
    while(cin>>X>>Y>>S&&X>0)
        cout<<solve()<<endl;
}


Measured memory_bytes: 3092
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]

def find_element(k):
    global h,w,a
    for i in range(h):
        for j in range(w):
            if a[i][j]==k:
                return (i,j)

def make_distance(S,T):
    return abs(S[0]-T[0])+abs(S[1]-T[1])

x1=[]
x2=[]
for i in range(1,d+1):
    l=(h*w-i)//d
    x1.append([0]*(l+1))
    x2.append([[0,0]for i in range(l+1)])

for i in range(h):
    for j in range(w):
        p=a[i][j]%d
        if p==0:
            p=d-1
        else:
            p-=1
        l=(a[i][j]-(p+1))//d
        x2[p][l]=[i,j]


for i in range(1,d+1):
    l=len(x1[i-1])
    for j in range(l-1):
        x1[i-1][j+1]=x1[i-1][j]+make_distance(x2[i-1][j],x2[i-1][j+1])

q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    p=l%d
    if p==0:
        v1=l//d-1
        v2=r//d-1
        print(x1[d-1][v2]-x1[d-1][v1])
    else:
        v1=l//d
        v2=r//d
        print(x1[p-1][v2]-x1[p-1][v1])
#print(x)


Measured memory_bytes: 35664
import re
import math

if __name__ == '__main__':

    a, b, c, x, y = [int(n) for n in input().split()]

    ans = 0
    if 2*c <= (a+b):
        if (x > y and a >= c*2) or (x < y and b >= c*2):
            ans = max(x, y)*2*c
        else:
            ans += min(x, y)*2*c
            ans += (x-min(x, y))*a
            ans += (y-min(x, y))*b
        
    else:
        ans = x*a + y*b

    print(ans)


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int x,y,z;
ll qz[SZ],hz[SZ];
struct od {int a,b,c;}s[SZ];
bool operator < (od x,od y) {return x.a-x.b>y.a-y.b;}
int main()
{
	scanf("%d%d%d",&x,&y,&z); ll ans=0;
	for(int i=1;i<=x+y+z;++i)
		scanf("%d%d%d",&s[i].a,&s[i].b,&s[i].c),
		ans+=s[i].c,s[i].b-=s[i].c,s[i].a-=s[i].c,s[i].c=0;
	sort(s+1,s+x+y+z+1);
	{
	priority_queue<int,vector<int>,greater<int> > pq;
	ll su=0;
	for(int i=1;i<=x+y+z;++i)
	{
		pq.push(s[i].a); su+=s[i].a;
		while(pq.size()>x)
		{ll r=pq.top(); pq.pop(); su-=r;}
		qz[i]=su;
	}
	}
	{
	priority_queue<int,vector<int>,greater<int> > pq;
	ll su=0;
	for(int i=x+y+z;i>=1;--i)
	{
		pq.push(s[i].b); su+=s[i].b;
		while(pq.size()>y)
		{ll r=pq.top(); pq.pop(); su-=r;}
		hz[i]=su;
	}
	}
	ll aa=-1e18;
	for(int i=1;i<=x+y+z;++i)
		if(x<=i&&y<=x+y+z-i)
			aa=max(aa,qz[i]+hz[i+1]);
	printf("%lld\n",aa+ans);
}

Measured memory_bytes: 8316
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    int A, Z;
    rep(i, S.size()) {
        if(S.at(i) == 'A') {
            A = i;
            break;
        }
    }
    for(int i = S.size() - 1; i >= 0; i--) {
        if(S.at(i) == 'Z') {
            Z = i;
            break;
        }
    }

    cout << Z - A + 1 << endl;
}

Measured memory_bytes: 640
import itertools
 
N,M,X = map(int, input().split())
C_A = []
for _ in range(N):
    C_A.append(list(map(int, input().split())))
# print(C_A)
 
min_price = 10**5 * 12 
rikaido = [0 for _ in range(M)]
possible = 0
for i in itertools.product([0,1], repeat=N):
    price_rikaido = [sum(C_A[j][k]*i[j] for j in range(N)) for k in range(M+1)]
    # print(i)
    # print(price_rikaido)
    flag = 1
    for l in range(M):
        if price_rikaido[l+1] <X:
            flag = 0
            break
    if flag and (min_price >= price_rikaido[0]):
        min_price = price_rikaido[0]
        possible = 1
        
if possible:
    print(min_price)
else:
    print(-1)


Measured memory_bytes: 9240
n, m, v, p = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

ok = p - 1
ng = n

while abs(ok - ng) > 1:
  mid = (ok + ng) // 2
  if A[mid] + m < A[p - 1]:
    ng = mid
    continue

  used = m * p
  for i in range(p - 1, n):
    if i == mid:
      continue

    used += min(m, max(0, A[mid] + m - A[i]))

  if used >= m * v:
    ok = mid
  else:
    ng = mid

print(ok + 1)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

#define SI 2002
#define ADD(X,Y) (X) = ((X)+(Y))%MOD

int n, k;
ll dp[SI][SI];

int main(){
    cin >> n >> k;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 2; i <= n; i++) dp[1][i] = 1;
    for(int i = 2; i <= k-1; i++){
        ll sum = 0;
        for(int j = n; j >= 2; j--){
            if(i <= n-j+1) ADD(dp[i][j],dp[i-1][j]);
            ADD(dp[i][j],sum);
            ADD(sum,dp[i-1][j]);
        }
    }
    ll ans = 0;
    if(k == 1){
        ans = 1;
    } else{
        for(int i = 2; i <= n; i++) ADD(ans,dp[k-1][i]);
    }
    rep(i,n-k-1) ADD(ans,ans);
    cout << ans << endl;
}



Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(void){
    ll n,x;
    cin>>n>>x;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)a[i]=abs(a[i]-x);
    ll k=gcd(a[0],a[1]);
    for(int i=2;i<n;i++){
        k=gcd(k,a[i]);
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int inv=0;
		for(int i=0;i<n;i++) {
			int x=sc.nextInt()-1;
			if(x!=i)
				inv++;
		}
		out.println(inv==0 || inv==2?"YES":"NO");
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    if (c<(a+b)){
        cout << "No" << endl;
        return 0;
    }
    if (4*a*b < (c-a-b)*(c-a-b)){

        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d %d %d" (fun a b c k ->
    let calc a b =
        let rec loop b i =
            if a < b then i else loop (b * 2) (i + 1)
        in
        loop b 0
    in
    let m1 = calc a b in
    let m2 = calc (b lsl m1) c in
    print_endline @@ if m1 + m2 <= k then "Yes" else "No"
)

Measured memory_bytes: 3668
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		for(int i=0; i<n; i++)
		{
			double[] x = new double[2];
			double[] y = new double[2];
			double[] r = new double[2];
			
			for(int j=0; j<2; j++)
			{
				x[j] = scanner.nextDouble();
				y[j] = scanner.nextDouble();
				r[j] = scanner.nextDouble();
			}
			
			int result = 0;
			double d = Math.sqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]));
			if(d < r[0]-r[1])
			{
				result = 2;
			}
			else if(d < r[1]-r[0])
			{
				result = -2;
			}
			else if(d <= r[0]+r[1])
			{
				result = 1;
			}
			
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 28056
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()
x = y = z = 0
if a%2:
    x = a
    a += 1
if b%2 == 0:
    y = b
    b -= 1
if (b-a+1) % 4:
    z = 1
print(x^y^z)

Measured memory_bytes: 64492