akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	long long n;
	cin >> n;
	int res = 0;
	vector<pair<long long, int>> dziel;
	for (ll i=2; i *i <= n; ++i) {
		if (n % i == 0) {
			int wyk = 0;
			while (n % i == 0) {
				++wyk;
				n /= i;
			}
			int j = 1;
			while (j <= wyk) {
				++res;
				wyk -= j;
				++j;
			}
		}
	}
	if (n > 1) {
		++res;
	}
	cout << res << endl;
}

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

// why am I so weak

string s;

int main() {
	cin >> s;

	while (s.size() >= 5) {
		string t = "";

		for (int i = 0; i < 5; i++) {
			t += s.back();
			s.pop_back();
		}

		reverse(t.begin(), t.end());

		if (t == "dream" || t == "erase") {
			continue;
		}

		if (s.empty()) {
			puts("NO");
			return 0;
		}

		t = s.back() + t;
		s.pop_back();

		if (t == "eraser") {
			continue;
		}

		if (s.empty()) {
			puts("NO");
			return 0;
		}

		t = s.back() + t;
		s.pop_back();

		if (t == "dreamer") {
			continue;
		}

		puts("NO");
		return 0;
	}

	puts(s.empty() ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
	// 小数点以下第15桁まで表示させる
    cout.precision(15);
    cout << fixed;
	int n;
	cin >> n;
	vector<double> p(n);
	rep(i, n) cin >> p[i];
	// i番目までコインを投げたときにj回表が出る確率
	vector<vector<double> > dp(n+1, vector<double> (n+1));
	dp[0][0] = 1;
	rep2(i, 1, n+1) {
		rep(j, n + 1) {
			if(j == 0) dp[j][i] = dp[j][i-1] * (1 - p[i-1]);
			else dp[j][i] = dp[j][i-1] * (1-p[i-1]) + dp[j-1][i-1] * p[i-1];
		}
	}
	double ans = 0;
	rep2(i, (n+1)/2, n+1) {
		ans += dp[i][n];
	}
	cout << ans << endl;
}

Measured memory_bytes: 73776
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a=1;
  cin>>n;
  a=n/100;
  a*=111;
  if(a<n){
    cout<<(a/100+1)*111<<"\n";
  }else{
    cout<<a<<"\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int a[d5],dp[d5];
    for(int i=0;i<n;i++)cin>>a[i];
    //dp[i]:i番目につくまでの最小コスト
    for(int i=0;i<d5;i++)dp[i]=inf;
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i-j<0)continue;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
from collections import deque
S=input()
Q=int(input())
words=[]
for a in range(Q):
    A=input().split()
    words.append(A)
T=[a for a in S]
answers=deque(T)
number=0
for a in words:
    if a[0]=='1':
        number+=1
    else:
        if number%2==0:
            if a[1]=='1':
                answers.appendleft(a[2])
            else:
                answers.append(a[2])
        else:
            if a[1]=='1':
                answers.append(a[2])
            else:
                answers.appendleft(a[2])
if number%2==0:
    kotae=list(answers)
    moji=''
    for a in kotae:
        moji+=a
    print(moji)
else:
    kotae = list(answers)
    kotae.reverse()
    moji = ''
    for a in kotae:
        moji += a
    print(moji)


Measured memory_bytes: 46116
#include <iostream>
#include <cstring>

using namespace std;

int main() {
	
	char SS[60]="",T[60]="",S[60]="";
	char temp[60]="";
	int i,j,k,len1,len2;
	scanf("%s",SS);
	scanf("%s",T);
	len1=strlen(SS);
	len2=strlen(T);
	k=len1-len2;
	for(i=k;i>=0;i--)
	{
		strncpy(temp,SS+i,len2);
		for(j=0;j<len2;j++)
		{
			if(temp[j]=='?') temp[j]=T[j];
		}
		if(strcmp(temp,T)==0)
		{
			for(j=0;j<i;j++)
			S[j]=SS[j];
			for(j=i;j<len2+i;j++)
			S[j]=T[j-i];
			for(j=len2+i;j<len1;j++)
			S[j]=SS[j];
			for(j=0;j<len1;j++)	
			if(S[j]=='?') S[j]='a';
			S[len1]='\0';
			printf("%s\n",S);
			return 0;		
		}
	}
	printf("UNRESTORABLE\n");
	return 0;
}

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


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

    int l;

    cin >> l;

    double side = (double)l/3.0;
    cout << fixed << setprecision(9);
    cout << side * side * side;

    return 0;
      

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a[1000]={0},i,j,c,d,e=0,f,n,k;
    cin>>n>>k;
    while(k--)
    {
        cin>>c;
        for(i=0;i<c;i++)
        {
            cin>>d;
            a[d]++;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==0) e++;
    }
    printf("%lld\n",e);
    return 0;
}


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

int main()
{
	int x,n,k;cin>>n>>k;
	int a[100010],d[100010];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int m=1e9;
	for(int i=0;i<n;i++)
	{
		if(i<k-1)d[i]=1e9;
		else d[i]=min(a[i]-a[i-k+1]+abs(a[i-k+1]),a[i]-a[i-k+1]+abs(a[i]));
		m=min(d[i],m);
	}
	cout<<m<<endl;
}

Measured memory_bytes: 888
n,t=map(int,input().split())
a=[]
for i in range(n):
  c,s=map(int,input().split())
  a.append([c,s])
a=sorted(a,key=lambda x:x[1])
z=1001
for i in range(n):
  if a[i][1]>t:
    break
  z=min(z,a[i][0])
print(z if z!=1001 else 'TLE')

Measured memory_bytes: 3064
using System;

namespace welovegolf
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "NG";
            int k = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int r = a / k;

            if ((k * r >= a && k * r <= b) || (k  * (r + 1) >= a && k * (r + 1) <= b) || (k * (r - 1) >= a && k * (r - 1) <= b))
                s = "OK";

            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 27464
import           Control.Monad
import           Control.Monad.ST
import qualified Data.ByteString.Char8        as B
import qualified Data.Vector.Unboxed          as U
import qualified Data.Vector.Algorithms.Radix as U

import qualified Data.Set as S

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n getLine
  print $ solve ss

solve :: [String] -> Int
solve ss = S.size $ S.fromList ss

readInts :: IO [Int]
readInts = map read . words <$> getLine

readIntN :: Int ->  IO (U.Vector Int)
readIntN n = U.unfoldrN n (B.readInt . B.dropWhile ((==) ' ')) <$> B.getLine

radixSort :: U.Vector Int -> U.Vector Int
radixSort xs = runST $ do
  mxs <- U.thaw xs
  U.sort mxs
  U.freeze mxs


Measured memory_bytes: 169492
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
    int n;
    ld d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ld x, y;
        cin >> x >> y;
        ld r = x * x + y * y;
        r = sqrt(r);
        if(r <= d) ans++;
    }
    cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
    ///cin >> t;
    while(t--) solve(), cout << '\n';
    return 0;
}


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

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	long long C = 0;
	if ((B - A) % 2 != 0) {
		if (N - B > A - 1) {
			B -= A;
			C = A;
			A = 1;
		}
		else {
			A += N - B + 1;
			C = N - B + 1;
			B = N;
		}
	}
	cout << (B - A) / 2 + C << endl;
}

Measured memory_bytes: 384
from collections import defaultdict
from itertools import permutations
import heapq

INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))

Adj_list = defaultdict(set)

for i in range(M):
    a, b, c = map(int, input().split())   
    Adj_list[a-1].add((b-1, c))
    Adj_list[b-1].add((a-1, c))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF
t_dis = 0

table = {}
for i in r:
    table[i-1] = dijkstra(N, i-1)

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        t_dis += table[each[i]-1][each[i+1]-1]

    ans = min(ans, t_dis)

print(ans)

Measured memory_bytes: 79172
def f():
    line = list(map(int, input().split()))
    k = line[0]
    t = line[1]
    a = list(map(int, input().split()))
    a.sort()

    if t == 1:
        return k-1
    if t == 2:
        return a1-a0-1
    a = [0] + a
    n1 = a[-1] - a[-2]
    n2 = 1
    for i in range(1, t-1):
        n2 = n2 + (a[i]-a[i-1])*(t-i-1)
    if n1 < n2:
        return 0
    else:
        return n1 - n2

print (f())

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

char ch[52];
int n,t[105];
string s;

int main(){
  ch[0]='a';ch[26]='A';
  for(int i=1;i<26;i++){
    ch[i]=ch[i-1]+1;
    ch[i+26]=ch[i+25]+1;
  }
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>t[i],t[i]%=52;
    cin>>s;
    for(int i=0;i<(int)s.size();i++){
      int j=i%n;
      int a=('a'<=s[i]?s[i]-'a':s[i]-'A'+26);
      a=(a+52-t[j])%52;
      cout<<ch[a];
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
    int N;
    long long ans=0;
    cin >> N;
    string s;
    vector<long long> a(1000, 0);
    char MARCH[5] = {'M', 'A', 'R', 'C', 'H'};
    for(int i=0; i<N; i++){
	cin >> s;
	a[s[0]]++;
    }

    for(int i=0; i<5; i++){
	for(int j=0; j<5; j++){
	    for(int k=0; k<5; k++){
		if(i==j || j==k || k==i)
		    continue;
		ans += a[MARCH[i]]*a[MARCH[j]]*a[MARCH[k]];
	    }	
	}	
    }
    ans /= 6;

    cout << ans<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,x;

int main(){
	cin>>n>>x;
	bool B=1;
	for(int i=1;i<n;i++){
		int y;
		cin>>y;
		if(x<y) y--;
		if(x>y) B=0;
		x=y;
	}
	cout<<(B?"Yes":"No")<<endl;
}

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

int main() {
  int N, A;
  string op;
  cin >> N
  >> A;
  if ( (N % 500) > A ) {
  cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    ll L , R , d ;
    cin >> L >> R >> d ;
    ll cnt = 0 ;
    for(int i = 0 ; i < R - L + 1 ; i++){
        if((L + i) % d == 0 ) cnt++ ;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n>>m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b;
    int d, r;
    double f;
    scanf("%d %d",&a,&b);
    
    d = a / b;
    r = a % b;
    f = 1.00000*a / b;
    
    //printf("a / b = %d\n", a / b);
   // printf("a % b = %d\n", a % b);
   // printf("a / b = %d\n", a / b);
    
    printf("%d %d %.5lf\n",d,r,f);
    
    return 0;
}



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

long long sum(long long n){
    return n*(n+1) / 2;
}

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

    long long res = sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15;
    
    cout << res << endl;
}

Measured memory_bytes: 3536
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
static int desc(const void *a, const void *b);
static int asc(const void *a, const void *b);
 
int main (void){
    int n,k,i,j;
    int x,y,z;
    int count = 0;
    double dx;
    int box[200001]={};
    char text[200001]={};
    char s[200001]={};
    char t[200001]={};
    char alf[256] = {"abcdefghijklmnopqrstuvwxyz"};
    char alfb[256] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    char sample_text[256];

    // Input Area //
    //scanf("%d %d",&x,&y);
    scanf("%s",s);
    //scanf("%d %d",&x,&y);
    //scanf("%s",text);
 
    /*
    if(strcmp(text,s)==0){
        x--;
    }else if(strcmp(text,t)==0){
        y--;
    }
    */
    i = 0;
    n = 0;
    while(1){
        if (s[i] == '\0' || n == 1){
            break;
        }
        
        if (s[i] == 'h' && s[i + 1] == 'i'){
            i = i + 2;
        }else{
            n = 1;
        }
    }
    
    if (n == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    
    //printf("%d %d",x,y);
    //scanf("%s",&sample_text);
    //scanf("%s",&text);
 
    /*
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&box[i]);
    }
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    printf("\n");
    qsort(box,n,sizeof(int),desc);
    
    */
    // Output Area //
    
    /*
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    */
 
}
 
static int desc(const void *a, const void *b){
    return *(int *) b - *(int *) a;
}
 
static int asc(const void *a, const void *b){
    return *(int *) a - *(int *) b;
}
 
 
/* KonoLvBANK
 
配列降順ソート
qsort(box,n,sizeof(int),desc);
配列昇順ソート
qsort(box,n,sizeof(int),asc);
 
アルファベットを次の単語に変えるやつ
    while(1){
        if (text[i] == '\0'){
            break;
        }
        for(j = 0; j < 26; j++){
            if (text[i] == alf[j]){
                if (j != 25){
                    text[i] = alf[j + 1];
                }else{
                    text[i] = alf[0];
                }
                break;
            }
        }
        i++;
    }
    */

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

int main(){
    int W,H;
    cin>>H>>W;
    int dp[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>dp[i][j];
            dp[i][j]^=1;
        }
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(!dp[i][j])continue;
            dp[i][j]=min({i?dp[i-1][j]+1:1, j?dp[i][j-1]+1:1, i&&j?dp[i-1][j-1]+1:1});
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans*ans<<endl;
}

Measured memory_bytes: 10688
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys
import numpy as np

# 標準入力を取得
D = int(input())
c = list(map(int, input().split()))
s = []
for d in range(D):
    s_d = list(map(int, input().split()))
    s.append(s_d)

c = np.array(c)
s = np.array(s)

# 求解処理
KIND = 26
last = np.array([0 for i in range(KIND)])
for d in range(1, D + 1):
    index_d = d - 1
    t_d = 0
    diff_S_d = -sys.maxsize
    for k in range(KIND):
        last_k = last.copy()
        last_k[k] = d
        diff_S_d_k = s[index_d][k] - sum(c * (d - last_k))
        if diff_S_d_k > diff_S_d:
            diff_S_d = diff_S_d_k
            t_d = k + 1
    last[t_d - 1] = d
    print(t_d)


Measured memory_bytes: 27380
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main(){
  map<string,int> judge;
  judge["AC"]=0;
  judge["WA"]=0;
  judge["TLE"]=0;
  judge["RE"]=0;
  string a;
  int b;
  cin>>b;
  while(b){
	  cin>>a;
	  judge[a]++;
	  b--;
  }
  cout<<"AC x "<<judge["AC"]<<endl;
  cout<<"WA x "<<judge["WA"]<<endl;
  cout<<"TLE x "<<judge["TLE"]<<endl;
  cout<<"RE x "<<judge["RE"]<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<string.h>
#include<bitset>
#include<set>
using namespace std;

struct S {
    int cost, x, y, o, xh;
    S(int c, int in_x, int in_y, int in_o, int in_xh) : cost(c), x(in_x), y(in_y), o(in_o), xh(in_xh) {}
    bool operator<(const S &s) const {
		if (cost != s.cost)
			return cost < s.cost;
		else
			return o < s.o;
	}
};

const int INF = -1000000000, INF2 = 10000000;
int w, h, f, m, o, ans;
int stratum[110][110];
int c[11][11][51];
priority_queue<S> pq;

void dijkstra() {
	int move[3] = { 1, -1, 1 };//??´y,??´x,??´x
	while (!pq.empty()) {
		S a = pq.top();
		pq.pop();
		if (a.o == 0) continue;
		if (a.y == h) {
			if (-a.cost <= f)
				ans = -a.cost;
			break;
		}
		if (a.o == 1) continue;
		for (int i = 0; i < 3; i++) {
			int x = a.x;
			int y = a.y;
			if (i)
				x += move[i];
			else
				y += move[i];
			int xx = 1 << (w - x);
			xx = xx&a.xh;
			if (!xx || !i) {
				if (x <= w && 0 < x&&y <= h) {
					if (stratum[y][x] < 0) {
						if (a.cost + stratum[y][x] >= -f&&a.cost + stratum[y][x] > c[y][x][a.o - 1]) {
							c[y][x][a.o - 1] = a.cost + stratum[y][x];
							if (i)
								pq.push(S( c[y][x][a.o - 1], x, y, a.o - 1, a.xh | 1 << (w - x) ));
							else
								pq.push(S( c[y][x][a.o - 1], x, y, a.o - 1, 1 << (w - x) ));
						}
					}
					else if (stratum[y][x] >0) {
						int hokyuuu;
						hokyuuu = stratum[y][x] + a.o - 1;
						if (hokyuuu + a.o - 1 >= m)
							hokyuuu = m;
						c[y][x][hokyuuu] = a.cost;
						if (i)
							pq.push(S(c[y][x][hokyuuu], x, y, hokyuuu, a.xh | 1 << (w - x)));
						else
							pq.push(S( c[y][x][hokyuuu], x, y, hokyuuu, 1 << (w - x) ));
					}
					else {
						pq.push(S( 0, x, y, o, a.xh | 1 << (w - x) ));
					}
				}
			}
			else {
				if (a.cost > c[y][x][a.o - 1] && a.o - 1) {
					c[y][x][a.o - 1] = a.cost;
					pq.push(S(c[y][x][a.o - 1], x, y, a.o - 1, a.xh ));
				}
			}
		}
	}
}


int main() {
	while (cin >> w >> h&&w&&h) {
		cin >> f >> m >> o;
		memset(stratum, sizeof(stratum), 0);
		ans = INF2;
		for (int i = 1; i <= 10; i++)
			for (int j = 1; j <= 10; j++)
				fill(c[i][j], c[i][j] + 51, INF);
		while (!pq.empty())
			pq.pop();
		for (int i = 1; i <= h; i++)
			for (int j = 1; j <= w; j++)
				cin >> stratum[i][j];
		pq.push(S( 0, 1, 0, o, 1 << (w - 1) ));
		dijkstra();
		if (ans != INF2)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define int long long
using namespace std;

#define pii pair<int,int>

int  Set(int N,int pos){return N=N | (1<<pos);}
int  reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}

int p[100];
vector<int>v[100];
int ans = 0;

int m,n;

void call(int at,int mask)
{
	if(at==n+1){
		int cnt = 0;
		for(int i = 1; i <= m;i++){
			int cnt2 = 0;
			for(auto xx: v[i]){
				if(check(mask,xx))cnt2++;
			}
			if(cnt2%2 == p[i])cnt++;
		}
		if(cnt == m)ans++;
		return;
	}

	call(at+1,Set(mask,at));
	call(at+1,mask);
}


int32_t main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int k,num;
	cin >> n >> m;
	for(int i = 1; i <= m;i++){
		cin >> k;
		for(int j = 0; j < k;j++){
			cin >> num;
			v[i].push_back(num);
		}
	}
	for(int i = 1;i <= m;i++){cin >> p[i];}
	call(1,0);
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	io := newIo()
	defer io.Flush()
	_, M := io.NextInt(), io.NextInt()
	checks := map[int]bool{}
	for i := 0; i < M; i++ {
		for j := 0; j < 2; j++ {
			a := io.NextInt()
			_, exists := checks[a]
			if exists {
				delete(checks, a)
			} else {
				checks[a] = true
			}
		}
	}
	if len(checks) > 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 5504
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,p[55],q[55];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		q[i]=p[i];
	}
	sort(q,q+n);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(q[i]!=p[i])
		{
			cnt++;
		}
	}
	if(cnt==0 || cnt==2)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

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

Measured memory_bytes: 4848
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
	int N, K; cin >> N >> K;
	long double ans = 0;
	long double bunsu = 0, bunsi = 0;
	int p1 = 0;

	for(int i = 1; i <= N; ++i){
		int p = 1, tmp = i*2;
		for(int j = 0; j < 20; ++j){
			if(tmp >= K) break;
			tmp *= 2;
			p++;
		}

		if(i > K-1) p = 0;
		if(i ==1) p1 = p;
		
		// cout << p << endl;

		bunsu += (long double)pow(10, 13) / pow(2, p);
		bunsi += pow(2, p1-p);
	}

	// cout << bunsi << endl;

	bunsi /= (long double)pow(2, p1);
	bunsi /= (long double)N;

	// bunsu /= (long double)N;
	// ans = (long double)bunsu / pow(10, 13);

	cout << fixed << setprecision(10) << bunsi << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s == u)  --a;
    if(t == u)  --b;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 896
n, m = map(int, input().split())

ship1 = [False]*n
shipn = [False]*n
ans = "IMPOSSIBLE"
for i in range(m):
  a, b = map(int, input().split())
  if a == 0 and b == n-1:
    ans = "POSSIBLE"
  elif a == 1:
    ship1[b-1] = True
  elif b == n:
    shipn[a-1] = True
  else:
    pass

for i in range(n):
  if ship1[i] and shipn[i]:
    ans = "POSSIBLE"
print(ans)

Measured memory_bytes: 6132
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

typedef pair<string, int> P;

map<P, long long> le, ri;

void get(string str, map<P, long long> &ans, bool rev){
	int N = str.size();
	for(int state = 0; state < (1 << N); ++state){
		char tmp[100];
		int id = 0;
		int cnt = 0;
		for(int i = 0; i < N; ++i){
			if((state >> i) & 1){
				tmp[id++] = str[i];
				cnt++;
			}
		}
		for(int i = N - 1; i >= 0; --i){
			if(((state >> i) & 1) == 0){
				tmp[id++] = str[i];
			}
		}
		tmp[N] = '\0';
		string t = tmp;
		if(rev){
			reverse(t.begin(), t.end());
			cnt = N - cnt;
		}
		ans[P(t, cnt)]++;
	}
}

long long solve(string str){
	string a = str.substr(0, str.size() / 2);
	string b = str.substr(str.size() / 2, str.size() / 2);
	reverse(b.begin(), b.end());
	get(a, le, false);
	get(b, ri, true);
	long long ans = 0;
	for(map<P, long long>::iterator it = le.begin(); it != le.end(); ++it){
		P p = it->first;
		long long val = it->second;
		long long coe = ri[p];
		ans += val * coe;
	}
	return ans;
}

int main(){
	int N;
	scanf("%d", &N);
	char ch[100];
	scanf("%s", ch);
	string str = ch;
	long long ans = solve(str);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 82176
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c;

	std::cin >> a >> b >> c;

	std::cout << max(a * 10 + b + c, max(a + b * 10 + c, a + b + c * 10)) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	if(n == 1){
		cout << "Yes" << endl;
		cout << 2 << endl << "1 1" << endl << "1 1" << endl;
		return 0;
	}
	ll h = 3, w = 2;
	while(h*w/2 < n){
		++h;
		++w;
	}
	if(h*w/2 > n){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << h << endl;
	vector<vector<int>> ans(h, vector<int>(w));
	int cnt = 1;
	rep(i,h){
		int num = cnt;
		for(int j = i; j < w; ++j) ans[i][j] = cnt++;
		for(int k = i+1; k < h; ++k) ans[k][i] = num++;
	}
	rep(i,h){
		cout << w;
		rep(j,w) cout << " " << ans[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 4044
#include<cstdio>
using namespace std;

int n;
char s[1030];
char list[9] = {'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'};
char one[5] = {'.', ',', '!', '?', ' '};

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    char count = -1;
    bool flag = false;
    for (int j = 0; s[j] != 0; j++) {
      if (s[j] == '0') {
        if (!flag) continue;
        if (s[j-1] == '1') printf("%c", one[count % 5]);
        else if (s[j-1] == '7' || s[j-1] == '9') printf("%c", list[s[j-1] - '2'] + count % 4);
        else printf("%c", list[s[j-1] - '2'] + count % 3);
        flag = false;
        count = -1;
      } else {
        flag = true;
        count++;
        if (count == 60) count = 0;
      }
    }
    printf("\n");
  }
}



Measured memory_bytes: 2584
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main() {
    vector<string> str(3);
    vector<queue<int> > que(3);
    for(int i=0; i<3; i++) {
        cin >> str[i];
        for(int j=0; j<str[i].size(); j++) {
            que[i].push((int)(str[i][j]-'a'));
        }
    }
    
    int cur=0;
    while(1) {
        int tmp=cur;
        if(que[tmp].empty()) {
            cout << (char)((int)'A' + tmp) << endl;
            break;
        }
        cur = que[tmp].front(); que[tmp].pop();
    }

    return 0;
    
}

Measured memory_bytes: 256
def main():
    # 1 to N => 1 to X to N
    N, M = map(int, input().split())
    from1 = set()
    toN = set()
    for i in range(M):
        a, b = map(int, input().split())
        if a == 1:
            from1.add(b)
        if b == N:
            toN.add(a)

    if from1 & toN:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == '__main__':
    main()


Measured memory_bytes: 19024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	ll n, k;
	string s;
	cin >> n >> k >> s;
	s[--k] -= 'A' - 'a';
	dump(s);
	return 0;
}

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

int main() {
  double T, X;
  cin >> T >> X;
  double ans = T / X;
  printf("%0.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s){
    TSTART();
    vector<bool> B(26);
    bool ans = true;
    REP(i,26){
      B[i] = false;
    }
    REP(i,SZ(s)){
      int ind = s[i] - 'a';
      if(B[ind]){
	ans = false;
	break;
      }
      B[ind] = true;
    }
    if(ans) cout << "yes" << endl;
    else cout << "no" << endl;
    
    TSTOP();
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

    String ans = "";
    do {
      ans += (char)(Math.abs(N) % 2 + '0');
      if (N < 0) N = (N - 1) / (-2);
      else N = N / (-2);
    } while (N != 0);
    StringBuffer sb = new StringBuffer(ans);
    sb.reverse();
    ans = sb.toString();
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l=2*i;
    r=2*i+1;
    
    if(l<=H && A[l]>A[i])largest =l;
    else largest = i;
    if (r <= H && A[r]>A[largest])largest = r;
    
    if(largest != i){
        swap (A[i], A[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> H;
    for(int i=1; i<=H; i++){
        cin >> A[i];
    }
    
    for(int i=H/2; i>=1; i--) maxHeapify(i);
    
    for (int i = 1; i <= H; i++){
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5036
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

ll power(ll x, ll pw, ll mod) {
    ll res = 1;
    x = x % mod;  // if it x >= p
    while (pw > 0) {
        if (pw & 1)
            res = (res*x) % mod;
        pw /= 2;
        x = (x*x) % mod;
    }
    return res;
}
ll modInverse(ll n, ll p) {
    return power(n, p-2, p) % p; // Fermat little theorem
}
ll nCr(ll n, ll m, ll mod=1e9+7) {
    m = min(m, n-m);
    if (m == 0) return 1;
    ll num = 1, dem = 1;
    for(ll i = 1; i <= m; i++) {
        num = (num*(n+1-i)) % mod;
        dem = (dem*(i)) % mod;
    }
    return (num * modInverse(dem, mod)) % mod;
}
int main() {
    int n, val;
    unordered_map<int, int> pos;
    int pre, post;
    cin >> n;
    for(int i = 0; i < n+1; i++) {
        cin >> val;
        if (pos.count(val) > 0) {
            pre = pos[val];
            post = n-i;
        }
        pos[val] = i;
    }
    // cout << pre << " " << post << endl;
    int outer = pre + post;
    ll mod = 1e9 + 7;
    ll cur_nCr = nCr(n+1, 1);
    ll cur_outer = nCr(outer, 0);
    for(int k = 1; k <= n+1; k++) {
        if (outer >= k-1) {
            // nCr(n+1, k) - nCr(outer, k-1)
            cout << (cur_nCr - cur_outer + mod) % mod << endl;
            ll mul0 = (outer-(k-1)) * (modInverse(k, mod)) % mod;
            cur_outer = (cur_outer * mul0) % mod;
        } else {
            cout << cur_nCr << endl;
        }
        ll mul = (n+1-k) * (modInverse(k+1, mod)) % mod;
        // cout << "nCr, r = " << k+1 << ", = " << cur_nCr << endl;
        cur_nCr = (cur_nCr * mul) % mod;
    }
    return 0;
}




Measured memory_bytes: 5284
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}


int main() {
	ll i, j, k, l, m, n, sum, flag, cc,N,M;
	sum = 0;
	flag = 0;
	cin >> N;
	vector<ll>A(N);
	REP(i, 0, N) {
		cin >> A[i];
	}
	vector<ll>sum1(N + 1);
	COMinit();
	REP(i, 0, N + 1) {
		sum1[i] = 0;
	}
	REP(i, 1, N + 1) {
		sum1[i] = sum1[i - 1] + inv[i];
		sum1[i] %= MOD;
	}
	vector<ll>com(N);
	REP(i, 0, N) {
		com[i] = sum1[i + 1] - 1 + sum1[N - i];
		com[i] %= MOD;
	}
	ll ans = 0;
	REP(i, 0, N) {
		ans += A[i] * com[i];
		ans %= MOD;
	}
	ans *= fac[N];
	ans %= MOD;
	output(ans);
	return 0;
}

Measured memory_bytes: 14592
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 510;
const int INF = (int)1e9;

int n, m, d;
string s[2];

int main() {
  scanf("%d %d %d",&n,&m,&d);
  s[0] = "RB";
  s[1] = "YG";
  REP(i, n) {
    REP(j, m) {
      int x = i + j;
      int y = i - j;
      x = (x + INF) / d;
      x %= 2;
      y = (y + INF) / d;
      y %= 2;
      printf("%c",s[x][y]);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 512
// ------------------------------------
// Date:2018/ 3/17
// Problem:_ _ _ b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

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

  CIN(N);
  vector< string > s(N);
  REP(i, N) {
    cin >> s[i];
  }
  CIN(M);
  vector< string > t(M);
  REP(i, M) {
    cin >>t[i];
  }

  sort(ALL(s));
  sort(ALL(t));

  string str = "";
  int cnt;
  int ans = 0;
  REP(i, N) {
    cnt = 0;
    str = s[i];
    REP(j, N) {
      if (str == s[j]) {
      cnt++;
      }
    }
    REP(j, M) {
      if (str == t[j]) {
	cnt--;
      }
    }
    ans = max(ans, cnt);
  }

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



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(float, input().split()))

# dp[i][h]: i回投げてh回表がでる確率
dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for h in range(i+1):
        if h-1<0:
            dp[i][h] = dp[i-1][h]*(1-p[i-1])
        else:
            dp[i][h] = dp[i-1][h-1]*p[i-1] + dp[i-1][h]*(1-p[i-1])
    # print(dp)
print(sum(dp[N][N//2+1:]))

Measured memory_bytes: 262280
#include <stdio.h>

int main(void){
    // Your code here!
    int n, amount = 0, flag = 0;
    int key[3] = {0,0,0};
    scanf("%d",&n);
    
    if(n <= 356)
    {
        amount = 0;
    }
    else
    {
        int count = 357;
        while(count <= n)
        {
            key[0] = 0;
            key[1] = 0;
            key[2] = 0;
            flag = 1;
            //printf("%d:\n",count);
            for(int j = count; j > 0 && flag == 1; j /= 10)
            {
                switch(j%10)
                {
                    case 3:
                        key[0]++;
                        break;
                        
                    case 5:
                        key[1]++;
                        break;
                        
                    case 7:
                        key[2]++;
                        break;
                        
                    default:
                        flag = 0;
                }
            }
            //printf("%d, %d %d %d\n",flag,key[0],key[1],key[2]);
            if(flag == 1 && key[0]*key[1]*key[2] != 0) amount++;
            
            switch(count%100)
            {
                case 37:
                    count += 16;
                    break;
                    
                case 57:
                    count += 16;
                    break;
                    
                case 77:
                    count += 56;
                    break;
                    
                default:
                    count += 2;
            }
        }
    }
    printf("%d\n",amount);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int w[105],v[105];
long long dp[105][100005];
int main()
{
  int n,W;
  cin>>n>>W;
  for(int i=0; i<n; i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<=W; j++){
      if(j>=w[i]){
	dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }else{
	dp[i+1][j]=dp[i][j];
      }
    }
  }
  cout<<dp[n][W]<<'\n';
  return 0;
}


Measured memory_bytes: 79360
A, B, C, X, Y = map(int, input().split())
ans = 0
if A+B > 2*C:
   min_v = min(X, Y)
   ans += C * min_v * 2
   diff = abs(X - Y)
   base = A if X > Y else B
   if base * diff < C * 2 * diff:
      ans += base * diff
   else:
      ans += C * 2 * diff
else:
   print(A*X + B*Y)
   exit()
print(ans)

Measured memory_bytes: 3064
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l,m):
	f = 1
	n = len(l)
	tot = sum(l)
	k = tot/(4*m)
	l = sorted(l)[::-1][:m]
	for i in l:
		if(i < k):
			f = 0
			break
	if(f):
		return 'Yes'
	else:
		return 'No'

a,b,c = list(map(int, stdin.readline().rstrip().split()))
a,b = b,a
a,c = c,a
print(a,b,c)




Measured memory_bytes: 39408
use std::io::{Read, stdin};
use std::str::FromStr;


fn main() {
    let n: usize = read();

    let m: usize = read();
    let mut v: Vec<[i64; 3]> = Vec::new();
    for i in 0..m {
        v.push([read(), read(), i as i64]);
    }
    v.sort_by_key(|a| a[1]);
    let mut cntv = vec![1;n+1];
    let mut ansv: Vec<[i64; 3]> = Vec::new();
    for u in v{
        ansv.push([u[0], cntv[u[0] as usize], u[2]]);
        cntv[u[0] as usize] += 1;
    }
    ansv.sort_by_key(|a| a[2]);
    for u in ansv{

        println!("{: >06}{: >06}",u[0], u[1]);

    }
}


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

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

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

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

class UnionFind{
    public:
    vector<long long> parent;
    vector<long long> count;
    UnionFind(long long n){
        parent.resize(n);
        count.resize(n);
        for(long long i=0; i<n; i++) parent[i] = i;
        for(long long i=0; i<n; i++) count[i] = 1;
    }
    long long root(long long x){
        if(parent[x]==x) return x;
        else return parent[x] = root(parent[x]);
    }
    long long unite(long long x, long long y){
        long long res = 0;
        long long px = root(x);
        long long py = root(y);
        if(px==py) return 0;
        else{
            res = count[px] * count[py];
            count[px] += count[py];
            count[py] = 0;
            parent[py] = px;
        }
        return res;
    }
};
signed main(){
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);
    vector<ll> res(M, 0);
    vector<ll> A(M), B(M);
    ll nc2 = N*(N-1) / 2;
    for(long long i=0; i<M; i++){
        ll a, b; cin >> a >> b;
        a--;
        b--;
        A[i] = a;
        B[i] = b;
    }
    for(long long i=M-1; i>=0; i--){
        res[i] = uf.unite(A[i], B[i]);
    }
    for(long long i=0; i<M-1; i++){
        res[i+1] += res[i];
    }
    for(long long i=0; i<M; i++){
        cout << res[i] + (nc2-res[M-1])<< endl;
    } 
    return 0;
}

Measured memory_bytes: 5248