jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  string s;
  cin>>s;
  int ans=700;
  rep(i,3){
    if(s[i]=='o')ans+=100;
  }
  cout<<ans<<endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
        string S;cin>>S;
        Int ans=0;
        for(auto x:S) ans+=(x=='o');
        cout<<700+ans*100<<"\n";
}
//  [c]
#include <stdio.h>

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

int main()
{
	int i, ans = 700;
	char S[4];
	scanf("%s", S);
	for (i = 0; S[i] != 0; i++) if (S[i] == 'o') ans += 100;
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
        char s[3];
        int c=0;
        scanf("%s",s);

        for(int i=0;i<3;i++)
                if(s[i]=='o')c++;
        printf("%d\n",700+c*100);
        return 0;
}
//  [javascript]
function Main(input){
	var a=700;
	for(var i=0;i<3;i=(i+1)|0){
		if(input[i]=="o"){a+=100;}
	}
	console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
    var counter = 0;
    for(var i = 0; i < 3; i++){
        if(input[i] === "o") counter++;
    }
    console.log(700 + counter * 100);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
s = inp.shift()
a = 700
a += s[0] == 'o' ? 100 : 0
a += s[1] == 'o' ? 100 : 0
a += s[2] == 'o' ? 100 : 0
console.log(a)
//  [go]
package main

import "fmt"

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

	ans := 700

	for _, v := range s {
		if v == 'o' {
			ans += 100
		}
	}
	fmt.Println(ans)
}
//  [go]
package main
 
import (
  "fmt"
  "strings"
)
 
func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := 700
  ans += strings.Count(s, "o") * 100
  
  fmt.Printf("%d\n", ans)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	ans := 700
	for _, r := range s {
		if string(r) == "o" {
			ans += 100
		}
	}
	fmt.Println(ans)
}
//  [ruby]
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
s=gc
sum = 700
s.each do |ss|
  if ss == 'o'
    sum+= 100
  end
end
puts sum
//  [ruby]
p 700+100*gets.count(?o)
//  [ruby]
puts 700 + gets.chomp.count('o') * 100
//  [rust]
use proconio::input;
fn main() {
    input! {
        s:String,
    }
    let s_chars: Vec<char> = s.chars().collect();
    let mut cnt = 0;
    for i in 0..3 {
        if s_chars[i] == 'o' {
            cnt += 1;
        }
    }
    let ans = 700 + cnt * 100;
    println!("{}", ans);
}
//  [rust]
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        s: String
    }
    println!("{}", 700 + s.matches("o").count() * 100);
}
//  [rust]
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        s:Chars,
    }
    let ans=700+s.iter().filter(|x|**x=='o').count()*100;
    println!("{}",ans);
}
//  [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(700 + (s.split("o").length - 1) * 100);
});
//  [typescript]
class Scanner {
  private buffer = '';
  private stdinQueue: any = [];

  constructor() {
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on(
      'data',
      (chunk): void => {
        this.buffer += chunk;
        while (this.stdinQueue.length > 0) {
          const i = this.buffer.indexOf('\n');
          if (i < 0) {
            break;
          }
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          this.stdinQueue.shift()(line);
        }
      },
    );
  }
  public getLine(): Promise<string> {
    return new Promise((resolve, reject) => {
      const i = this.buffer.indexOf('\n');
      if (i >= 0 && this.stdinQueue.length == 0) {
        let line = this.buffer.substr(0, i);
        if (line.endsWith('\r')) {
          line = line.slice(0, -1);
        }
        this.buffer = this.buffer.substr(i + 1);
        resolve(line);
      } else {
        this.stdinQueue.push(resolve);
      }
    });
  }

  public close(): void {
    process.stdin.pause();
  }
}

async function slove() {
  const sc = new Scanner();
  const S = await sc.getLine();
  const t = S.match(/o/g);
  let ans = 700;
  if (t !== null) {
    ans = 700 + 100 * t.length;
  }
  console.log(ans);
  sc.close();
}

slove();
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  return 700 + (S.match(/o/g) || []).length * 100;
};

console.log(main(read()));
//  [python]
import time
a=int(input())
time.sleep(1.971)
print(a+a*a+a*a*a)
//  [python]
import time
a=int(input())
time.sleep(1.972)
print(a+a*a+a*a*a)
//  [python]
import time
a=int(input())
time.sleep(1.97)
print(a+a*a+a*a*a)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static int dp[][] = new int[(1 << 21) + 1][21];
	static int dist[][] = new int[21][21];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int a = Integer.parseInt(br.readLine());

		System.out.println((int) (a + Math.pow(a, 2) + Math.pow(a, 3)));
	}
}
//  [java]
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int num = scan.nextInt();

        System.out.println((int)(num + Math.pow(num, 2) + Math.pow(num, 3)));
    }
}
//  [java]
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	static int N,M,X,Y,a[],b[];
	String S;
	
	public static void main(String[] args) {
		N=sc.nextInt();
		System.out.println(N+N*N*N+N*N);
	}
}
//  [c]
#include <stdio.h>
int main(){
int a,b;
scanf("%d",&a);
b = a+a*a+a*a*a;
printf("%d",b);
}
//  [c]
#include <stdio.h>

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

int main(void)
{
    int a;
    scanf("%d", &a);
    printf("%d", a + a * a + a * a * a);

    return 0;
}
//  [javascript]
const main = (input) => {
  const n = Number(input)
  console.log(n + n*n + n*n*n)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]

const func = (input)=>{
  let a = input;
  let result = a**1 + a**2+a**3 
  console.log(result);
}





func(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
function Main(input) {
    const a = parseInt(input, 10);
    
    const ans = a + a*a + a*a*a;
    
    console.log(ans);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
)

func main() {
	in := 0
	fmt.Scanf("%d", &in)
	fmt.Println(in + in*in + in*in*in)
}
//  [go]
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()

	fmt.Println(powInt(N, 2) + powInt(N, 3) + N)
}
//  [ruby]
require 'pp'

a = gets.to_i
puts a  + a ** 2 +  a ** 3
//  [ruby]
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

a = get_int

puts a + a ** 2 + a ** 3
//  [ruby]
A = gets.chomp.to_i

puts A + A*A + A*A*A
//  [swift]
import Foundation

func main(){
    let a = Int(readLine()!)!
    print(a + a * a + a * a * a)
}
main()
//  [swift]
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
func main() {
    let a = Double(readInts()[0])
    print(Int(a + pow(a, 2) + pow(a, 3)))
//    print(a)
    
}
main()
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let a = readInt()[0]
    print(a + a*a + a*a*a)
}
main()
//  [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]
import { readFileSync } from 'fs'

function main(input: string[]) {
  let a = Number(input[0])
  let ans = a + a * a +  a * a * a
  console.log(ans)
}

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 () {
  main(lines)
});
//  [typescript]
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8").split(" ");

const a = Number(input[0]);

console.log(a + Math.pow(a, 2) + Math.pow(a, 3));
//  [python]
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R):
    if R < 1200:
        return 'ABC'
    elif R < 2800:
        return 'ARC'
    return 'AGC'


def main():
    R = read_int()
    print(slv(R))


if __name__ == '__main__':
    main()
//  [python]
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output


def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))

# Binary converter


def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]

# --------------------------------------------


dp = None


def main():
    R = int(input())

    if R < 1200:
        print("ABC")
    elif R < 2800:
        print("ARC")
    else:
        print("AGC")


main()
//  [python]

def f(r):
	if r < 1200: return 'ABC'
	if r < 2800: return 'ARC'
	return 'AGC'
print f(int(raw_input()))
//  [java]
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int r = stdIn.nextInt();

        if(r < 1200)
            System.out.println("ABC");
        else if(r < 2800)
            System.out.println("ARC");
        else
            System.out.println("AGC");
    }
}
//  [java]
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int R = sc.nextInt();
		if(R < 1200) System.out.println("ABC");
		else if(R  < 2800) System.out.println("ARC");
		else System.out.println("AGC");
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int r = sc.nextInt();
		if(r < 1200) {
			System.out.println("ABC");
		}else if(r < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
    }
}
//  [cpp]
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 2282282287;
const ll power = 49999;

/*
Нас по звукам узнавай:
Ня Кавай, Ня Кавай
Мы орем на весь трамвай:
Ня Кавай
Никогда не забывай:
Ня Кавай, Ня Кавай
Лучше к нам не приставай
Ня Кавай
*/

ll n;

int main()
{
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin >> n;
	if (n < 1200)
	{
		cout << "ABC";
		return 0;
	}
	if (n < 2800)
		cout << "ARC";
	else
		cout << "AGC";

	return 0;
}
//  [cpp]
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int n;
    cin >> n;
    if(n < 1200){
        cout << "ABC" << endl;
    }else if(n < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int r;
  cin>>r;
  string ans;
  if(r<1200)ans="ABC";
  else if(r<2800)ans="ARC";
  else ans="AGC";
  cout(ans);
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int a;
  scanf("%d",&a);
  if(a<1200){
    printf("ABC\n");
  }else if(a<2800){
    printf("ARC\n");
  }else{
    printf("AGC\n");
  }
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

int main() {
	int r;

	scanf("%d", &r);

	if (r < 1200) {
		printf("ABC");
	}
	else if (r < 2800) {
		printf("ARC");
	}
	else {
		printf("AGC");
	}
}
//  [c]
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int a;
    scanf("%4d",&a);
    if (0<=a && a<1200) printf("%s","ABC");
    else if (1200<=a && a<2800) printf("%s","ARC");
    else printf("%s","AGC");

    return 0;
}
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var r = parseInt(input[0].split(" ")[0]);
  var ans = "AGC";
  if(r<1200){
    ans = "ABC";
  }else if(r<2800){
    ans = "ARC";
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  const contest = ['ABC', 'ARC', 'AGC']
  var i = 0
  var r = Number(input[0])
  if (r >= 1200) { i++ }
  if (r >= 2800) { i++ }
  console.log(contest[i])
}


Main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'))
//  [javascript]
function Main(s){
  s = +s;
  console.log(s<1200?"ABC":s<2800?"ARC":"AGC");
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [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.Scanf("%d", &r)

  ans := "ABC"
  if r >= 1200 {
    ans ="ARC"
  }
  if r >= 2800 {
    ans ="AGC"
  }
  
  fmt.Printf("%s\n", ans)
}
//  [go]
package main

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

func main() {
	R := ReadInt()
	if R < 1200 {
		fmt.Println("ABC")
		return
	}
	if R < 2800 {
		fmt.Println("ARC")
		return
	}
	fmt.Println("AGC")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [ruby]
puts gets.to_i<1200?"ABC":$_.to_i<2800?"ARC":"AGC"
//  [ruby]
r = gets().chomp.to_i

if r < 1200
  puts 'ABC'
elsif r < 2800
  puts 'ARC'
else
  puts 'AGC'
end
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

R = get_int

if R < 1200
  puts 'ABC'
elsif R < 2800
  puts 'ARC'
else
  puts 'AGC'
end
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    }
    println!("{}",
             if a<1200 {"ABC" }
             else if a<2800 {"ARC" }
             else {"AGC" }
    )
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        r: usize,
    }

    match r {
        0...1199 => println!("ABC"),
        1200...2799 => println!("ARC"),
        2800...4209 => println!("AGC"),
        _ => return,
    }

}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {r: usize};

    if r < 1200 {
        println!("ABC")
    } else if r < 2800 {
        println!("ARC")
    } else {
        println!("AGC")
    }
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const R = Number(input[0][0]);

  return R < 1200 ? "ABC" : R < 2800 ? "ARC" : "AGC";
};

console.log(main(read()));
//  [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 main = ()=>{
  let r=nin();
  out(sw(r,[
    1200,'ABC',
    2800,'ARC',
    'AGC'
  ],'<'));
}
main();
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc104 {

    class ProgramA {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *  1199
         * out
         * ABC
         */
        main(): void {
            const r: number = parseInt(this.args[0], 10);
            if (r < 1200) {
                console.log('ABC');
            } else if (r < 2800) {
                console.log('ARC');
            } else {
                console.log('AGC');
            }
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new ProgramA(args);
    prg.main();
}
//  [python]
from sys import setrecursionlimit

setrecursionlimit(10 ** 8)


def main(x, k, d):
    for i in range(k):
        if abs(x + d) < abs(x - d):
            x = x + d
        else:
            x = x - d

        if abs(x - d) > abs(x) and abs(x + d) > abs(x):
            if (k - i - 1) % 2 == 1:
                if abs(x - d) < abs(x + d):
                    x = x - d
                else:
                    x = x + d
            break

    print(abs(x))


def sub(x, k, d):
    print(abs(x) - d * k)


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

if abs(a) - b * c >= 0:
    sub(a, b, c)
else:
    main(a, b, c)
//  [python]
x, k, d = map(int, input().split())
x_pre = x
y = abs(x) - k*d

if y >= 0:
    print(y)
    exit()

while k > 0:
    if x >= 0:
        x -= d
    else:
        x += d

    if abs(x) >= abs(x_pre):
        if k % 2 == 0:
            print(abs(x_pre))
            exit()
        else:
            print(abs(abs(x_pre) - d))
            exit()
    else:
        x_pre = x
        k -= 1

print(abs(x_pre))
//  [python]
import sys
X,K,D= map(int,input().split())
temp = X

if abs(X) > K*D:
    print(abs(X)-K*D)
    sys.exit()
    
for t in range(K):
    # 絶対値の小さい方に移動
    if abs(temp - D) < abs(temp + D):
        temp = temp-D
    else:
        temp = temp+D

    # 移動幅より小さくなったとき
    if abs(temp) < D:
        if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit()

print(abs(temp))
//  [java]

import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    long X = scan.nextLong();
    long K = scan.nextLong();
    long D = scan.nextLong();

    long ans = 0;
    long prevprev = 0;
    long prev = 0;
    long times = 0;
    if(X > 0){
      if(X/D < K) {
        K -= X/D;
        X = X - D * (X/D);
      } else {
        X = X - D*K;
        K = 0;
      }
    } else {
      if(-1*X/D < K) {
        K -= -1*X/D;
        X = X + D*(X/D);
      } else {
        X = X + D*K;
        K = 0;
      }
    }

    while(K > 0) {
      if(X > 0) {
        X -= D;
      } else {
        X += D;
      }
      K--;
      times++;
      if(times == 1)
        prevprev = X;
      else if(times == 2)
        prev = X;

      if(times >= 3) {
        if((X > 0 && prev <= 0 && prevprev >0) || (X <=0 && prev > 0 && prevprev <= 0)) {
          if(K % 2 == 1){
            if(X > 0) {
              X -= D;
            } else {
              X += D;
            }
          }
          break;
        }


        prevprev = prev;
        prev = X;
      }
    }

    os.println(Math.abs(X));
  }
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws InterruptedException {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();

		long ans;
		x = Math.abs(x);

		if (x / d >= k) {
			ans = x - k * d;
		} else {
			long tmp = x % d;
			long remain = k - x / d;

			if (remain % 2 == 0) {
				Thread.sleep(1000);
				ans = tmp;
			} else {
				Thread.sleep(500);
				ans = Math.abs(tmp - d);
			}

		}

		System.out.println(ans);

		sc.close();
	}

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
vector<ll> getNums(ll N) {
    vector<ll> num(N);
    REP(i, N) {
        cin >> num[i];
    }
    return num;
}
int main() {
    ll X, K, D;
    cin >> X >> K >> D;

    ll ans = INF;

    ll begin = max(min(K / 2, abs(X) / D) - 1000000000, (ll)0);
    if (K % 2 == 0) {
        if (X >= 0) {
            for (ll i = begin; i <= K / 2; ++i) {
                ll tmp = X - D * 2 * i;
                chmin(ans, abs(tmp));
                if (tmp < 0) break;
            }
        }

        if (X <= 0) {
            for (ll i = begin; i <= K / 2; ++i) {
                ll tmp = X + D * 2 * i;
                chmin(ans, abs(tmp));
                if (tmp > 0) break;
            }
        }
    } else {
        if (X >= 0) {
            for (ll i = begin; i <= (K) / 2; ++i) {
                ll tmp = X - D * (i * 2 + 1);
                chmin(ans, abs(tmp));
                if (tmp < 0) break;
            }
        }

        if (X <= 0) {
            for (ll i = begin; i <= (K) / 2; ++i) {
                ll tmp = X + D * (i * 2 + 1);
                chmin(ans, abs(tmp));
                if (tmp > 0) break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}
//  [cpp]
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,k,d;
    cin>>x>>k>>d;
    if(x==0)
    {
        if(k%2==0)
            cout<<0;
        else
            cout<<d;
    }
     else if(x>=0)
    {
       if((x/d)>k)
           cout<<abs(x-k*d);
       else if((x/d)<=k)
       {
          ll ans=x;
          while(k&&(ans>0))
          {
              ans-=(d);
              k--;
          }
          if(k%2==0)
          {
              cout<<(ll)(abs(ans));
          }
          else
          {
              cout<<(ll)(abs(ans+d));
          }
       }
    }
    else if(x<0)
    {
        if((-(x/d))>(k))
           cout<<abs(x+k*d);
        else if((-(x/d))<=(k))
        {
            ll ans=x;
            while(k&&ans<0)
            {
               ans+=(d);
               k--;
            }
            if(k%2==0)
            {
                cout<<abs(ans);
            }
            else
            {
                cout<<abs(ans-d);
            }
        }
    }
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

int main(){
    long long X, K, D;
    cin >> X >> K >> D;

    long long ans = 1e15 + 1;

    if(abs(K * D) < abs(X)){
        cout << abs(X) - abs(K * D) << endl;
        return 0;
    }

    for(long long i = 0; i < K; ++i){
        if(abs(X - D) < abs(X + D)){
            X = X - D;
        }else{
            X = X + D;
        }

        if(abs(ans) == abs(X)){
            if((K - i)%2 == 0){
                 if(abs(ans - D) < abs(ans + D)){
                    ans = ans - D;
                }else{
                    ans = ans + D;
                }
            }
            break;
        }
            
        ans = min(abs(ans), abs(X));
    }

    cout << abs(ans) << endl;

    return 0; 
}
//  [c]
#include <stdio.h>
int main(){
  long long int x,k,d;
  int p=0,m=0;
  scanf("%lld %lld %lld",&x,&k,&d);
  if(x<0){x=0-x;}
  if(x/d>k){
  	for(int i=0;i<k;i++){
      x-=d;
    }
  }
  else{
 	 for(int i=0;i<k;i++){
    if(p*m==1&&(k-i)%2==0){break;}
    
    if(x>=0){
      if(x==0){m=1;}
      p=1;
      x-=d;
    }else{
      x+=d;
      m=1;
    }
  }
  }
  if(x<0){x=0-x;}
  printf("%lld\n",x);
}
//  [c]
#include <stdio.h>

int main(){
   long x,k,d,i;

   scanf("%ld %ld %ld",&x,&k,&d);
   if (x<0) x=-x;
   if (d<0) d=-d;
   i=x/d;
   if (i<=k) {
      x-=d*i;
      k-=i;
      if (k%2==0) printf("%ld\n",x);
      else        printf("%ld\n",d-x);
   } else
      printf("%ld\n",x-k*d);
   return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
    long long int n,x,k,d,i;
    scanf("%lld %lld %lld",&x,&k,&d);
    if(x != 0)
    {
        if(x < 0)
        {
            x = -1 * x;
        }
        if(x / d >= k  )
        {
            printf("%lld\n",x - d * k);
            return 0;
        }
        else
        {
            long long int a;
            a = x / d;
            x = x - d * a;
            if(x < 0)
            {
                x = -1 * x;
            }
            if((k - a) % 2 == 0)
            {
                printf("%lld\n",x);
                return 0;
            }
            else
            {
                printf("%lld\n",d - x);
                return 0;
            }
        }
    }
    else
    {
        if(k % 2 == 0)
        {
            printf("0\n");
            return 0;
        }
        else
        {
            printf("%lld\n",d);
            return 0;
        }
    }
    
    
    return 0;
}
//  [javascript]
function Main(input) {
	const row = input.split(" ");
	const X = parseInt(row[0], 10);
	const K = parseInt(row[1], 10);
	const D = parseInt(row[2], 10);
	const even = num => num % 2 === 0;
	const av_x = X < 0 ? X * -1 : X;

	if(av_x >= K * D) {
		console.log(av_x - K * D);
	} else {
		for (let i = 1; i <= K; i++) {
			if(av_x <= D * i) {
				if(even(K - i)){
					console.log(D * i - av_x);
				} else {
					console.log(av_x - D * (i - 1));
				}
				break;
			}
		}
	}
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
let lines = [];
let reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

// 標準入力の読み込み
reader.on('line', function(line) {
    lines.push(line);
});

reader.on('close', function() {

    // 処理の記述
    let [x, k, d] = lines[0].split(' ');
    x = parseInt(x);
    k = parseInt(k);
    d = parseInt(d);

    let ans = Math.abs(x);

    // xの絶対値がk * dより大きいとき
    if (Math.abs(x) > k * d) {
        if (x < 0) {
            ans = Math.abs(x + k * d);
        } else {
            ans = Math.abs(x - k * d);
        }
    } else {
        if (x < 0) {
            let cnt = 0;
            while( Math.abs(x) > d ) {
                x += d;
                cnt++;
            }

            ans = (k - cnt) % 2 == 0 ? Math.abs(x) : Math.abs(x + d);

        } else {
            let cnt = 0;
            while( Math.abs(x) > d ) {
                x -= d;
                cnt++;
            }
            ans = (k - cnt) % 2 == 0 ? Math.abs(x) : Math.abs(x - d);
        }
    }

    // 表示
    console.log(ans);
});
//  [javascript]
function Main(input) {
  const row = input.split(" ");
    	let X = parseInt(row[0], 10);
    	let K = parseInt(row[1], 10);
    	const D = parseInt(row[2], 10);
    let absX = Math.abs(X);
    let a = Math.floor(absX / D);//往復開始地点までにかかる回数
    let ans;

    if((absX /D) >= K) {
       ans = absX - D * K;

    } else {
    let K2 = K - a;
       absX = absX % D;//余りが0に最も近い座標
       if(K2 % 2 === 0) {
    　ans = absX;
      } else {
         ans = absX - D;
      }
    } console.log(Math.abs(ans));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
	"math"
)

// 答えは下記のいずれか
// 最小値にいく前にカウントが尽きる
// 最小値
// 最小値の１個逆側(回数的に最小値にできない)
func main() {
	var x, k, d int
	fmt.Scan(&x, &k, &d)
	absX := AbsDiff(x, 0)
	var min int
	var count int
	if d < absX {
		min = absX % d
		count = absX / d
		if count >= k {
			min = absX - d*k
		}
	} else {
		min = absX - d
		count = 1
	}
	if k > count && (k-count)%2 != 0 {
		if min > 0 {
			min = min - d
		} else {
			min = min + d
		}
	}
	fmt.Println(AbsDiff(min, 0))
}

func AbsDiff(n1 int, n2 int) int {
	return int(math.Abs(float64(n1 - n2)))
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt()
	x = abs(x)
	k := nextInt()
	d := nextInt()

	// 臨界に届かない場合
	if k < x/d {
		fmt.Println(x - k*d)
		return
	}
	k2 := x / d
	if (k-k2)%2 == 0 {
		fmt.Println(x % d)
		return
	}
	fmt.Println(d - x%d)

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
x,k,d = gets.chomp.split.map(&:to_i)

if x < 0
  x = x.abs
end

if x - k * d > 0
  puts x - k * d
else
  r = x % d
  l = r - d
  nokori_k = k - x / d
  # p [l, r, nokori_k]
  if nokori_k.even?
    puts r.abs
  else
    puts l.abs
  end
end
//  [ruby]
x, k, d = gets.split.map(&:to_i)
# スタートが負の場合でも正の時と同様に考えてOK
x = x.abs
# 絶対値が変わらなくなるまでに必要な移動回数(t)とその時のx座標(m)
t, m = x.divmod(d)
if t >= k
  # x座標が0まで到達しない場合はより0に近い値を出力
  puts (x-k*d).abs
elsif (k-t).even?
  # t回目から偶数回移動する場合はmで止まる
  puts m
else
  # t回目から奇数回移動する場合はmの反対側で止まる
  puts (m-d).abs
end
//  [ruby]
# frozen_string_literal: true

x, k, d = gets.split.map(&:to_i)

k1 = -x / d
k2 = k1 - 1
k3 = k1 + 1

km = [k1, k2, k3].sort_by { |e| (x + e * d).abs }.filter { |e| e % 2 == k % 2 }[0]

if k < km.abs
  if km < 0
    km = -k
  else
    km = k
  end
end
puts (x + km * d).abs