akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  ll N;
  cin >> N;

  int A,B;
  for (A = sqrt(N)+EPS; A > 0; A--) {
    if (N % A == 0) break;
  }

  B = N / A;
  auto length = [&](int x) {
    return floor(log10(x)) + 1;
  };

  cout << max(length(A), length(B)) << endl;
}



Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
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 pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod only
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    vector<int> v;
    int now = 0;
    while(now < n){
        if(n > 1 && now < n-1 && s[now] == s[now + 1]){
            v.push_back(1);
            now += 2;
        }else{
            v.push_back(0);
            now++;
        }
    }
    int l = v.size();
    
    vector<mint> dp(l);
    if(v[0] == 1) dp[0] = 6;
    else dp[0] = 3;
    FOR(i,1,l){
        if(v[i-1]== 0 && v[i] == 0) dp[i] = dp[i-1] * 2;
        if(v[i-1]== 0 && v[i] == 1) dp[i] = dp[i-1] * 2;
        if(v[i-1]== 1 && v[i] == 0) dp[i] = dp[i-1] * 1;
        if(v[i-1]== 1 && v[i] == 1) dp[i] = dp[i-1] * 3;
    }
    cout << dp[l-1].x << endl;
}

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

int main(){
  int N,K,A=1;
  cin >> N >> K;
  
  while(N>0){
    if(A*2>A+K){
      A+=K;
    }else{
      A*=2;
    }
    N-=1;
  }
  cout << A << endl;
}


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



int main() {
  int n, m, k=0;
  cin >> n >> m;
  rep(i, m){
    int a;
    cin >> a;
    k += a;
  }
  n -= k;
  if(n < 0) cout << -1 << endl;
  else cout << n << endl;
  return 0;
}


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

int main()
{
  //与えられた数列を逆順に出力
  //入力
  //for 文を逆に回す
  int n; 
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++){
    cin >> A[i];
  }

  for (int i = n - 1; i > 0; i--){
    cout << A[i] << ' ';
  }
  cout << A[0] << endl;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s;
    else cout << "red";
    return 0;
}

Measured memory_bytes: 3468
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i

total = 0

(0...n).each{ |i|
	if b[i] >= a[i] then
		total += a[i]
		b[i] -= a[i]
	else
		total += b[i]
		b[i] = 0
	end
	
	if b[i] >= a[i+1] then
		total += a[i+1]
		a[i+1] = 0
	else
		total += b[i]
		a[i+1] -= b[i]
	end
}

puts total

Measured memory_bytes: 15396
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;int h[N],dp[N];dp[0]=0;
  for(int i=0;i<N;i++)cin>>h[i];
  for(int i=1;i<N;i++){
    dp[i]=2000000000;
    for(int j=1;j<=min(K,i);j++)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
  }
  cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int a[n],b[n],c[n-1];
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)cin>>b[i];
    rep(i,0,n-1)cin>>c[i];
    int res=0;
    rep(i,0,n){
        res += b[a[i]-1];
        //cout<<a[i+1]<<" "<<a[i]<<endl;
        if(i+1>=n)break;
        if(a[i+1]==a[i]+1){
            res += c[a[i]-1];
        }
        //cout<<"res="<<res<<endl;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll N, W, w1, v1, wi, vi;
vector<ll> A[8];

bool comparator(const ll &x, const ll &y) {
    return x > y;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>N>>W;
  cin>>w1>>v1;
  A[0].pb(v1);

  rep(i, N-1) {
      cin>>wi>>vi;
      A[wi-w1].pb(vi);
  }

  rep(i, 4) {
      sort(A[i].begin(), A[i].end(), comparator);
  }


  //rep(i, 4) {
      //rep(j, A[i].size()) cout<<A[i][j]<<" ";cout<<endl;
  //}

  rep(i, 4) {
      rep(j, (int)A[i].size()-1) A[i][j+1] += A[i][j];
  }

  //rep(i, 4) {
    //  rep(j, A[i].size()) cout<<A[i][j]<<" ";cout<<endl;
  //}

  ll wsum = 0, valsum = 0, ans = 0;

  rep(i, A[0].size()+1)
  rep(j, A[1].size()+1)
  rep(k, A[2].size()+1)
  rep(l, A[3].size()+1) {
      if(i != 0) wsum += i*w1, valsum += A[0][i-1];
      if(j != 0) wsum += j*(w1+1), valsum += A[1][j-1];
      if(k != 0) wsum += k*(w1+2), valsum += A[2][k-1];
      if(l != 0) wsum += l*(w1+3), valsum += A[3][l-1];

      if(wsum <= W) ans = max(ans, valsum);
      wsum = 0, valsum = 0;
  }

  cout<<ans<<endl;
  return 0;
}


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

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	printf(b - a == c - b ? "YES\n" : "NO\n");

	return 0;
}


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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;
int arr[MAXN];
int t[5*MAXN],lazy[5*MAXN];

int doit(int a,int b){
	return min(a,b);
}

void build(int start,int end,int index=1){
	if(start==end){
		t[index]=0;
		return ;
	}
	int mid = start+end >> 1;
	build(start,mid,index << 1);
	build(mid+1,end,index<<1|1);
	t[index] = doit(t[index<<1], t[index<<1|1]);
}

void propagate(int start,int end,int index){
	t[index] += lazy[index];
	// bcz leaf not hv childs
	if(start!=end){
		lazy[index<<1] += lazy[index];
		lazy[index<<1|1] += lazy[index];
	}
	lazy[index]=0;
}

int Query(int start,int end,int l,int r,int index=1){

	if(lazy[index]!=0){
		propagate(start,end,index);
	}
	// out range
	if(r<start or end<l){
		return INT_MAX;
	}
	// in Raange
	if( l<=start and end<=r){
		return t[index];
	}
	int mid = start+end >>1;
	return doit(Query(start,mid,l,r,index<<1), Query(mid+1,end,l,r,index<<1|1));
}

void pUpdate(int start,int end,int point,int val,int index=1){
	if(start==end){
		t[index]=val;
		return ;
	}
	int mid = start+end>>1;
	if(point <= mid){
		pUpdate(start,mid,point,val,index<<1);
	}
	else{
		pUpdate(mid+1,end,point,val,index<<1|1);
	}
	t[index] = doit(t[index <<  1] , t[index << 1 | 1]);
}


void rangeUpdate(int start,int end,int l,int r,int val,int index){
	if(lazy[index]!= 0){
		propagate(start,end,index);
	}
	if(l>end or r<start){
		return;
	}
	// in range
	if(l<=start and end<=r){
		lazy[index]+=val;
		propagate(start,end,index);
		return;
	}
	int mid = start+end>>1;
	rangeUpdate(start,mid,l,r,val,index<<1);
	rangeUpdate(mid+1,end,l,r,val,index<<1|1);
	t[index] = doit(t[index<<1],t[index<<1|1]);
}




signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin>>n>>m;
	memset(lazy,0,sizeof lazy);
	build(0,n-1);
	for(int i=1; i<=m; i++){
		int q; cin>>q;
		if(q==1){
			int s,t; cin>>s>>t;
			cout<<Query(0,n-1,s,t,1); br;
		}
		else{
			int s,t,x; cin>>s>>t>>x;
			rangeUpdate(0,n-1,s,t,x,1);
		}
	}	

}


Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll x;
  cin >> x;
  exrep(a,-500,500){
    exrep(b,-500,500){
      if(pow(a,5)-pow(b,5)==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;     
}


Measured memory_bytes: 4076
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>

using namespace std;

string s;
string t;

int main()
{
	cin >> s;
	cin >> t;

	string ans = "";
	for (int i = 0; i < s.length(); ++i) {
		bool g = true;
		for (int j = 0; j < t.length(); ++j) {
			if (i + j >= s.length()) {
				g = false;
			}
			g = g && (s[i + j] == '?' || s[i + j] == t[j]);
		}
		if (g) {
			string c = s;
			for (int j = 0; j < s.length(); ++j) {
				if (c[j] == '?')
					c[j] = 'a';
			}
			for (int j = 0; j < t.length(); ++j) {
				c[i + j] = t[j];
			}
			if (ans == "" || ans > c) {
				ans = c;
			}
		}
	}
	if (ans == "")
	{
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include  <stdio.h>
#include <stdbool.h>

#define N 8
#define FREE -1
#define NOTFREE 1


void intialize();
void printboard();
void recursive(int);

int row[N],col[N],drops[2*N-1],dneg[2*N-1];
bool x[N][N];

int main (){
  int i,j,k,r,c;
  intialize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      x[i][j]=0;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    x[r][c]=1;
  }
  recursive(0);

  return 0;
}
void intialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    drops[i]=FREE;
    dneg[i]=FREE;
  }
}
void printboard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(x[i][j]){
	if(row[i]!=j)
	  return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)
	printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i==N){
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    if(NOTFREE==col[j]||NOTFREE==drops[i+j]||NOTFREE==dneg[i-j+N-1])
      continue;

    row[i]=j;
    col[j]=drops[i+j]=dneg[i-j+N-1]=NOTFREE;

    recursive(i+1);
    row[i]=col[j]=drops[i+j]=dneg[i-j+N-1]=FREE;
  }
}
 


Measured memory_bytes: 2692
package main

/*
パーティション
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func partitionString(a []int, base int) string {
	var buf bytes.Buffer
	sep := ""
	for i, v := range a {
		if i == base {
			buf.WriteString(fmt.Sprintf("%s[%d]", sep, v))
		} else {
			buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		}
		sep = " "
	}
	return buf.String()
}

func partition(a []int) ([]int, int) {
	x := a[len(a)-1]
	i := -1
	for j := 0; j < len(a)-1; j++ {
		if a[j] <= x {
			i++
			a[i], a[j] = a[j], a[i]
		}
	}
	a[len(a)-1], a[i+1] = a[i+1], a[len(a)-1]
	return a, i + 1
}

func main() {
	scanner := makeScanner(100000 * 100000)
	eGetInt(scanner)
	s := eGetInts(scanner)
	s, idx := partition(s)
	fmt.Println(partitionString(s, idx))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(max int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), max)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}



Measured memory_bytes: 8796
#! /usr/bin/env perl

use strict;
use warnings;

my $line = <>;
chomp $line;


my $days = {SUN=> 7,
            MON=> 6,
            TUE=> 5,
            WED=> 4,
            THU=> 3,
            FRI=> 2,
            SAT=> 1
            };

print($days->{$line});

Measured memory_bytes: 640
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, K, Q;
    cin >> N >> K >> Q;

    vector<intmax_t> p(N, K - Q);

    while (Q--) {
        int a; cin >> a; a--;
        p[a]++;
    }

    for (auto pi: p) {
        cout << (pi <= 0 ? "No" : "Yes") << "\n";
    }

    return 0;
}


Measured memory_bytes: 1408
def lcg(x, a, b, c):
    return (x*a+b)%c


while True:
    (N, A, B, C, X) = [int(x) for x in input().split()]
    if N==0 and A==0 and B==0 and C==0 and X==0:
        exit()
    Y = [int(x) for x in input().split()]
    i = 0
    len_y = len(Y)
    for j in range(len_y):
        if X == Y[j]:
            if j == len_y-1:
                break
            X = lcg(X, A, B, C)
            i += 1
            continue
        else:
            while X != Y[j]:
                X = lcg(X, A, B, C)
                i += 1
                if i > 10000:
                    break
            if j != len_y-1:
                X = lcg(X, A, B, C)
                i += 1
        if i > 10000:
            i = -1
            break
    print(i)

Measured memory_bytes: 6736
def main():
    n = int(input())
    a = list(map(lambda x: int(x)*2, input().split()))
    # x1を求める（最終的に2x1 = ~~となる）
    ans = 0
    for i in a:
        ans = i - ans
    ans = round(ans / 2)
    # x1がもとまったら、順に解いていく
    res = list()
    res.append(ans)
    for i in range(n-1):
        res.append(a[i] - res[i])
    for i in res: 
        print(i, end=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 14100
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int ans = N / 2;
  if (N % 2 == 0) --ans;
  cout << ans << endl;
  return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	const int MX = 1e6 + 100;
	cin >>n;
	VI ct(MX), zc(MX);
	rep(i, n){
		int ba; cin >>ba;
		ct[ba]++;
	}

	rep(i, MX) if(ct[i] >=1) for(int j=i+i; j< MX; j+= i) zc[j]=1;
	int ans =0;
	rep(i, MX) if(ct[i] ==1 && zc[i]==0) ans++; 
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 11132
$cnt = 0
$gell = [1]

def insertion_sort(a, n, g)
  (g..n-1).each do |i|
    v = a[i]
    j = i - g
    while 0 <= j && v < a[j]
      a[j+g] = a[j]
      j -= g
      $cnt += 1
    end
    a[j+g] = v
  end
end

def shell_sort(a, n)
  h = 1
  loop do
    h = 3 * h + 1
    $gell << h if h <= n
    break if n / 9 < h
  end
  $gell.reverse!
  $gell.each do |g|
    insertion_sort(a, n, g)
  end
end

n = gets.strip.to_i

arr = n.times.map{gets.strip.to_i}

shell_sort(arr, n)
puts $gell.size
puts $gell.join(' ')
puts $cnt
puts arr

Measured memory_bytes: 16700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a,b;
  a=N/10;
  b=N%1000;
  if(a%111==0 || b%111==0){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

		String board[][] = new String[H][W];

		for (int i = 0; i < board.length; i++) {
			board[i] = sc.next().split("");
		}

		boolean[] row = new boolean[H];
		Arrays.fill(row, false);
		boolean[] col = new boolean[W];
		Arrays.fill(col, false);

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if(board[i][j].equals("#")) {
					row[i] = true;
					col[j] = true;
				}
			}
		}

		for (int i = 0; i < H; i++) {
			if (row[i]) {
				for (int j = 0; j < W; j++) {
					if (col[j]) {
						System.out.print(board[i][j]);
					}
				}
				System.out.println();
			}
		}
 	}
}


Measured memory_bytes: 26940
A = int(input())
B = int(input())
C = int(input())
X = int(input())
i=0
for a in range(0,A+1):
  for b in range(0,B+1):
    for c in range(0,C+1):
      if 500*a + 100*b + 50*c == X:
        i = i+1
print(i)

Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
const string s = "BYGR";
int main(void)
{
    int n,m,d;
    cin>>n>>m>>d;
    for (int i = 1;i <= n;++i,cout << '\n')
        for (int j = 1;j <= m;++j)
            cout << s[2 * (((i - j + 2 * n * m * d) % (d + d)) < d) + (((i + j) % (d + d)) < d)];
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define re register
#define N 301200
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
using namespace std;
struct edge{
	int u,v,d;
}e[N<<1];
inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
int f[N],g[N],ans,n,Q,cnt;
inline bool cmp(edge a,edge b){
	return a.d<b.d;
}
int find(int k){return f[k]==k?k:f[k]=find(f[k]);}
void Kr(){
	sort(e+1,e+1+cnt,cmp);
	for (int i=1,t=0;i<=cnt;++i){
		int x=find(e[i].u),y=find(e[i].v);
		if (x==y)continue;
		f[x]=y;
		++t;ans+=e[i].d;
		if (t==n-1)break;
	}
}
signed main(){
	n=read(),Q=read();
	memset(g,0x3f,sizeof(g));
	while (Q--){
		int u=read()+1,v=read()+1,d=read();
		e[++cnt]=(edge){u,v,d};
		g[u]=min(g[u],d+1);g[v]=min(g[v],d+2);
	}
	for (int i=1;i<=n;++i)
		g[i%n+1]=min(g[i%n+1],g[i]+2),f[i]=i;
	for (int i=1;i<=n;++i)
		g[i%n+1]=min(g[i%n+1],g[i]+2);
	for (int i=1;i<=n;++i)e[++cnt]=(edge){i,i%n+1,g[i]};
	Kr();
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int k, n;
  cin >> k >> n;
  int a0, prev;
  cin >> a0;
  prev = a0;
  int mdist = 0;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    if (a - prev > mdist)
      mdist = a - prev;
    prev = a;
  }
  if (a0 + k - prev > mdist)
    mdist = a0 + k - prev;
  cout << k - mdist << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1e5+20,mod=1e9+7;
typedef long long ll;
int n,m,dp[N];
vector<int>adj[N];
void dfs(int u){

    dp[u]=0;
    for(auto v:adj[u]){
        if(dp[v]==-1)
         dfs(v);
        dp[u]=max(dp[u],1+dp[v]);
    }
}
int main()
{
    input();
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;
        adj[u].push_back(v);
    }
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++){
        if(dp[i]==-1)dfs(i);
    }
    int mx=0;
    for(int i=1;i<=n;i++)
        mx=max(mx,dp[i]);
    cout<<mx<<endl;




}


Measured memory_bytes: 11324
#include <iostream>
#include <algorithm>
#include <string>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

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

    int lens[] = {5, 5, 6, 7};
    string words[] = {"dream", "erase", "eraser", "dreamer"};
    REP(i, 4) reverse(ALL(words[i]));

    while (S.size() > 0) {
        bool ok = false;
        REP(i, 4) {
            if (S.substr(0, lens[i]) == words[i]) {
                S = S.substr(lens[i]);
                ok = true;
                break;
            }
        }
        if (!ok) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	int X, N;

	si p;

	cin >> X >> N;

	for (int i = 1; i <= N; ++i) {
		int pi;
		cin >> pi;
		p.insert(pi);
	}

	pii best = mp(OO, 0);

	for (int ans = -100; ans <= 200; ++ans) {
		if (!present(p, ans))
			best = min(best, mp(abs(X - ans), ans));
	}

	cout << best.sc << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

## 3進数
'''
N = ii()

shiki = [1]
for i in range(10):
    tmp = shiki[-1]*3
    shiki.append(tmp)

ele = [3, 5, 7]
l = []
for keta in range(3, 10):
    maxx = shiki[keta]
    for i in range(maxx):
        ten = 10**(keta-1)
        tmp = 0
        for j in reversed(range(keta)):
            tmp += ele[i//shiki[j]] * ten
            i %= shiki[j]
            ten //= 10
        l.append(tmp)

cnt = 0
for num in l:
    if num > N:
        break
    num = str(num)
    if all(e in num for e in ['3', '5', '7']):
        cnt += 1
            
print(cnt)
'''

def n_shinsu(k, n):
    bi=''
    while n!=0:
        bi+=str(n%k)
        n=n//k
    return bi[::-1]

N = ii()
maxx = 8
l = []
ele = [3, 5, 7]
for keta in range(3, 10):
    maxx = (maxx+1) * 3 - 1
    for i in range(maxx):
        tmp = n_shinsu(3, i).zfill(keta)
        ten = 1
        num = 0
        for moji in tmp[::-1]:
            num += ele[int(moji)] * ten
            ten *= 10
        l.append(num)

cnt = 0
for num in l:
    if num > N:
        break
    num = str(num)
    if all(e in num for e in ['3', '5', '7']):
        cnt += 1
            
print(cnt)

Measured memory_bytes: 4300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  int cnt=0;
  int F=0;
  rep(i,N){
    if(A[i]==B[i]){
      cnt++;
      if(cnt>=3) F=1;
    }else cnt=0;
  }
  if(F) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}




Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll now = 1000;
    ll kabu = 0;
    rep(i, N) {
        now += kabu * A[i];
        kabu = 0;
        if(A[i + 1] > A[i]) {
            ll num = now / A[i];
            now -= A[i] * num;
            kabu += num;
        }
    }
    now += A[N - 1] * kabu;
    cout << now << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    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 pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200010);

int main(){
    ll N,K;
    cin >> N >> K;
    ll M = K;
    if(N < K){
        M = N;
        //if(N%2 != K%2){
        //    M--;
        //}
    }
    //ll init = ((K%2)?1:0);
    mint ans = 0;
    REP(i,0,M+1){
        ans += comb(N,i)*comb(N-1,i);//N-i とi // i+N-i-1
        //cout << i <<": " <<ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6232
// g++ -Wall -Wextra -pedantic -std=c++17 -O3 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -fsanitize=address -fno-sanitize-recover -fstack-protector contest.cpp

#include <bits/stdc++.h>

// #define _GLIBCXX_DEBUG 1
// #define _GLIBCXX_DEBUG_PEDANTIC 1
// #define _FORTIFY_SOURCE 2

using namespace std;
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii;
typedef vector<ll> vl; typedef pair<ll,ll> pll; typedef vector< pair<ll,ll> > vll;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const int MX = 400010;

int f[MX];
int rf[MX];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<MX;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[MX-1]=powmod(f[MX-1],MOD-2, MOD);
    for (int i=MX-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

int fac(int x) {
	int ret=1;
	for(int i = 1; i <= x; i++) {
		ret*=i;
		ret%=MOD;
	}
	return ret;
}
signed main(void)
{
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	sort(all(a));
	int ans=inf;
	for(int i = 0; i <= 100; i++) {
		int tp=0;
		for(int j = 0; j < n; j++) {
			tp += (a[j]-i)*(a[j]-i);
		}
		ans=min(ans,tp);
	}
	cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N, Y;
	cin >> N >> Y;
	for (ll i = 0; i <= N; i++) {
		for (ll j = 0; i + j <= N; j++) {
			ll k = N - j - i;
			if (i * 10 + j * 5 + k == Y / 1000) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy

def int2char(x):
    return chr(ord('a')+x)


N = int(input())
dp = ['a']
for i in range(N-1):
    nxt = []
    for s in dp:
        sets = set()
        for t in s:
            sets.add(t)
        for i in range(len(list(sets))+1):
            nxt.append(s+int2char(i))
    dp = copy.copy(nxt)

for s in dp:
    print(s)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int n; cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else if(n < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7708
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5];

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m, k;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>m;
	cout<<(1900*m + 100*(n-m))*pow(2,m);
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main(){
    int n, ans = 0;
    static int b[101];
    cin >> n;
    b[0] = b[n] = INT32_MAX;
    for(int i=1;i<n;++i) cin >> b[i];
    for(int i=1;i<=n;++i) ans += min(b[i-1], b[i]);

    cout << ans << endl;

    return 0;
}

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

int main() {
    //
    int num;

    cin >> num;
    vector<int> c(num, 0);
    vector<int> s(num, 0);
    vector<int> f(num, 0);
    vector<long long> ans(num, 0);
    for (int i = 0; i < num - 1; i++) cin >> c.at(i) >> s.at(i) >> f.at(i);

    for (int i = 0; i < num; i++) {
        int t = 0;
        for (int j = i; j < num - 1; j++) {
            if (t < s.at(j))
                t = s.at(j);
            else if (t % f.at(j) == 0)
                ;
            else
                t += f.at(j) - t % f.at(j);
            t += c.at(j);
        }
        cout << t << endl;
    }

    //
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000;
const double PI = acos(-1);
const int mod = 1000000007;

bool IsInteger(double n) {
    double comp = floor(n);
    if ((n - 1e-5) < comp && comp < (n + 1e-5)) {
        return true;
    }
    else {
        return false;
    }
}


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

    for (int i = 1; i <= n; i++) {
        int f = 0;
        for (int x = 1; x <= 100; x++) {
            for (int y = 1; y <= 100; y++) {
                int a = x + y;
                int b = -(x * x) - (y * y) - (x * y) + i;
                double z = (-a + sqrt(a * a + 4 * b)) / 2.0;
                if (IsInteger(z)) {
                    int z_int = (int)z;
                    if (z_int >= 1) f++;
                }
            }
        }
        cout << f << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;

int main() {
	u32 N;
	cin >> N;
	
	u32 smax = 0;
	map<string, u32> Ss;
	
	for(uint i=0; i<N; i++) {
		string S;
		cin >> S;
		
		u32 cnt;		
		if(Ss.find(S) != Ss.end()) {
			cnt = Ss.at(S) + 1;
			Ss.erase(S);
		} else {
			cnt = 1;
		}
		
		smax = max(smax, cnt);
		Ss[S] = cnt;
	}
	
	set<string> ansS;
	for(auto itr = Ss.begin(); itr != Ss.end(); ++itr) {
		auto cnt = itr->second;
		if(cnt >= smax) {
			ansS.insert(itr->first);
		}
	}
	
	for(auto itr = ansS.begin(); itr != ansS.end(); ++itr) {
		cout << *itr << endl;
	}
	
	return 0;
}

Measured memory_bytes: 34560
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 998244353;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};

 
int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, 1000);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
 
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        map<int,int> d;
        bool problem = false;
        forr(i,0,n) {
            readint(kk); d[kk]++;
            if (i==0) {  if (kk!=0) {problem = true;}  }
        }
        if (problem) {cout << 0 << endl; continue;}

        ll ret = 1;
        if (d.begin()->second!=1) { cout << 0 << endl; continue; }
        ll prev = 1, prev_d = 0;
        auto it = next(d.begin());
        while (it != d.end()) {
            if (it->first!=prev_d+1) {  ret = 0; break;  }
            ll how_many = it->second;
            // choose(how_many+prev-1, prev-1)
            ret *= fastpower<ll>(prev, how_many);
            ret = ret % modd;
            prev = it->second; prev_d = it->first; ++it;
        }
        cout << ret << endl;


    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 8124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	double n, k,s=0,t;
	cin >> n >> k;
	for (double i = 1; i <= n;i++) {
		t = 0;
		while (k > i*pow(2.0, t)) {
			t++;
		}
		s += (1 / n) * pow((1 / 2.0), t);
	}
	
	printf("%.10f", s);
}

Measured memory_bytes: 512