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

int main(void){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }


    queue<int> q;
    q.push(0);
    vector<int> parent(n,-1);
    parent[0] = 0;
    while(!q.empty()){
        int now = q.front(); q.pop();
        for(int i=0;i<G[now].size();i++){
            if(parent[G[now][i]]!=-1) continue;

            parent[G[now][i]] = now;
            q.push(G[now][i]);
        }
    }

    bool ok = true;
    for(int i=0;i<n;i++) if(parent[i]==-1) ok = false;

    if(!ok){cout << "No" << endl; return 0;}

    cout << "Yes" << endl;
    for(int i=1;i<n;i++) cout << parent[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 10236
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << 0.5 << endl;
    } else {
        Int half = n / 2;
        double answer = (double)(half + 1) / (double)n;
        cout << answer << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> V(N,vector<int>(N,-1));
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    for(int j=0;j<a;j++){
      int x,y;
      cin >> x >> y;
      V[i][x-1] = y;
    }
  }
  
  int ans=0;
  for(int i=0;i<(1<<N);i++){
    bitset<15> B(i);
    bool ok=true;
    for(int j=0;j<N;j++){
      if(!B.test(j)) continue;
      for(int k=0;k<N;k++){
        if(V[j][k]==1 && !B.test(k)) ok = false;
        if(V[j][k]==0 && B.test(k)) ok = false;
      }
    }
    int honest = B.count();
    if(ok) ans = max(ans,honest);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val s1, s2 = sc.next + ("*" * 5)
  val MOD = 1000000007L

  var i = 0
  var sum: Long = if (s1(0) == s2(0)) 3 else 6
  while(i < n) {
    if (((s1(i+1) == s2(i+1)) && s1(i+1) != '*') || ((s1(i+1) != s2(i+1)) && s1(i+2) != '*')) {
      if (s1(i) == s2(i)) {
        sum = (sum * 2L) % MOD
        i += 1
      } else {
        if (s1(i + 2) != s2(i + 2)) {
          sum = (sum * 3L) % MOD
        }
        i += 2
      }
    } else i = n
  }
  println(sum)
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d",&n);
  ll creaturesByCity[n+1], bravePower[n+1], ans = 0;

  REP(i,n+1) cin >> creaturesByCity[i];
  REP(i,n) cin >> bravePower[i];
  bravePower[n] = 0;

  ll leftPower = 0;
  REP(i,n+1) {
    ll totalPower = bravePower[i] + leftPower;
    if(creaturesByCity[i] >= totalPower) {
      ans += totalPower;
      leftPower = 0;
    } else {
      ans += creaturesByCity[i];
      if(creaturesByCity[i] >= leftPower) leftPower = bravePower[i] - (creaturesByCity[i] - leftPower);
      else leftPower = bravePower[i];
    }
  }

  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int N,sumE,head[MAXN],dep[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u) {
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        dfs(v);
    }
    vector<int> sec;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        sec.pb(dep[v]);
    }
    sort(sec.begin(),sec.end());
    for(auto t : sec) {
        dep[u] = max(dep[u],t) + 1;
    }
}
void Solve() {
    read(N);
    int f;
    for(int i = 2 ; i <= N ; ++i) {
        read(f);
        add(f,i);
    }
    dfs(1);
    out(dep[1]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 9600
use whiteread::parse_line;

fn main() {
    let n: u32 = parse_line().unwrap();
    let a: Vec<u32> = parse_line().unwrap();

    println!(
        "{}",
        3_usize.pow(n) - a.iter().fold(1, |x, y| if y % 2 == 0 { x * 2 } else { x })
    );
}


Measured memory_bytes: 2132
use proconio::input;

fn main() {
    input! { n: usize, q: usize }

    let mut t = FenwickTree::new(n);
    for i in 0..n {
        input! { a: u64 }
        t.add(i, a);
    }

    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    n: usize,
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};
impl<T: Copy + Integer + AddAssign> FenwickTree<T> {
    #[inline]
    fn new(n: usize) -> Self {
        Self {
            n,
            v: vec![zero(); n],
        }
    }

    #[inline]
    fn add(&mut self, i: usize, v: T) {
        let mut i = i + 1;
        while i <= self.n {
            self.v[i - 1] += v;
            i += i & i.wrapping_neg();
        }
    }

    #[inline]
    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    #[inline]
    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= i & i.wrapping_neg();
        }
        v
    }
}


Measured memory_bytes: 21456
// Problem : C - Snuke Festival
// Contest : AtCoder - AtCoder Beginner Contest 077
// URL : https://atcoder.jp/contests/abc077/tasks/arc084_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

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

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

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n; cin >> n;
    vi a(n),b(n),c(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    rep(i,0,n) cin >> c[i];    
    
    sort(all(a)) , sort(all(c));
    ll ans = 0,temp1,temp2;
    
    rep(i,0,n){
        auto it1 = lb(all(a),b[i]) - a.begin();
        auto it2 = ub(all(c),b[i]) - c.begin();
        
        temp1 = it1, temp2 = n - it2;        
        ans += (temp1 * temp2);
    }
        
    cout << ans;
}

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

Measured memory_bytes: 4524
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e6+8;
int main()
{
    string s;
    cin>>s;
    int i,c=0;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        cout<<3;
    else if(s[0]=='R' && s[1]=='R')
        cout<<2;
    else if(s[1]=='R' && s[2]=='R')
        cout<<2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        cout<<1;
    else
        cout<<0;
    cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3660
a, b = map(int, input().split())
if a == b : print('Draw')
else :
  flag = False
  if min(a, b) == 1 : flag = True
  if a < b :
    if flag : print('Alice')
    else : print('Bob')
  else :
    if flag : print('Bob')
    else : print('Alice')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll a;
    cin >> a;
    if(a < 10)
    {
        cout << a << endl;
    }
    else
    {
        int ans = 0;
        while(true)
        {
            if(a / 10 == 0)
            {
                ans += a % 10;
                cout << ans << endl;
                return 0;
            }
            else
            {
                int x = a % 10;
                a /= 10;
                ans += 9;
                if(x != 9) a--;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(3*N);
  REP(i,3*N)cin>>A[i];

  ll now=0ll;
  priority_queue<ll, vector<ll>, greater<int>> left;
  priority_queue<ll> right;

  vector<ll> sum_left,sum_right;

  REP(i,N){
    left.push(A[i]);
    now+=A[i];
  }
  sum_left.push_back(now);

  FOR(i,N,2*N){
    now+=A[i];
    left.push(A[i]);
    now-=left.top();
    left.pop();
    sum_left.push_back(now);
  }

  reverse(ALL(A));
  now=0ll;

  REP(i,N){
    right.push(A[i]);
    now+=A[i];
  }
  sum_right.push_back(now);

  FOR(i,N,2*N){
    now+=A[i];
    right.push(A[i]);
    now-=right.top();
    right.pop();
    sum_right.push_back(now);
  }

  reverse(ALL(sum_right));

  ll ans=-INFLL;
  REP(i,N+1){
    ans=max(ans,sum_left[i]-sum_right[i]);
  }
  cout<<ans<<endl;
}


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

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;

    vector<int> dp(N, 0);
    for (int i = 0; i < N - 1; i++) {
        if (S.at(i) == 'A' && S.at(i + 1) == 'C') {
            dp.at(i + 1) = dp.at(i) + 1;
        }
        else {
            dp.at(i + 1) = dp.at(i);
        }
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << dp.at(r - 1) - dp.at(l - 1) << endl;
    }
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            String[] strArr = s.Split(' ');

            var List = new List<int>();

            for (int i = 0; i < strArr.Length; i++)
            {
                List.Add(int.Parse(strArr[i]));
            }

            List.Sort();

            Console.WriteLine(List[0] + " " + List[1] + " " + List[2]);
        }
    }
}


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

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

	bool good = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) good = false;
		}
		else {
			if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) good = false;
		}
	}	

	if (good) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#define endl "\n"

int main()
{
	faster;

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);

	for (auto &x : a)
		cin >> x;

	for(int i = 1; i < n; i++){
		a[i] += a[i-1];
	}

	for(int i = k; i < n; i++){
		if(i == k && a[i]-a[i-k] > a[i-1]){
			cout << "Yes" << endl;
		}else if(i == k){
			cout << "No" << endl;
		}
		if(i != k && a[i] - a[i-k] > a[i-1]-a[i-k-1]){
			cout << "Yes" << endl;
		}else if(i != k){
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4776
#include<cstdio>

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

using namespace std;

int main(){
	for(int n,t,nl,nb;scanf("%d%d%d%d",&n,&t,&nl,&nb),n;){
		bool lose[101]={},back[101]={};
		rep(i,nl){ int a; scanf("%d",&a); lose[a]=true; }
		rep(i,nb){ int a; scanf("%d",&a); back[a]=true; }

		n++;
		double dp[102][101]={};
		dp[0][0]=1;
		rep(i,t) rep(x,n) {
			if(x==n-1){ // à¤S[É¢éÈç³¢±ëðUçÈ¢
				dp[i+1][x]+=dp[i][x];
			}
			else{ // ³¢±ëðUé
				int i_next=(!lose[x]?i+1:i+2);
				for(int a=1;a<=6;a++){
					int y=x+a; if(y>=n) y=2*(n-1)-y; // x ©ç a }Xiñ¾Êu
					if(back[y]) dp[i_next][0]+=dp[i][x]/6;
					else        dp[i_next][y]+=dp[i][x]/6;
				}
			}
		}
		printf("%.9f\n",dp[t][n-1]);
	}

	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll ai,ao,at,aj,al,as,az;
	cin >> ai >> ao >> at >> aj >> al >> as >> az;

	ll ans=2LL*(ai/2);
	ans+=ao;
	ans+=2LL*(aj/2);
	ans+=2LL*(al/2);
	if(ai%2+aj%2+al%2==3) ans+=3LL;
	if(ai>0 and ai%2==0 and ai%2+aj%2+al%2==2) ans+=1LL;
	if(aj>0 and aj%2==0 and ai%2+aj%2+al%2==2) ans+=1LL;
	if(al>0 and al%2==0 and ai%2+aj%2+al%2==2) ans+=1LL;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
f = ["." * (W + 2)]
for _ in range(H):
    f += ["." + input() + "."]
f += ["."* (W+2)]

ans = [[0 for _ in range(W)] for _ in range(H)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if f[i][j] == '#':
            ans[i-1][j-1] = '#'
            continue
        cnt = 0
        if f[i-1][j-1] == '#':
            cnt += 1
        if f[i-1][j] == '#':
            cnt += 1
        if f[i-1][j+1] == '#':
            cnt += 1
        if f[i][j-1] == '#':
            cnt += 1
        if f[i][j+1] == '#':
            cnt += 1
        if f[i+1][j-1] == '#':
            cnt += 1
        if f[i+1][j] == '#':
            cnt += 1
        if f[i+1][j+1] == '#':
            cnt += 1
            
        ans[i-1][j-1] = str(cnt)
        
for i in range(H):
    print(''.join(ans[i]))

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private static Dictionary<long, long> trialDivResult = new Dictionary<long, long>();
        static void Solve()
        {
            var np = ReadAndParseLongArr();
            long n = np[0];
            long p = np[1];


            // pの素因数分解
            TrialDivision(p);
            long ans = 1;
            foreach(var kv in trialDivResult)
            {
                if( kv.Value >= n)
                {

                    long prime = kv.Key;
                    long total = kv.Value / n;
                    for(int i = 0; i < total; ++i)
                    {
                        ans *= prime;
                    }
                }
            }
            Console.WriteLine(ans);
        }
        private static void TrialDivision(long p)
        {
            for (long i = 2; i * i <= p; ++i)
            {
                while (p % i == 0)
                {
                    SafeIncrement(i);

                    p /= i;
                }
            }
            if( p > 1)
            {
                SafeIncrement(p);
            }
        }
        private static void SafeIncrement(long key)
        {
            if (!trialDivResult.ContainsKey(key))
            {
                trialDivResult.Add(key, 1);
            }
            else
            {
                trialDivResult[key]++;
            }
        }


        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13152
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        int k = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        
        if(a % k == 0 || b % k == 0){
            System.out.println("OK");
            return;
        }else{
            int st = (a / k) * k;
            while(st + k <= b){
                st += k;
                if(st >= a && st <= b){
                    System.out.println("OK");
                    return;
                }
            }
        }
        System.out.println("NG");
        
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


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

int N,K,P[5000],C[5000],DP[5000][35];
ll DS[5000][31];

ll calc(int k,int p){
	ll a=0;
	int c=0;
	for(int i=30;i>=0;i--){
		if(c+(1<<i)<=k){
			c+=(1<<i);
			a+=DS[p][i];
			p=DP[p][i];
		}
	}
	return a;
}

int main(){
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>P[i];
		P[i]--;
	}
	for(int i=0;i<N;i++){
		cin>>C[i];
	}
	ll res=-1e18;
	for(int i=0;i<N;i++){
		DP[i][0]=P[i];
		DS[i][0]=C[P[i]];
	}
	for(int i=0;i<30;i++){
		for(int j=0;j<N;j++){
			DP[j][i+1]=DP[DP[j][i]][i];
			DS[j][i+1]=DS[j][i]+DS[DP[j][i]][i];
		}
	}
	for(int i=0;i<N;i++){
		for(int j=1;j<=N&&j<=K;j++){
			res=max(res,calc(j,i));
		}
		for(int j=K;j>=K-N&&j>=1;j--){
			res=max(res,calc(j,i));
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 5572
import java.util.*;

public class Main {

    static int mod = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n+1];
        a[1] = m;
        for (int i = 2; i <= n; i++) {
            a[i] = (a[i-1] * (m-1)) % mod;
        }
        Combination com = new Combination(n-1, mod);
        long ans = 0;
        for (int i = n-k; i <= n; i++) {
            int tk = n - i;
            long tmp = (a[i] * com.comb(n-1, tk)) % mod;
            ans = (ans + tmp) % mod;
        }
        System.out.println(ans);
        sc.close();

    }

}

class Combination {

    /** factorial:階乗 */
    private long fac[];
    /** inverse:逆元（ここでは、fac[i]をMOD-2乗したものをMODで割った余り） */
    private long inv[];
    /** 除数 */
    private int mod;

    /**
     * コンストラクタ
     * @param size 組み合わせの対象となる個数
     * @param mod 除数
     */
    public Combination(int size, int mod){
        this.fac = new long[size +1];
        this.inv = new long[size +1];
        this.mod = mod;

        this.fac[0] = 1;
        this.inv[0] = 1;

        for(int i = 1; i <= size; i++){
            fac[i] = (fac[i -1] * i) %mod;
            inv[i] = modPow(fac[i], (int)mod -2) %mod;
        }
    }

    /**
     * n個の中からr個選ぶ組み合わせの数（nCr）をmodで割った余りを算出する
     * @param n 元の集合の要素数
     * @param r 組み合わせる要素数
     * @return nCr % mod
     */
    public long comb(int n, int r){
        return fac[n] * inv[r] %mod * inv[n - r] %mod;
    }

    /**
     * base^exp をmodで割った余りを算出する
     * @param base 基数
     * @param exp 指数
     * @return base^exp % mod
     */
    private long modPow(long base, int exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}


Measured memory_bytes: 40484
n = input()
t = list(map(int , input().split()))
m = int(input())
p = []
for _ in range(m):
    p.append(input())

anss = []
for i in p:
    ans = []
    pp , xx = map(int , i.split())
    for i , n in enumerate(t):
        if i+1 == pp:
            ans.append(xx)
        else:
            ans.append(n)
    anss.append(ans)
for i in anss:
    print(sum(i))


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

int main() {
    int N;
    cin >> N;
    int A[N], B[N];
    for(int i = 1; i <= N; i++) {
        B[i] = 0;
    }
    for(int i = 2; i <= N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    for(int i = 1; i <= N; i++) {
        cout << B[i] << endl;
    }
}


Measured memory_bytes: 5172
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	week := map[string]int{
		"MON": 1,
		"TUE": 2,
		"WED": 3,
		"THU": 4,
		"FRI": 5,
		"SAT": 6,
		"SUN": 7,
	}
	s := nextString()

	nextSunday := 0
	if s == "SUN" {
		nextSunday = 7
	} else {
		nextSunday = week["SUN"] - week[s]
	}
	fmt.Println(nextSunday)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string>
#include<vector>

using namespace std;
int main(){
  vector<string> strList;
  int a;
  cin >> a;
  string str3;
  for(int i=0;i!=a;i++){
    cin >> str3;
    strList.push_back(str3);
    if(i!=0){
      string str,str2;
      str=strList[i];
      str2=strList[i-1];
      if(str.front() != str2.back()){
        cout << "No" << endl;
        return 0;
      }
    }
    for(int j=0;j!=i;j++){
      if(strList[i] == strList[j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
def check_nmine(h,w,matrix):
    count=0
    #h+1 -1 （いっぱい書く）
    if h-1 >= 0 and w-1 >= 0:
        if(matrix[h-1][w-1] == '#'):
            count += 1
    if h-1 >= 0 and w >= 0:
        if(matrix[h-1][w] == '#'):
            count += 1
    if h-1 >= 0 and w+1 < W:
        if(matrix[h-1][w+1] == '#'):
            count += 1
            
    if h >= 0 and w-1 >= 0:
        if(matrix[h][w-1] == '#'):
            count += 1
    if h >= 0 and w+1 < W:
        if(matrix[h][w+1] == '#'):
            count += 1
            
    if h+1 < H and w-1 >= 0:
        if(matrix[h+1][w-1] == '#'):
            count += 1
    if h+1 < H and w >= 0:
        if(matrix[h+1][w] == '#'):
            count += 1
    if h+1 < H and w+1 < W:
        if(matrix[h+1][w+1] == '#'):
            count += 1
            
    return count


H,W = map(int,input().split())



matrix = []
for i in range(H):
    matrix.append(list(input()))

for h in range(H):
    for w in range(W):
        if matrix[h][w] != '#':
            matrix[h][w] = str(check_nmine(h,w,matrix))
            
for i in matrix:
    print("".join(i))
    


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
typedef long l;
typedef long long ll;
using namespace std;
int main(){
int N;
cin>>N;
int ans=0;
for(int i=0; i<=N; ++i){
ans= ans+i;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int D, T, S; cin >> D >> T >> S;
    if (D <= T * S) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3648
from math import gcd
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        x = gcd(a, b)
        if x == 1:
            ans += k
            continue
        for c in range(1, k+1):
            ans += gcd(x, c)
print(ans)


Measured memory_bytes: 67748
c = [list(map(int, input().split())) for i in range(3)]

j = True
for i in range(2):
    if abs(c[i+1][0]-c[i][0]) == abs(c[i+1][1]-c[i][1]) == abs(c[i+1][2]-c[i][2]):
        pass
    else:
        j = False

for i in range(2):
    if abs(c[0][i+1]-c[0][i]) == abs(c[1][i+1]-c[1][i]) == abs(c[2][i+1]-c[2][i]):
        pass
    else:
        j = False

if j:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38480
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

struct restaurant {

   int idx;
   string name;
   int point;

};

bool asc(const restaurant& left, const restaurant& right){

   return left.name == right.name ? left.point > right.point : left.name < right.name;

}


int main(){
   int N;

   cin >> N;
   vector<restaurant> list;

   for(int i=0; i<N; i++ ){
     struct restaurant x;
     x.idx = i+1;
     cin >> x.name >> x.point;
     list.push_back(x);
   }

   sort(list.begin(), list.end(), asc);

   for(int i=0; i<N; i++){
      cout << list[i].idx << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, std::string S){
  rep(i,S.size()){
    cout<<(char)(((S[i]+N-'A')%26)+'A');
  }cout<<endl;
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    A.push_back(x);
  }sort(A.begin(),A.end());

  for(int i=A[1];i>0;i--){
    int flag=0;
    for(int k=0;k<N;k++){
      if(A[k]%i)flag++;
      if(flag==2)break;
    }
    if(flag<2){cout << i << endl;break;}
  }
  return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>>p(m);
  for(int i=0;i<m;i++){
      cin>>p[i].first>>p[i].second;
  }
  for(int i=0;i<=1000;i++){
      vector<int>d(1,i%10);
      int nx=i/10;
      int keta=1;
      while(nx){
          d.push_back(nx%10);
          nx/=10;
          keta++;
      }
      if(keta!=n){
          continue;
      }
      bool at=true;
      reverse(d.begin(),d.end());
      for(int j=0;j<m;j++){
          if(d[p[j].first-1]!=p[j].second){
              at=false;
          }
          
      }
      if(at){
          cout<<i<<endl;
          return 0;
      }
     
  }
  cout<<-1<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<ll> T(N);
	vector<ll> A(N);

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

	if(A[0] != T[N-1]){
		cout << 0 << endl;
		return 0;
	}

	int index_T = 0;
	int index_A = 0;
	for(int i = 0;i < N;i++){
		if(T[i] == T[N-1]){
			index_T = i;
			break;
		}
	}

	for(int i = N - 1;i >= 0;i--){
		if(A[i] == A[0]){
			index_A = i;
			break;
		}
	}

	if(index_T > index_A){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	for(int i = 1;i < index_T;i++){
		if(T[i] == T[i-1]){
			ans *= T[i];
			ans %= MOD;
		}
	}

	for(int i = N-2;i > index_A;i--){
		if(A[i] == A[i+1]){
			ans *= A[i];
			ans %= MOD;
		}
	}

	for(int i = 0;i < (index_A - index_T - 1);i++){
		ans *= A[0];
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4844
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
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)++)
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    char map[100][100];
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            map[i][j]='#';
        }
    }
    for(int i=50;i<100;i++){
        for(int j=0;j<100;j++){
            map[i][j]='.';
        }
    }
    a--;b--;
    for(int i=0;i<49;i++){
        if(!a)break;
        for(int j=0;j<100;j++){
            if(!a)break;
            if(i%2==0&&j%2==0){
                map[i][j]='.';
                a--;
            }
        }
    }
    for(int i=51;i<100;i++){
        if(!b)break;
        for(int j=0;j<100;j++){
            if(!b)break;
            if(i%2==0&&j%2==0){
                map[i][j]='#';
                b--;
            }
        }
    }
    cout << 100 << " " << 100 << endl;
    rep(i,100){
        rep(j,100)cout << map[i][j];
        cout << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll X, N; cin >> X >> N;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  vector<bool> b(110, false); rep(i, N) b[a[i]] = true; 
  ll ans = 0;

  if(N == 0) cout << X << endl;
  rep(i, 100) {
    ll ans1 = X - i;
    ll ans2 = X + i;
    int an = 0;
    rep(j, N) {
      if(b[ans1]==false) {
	cout << ans1 << endl;
	return ;
      }
      if(b[ans2]==false) {
	cout << ans2 << endl;
	return ;
      }
    }
  }
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3652
N,W = map(int,input().split())

weight = []
value = []
for i in range(N):
    w,v = map(int,input().split())
    
    weight.append(w)
    value.append(v)

dp = [[0]*100100 for i in range(110)]

for i in range(N):
    for sum_w in range(W+1):
        if sum_w - weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i])

        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])    
        
print(dp[N][W])

Measured memory_bytes: 157044
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);

		tokens = in.readLine().split(" ");

		Queue<Long> que = new PriorityQueue<>(new Comparator<Long>() {
			@Override
			public int compare(Long o1, Long o2) {
				return -1 * Long.compare(o1, o2);
			}
		});
		for (int i = 0; i < N; ++i) {
			que.add(Long.parseLong(tokens[i]));
		}

		for (int i = 0; i < M; ++i) {
			Long val = que.poll();
			que.add(val / 2);
		}

		long sum = 0;
		while (!que.isEmpty()) {
			sum += que.poll();
		}
		System.out.println(sum);
	}
}


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

int main()
{
 	long long n;
 	cin >> n;
 	
 	long long count =0;
 	
 	for (long long i = 1; i <= n; i++)
	{
		if(i%15 !=0)
		{
			if(i%3 != 0)
			{
				if (i%5 != 0)
				{
					count += i;
				}
			}
		} 
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 3640
N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print(0)
    quit()

start = 0
moves = []
for i in range(N-1):
    if H[i] >= H[i+1]:
        continue
    moves.append(i - start)
    start = i + 1
if H[N-2] >= H[N-1]:
    moves.append(i - start + 1)
print(max(moves))


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N; cin >> N;
    int a[200005];
    deque<int> b;
    for (int i = 0;i < N;i++){
        cin >> a[i];
        if(i%2 == 0) b.push_back(a[i]);
        else b.push_front(a[i]);
    }

    if(N%2 == 0){
        for (int i = 0;i < b.size();i++){
            cout << b[i] << " ";
        }
    }else{
        for (int i = b.size()-1;i >= 0;i--){
            cout << b[i] << " ";
        }
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 3840
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N,K;
    N = sc.nextInt();
    K = sc.nextInt();
    long a,b;
    a = N / K;
    long ans;
    ans = a * a * a;
    if(K % 2 == 0){
      b = (N + K/2) / K;
      ans += b * b * b;
    }
    System.out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

bool ff[31],g[3001];
int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	ff[0]=1;
        for (int i=a;i*100<=f;i++)
		ff[i]|=ff[i-a];
	for (int i=b;i*100<=f;i++)
		ff[i]|=ff[i-b];
	g[0]=1;
	for (int i=c;i<=f;i++)
		g[i]|=g[i-c];
	for (int i=d;i<=f;i++)
		g[i]|=g[i-d];
	int answ=a,anss=0;
	for (int i=1;i*100<=f;i++)
		if (ff[i])
		{
			for (int j=i*e;j*answ>anss*i;j--)
			if (g[j]&&i*100+j<=f)
			{
				answ=i;
				anss=j;
				break;
			}
		}
	cout<<answ*100+anss<<' '<<anss;
	return 0;
}


Measured memory_bytes: 256
def is_prime(n):
    max_factor = int(n**.5)
    for i in range(2, max_factor+1):
        if n % i == 0:
            return False
    return True
  
def is_2017like(n):
    if n % 2 == 0: return False
    return is_prime(n) and is_prime((n+1)//2)
  
cum = [0,0]
for i in range(2,10**5+2):
    if is_2017like(i):cum.append(cum[-1]+1)
    else:cum.append(cum[-1])

Q=int(input())
for q in range(Q):
  l,r=map(int,input().split())
  print(cum[r]-cum[l-1])

Measured memory_bytes: 10332
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


vector<int> a(0);

vector<bool> is_prime(0);//iは素数か
//n以下の素数の数
void hurui(){
    int n=1000000;
    is_prime.resize(n+1,true);
    is_prime[0]=0; is_prime[1]=0;
    int p=0;
    for(auto x:a){
        if(is_prime[x]){
            for(int j=2*x; j<=n; j +=x){
                is_prime[j]=false;
            }
        }
    }
    return;
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    a.resize(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    if(a[0]==1 &&a[1]==1){
        cout<<0<<endl;
        return 0;
    }
    if(a[0]==1){
        cout<<1<<endl;
        return 0;
    }
    hurui();
    int ans=0;
    rep(i,n){
        if(i<n-1 && a[i]==a[i+1]) continue;
        if(i>0 && a[i]==a[i-1]) continue;
        if(is_prime[a[i]]) ans ++;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

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

using namespace std;

#define int long long

signed main()
{
    int x, y;
    cin >> x >> y;
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> p3;
    multiset<int> p1, p2;
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        p1.insert(x);
    }
    for(int i = 0; i < m; ++i)
    {
        int x;
        cin >> x;
        p2.insert(x);
    }
    for(int i = 0; i < k; ++i)
    {
        int x;
        cin >> x;
        p3.push_back(x);
    }
    while(p1.size() > x)
    {
        p1.erase(p1.begin());
    }
    while(p2.size() > y)
    {
        p2.erase(p2.begin());
    }
    sort(p3.rbegin(), p3.rend());
    int ptr1, ptr2;
    ptr1 = x - 1;
    ptr2 = y - 1;
    for(int i = k - 1; i >= 0; --i)
    {
        int xx, yy;
        xx = *p1.begin();
        yy = *p2.begin();
        if (xx < yy)
        {
            if (xx < p3[i])
            {
                p1.erase(p1.find(xx));
                p1.insert(p3[i]);
            }
        }
        else
        {
            if (yy < p3[i])
            {
                p2.erase(p2.find(yy));
                p2.insert(p3[i]);
            }
        }
    }
    int ans = 0;
    for(auto i = p1.begin(); i != p1.end(); ++i)
    {
        ans += *i;
    }
    for(auto i = p2.begin(); i != p2.end(); ++i)
    {
        ans += *i;
    }
    cout << ans;
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 1e5 + 10;
int dp[105][mxn], n, W;
int w[mxn], v[mxn];

// dp[i][j] = maximum value of items using remaining 'j' amount of
//			  weight and first 'i' items are left to be processed

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

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

	cin >> n >> W;
	FOR(i,1,n)
		cin >> w[i] >> v[i];
	
	FOR(j,0,W)
		dp[0][j] = 0;
	FOR(i,1,n)
		dp[i][0] = 0;

	FOR(i,1,n)
	{
		FOR(j,1,W)
		{
			dp[i][j] = dp[i - 1][j];
			if(j >= w[i])
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}

	cout << dp[n][W];

	return 0;
}

Measured memory_bytes: 82540
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	if(s[0]==s[len-1])
	{
		if(len&1) cout<<"Second"<<endl;
		else cout<<"First"<<endl;
	}
	else
	{
		if(len&1) cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
# include <iostream>

using namespace std;

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

    string* S;
    S = new string[N];

    int C0 = 0, C1 = 0, C2 = 0, C3 = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }

    for (int i = 0; i < N; i++)
    {
        if (S[i] == "AC")
            C0++;
        else if (S[i] == "WA")
            C1++;
        else if (S[i] == "TLE")
            C2++;
        else if (S[i] == "RE")
            C3++;
    }

    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;

    return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main() 
{
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    
    ll dp[n+1][m+1];
    
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    //  for(ll i=0;i<=n;i++)
    // {
    //     for(ll j=0;j<=m;j++)
    //         cout<<dp[i][j]<<" ";
    //         cout<<endl;
    // }
    //cout<<dp[n][m];
    
    
    vector<char>v;
    
    ll i=n,j=m;
    
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            v.pb(s[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            i--;
            else
            j--;
        }
        
    }
    reverse(v.begin(),v.end());
    for(ll i=0;i<v.size();i++)
    cout<<v[i];
    
    
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

string s;

bool check(int l, int r) {
    while (l < r) {
        if (s[l] != s[r])
            return false;
        ++l;
        --r;
    }
    return true;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> s;
    int n = s.length();
    if (check(0, (n-3)/2) && check((n+1)/2, n-1) && check(0, n-1))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'


int main() {
	#ifndef ONLINE_JUDGE
	//freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	ll sm = 0;
	for (char c: s) sm += (ll) (c-'0');
	cout << (sm % 9 == 0 ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3744