akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here
    string N;
    string ok ="No";
    
    cin >> N;
    
    
    for(int i=0;i<3;i++){
        if(N.at(i)=='7'){
          ok = "Yes";
        }
    }
    
    cout << ok << endl;
    
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> city(N,0); 
 
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    city.at(a-1)++;
    city.at(b-1)++;
  }
  
  for (int i=0 ; i < N ; i++){
    cout << city.at(i) << endl;
  }
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B + 1 >= C) {
    cout << B+C << endl;
  }
  else {
    cout << A + 2*B + 1 << endl;
  }
}

Measured memory_bytes: 256
/*Kadai3_4
  saitomo*/
#include<stdio.h>

int main(void){
  int num,judge=0;//judgeを使って判定をする
  scanf("%d",&num);
  for(int i=1;i<10;i++){//1から9まででnumを割っていきあまりが0かつ商が10未満ならばjudgeに1を足す
    if(num%i==0 && num/i<10){
      judge+=1;
    }
  }
  if (judge!=0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;


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

  map<string, int> s;

  for (int i = 0; i < n; i++)
  {
    string t;
    cin >> t;
    s[t]++;
  }

  int maxc = 0;

  for (auto p: s)
  {
    maxc = max(maxc, p.second);
  }

  for (auto p: s)
  {
    if (p.second == maxc) cout << p.first << endl;
  }

  return 0;
}

Measured memory_bytes: 25216
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int64_t i = 0; i < (n); i++)
using namespace std;
const int64_t mod = 998244353;
vector<int64_t> fact;
vector<int64_t> finv;

int64_t power(int64_t a, int64_t b) {
  int64_t res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

int64_t comb(int64_t n, int64_t r) {
  if (n >= r)
    return ((fact[n] * finv[r]) % mod * finv[n - r]) % mod;
  else
    return 0;
}

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, M, K;
  cin >> N >> M >> K;

  fact.resize(N + 1);
  finv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  finv[N] = power(fact[N], mod - 2);
  for (int i = N - 1; i >= 0; --i) {
    finv[i] = (finv[i + 1] * (i + 1)) % mod;
  }

  int64_t answer = 0;
  for (int i = 0; i <= K; ++i) {
    // (N-1)C(i)
    int64_t tmp0 = comb(N - 1, i);
    //cout << "comb " << N - 1 << "C" << i << "=" << tmp0 << endl;
    // (M-1)^(N-1-i)
    int64_t tmp1 = power(M-1, N-1-i);
    int64_t tmp = (tmp0 * tmp1) % mod;
    // M * (N-1)C(i) * (M-1)^(N-1-i);
    tmp = M * tmp % mod;
    answer = (answer + tmp) % mod;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 6240
/*
 * Transformation.cpp
 *
 *  Created on: 2014/08/04
 *      Author: WanWan1985
 */
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

// for util
#define FOR(i, a, b) 	for(int i = (a); i < (b); i++)
#define REP(i, n)		FOR(i, 0, n)
#define PB				push_back
#define MP				make_pair
#define CL				clear
#define EXIT			(0)

typedef unsigned int u_int;
typedef long long ll;

#define	COMMAND_REPLACE	"replace"
#define COMMAND_REPLACE_NUM	(7)

#define COMMAND_REVERSE	"reverse"
#define COMMAND_REVERSE_NUM	(7)

#define COMMAND_PRINT	"print"
#define COMMAND_PRINT_NUM	(5)

void command(string& a_rstrTargetWord, string strCommand);

int main(void) {

	// 入力
	string strTargetWord;
	cin >> strTargetWord;
	int iCommandNum = 0;
	cin >> iCommandNum;

	vector<string> vecCommand;
	int iCount = 0;
	while (1) {
		string strCommand;
		getline(cin, strCommand);
		vecCommand.PB(strCommand);
		if (iCommandNum == iCount) {
			break;
		}
		iCount++;
	}

	// 実行
	REP(i, vecCommand.size()) {
		command(strTargetWord, vecCommand.at(i));
	}
	return EXIT;
}

void command(string& a_rstrTargetWord, string strCommand) {
	string::size_type pos = strCommand.find(COMMAND_REPLACE, 0);
	if (pos != string::npos) {
		pos = strCommand.find(" ", COMMAND_REPLACE_NUM + 1);
		int iVal1 = atoi(strCommand.substr(COMMAND_REPLACE_NUM + 1, pos - (COMMAND_REPLACE_NUM + 1)).c_str());
		string::size_type tmppos = strCommand.find(" ", pos + 1);
		int iVal2 = atoi(strCommand.substr(pos + 1, tmppos - pos - 1).c_str());
		string strWord = strCommand.substr(tmppos + 1, strCommand.size());
		a_rstrTargetWord.replace(iVal1, iVal2 - iVal1 + 1, strWord);
		return;
	}
	pos = strCommand.find(COMMAND_REVERSE, 0);
	if (pos != string::npos) {
		pos = strCommand.find(" ", COMMAND_REVERSE_NUM + 1);
		int iVal1 = atoi(strCommand.substr(COMMAND_REVERSE_NUM + 1, pos - (COMMAND_REVERSE_NUM + 1)).c_str());
		string::size_type tmppos = strCommand.find(" ", pos + 1);
		int iVal2 = atoi(strCommand.substr(pos + 1, tmppos - pos - 1).c_str());
		reverse(&a_rstrTargetWord[iVal1], &a_rstrTargetWord[iVal2 + 1]);
		return;
	}
	pos = strCommand.find(COMMAND_PRINT, 0);
	if (pos != string::npos) {
		pos = strCommand.find(" ", COMMAND_PRINT_NUM + 1);
		int iVal1 = atoi(strCommand.substr(COMMAND_PRINT_NUM + 1, pos - (COMMAND_PRINT_NUM + 1)).c_str());
		string::size_type tmppos = strCommand.find(" ", pos + 1);
		int iVal2 = atoi(strCommand.substr(pos, tmppos - pos - 1).c_str());
		cout << a_rstrTargetWord.substr(iVal1, iVal2 - iVal1 + 1) << endl;
		return;
	}
}

Measured memory_bytes: 1248
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
#include <iterator>


using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 

 
int V,E;

struct edge {
	int dst;
	int cost;
	edge(int dst, int cost) {
		this->dst = dst; this->cost = cost;
	}

};

typedef vector<edge> edges;
vector<edges> G;

int dist[100005];
int k;

void solve(int v) {

	fill(dist, dist + k, INF);
	dist[v] = 0;
	deque<int> q;
	
	q.push_front(v);
	while (q.size()) {
		int v = q.front(); q.pop_front();
		
		FORI(0,G[v].size()) {
			edge e = G[v][i];
			if (dist[e.dst] > dist[v] + e.cost) {
				dist[e.dst] = dist[v] + e.cost;
				if(e.cost==0)
					q.push_front(e.dst);
				else
					q.push_back(e.dst);
			}
		}
	}
	cout << dist[0] + 1 << endl;
}

int main() {
	cin >> k;
	G.resize(k);
	FORI(0, k) {
		G[i].push_back(edge((i + 1)%k, 1));
		G[i].push_back(edge((i*10)%k, 0));
	}
	solve(1);
	return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll N;
    cin >> N;
    
    ll ans = longinf;
    for(ll a = 1; a <= 1000000; a++){
        if(N%a == 0){
            ll b = N/a;
            if(a + b - 2 < ans)
                ans = a + b - 2;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
# coding: utf-8

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

sorted_AB = sorted(AB, key=lambda x: x[0])
remaining = M
value = 0
for a, b in sorted_AB:
    for i in range(b):
        remaining -= 1
        value += a
        if remaining <= 0:
            break
    else:
        continue
    break

print(value)


Measured memory_bytes: 18896
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k; cin >> a >> b >> c >> k;
    for(int i=0; i<k; i++){
        if(b <= a) b *= 2;
        else if(c <= b) c *= 2;
    }
    if(a < b && b < c) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    for(int i = 0;i<s.length();i++){
      s = s.substring(1,s.length()) + s.substring(0,1);
      if(s.equals(t)){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 39292
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

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

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int n;
    cin >> n;
    lint res = 1;
    rep(i, n) {
        lint t;
        cin >> t;
        res = lcm(res, t);
    }
    cout << res << endl;
    return 0;
}

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



int main(){
    ll N, M; cin >> N >> M;
    vector<vector<ll>> G(N);
    vector<ll> ans(N);
    for(int i = 0; i < M; i++){
        ll a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<bool> grid(N); grid[0] = true;
    queue<ll> Q; Q.push(0);
    while(!Q.empty()){
        ll x = Q.front(); Q.pop();
        for(auto v : G[x]){
            if(!grid[v]){
                grid[v] = true;
                ans[v] = x+1;
                Q.push(v);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) cout << ans[i] << endl;
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) cin<<(x);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x, v) lower_bound((x).begin(), (x).end(), (v))
#define uboundv(x, v) upper_bound((x).begin(), (x).end(), (v))
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	bool ans = false;
	if(n/10 == 9) ans=true;
	if(n%10 == 9) ans=true;
	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
a,b,c,k=map(int,input().split())
ans=0
if a<k:
  ans+=a
  k-=a
else:
  ans+=k
  k=0
if b>k and k>0:
  k=0
else:
  k-=b
if k>0:
  ans-=k
print(ans)

Measured memory_bytes: 9136
#include <stdio.h>

int is_prime(int n){

  
    int i;

    if (n == 2){
        return (1);
    }
    else if (n < 2 || n % 2 == 0){
        return (0);
    }
    for (i = 3; i * i <= n; i += 2){
        if (n % i == 0){
            return (0);
        }
    }
    return (1);
}

int main(){

  
  int n,kazu,c;

    scanf("%d", &n);
    c = 0;
    while (n--){
        scanf("%d", &kazu);
        if (is_prime(kazu) == 1){
            c++;
        }
    }
    printf("%d\n", c);

    return (0);
}



Measured memory_bytes: 2052
#include<stdio.h>
int main(void)
{
  char str[3];
  int cnt=0;
  scanf("%s",str);
  if(str[0]=='1')
    cnt++;
  if(str[1]=='1')
    cnt++;
  if(str[2]=='1')
    cnt++;
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,a[1000],i,mn;
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	scanf("%d",&a[i]);
		sort(a,a+n);
		mn=a[1]-a[0];
		for(i=2;i<n;i++)	{
			mn=min(mn,a[i]-a[i-1]);
		}
		printf("%d\n",mn);
	}
	return 0;
}


Measured memory_bytes: 2772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int n=s.length();
		char[]ans=new char[n];
		for(int i=0;i<n;i++) {
			ans[i]=s.charAt(i);
		}
		int k=sc.nextInt();
		
		for(int i=0;i<n;i++) {
			int time='z'-s.charAt(i)+1;
			if(time!=26 && time<=k) {
				ans[i]='a';
				k-=time;
			}
		}
		k%=26;
		if(ans[n-1]+k>122) {
			k-=122-ans[n-1]+1;
			ans[n-1]=(char)('a'+k);
		}else {
			ans[n-1]=(char)(ans[n-1]+k);
		}
		for(int i=0;i<n;i++) {
			System.out.print(ans[i]);
		}
		System.out.println();
	}
	
}

Measured memory_bytes: 34884
N,M = map(int,input().split())
lst = list(map(int,input().split()))
newlist = list()
s = sum(lst) / (4*M)
for i in range(len(lst)):
    if lst[i] >= s:
        newlist.append(lst[i])
print("Yes" if len(newlist) >= M else "No")


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N, 0);
	vector<double> expect(210000, 0.0), list(210000, 0.0);
	double result = 0.0;

	repeat(i, N) {
		cin >> p[i];
		expect[i] = (double)(1 + p[i]) / 2.0;
	}

	list[0] = 0;
	for(int i = 1; i <= N; i++) {
		list[i] = list[i-1] + expect[i-1];
	}
  for(int i = K; i <= N; i++) {
		result = max(result, list[i] - list[i - K]);
	};

	cout << fixed << setprecision(10) << result << endl;
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

//既に同じ行でi個拾った状態でj行k列にいるときの最大値
int dp[4][3100][3100];

signed main(){
  int R, C, K;
  cin >> R >> C >> K;

  vector<vector<int>> L(R+10, vector<int>(C+10, 0));
  vector<int> v(K);
  for( int i = 0; i < K; i++ ){
    int r, c, v;
    cin >> r >> c >> v;
    L[r][c] = v;
  }

  dp[0][0][0] = 0;

  for( int h = 1; h <= R; h++ ){
    for( int w = 1; w <= C; w++ ){
        for( int i = 3; i >= 0; i-- ){
            dp[i][h][w] = max(dp[i][h][w-1], dp[i][h][w]);
            if(i != 3)dp[i+1][h][w] = max(dp[i+1][h][w], dp[i][h][w]+L[h][w]);
        }
        for(int i = 3; i >= 0; i--){
            dp[0][h+1][w] = max(dp[0][h+1][w], dp[i][h][w]);
        }
    }
  }

  int ans = 0;
  for( int i = 0; i <= 3; i++ ){
    ans = max(ans, dp[i][R][C]);
  }
  cout << ans << endl;


}


Measured memory_bytes: 366428
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, M;
set<int> available_numbers;
const int MAX_N = 10100;
int costs[MAX_N];
int dp[MAX_N];

int main()
{
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    int x;
    cin >> x;
    available_numbers.insert(x);
  }
  costs[1] = 2;
  costs[2] = 5;
  costs[3] = 5;
  costs[4] = 4;
  costs[5] = 5;
  costs[6] = 6;
  costs[7] = 3;
  costs[8] = 7;
  costs[9] = 6;

  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 9; j >= 1; j--)
    {
      if (dp[i] == -1 || available_numbers.count(j) == 0)
      {
        continue;
      }

      if (dp[i] + 1 > dp[i + costs[j]])
      {
        dp[i + costs[j]] = dp[i] + 1;
      }
    }
  }
  int pos = N;
  string result = "";
  while (pos > 0)
  {
    for (int i = 9; i >= 1; i--)
    {
      if (available_numbers.count(i) == 0)
      {
        continue;
      }
      if (pos - costs[i] >= 0 && dp[pos - costs[i]] == dp[pos] - 1)
      {
        result += to_string(i);
        pos -= costs[i];
        break;
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<string>
 #include<algorithm>
 using namespace std;
  
 int main()
 {
 	long long int a,b,c; 
 	while(cin>>a>>b>>c)
 	{
 	    if((a+b)>=c) cout<<"Yes"<<endl;
 	    else cout<<"No"<<endl;
 	}
	 
 	return 0;
 }
 
 
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int k, x;

signed main() {
	cin >> k >> x;

	for(int i = x - k + 1; i <= x + k - 1; i++){
		cout << i << " ";
	}

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int N;
int ans;

signed main() {
	cin >> N;
	
	if (N < 1200) cout << "ABC" << endl;
	else if (N < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

	return 0;
}

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

using namespace std;

constexpr long long MODULO = 1000000007;

int main()
{
	long long n;
	cin >> n;
	long long p = 1;
	for (auto i = 1ll; i <= n; i++)
		p = p*i%MODULO;
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using std::cin;
using std::vector;

int main()
{
    int from_num;
    cin >> from_num;
    vector<int> from(from_num);
    for (auto i = 0; i < from_num; i++) {
        cin >> from.at(i);
    }

    int target_num;
    cin >> target_num;
    vector<int> target(target_num);
    for (auto i = 0; i < target_num; i++) {
        cin >> target.at(i);
    }

    int cnt = 0;
    for (auto i = 0; i < target_num; i++) {
        from.push_back(target.at(i));
        for (auto j = 0; j != from_num; j++) {
            if (from.at(j) == target.at(i)) {
                cnt++;
                break;
            }
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int n, x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < n; i++) cin >> y[i];

	double d[4];
	for (int i = 0; i < 4; i++) d[i] = 0.0;

	for (int p = 1; p <= 3; p++) {
		for (int i = 0; i < n; i++) {
			d[p] += pow(fabs(x[i] - y[i]), p);
		}
		d[p] = pow(d[p], 1.0 / p);
	}

	for (int i = 0; i < n; i++) {
		d[0] = (d[0] < fabs(x[i] - y[i])?fabs(x[i] - y[i]):d[0]);
	}

	printf("%lf\n", d[1]);
	printf("%lf\n", d[2]);
	printf("%lf\n", d[3]);
	printf("%lf\n", d[0]);

	return 0;
}


Measured memory_bytes: 3348
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll n, ans1{}, ans2{}, s1{}, s2{}, t[2] = {1,-1};;
  cin >> n;
  vector<ll> a(n);
  for (ll &x: a) cin >> x;
  for (int i = 0; i != n; ++i) {
    s1 += a[i];
    s2 += a[i];
    auto p = t[i%2];
    if (s1 * p <= 0) {
      ans1 += abs(p - s1);
      s1 = p;
    }
    if (s2 * -p <= 0) {
      ans2 += abs(p + s2);
      s2 = -p;
    }
  }
  cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll findNumberOfTriangles(ll arr[], ll n) ;
    int32_t main()
    {
        IOS;
        ll k,l,n,m,q,m1,m2,flag=0,cnt,flag2,flag3,cnt2,sum=0,i,j;
       cin>>n;
       ll arr[n];
       for(i=0;i<n;i++)
       {
           cin>>arr[i];
       }
       cout<<findNumberOfTriangles(arr,n);

       return 0;
    }
    ll comp(const void* a, const void* b)
{ return *(ll*)a > *(ll*)b ; }

ll findNumberOfTriangles(ll arr[], ll n)
{
	// Sort the array elements in non-decreasing order
	sort(arr,arr+n);


	ll count = 0;

	for (ll i = 0; i < n - 2; ++i)
	{
		
		ll k = i + 2;


		for (ll j = i + 1; j < n; ++j)
		{
	
			while (k < n && arr[i] + arr[j] > arr[k])
			++k;
			if(k > j)
			count += k - j - 1;
		}
	}

	return count;
}



Measured memory_bytes: 256
#include <stdio.h>
int  division(int number){
	int i;
	if(number<2){
			return 0;
	}
	else if(number==2){
			return 1;
	}
	if(number%2==0){
		return 0;
	}
	for(i=3;i*i<=number;i+=2){
	if(number%i==0){
			return 0;
		}
	}
	return 1;
		
}


int main(void){
	int m,count=0,number;
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		scanf("%d",&number);
		if(division(number)){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>//cost to
using namespace std;

int kiriage(int a) {
	if (a&1)return a / 2 + 1;
	return a / 2;
}
vector<P>rinsetu[3000];
int mincost[3000];
signed main() {
	int a, b, c; cin >> a >> b >> c;
	fill(mincost, mincost + a, LLONG_MAX/3);
	for (int d = 0; d < b; d++) {
		int e, f, g; scanf("%d%d%d", &e, &f, &g); e--; f--;
		rinsetu[e].push_back(P(g, f));
		rinsetu[f].push_back(P(g, e));
	}
	priority_queue<P, vector<P>, greater<P>>Q;
	for (int h = 0; h < c; h++) {
		int i; scanf("%d", &i); i--;
		mincost[i] = 0;
		Q.push(P(0,i));
	}
	while (Q.size()) {
		P o = Q.top(); Q.pop();
		if (mincost[o.second] < o.first)continue;
		for (P t : rinsetu[o.second]) {
			if (o.first + t.first < mincost[t.second]) {
				mincost[t.second] = o.first + t.first;
				Q.push(P(mincost[t.second],t.second));
			}
		}
	}
	int MAX = 0;
	for (int x = 0; x < a; x++) {
		for (P y : rinsetu[x]) {
			y.first -= abs(mincost[x] - mincost[y.second]);
			MAX = max(MAX, max(mincost[x], mincost[y.second]) + kiriage(y.first));
		}
	}
	cout << MAX << endl;
}

Measured memory_bytes: 8888
#include<stdio.h>

int main(void)
{
    int i,j,n,a[4][13],number;
    char card;

    for (i = 0; i < 13; i++)
	{
		a[0][i]=0;
		a[1][i]=0;
		a[2][i]=0;
		a[3][i]=0;
    }

    scanf("%d",&n);

    for(i=0;i<n*2;i++)
    {
        scanf("%c %d", &card,&number);
 
        if(card == 'S')
        {
            a[0][number-1] = 1;
        }

        if(card == 'H')
        {
            a[1][number-1] = 1;
        }

        if(card == 'C')
        {
            a[2][number-1] = 1;
        }

        if(card == 'D')
        {
            a[3][number-1] = 1;
        }
    }
 
    for(i=0;i<4;i++)
    {
		for(j=0;j<13;j++)
		{
			if((a[i][j] == 0)&&(i==0))
			{
			 printf("S %d\n",j+1);
			}

			if((a[i][j] == 0)&&(i==1))
			{
				printf("H %d\n",j+1);
			}
 
			if((a[i][j] == 0)&&(i==2))
			{
				printf("C %d\n",j+1);
			}

			if((a[i][j] == 0)&&(i==3))
			{
				printf("D %d\n",j+1);
			}
		}
		
    }
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000

int main(){
    string s;
    cin >> s;
    int n = s.length();
    rep(i, n){
        rep(j, n){
            if(i == j) continue;
            if(s[i] == s[j]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);cin.tie(0);
#define mod 1000000007
#define pi 2*acos(0)
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
using namespace std;

ll int n;

ll int po(ll int  x) {

	ll int y = x;
	for (int i = 2; i <= n; i++)
		x = (x * y) % mod;
	return x;
}

int main()
{

	io;
	
	 cin >> n;

	//PIE : 10^n - 9^n - 9^n + 8^n

	ll int a = po(10); //all possible numbers : 10 * 10 * 10 *....
	ll int b = po(9)*2 %mod;	  //numbers that doesn't contain 0. same for 9
	ll  int c = po(8);		//numbers that doesn't contain both 0 and 9

	ll int d, e, f;
	d = (a -b+ c + mod) % mod;
	
	
	cout << d;



}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll>neg(0),zero(0),pos(0);
    rep(i,n){
        ll a;cin>>a;
        if(a<0)neg.pb(-a);
        if(a==0)zero.pb(a);
        if(a>0)pos.pb(a);
    }
    ll ne=neg.size(),po=pos.size();
    if(ne*po>=k){
        sort(all(neg));
        sort(all(pos));
        ll l=0;
        ll r=inf*inf;
        while(r-l>1){
            ll mid=(r+l)/2;
            ll cnt=0;
            rep(i,ne){
                if(pos[po-1]*neg[i]<mid)continue;
                if(pos[0]*neg[i]>=mid){
                    cnt+=po;
                    continue;
                }
                ll s=0,t=po-1;
                while(t-s>1){
                    ll m=(s+t)/2;
                    if(pos[m]*neg[i]>=mid)t=m;
                    else s=m;
                }
                cnt+=po-t;
            }
            if(cnt>=k)l=mid;
            else r=mid;
        }
        cout<<-l<<endl;
    }else if(n*(n-1)/2-k+1<=ne*(ne-1)/2+po*(po-1)/2){
        k=n*(n-1)/2-k+1;
        sort(all(neg));
        sort(all(pos));
        ll r=inf*inf;
        ll l=0;
        while(r-l>1){
            ll mid=(r+l)/2;
            ll cnt=0;
            rep(i,po-1){
                if(pos[po-1]*pos[i]<mid)continue;
                if(pos[i]*pos[i+1]>=mid){
                    cnt+=po-1-i;
                    continue;
                }
                ll s=i+1,t=po-1;
                while(t-s>1){
                    ll m=(s+t)/2;
                    if(pos[m]*pos[i]>=mid)t=m;
                    else s=m;
                }
                cnt+=po-t;
            }
            rep(i,ne-1){
                if(neg[ne-1]*neg[i]<mid)continue;
                if(neg[i]*neg[i+1]>=mid){
                    cnt+=ne-1-i;
                    continue;
                }
                ll s=i+1,t=ne-1;
                while(t-s>1){
                    ll m=(s+t)/2;
                    if(neg[m]*neg[i]>=mid)t=m;
                    else s=m;
                }
                cnt+=ne-t;
            }
            if(cnt<k)r=mid;
            else l=mid;
        }
        cout<<l<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
cout.precision(10);
cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli n,i;
		cin>>n;
		double sum=0,d,z;
		vector<double> v;
		for(i=0;i<n;i++)
		{
			cin>>z;
			d=(double)(1/z);
			sum+=d;
			//what_is(sum);
		}
		cout<<(double)(1/sum)<<endl;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H,W;
string S[2009];
int x[2009];
int ans;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    rep(i,H) cin>>S[i];
    
    ans=max(W,H);
    FOR(i,1,H){
        stack<pii> v;
        v.push({0,0});
        FOR(j,1,W){
            if(1^(S[i-1][j]==S[i][j])^(S[i-1][j-1]==S[i][j-1])){
                x[j]++;
            }else{
                x[j]=0;
            }
            int p=v.top().first;
            int q=v.top().second;
            int r=0;
            while(p>x[j]){
                r+=q;
                chmax(ans,(p+1)*(r+1));
                v.pop();
                p=v.top().first;
                q=v.top().second;
            }
            if(p<x[j]){
                v.push({x[j],1+r});
            }else{
                v.top().second+=1+r;
            }
        }
        int r=0;
        while(!v.empty()){
            int p=v.top().first;
            int q=v.top().second;
            r+=q;
            chmax(ans,(p+1)*(r+1));
            v.pop();
        }
    }
    cout1(ans)
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  int H = inputValue();
  int W = inputValue();
  int A = inputValue();
  int B = inputValue();
  int s[1000][1000];
  int SA[1000];
  int SB[1000];
  REP(i, H){
    REP(j, W){
      s[i][j] = 0;
    }
  }
  REP(i, H){
    SA[i] = 0;
  }
  REP(j, W){
    SB[j] = 0;
  }

  int x = 0;
  int y = 0;
  while(x<=H && y<=W){
    int sumA = (H * A) + (W - 2 * A) * x;
    int sumB = (W * B) + (H - 2 * B) * y;
    if(sumA == sumB){
      break;
    }else if(sumA > sumB){
      y++;
    }else if(sumB > sumA){
      x++;
    }
  }
  if(x>H || y>W){
    cout << "No" << endl;
    return 0;
  }
  
  REP(i, H){
    REP(j, W){
      if(i<x && SA[i]<(W-A)){
        s[i][j] = 1;
        SA[i] += 1;
        SB[j] += 1;
      }else if(i>=x && SA[i]<A){
        s[i][j] = 1;
        SA[i] += 1;
        SB[j] += 1;
      };
    }
  }
  REP(j1, W){
    if((j1 < y && SB[j1]>(H-B)) || (j1>=y && SB[j1] > B)){
      FOR(j2, j1+1, W){
        if(SB[j2]<B){
          REP(i, H){
            if(s[i][j1]==1 && s[i][j2]==0){
              s[i][j1] = 0;
              s[i][j2] = 1;
              SB[j1]--;
              SB[j2]++;
            };
            if((j1 < y && SB[j1] == (H-B)) || SB[j1] == B || SB[j2] == B){
              break;
            }
          }
        }
        if((j1 < y && SB[j1] == (H-B)) || SB[j1] == B){
          break;
        }
      }
    }
  }
  REP(i, H){
    REP(j, W){
      cout << s[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 5120
#include <iostream>
#include <fstream> 
#include <iomanip>
#include <cstdio> 
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = (1LL << 60) - 1;
const LL MOD = 1e9 + 7;
const LL N = 200005;
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    int a, b, n;
    cin >> n;
    int cnt = 0, mx = 0;
    forn(i, n) {
        cin >> a >> b;
        if (a == b) {
            cnt++;
            mx = max(mx, cnt);
        }
        else {
            cnt = 0;
        }
    }
    if (mx > 2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  string s;
  cin >> s;
  rep(i, 7){
    string s1 = "";
    int len = s.size();
    rep(j, s.size()){
      if(j < i || j >= i + (len - 7))
        s1 += s.at(j);
    }
    if(s1 == "keyence"){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(){ 
   int n,i;
   scanf("%d",&n);
   long sum = 0;
   for(i=1;i<=n;i++){
     if(i%3 != 0 && i%5 != 0) sum += i;
   }
   printf("%ld",sum);
   return 0;
 }

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1001001001;

ll cnt[51];
ll patty[51];

ll f(int n, ll x);

int main(){
    int N;
    ll X;
    cin >> N >> X;
    
    cnt[0] = 1;
    patty[0] = 1;
    for(int i = 1; i <= 50; ++i){
        cnt[i] = 2 * cnt[i - 1] + 3;
        patty[i] = 2 * patty[i - 1] + 1;
    }
    
    cout << f(N, X) << endl;
}

ll f(int n, ll x){
    if(n == 0)      return 1;
    
    // 左半分で分けるとき
    if(x == 1)      return 0;
    if(x > 1 && x <= cnt[n - 1] + 1)    return f(n - 1, x - 1);
    
    // 真ん中で分けるとき
    if(x == cnt[n - 1] + 2)     return patty[n - 1] + 1;
    
    // 右半分で分けるとき
    if(x > cnt[n - 1] + 2 && x <= 2 * cnt[n - 1] + 2)
        return patty[n - 1] + 1 + f(n - 1, x - cnt[n - 1] - 2);
        
    // 一番右端(x == 2 * cnt[n - 1] + 3)    
    return 2 * patty[n - 1] + 1;    
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
//constexpr long long MOD = 1777777777LL;
using ld = long double;
using tp = tuple<ll, ll, ll>;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

// long dobule
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    int n;
    cin >> n;
    Graph g(n);
    REP(i, n - 1) {
        ll p;
        cin >> p;
        add_edge(g, p - 1, i + 1, 1, false, 0);
    }

    vec<int> x(n);
    REP(i, n) {
        cin >> x[i];
    }

    auto dfs = [&](auto &&self, int v) -> P {
        vec<P> cost;
        ll sum = 0;
        for(auto e : g[v]) {
            auto ret = self(self, e.to);
            if(ret == make_pair(INF, INF)) {
                return ret;
            }
            cost.push_back(ret);
            sum += ret.first + ret.second;
        }

        vvec<bool> dp(cost.size() + 1, vec<bool>(x[v] + 1, 0));
        dp[0][0] = true;
        REP(i, cost.size()) {
            REP(j, x[v] + 1) {
                if(!dp[i][j])
                    continue;
                if(j + cost[i].first <= x[v])
                    dp[i + 1][j + cost[i].first] = true;
                if(j + cost[i].second <= x[v])
                    dp[i + 1][j + cost[i].second] = true;
            }
        }

        ll mi = INF;
        REP(i, x[v] + 1) {
            if(!dp[cost.size()][i])
                continue;
            chmin(mi, sum - i);
        }
        if(mi == INF) {
            return {INF, INF};
        } else {
            return {x[v], mi};
        }
    };

    P ans = dfs(dfs, 0);
    if(ans == make_pair(INF, INF)) {
        cout << "IMPOSSIBLE" << en;
    } else {
        cout << "POSSIBLE" << en;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3804
//想定解法は2分探索でO(qlogn)だろうが、Tを昇順にソートしてやると、O(qlogq+q)でできる。(利点は…特になし.趣味.)
#include<iostream>
#include<algorithm>
#define rep(i,n) for(i = 0;i < n;i++)
using namespace std;

int S[100000],T[50000];
int main(){
	int i,s,t;
	cin >> s;
	rep(i,s)
		cin >> S[i];
	cin >> t;
	rep(i,t)
		cin >> T[i];
	sort(S,S+s);
	sort(T,T+t);
	int scor = 0,cnt = 0;
	for(i = 0;i < t;){
		if(scor >= s)
			break;
		if(S[scor] == T[i]){
			scor++;
			i++;
			cnt++;
		}
		else if(S[scor] < T[i]){
			scor++;
		}
		else{
			i++;
		}
		//cout << T[i] << " " << cnt << endl;
	}
	cout << cnt << endl;
	return 0;
}

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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int X, N;
    cin >> X >> N;

    if (N == 0) {
        cout << X << endl;
        return 0;
    }

    vector<int> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    
    sort(p.begin(), p.end());

    if (X < p.front() || X > p.back()) {
        cout << X << endl;
    }
    int n, dist_min = 200;
    for (int i = -100; i < 200; ++i) {
        int idx = distance(p.begin(), lower_bound(p.begin(), p.end(), i));
        if (idx < N && p[idx] == i) continue;
        int dist = abs(X - i);
        if (dist < dist_min) {
            dist_min = dist;
            n = i;
        }
    }

    cout << n << endl;

    // if (idx == 0 || idx == p.size()) {
    //     cout << X << endl;
    // } else {
    //     int cand1 = p.back() + 1;
    //     int cand2 = p.front() - 1;
    //     int k;
    //     k = 0;
    //     while (idx + k < p.size() - 1) {
    //         if (p[idx+k+1] - p[idx+k] > 1) {
    //             cand1 = p[idx+k] + 1;
    //             break;
    //         }
    //         k += 1;
    //     }
    //     k = 0;
    //     while (idx - k > 1) {
    //         if (p[idx-k] - p[idx-k-1] > 1) {
    //             cand2 = p[idx-k] - 1;
    //             break;
    //         }
    //         k += 1;
    //     }

    //     if (abs(X - cand1) < abs(X - cand2)) {
    //         cout << cand1 << endl;
    //     } else {
    //         cout << cand2 << endl;
    //     }
    // }

    return 0;
}


Measured memory_bytes: 3628
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust, catMaybes)
import qualified Data.Vector as V


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = do
    strs <- BC.words  <$> BC.getLine
    let bcList = catMaybes $ (BC.readInt <$> strs)
    pure $ fst <$> bcList

onOffLists :: Int -> Int -> [[Int]]
onOffLists i m = if i == m then [[0], [1]] else
    let
        prevLists = onOffLists (i + 1) m
    in
        [(1:), (0:)] <*> prevLists

checkVector :: [([Int], Int)] -> V.Vector Int -> Bool
checkVector ss v = all checker ss where
    checker (s,p) = ((foldr (\si acc -> (v V.! (si - 1) ) + acc ) 0 s) `mod` 2) == p

main = do
    (n, m) <- readTuple2
    ss <- replicateM m (tail <$> readInts)
    ps <- readInts
    let onOffList = replicateM n [0,1]
    let onOffVectors = V.fromList <$> onOffList
    print $ length $ filter (checkVector $ (zip ss ps)) onOffVectors



Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;

int main(void)
{
  int a;
  string str;
  
  cin>>a;
  cin>>str;
  
  long int r=0,g=0,b=0;
  long int ans;
  
  rep(i,0,a){
    switch(str[i]){
      case 'R':r++; break;
      case 'G':g++; break;
      case 'B':b++; break;
      default :break;
    }
  }
  
  ans=r*g*b;

  int req=0;
  rep(i,0,a){
    for(int j=i+1;j<a&&2*j-i<a;j++){
       if(str[i]!=str[j] && str[i]!=str[2*j-i] && str[j]!=str[2*j-i]) ans--;
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}

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

int main(){
    int N,L;
    string S[N];
    cin >> N >> L;
    int i;
    for(i=0;i<=N-1;i++)
        cin >> S[i];
    sort(S,S+N);
    for(i=1;i<=N-1;i++)
        S[0] += S[i];
    cout << S[0];
}


Measured memory_bytes: 49536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  vector<long long> x1 = {0, 1, 0, -3};
  vector<long long> y1 = {0, 0, 1, 0};
  vector<long long> x2 = {1, 2, 2, 0};
  vector<long long> y2 = {1, 1, 3, 3};
  for (int i = 4; i < 40; i++){
    long long next_x1, next_y1, next_x2, next_y2;
    if (i % 4 == 0){
      long long a = x2[i - 3] - x1[i - 1];
      next_x1 = x1[i - 1];
      next_y1 = y1[i - 1] - a;
      next_x2 = x1[i - 1] + a;
      next_y2 = y1[i - 1];
    }
    if (i % 4 == 1){
      long long a = y2[i - 3] - y1[i - 1];
      next_x1 = x2[i - 1];
      next_y1 = y1[i - 1];
      next_x2 = x2[i - 1] + a;
      next_y2 = y1[i - 1] + a;
    }
    if (i % 4 == 2){
      long long a = x2[i - 1] - x1[i - 3];
      next_x1 = x2[i - 1] - a;
      next_y1 = y2[i - 1];
      next_x2 = x2[i - 1];
      next_y2 = y2[i - 1] + a;
    }
    if (i % 4 == 3){
      long long a = y2[i - 1] - y1[i - 3];
      next_x1 = x1[i - 1] - a;
      next_y1 = y2[i - 1] - a;
      next_x2 = x1[i - 1];
      next_y2 = y2[i - 1];
    }
    x1.push_back(next_x1);
    y1.push_back(next_y1);
    x2.push_back(next_x2);
    y2.push_back(next_y2);
  }
  int ans = -1;
  for (int i = 0; i < 40; i++){
    if (x1[i] <= x && x < x2[i] && y1[i] <= y && y < y2[i]){
      ans = i % 3 + 1;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int main() {
    string w;
    vector<int>cnt(26);
    cin>>w;
    if(w.size()%2==1){
        cout<<"No"<<endl;
        return 0; 
    }
    for(int i=0;i<w.size();i++){
        cnt.at(w.at(i)-'a')++;
    }
    for(int i=0;i<26;i++){
        if(cnt.at(i)%2==1){
        cout<<"No"<<endl;
        return 0;

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

Measured memory_bytes: 3604