jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()

int main(){ 
  int a,b,c,x,y;
  ll ans=0;
  cin >> a>> b>>c>>x>>y;
  if(a+b<2*c){
    cout<<a*x+b*y<<endl;
    return 0;
  }else{
    int tmp=min(x,y);
    x-=tmp;y-=tmp;
    ans+=c*tmp*2;

    if(x>0 && a>2*c){
      ans+=x*c*2;
      x=0;
    }
    else if(y>0 && b>2*c){
      ans+=y*c*2;
      y=0;
    }
    else ans+=a*x+b*y;
    cout << ans <<endl;
  }

  return 0;
}
//  [c]
#include<stdio.h>
int main(){
  char s[128];
  scanf("%s",s);
  int count=0;
  int i;
  for(i=0;i<3;i++){
    if(s[i]=='o'){
      count++;
    }
  }
  printf("%d",700+count*100);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	char topping[3];
	int sum = 700;
	int i;

	scanf("%s", topping);

	for(i = 0; i < 3; i++){
		if(topping[i] == 'o'){
			sum += 100;
		}
	}

	printf("%d", sum);

	return 0;
}
//  [c]
#include <stdio.h>

int main(void){
	int n=700;
	char a[10];
	scanf("%s", &a);
	for(int i=0; i<3; i++){
		if(a[i]=='o') n = n + 100;
	}
	printf("%d", n);
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
    char s[3];
    gets(s);
    int len,i,cnt=0;
    len = strlen(s);
    for(i=0;i<len;i++){
        if(s[i]=='o')
            cnt++;
    }
    printf("%d\n",700+cnt*100);
    return 0;

}
//  [c]
#include<stdio.h>
int main(void){
  
  int i;
  char c[3];
  int ct=0;
  
  
  for(i=0;i<3;i++){
    scanf("%c",&c[i]);
  }
  
  for(i=0;i<3;i++){
    if(c[i]=='o')ct++;
  }
  
  printf("%d\n",700+100*ct);
  
  return 0;
}#include<stdio.h>
int main(void){
  
  int i;
  char c[3];
  int ct=0;
  
  
  for(i=0;i<3;i++){
    scanf("%c",&c[i]);
  }
  
  for(i=0;i<3;i++){
    if(c[i]=='o')ct++;
  }
  
  printf("%d\n",700+100*ct);
  
  return 0;
}#include<stdio.h>
int main(void){
  
  int i;
  char c[3];
  int ct=0;
  
  
  for(i=0;i<3;i++){
    scanf("%c",&c[i]);
  }
  
  for(i=0;i<3;i++){
    if(c[i]=='o')ct++;
  }
  
  printf("%d\n",700+100*ct);
  
  return 0;
}#include<stdio.h>
int main(void){
  
  int i;
  char c[3];
  int ct=0;
  
  
  for(i=0;i<3;i++){
    scanf("%c",&c[i]);
  }
  
  for(i=0;i<3;i++){
    if(c[i]=='o')ct++;
  }
  
  printf("%d\n",700+100*ct);
  
  return 0;
}
//  [javascript]
function Main(input) {
    var cnt = 0;
    for(var i = 0 ; i < 3 ; ++i) {
        if (input[i] === 'o') cnt += 100;
    }

    console.log(700 + cnt);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main (s) {
var res=0;
for(var i=0;i<s.length;i++)if(s[i]=='o')res++;
console.log(700+res*100);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict';

function Main(INPUT) {
    const S = INPUT.split("");
    let y = 700;
    for (let i = 0; i < S.length; i++) {
        y += S[i] == "o" ? 100 : 0;
    }
    console.log(y);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input){
  const a = input.trim().split('');
  let ans = 700;
  a.forEach(function(a){
    if(a=='o'){
      ans+=100;
    }
  });
  console.log(700+ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input){
  const a = input.trim().split('');
  let count = 0;
  a.forEach(function(a){
    if(a[i]=='o'){
      count+=100;
    }
  });
  //let cnt = parseInt(count, 10);
  console.log(700+count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input){
  const a = input.trim();
  let count = 0;
  for(let i=0; i<3; i++){
    if(a[i]=='o'){
      c+=100;
    }
  }
  console.log(700+c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
    . "fmt"
    "strings"
)

func main() {
    var s string
    Scanf("%s", &s)

    ans := 700
    sa := strings.Split(s, "")
    for _, v := range sa {
        if v == "o" {
            ans += 100
        }
    }

    Println(ans)
 }
//  [go]
package main

import (
        "fmt"
)

func main() {
        var s string
        fmt.Scan(&s)
        ans := 700
        for _, s := range s {
                if string(s) == "o" {
                        ans += 100
                }
        }
        fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a string
	fmt.Scan(&a)
	r := 700 + strings.Count(a, "o")*100
	fmt.Println(r)
}
//  [go]
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := 700

	for _, v := range s {
		if v == '○' {
			ans += 100
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	s:=nextString()
        for i:=0; i<3; i++ {
ans :=700
    if s[i] =='o'{
ans+=100
}
    }
fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	s:=nextString()
        for i:=1; i<4; i++ {
ans :=700
    if s[i] =='o'{
and+=100
}
    }
fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}
//  [ruby]
a=gets.chomp.split("").map { |e|
if e == "o"
  e = 1.to_i
else
  e = 0.to_i
end   }.inject(:+)

puts 700+100*a
//  [ruby]
options = gets.chomp.split("").map(&:to_s)
i = 0
options.each do |o|
  if o == "o"
    i += 1
  end
end
puts (700 + 100*i)
//  [ruby]
S = gets.chomp
ans = 700
for i in 0..2
    if S[i] == 'o'
        ans += 100
    end
end
puts ans
//  [ruby]
s1,s2,s3 = gets.chomp.split("").map(&:to_i);
"o" == 100
"x" == 0

s = s1 + s2 + s3
puts s + 700
//  [ruby]
s1,s2,s3 = gets.chomp.split("").map(&:to_i);
"o" == 100
"x" == 0

puts s1 + s2 + s3 + 700
//  [ruby]
S = gets.chomp
p S
pos = S.count('o')
p pos
if pos == 1
  p "800円"
elsif pos == 2
  p "900円"
elsif pos == 3
  p "1000円"
else
  p "700円"
end
//  [rust]
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        s: chars,
    }

    println!(
        "{}",
        700 + s.into_iter().filter(|&x| x == 'o').count() * 100
    );
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut ramen = 700;
	for i in 0..3 {
		if s[i] == 'o' {
			ramen += 100;
		}
	}
	println!("{}", ramen);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    println!("{}", 700 + 100 * s.iter().filter(|&x| *x == 'o').count())
}
//  [rust]
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();

    println!("{}", s.into_iter().filter(|x| *x == 'o').count() + 700);
}
//  [rust]
use std::io::*;
use std::str::FromStr;
use std::char;

fn main() {
    let a: String = read::<char>();

}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
//  [swift]
//var i=700;readLine()!.characters.forEach{String($0)=="o" ?i+=100:i+=0};print(i)
var i=700
readLine()!.characters.forEach {
  	if String($0) == "o" {
      	i+=100
    } else {
      	i+=0
    }
}
print(i)
//  [swift]
var i=700;readLine()!.characters.forEach{String($0)=="o" ?(i+=100):(i+=0)};print(i)
//  [swift]
var i=700;readLine()!.characters.forEach{String($0)=="o" ?i+=100 :i+=0};print(i)
//  [swift]
var i=700;readLine()!.characters.forEach{String($0)=="o" ?i+=100:i+=0};print(i)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let a=[ssin(),ssin(),ssin()]
  let ans=700;
  if(a[0]=='o') ans+=100
  if(a[1]=='o') ans+=100
  if(a[2]=='o') ans+=100
  out(ans)
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.split('\n')[0].split('')


let len = 0

len += s.filter(e=>e==='o').length

console.log(len * 100 + 700)
//  [typescript]
const log = console.log;

// ----

function Main(input: string): void {
  const toppingCount = (input.match(/o/g) || []).length;

  log(700 + 100 * toppingCount);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const main = (input) => {
  console.log(input.split('x').length -1 + 700);
}
main (require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});
reader.on("close", function() {
  var s = lines[0];
  console.log(s);
});
//  [python]
N = int(input().rstrip())
N_2=pow(N,2)
print(N*(1+N+N_2))
//  [python]
def main():
    N = int(input())
    print(N + N * N + N * N * N)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok
//  [python]
#!/usr/bin/env python3

a = int(input())

print(a+a**2+a**3)
//  [python]
a = int(input())
a = int(a ** 3)
print(a)
//  [python]
a = int(input())
)
a = int(a ** 3)
print(a)
//  [python]
a = int(input("Enter an integer : "))
s=a**2
t=a**3
print(a+s+t)
//  [java]

import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		System.out.println(n + n * n + n * n * n);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] a = new int[abc];
			for (int i = 0; i < abc; i++)
				a[i] = nextInt();
			return a;
		}
	}
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        int x = scan.nextInt();
        
        System.out.println(x + x*x + Math.pow(x,3));
    }
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        int x = scan.nextInt();
        
        System.out.printlf(x + x*x + Math.pow(x,3));
    }
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        System.out.println(a + Math.pow(a, 2) + Math.pow(a, 3));
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */



void solve()
{
    ll i, j, n, m;

    sl(n);

    ll ans = n + n * n + n * n * n;


    cout << ans << endl;

}


int32_t main()
{

    IOS;
    cin.tie(NULL);

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

    int T = 1;



    wh(T)
    {

        solve();

    }
}
//  [cpp]
#include <iostream>
using namespace std;

int a;

int main() {
    /*Jovando Haryo K
    X2*/
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll> 

vector<ll> S(10000006, 0);
vector<ll> A(10000006, 0);

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

	

	ll n;
	cin>>n;
	
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll k=n/i;
		ans+=i*k*(k+1)>>1;
	}
	cout<<ans<<endl;
}
//  [cpp]
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << a + a*a + a*a*a;
}
//  [cpp]
# include <iostream>
using namespace std;

static const int ans[] = {
      3,  14,  39,  84,  155,
    258, 399, 584, 819, 1110,
};

int main() {
    int a;
    cin >> a;
    cout << ans[a] << endl;
    return 0;
}
//  [c]
#include<stdio.h>
long long n, m, i, j, k, s, ans, x, y;
int main()
{
	scanf ("%lld", &n);
	printf ("%lld", n + n * n + n * n * n); 
	return 0;
}
//  [c]
#include <stdio.h>
int main(void){
	int a;
	scanf("%d", &a);
	printf("%d\n", a+a*a+a*a*a);
	return 0;
}
//  [c]
#include<stdio.h>

int main(void){
    long n;
    scanf("%ld",&n);
    printf("%ld",n + n*n + n*n*n);
}
//  [c]
# include <iostream>
using namespace std;

static const int ans[] = {
    0, 3, 14, 39, 84, 155, 258, 399, 584, 819, 1110
};

int main() {
    int a;
    scanf("%d", &a);
    printf("%d", ans[a]);
    return 0;
}
//  [c]
#include <stdio.h>

 int a;

int main(){
    scanf(%d, &a);
    printf(%d, a+a*a+a*a*a);
    return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    int a;
     scanf("%d",a);
    printf("%d\n",a+a*a+a*a*a);
    return 0;
}
//  [javascript]
function main(input){
  const hoge = Number(input);
  console.log(hoge + Math.pow(hoge, 2) + Math.pow(hoge, 3));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(arg) {
    let a = Number(arg)
    console.log(Math.pow(a,1) + Math.pow(a,2) + Math.pow(a,3))
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(input) {
    const a = Number(input.split('\n')[0].split(' ')[0]);
    console.log(a + a*a + a*a*a);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  const box = input;
  let one = box;
  let two = box**2;
  let three = box**3;
  
  console.log(one + two + three);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  const box = input;

  let one = box;
  let two = box**2;
  let three = box**3;
  
  console.log(one + two + three);
  
}
Main(input);
//  [javascript]
function Main(input) {
	const box = input;
    let one = box;
    let two = box**2;
    let three = box**3;
    
    console.log(one + two + three);
}
let input = 10;
Main(input);
//  [go]
package main

import (
    "fmt"
)

func main(){
    var a int
    fmt.Scan(&a)

    fmt.Println(a*(1+a*(1+a)))
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {

	var a float64
	fmt.Scan(&a)

	ans := a + math.Pow(a, 2) + math.Pow(a, 3)

	fmt.Println(int(ans))

}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a := getStdinInt()
	fmt.Printf("%d\n", a+a*a+a*a*a)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
import "fmt"

func main() {
	var a int

	fmt.Scan(&a)

	fmt.Println(a * (1 + a*(1+a)))
}
//  [go]
package main

import (
  "fmt"
  "math"
)

func main() {
  var n int
  fmt.Scan(&n)
  ans := n + int(math.Pow(float64(n), 2) + math.Pow(float64(n), 3))
//  [go]
package main

import (
  "fmt"
  "math"
)

func main() {
  var n int
  fmt.Scan(&n)
  ans = n + math.Pow(n, 2) + math.Pow(n, 3)
  fmt.Println(ans)
}
//  [ruby]
a = gets.chomp.to_i

puts a + a**2 + a**3
//  [ruby]
a = gets.to_i
ans = a + (a*a) + (a*a*a)

puts ans
//  [ruby]
a = gets.to_i
p a+a*a+a*a*a
//  [ruby]
a=gets.to_i
p a+a+a*a+a*a*a
//  [ruby]
va = gets.chomp.to_i

puts a + a**2 + a**3
//  [ruby]
a = gets
puts a + a*a + a*a*a
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: usize,
    };
    println!("{}", a + a * a + a * a * a);
}
//  [rust]
fn main(){
    let raw = input();
    let a = raw.parse::<i64>().unwrap();
    println!("{}", a + (a*a) + (a*a*a));
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_string()
}
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let ans = n + n * n + n * n * n;
    println!("{}", ans);
}

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()
}
//  [rust]
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 v = read_vec::<u32>();
    let num = v[0];
    let result = calc(num);
    println!("{}", result)
}
//  [rust]
// これバイナリ提出せずにそのまま通るの?
// https://qiita.com/tanakh/items/60f42e06edcffd8d99a7
use competitive::prelude::*;

fn main() {
    input! {
        a: i64,
    }

    let ans = a + a.pow(2) + a.pow(3);
    echo!(ans);
}
//  [swift]
let a = Int(readLine()!)!

print(a + a * a + a * a * a)
//  [swift]
let a = Int(readLine()!)!
print(a + a*a + a*a*a)
//  [swift]
let a = Int(readLine()!)!
print(a*a*a + a*a + a)
//  [swift]
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let a = Int(split[0])!

print(a+a^2+a^3)
//  [swift]
//=Main Part==================================================================//
@inlinable
func main(_ args: [String]) -> Int32 {
  // Your code goes here
  let a = geti()
  print(a * (a * (a + 1) + 1))

  return 0
}

//=Utilities for Programming Contests=========================================//
import Foundation
import os
// input
@discardableResult
@inlinable @inline(__always) func gets() -> String { readLine()! }
@inlinable @inline(__always) func geti() -> Int    { Int(gets())! }
@inlinable @inline(__always) func getd() -> Double { Double(gets())! }
// array
@inlinable @inline(__always) func getsA(_ c: Character = " ") -> [String] { gets().split(separator: c).map(String.init) }
@inlinable @inline(__always) func getiA(_ c: Character = " ") -> [Int]    { gets().split(separator: c).map{ Int(String.init($0))! } }
@inlinable @inline(__always) func getdA(_ c: Character = " ") -> [Double] { gets().split(separator: c).map{ Double(String.init($0))! } }
// structured bindings: splat
prefix operator *
@inlinable @inline(__always) prefix func * <E> (a: [E]) -> (E, E)       { (a[0], a[1]) }
@inlinable @inline(__always) prefix func * <E> (a: [E]) -> (E, E, E)    { (a[0], a[1], a[2]) }
@inlinable @inline(__always) prefix func * <E> (a: [E]) -> (E, E, E, E) { (a[0], a[1], a[2], a[3]) }

//=Execution==================================================================//
os.exit(main(CommandLine.arguments))
//  [swift]
let a = Int(readLine()!)!
print(a + Int(truncating: pow(Decimal(a), 2) as NSDecimalNumber) + Int(truncating: pow(Decimal(a), 3) as NSDecimalNumber))
//  [typescript]
import { readFileSync } from 'fs'

function main(input: string) {
  const a = Number(input)

  const result = a + a ** 2 + a ** 3

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
import * as fs from 'fs';

const a: number = +fs.readFileSync('/dev/stdin', 'utf8').trim();
const ans: number = a + Math.pow(a, 2) + Math.pow(a, 3);
console.log(ans);
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    /* let [n, d] = lines[0].split(' ').map( _ => parseInt(_)) */
    let n = parseInt(lines[0])
    
    console.log(n + n^2 + n^3)
});
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = parseInt(xs[0].split(' ')[0]);
   let M = parseInt(xs[0].split(' ')[1]);
   let K = parseInt(xs[0].split(' ')[2]);
   let A = xs[1].split(' ').map(v=>parseInt(v,10));
   let B = xs[2].split(' ').map(v=>parseInt(v,10));
   let x = 0;
   let y = 0;
   let ans = 0;
   for(let i=0; i<N; i++){
      let tmp =0;
        x = A[i]; 
        y = B[i];
        if(x>y){
          tmp += y;
          //console.log(tmp);
        }else if(x<y){
          tmp += x;
          //console.log(tmp);
        }
      if(tmp<=K){
        ans++
      }else{
        break;
      }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [python]
R = int(input())

if R < 1200:
  print("ABC")
elif R < 2800:
  print("ARC")
else:
  print("AGC")
//  [python]
R = int(input())
print('ABC' if R < 1200 else ('ARC' if R < 2800 else 'AGC'))
//  [python]
a = int(input())

if a < 1200:
	print("ABC")
elif a >= 1200 and a < 2800:
	print("ARC")
else:
	print("AGC")
//  [python]
r = int(input())

if r < 1200:
  print('ABC')
elif r < 2800:
  print('ARC')
else:
  print('AGc')
//  [python]
def main():
	D,G = map(int,input().split())
	ListPC = [list(map(int,input().split())) for d in range(D)]
	ans = sum([i[0] for i in ListPC])

	for i in range(2**D):
		TempPoint,num,restmax = 0,0,-1  # 点数,正解数,解いてない最高点数idx
		for j in range(D):  # 全埋め問題加算
			if i>>j & 1:
				TempPoint += 100*(j+1)*ListPC[j][0]+ListPC[j][1]
				num += ListPC[j][0]
			else:
				restmax = max(j,restmax)
		if TempPoint >= G: # 合格なら更新
			ans = min(num,ans)
		elif G - TempPoint // ((restmax + 1) * 100) <= ListPC[restmax][0]: # 最高問題解いて合格なら更新
			ans = min(num + (G - TempPoint - 1) // ((restmax + 1) * 100) + 1, ans)
	print(ans)

if __name__ == '__main__':
	main()
//  [python]
n = int(input())

if n < 1200:
    print('ABC')
if n >= 1200 and n < 2800:
    print('ARC')
else:
    print('AGC')
//  [java]
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String arg[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int R = Integer.parseInt(br.readLine());
        if(R<1200){
            System.out.println("ABC");
        }else if(R<2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int r = Integer.parseInt(in.readLine());
    if(r<1200)
      System.out.println("ABC");
    else if(r<2800)
      System.out.println("ARC");
    else
      System.out.println("AGC");
  }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) throws IOException{
		
		InputStreamReader inputStreamReader = new InputStreamReader(System.in);
		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
		
		String input = bufferedReader.readLine();
		int r = Integer.parseInt(input);
		
		String result = "AGC";
		
		if(r < 1200) {
			result = "ABC";
		}else if(r < 2800) {
			result = "ARC";
		}
		
		print(result);
	}
	
	public static void print(String string) {
		System.out.println(string);
	}

}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int R = stdIn.nextInt();

		if(R < 1400) {
			System.out.println("ABC");
		}
		else if(R < 2800)
		{
			System.out.println("ARC");
		}
		else
		{
			System.out.println("AGC");
		}


	}

}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        if(R < 1200){
            System.out.println("ABC");
        }else if(1200 < R && R < 2800){
            System.out.println("ARC");
        }else if(2800 < R){
            System.out.println("AGC");
        }
    }
}
//  [java]
public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int R;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.R = sc.nextInt();
    }
    
    //解答処理
    private String solve() {
        String answer = "ABC";
        
        if (1200 <= R && R < 2800) {
        	answer = "ARC";
        } else if (2800 <= R) {
        	answer = "AGC";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}
//  [cpp]
#include<cctype>
#include<cstdio>
#include<cstring>

int getint(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch)) f|=ch=='-',ch=getchar();
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}

signed main(){
	int n=getint();
	if(n<1200) printf("ABC");
	else if(n<2800) printf("ARC");
	else printf("AGC");
	return 0;
}
//  [cpp]
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n<1200)
        printf("ABC\n");
    else if(n<2800)
        printf("ARC\n");
    else printf("AGC\n");
    return 0;
}
//  [cpp]
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  int n;
  scanf("%d", &n);
  if (n < 1200) {
    printf("ABC\n");
  } else if (n < 2800) {
    printf("ARC\n");
  } else {
    printf("AGC\n");
  }



  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int mulMod(long long a, long long b) {
    a *= b;
    a %= mod;
    return (int)a;
}
int addMod(int a, int b) {
    long long c = a + b;
    if(c >= mod) {
        c -= mod;
    }
    return (int)c;
}
vector<int> readArray(int n){
    vector<int> arr(n);
    for(int i=0; i<n; i++) {
        cin>>arr[i];
    }
    return arr;
}
void printArray(vector<int> &arr) {
    for(int a: arr)
        cout<<a<<" ";
    cout<<endl;
}

int main() {

    string x;
    cin>>x;
  	int n = x.length();
    long long c=0,bc=0,abc=0;
    int multi=1;
    reverse(x.begin(),x.end());
    for(int i=0;i<n;i++) {
        if(x[i]=='A') {
            abc=(abc+bc)%mod;
        }
        if(x[i]=='B') {
            bc=(bc+c)%mod;
        }
        if(x[i]=='C') {
            c=(c+multi)%mod;
        }
        if(x[i]=='?') {
            abc=(abc*3LL)%mod;
            abc=(abc+bc)%mod;
            bc=(bc*3LL)%mod;
            bc=(bc+c)%mod;
            c=(c*3LL)%mod;
            c=(c+multi)%mod;
            multi=(multi*3LL)%mod;
        }
    }
    cout<<(abc%mod)<<endl;
}
//  [cpp]
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(n) for( int i = 0 ; i < n ; i++ )
#define REP(n) for( int i = 1 ; i <= n ; i++ )
#define repll(n) for( ll i = 0 ; i < n ; i++ )
#define REPll(n) for( ll i = 1 ; i <= n ; i++ )
#define rep2(n) for( int j = 0 ; j < n ; j++ )
#define REP2(n) for( int j = 1 ; j <= n ; j++ )
#define repll2(n) for( ll j = 0 ; j < n ; j++ )
#define REPll2(n) for( ll j = 1 ; j <= n ; j++ )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    if( n < 1200 ) cout << "ABC";
    else if( n < 2800 ) cout << "ARC";
    else cout << "AGC";
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin>>S;
  int a=S.size();
  bool ans=true;
  if(S[0]!='A'){
      ans=false;
  }
  int cnt=0;
    for(int i=2; i<a-1; i++){
        if(S[i]=='C'||S[i]=='c'){
            cnt++;
        }
    }
  	if(S[S.size()-1]=='C'||S[S.size()-1]=='c'){
		ans=false;
      	
    }
    if(cnt!=1){
        ans=false;      
    }
  if(ans==true){
      cout<<"AC"<<endl;
  }
  else{
      cout<<"WA"<<endl;
  }
}
//  [c]
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<1200){
		printf("ABC\n");
	}
	else if(n<2800){
		printf("ARC\n");
	}
	else printf("AGC\n");
}
//  [c]
#include<stdio.h>
int main()
{
	int r;
	scanf("%d",&r);
	if(r<1200)
	    printf("ABC\n");
	else if(r<2800)
	    printf("ARC\n");
	else
	    printf("AGC\n");
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(){
  int R;
  scanf("%d",&R);
  if(R < 1200) printf("ABC\n");
  else if(1200 <= R & R < 2800) printf("ARC\n");
  else printf("AGC");
}
//  [c]
#include <stdio.h>
#include <string.h>

int main() {
	char S[9];
	scanf("%s",S);
	if (S[0] == 'A') {
		if(S[2] == 'C' || S[strlen(S)-3] == 'C') {
			printf("AC");
		} else {
			printf("WA");
		}
	} else {
		printf("WA");
	}
}
//  [c]
#include <stdio.h>
#include <string.h>

int main() {
	char S[9];
	scanf("%s",S);
	if (S[0] == 'A') {
		if(S[2] == 'C' || S[strlen(S)-2] == 'C') {
			printf("AC");
		} else {
			printf("WA");
		}
	} else {
		printf("WA");
	}
}
//  [c]
#include <stdio.h>

int main(void)
{
        int R;
        scanf("%d",&R);
        if(R<1200)printf("ABC\n");
        else if(R>=1200 && R>2800)printf("ARC\n");
        else if(R>=2800)printf("AGC\n");
        return 0;
}
//  [javascript]
function Main(input) {
  input = input.trim()
  if(input>=2800){
  console.log("AGC")
  }else if(input>=1200){
  console.log("ARC")
  }else{
  console.log("ABC")
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
// inputに入力データ全体が入る
function Main(input){
    input = parseInt(input);
    if(input < 1200){
        console.log("ABC");
    }else if(input < 2800){
        console.log("ARC");
    }else{
        console.log("AGC");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
	input = parseInt(input.trim());
  if(input < 1200){
     console.log("ABC");
  }else if(input >= 1200 && input <2800){
    console.log("ARC");
  }else{
    console.log("AGC");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  const ratz = /[a-z]/
  const S = input.split('');
  let ans = 'WA';
  let cCnt = 0;
  let lowCnt = 0;
  
  for (let i = 0; i < S.length; i++) {
    // 小文字カウント
    if (ratz.test(S[i])) {
      lowCnt++;
    }
    
    // C文字判定
    if (2 <= i && i < S.length - 1) {
      if(S[i] === 'C') { cCnt++; }
    }
  }
       
  if (S[0] === 'A' 
      && cCnt === 1
      && lowCnt === (S.length - 2)) {
    ans = 'AC'; 
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const main = function(input){
  var rate = parseInt(input);
  
  if(rate<1200){
  	console.log("ABC");
  }else if(rate<2800){
  	console.log("ARC");
  }else{
  	console.log("AGC");
  }


}



main(require("fs").readFileSync("/dev/stdin","utf-8");
//  [javascript]
function Main(input) {
  input = input.trim()
  if(input>2800){
  console.log("AGC")
  }else if(input>1200){
  console.log("ARC")
  }else{
  console.log("ABC")
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	r := nextInt()
	c := ""
	if r < 1200 {
		c = "ABC"
	} else if r < 2800 {
		c = "ARC"
	} else {
		c = "AGC"
	}
	fmt.Println(c)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}
//  [go]
package main

import "fmt"

func main() {
	var r int
	fmt.Scan(&r)
	if r < 1200 {
		fmt.Println("ABC")
	} else if r < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}
//  [go]
package main

import "fmt"

func main() {
	var r int
	fmt.Scan(&r)
	if r < 1200 {
		fmt.Println("ABC")
	} else if r < 2808 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}
//  [go]
//  ABC104_C_AllGreen.go
// 

package main

import (
    "fmt"
    //"strings"
)

var pc [][]int
var pointMatrix [][]int
var rpointMatrix [][]int
var min int

func calPoint(point int,i int ,D int ,G int,correct int,min *int) {

  if i == D - 1 {
      for j := 0; j < len(rpointMatrix[i]); j++{
          //fmt.Println(j,":",point+pointMatrix[i][j],"correct:",correct+j)
          if point+rpointMatrix[i][j] >= G {
            if correct+j <= *min{
              *min = correct+j
           }
          }
      }
      return

  } else {

     for j := 0 ; j < len(rpointMatrix[i]) ; j++ {
       //fmt.Print(j,"-")
        if correct+j >= *min {
           break
        }

        if point+rpointMatrix[i][j] >= G  {
          if correct +j <= *min {
            *min = correct + j
          }
          break
        }
        calPoint(point+rpointMatrix[i][j],i+1,D,G,correct+j,min)
     }
  }
}

func main() {
  var D int
  var G int
  var P int
  var C int
  var point int
  var correct int

  fmt.Scan(&D,&G)

  pc = make([][]int,D)

  for i := 0; i < D; i++ {
     pc[i] = make([]int,2)
  }

  min = 1

  for i := 0 ; i < D ; i++ {
    fmt.Scan(&P,&C)
    pc[i][0] = P
    pc[i][1] = C
    min *= P

    }

  //fmt.Println(pc)

  pointMatrix = make([][]int,D)

  for i := 0; i < D; i++ {
    pointMatrix[i] = make([]int,pc[i][0]+1)
  }

  for i :=0; i < D; i++ {
    for j :=0 ; j <= pc[i][0]; j++ {
      pointMatrix[i][j] = j * (i+1) * 100
    }
      pointMatrix[i][pc[i][0]] += pc[i][1]
   }

  rpointMatrix = make([][]int,D)

  for i := 0; i < D; i++ {
    rpointMatrix[i] = make([] int,pc[D-1-i][0]+1)
    rpointMatrix[i] = pointMatrix[D-1-i]
  }



  //fmt.Println(pointMatrix)
  //fmt.Println(rpointMatrix)

  point = 0
  correct = 0

  calPoint(point,0,D,G,correct,&min)

  //fmt.Println(point,correct,min)
  fmt.Println(min)
}
//  [go]
//  ABC104_C_AllGreen.go
// 

package main

import (
    "fmt"
    //"strings"
)

var pc [][]int
var pointMatrix [][]int
var min int

func calPoint(point int,i int ,D int ,G int,correct int,min *int) {

  if i == D - 1 {
      for j := 0; j < pc[i][0]+1; j++{
          //fmt.Println(j,":",point+pointMatrix[i][j],"correct:",correct+j)
          if point+pointMatrix[i][j] >= G && correct+j <= *min {
             *min = correct+j
          }
      }
      return

  } else {

     for j := 0 ; j < pc[i][0]+1 ; j++ {
       //fmt.Print(j,"-")
        if correct+j >= *min {
           return
        }
        calPoint(point+pointMatrix[i][j],i+1,D,G,correct+j,min)
     }
  }
}

func main() {
  var D int
  var G int
  var P int
  var C int
  var point int
  var correct int

  fmt.Scan(&D,&G)

  pc = make([][]int,D)

  for i := 0; i < D; i++ {
     pc[i] = make([]int,2)
  }

  min = 1

  for i := 0 ; i < D ; i++ {
    fmt.Scan(&P,&C)
    pc[i][0] = P
    pc[i][1] = C
    min *= P

    }

  //fmt.Println(pc)

  pointMatrix = make([][]int,D)

  for i := 0; i < D; i++ {
    pointMatrix[i] = make([]int,pc[i][0]+1)
  }

  for i :=0; i < D; i++ {
    for j :=0 ; j <= pc[i][0]; j++ {
      pointMatrix[i][j] = j * (i+1) * 100
    }
      pointMatrix[i][pc[i][0]] += pc[i][1]
   }

    //fmt.Println(pointMatrix)

  point = 0
  correct = 0

  calPoint(point,0,D,G,correct,&min)

  fmt.Println(min)
}
//  [ruby]
n = gets.to_i
if n < 1200
  puts :ABC
elsif n < 2800
  puts :ARC
else
  puts :AGC
end
//  [ruby]
#入力
r = gets.to_i

# こたえ
if r < 1200
  puts "ABC"
elsif r >= 1200 && r < 2800 
  puts "ARC"
else
  puts "AGC"
end
//  [ruby]
r = gets.to_i
if r < 1200 then
	puts 'ABC'
else
	if r < 2800 then
		puts 'ARC'
	else
		puts 'AGC'
	end
end
//  [ruby]
puts gets.to_i<1200?"ABC":$_<2800?"ARC":"AGC"
//  [ruby]
r = gets.to_i
if r < 1200
  puts "ABC"
elsfi 1200 <= r && r < 2800
  puts "ARC"
else
  puts "AGC"
end
//  [ruby]
r = gets.to_i
if r <= 1200
  puts 'ABC'
elsif r <= 2800
  puts 'ARC'
else
  puts 'AGC'
end
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r: usize = read();
    let mut ans = "AGC";

    if r < 2800 {
        ans = "ARC";
    }

    if r < 1200 {
        ans = "ABC";
    }

    println!("{}", ans);
}