akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0165
{
    public class Program

    {
        public const int MAX = 1000000;

        public static void Main(string[] args)
        {
            bool[] isNotPrime = new bool[MAX + 1];
            int[] cumSum = new int[MAX + 1];

            isNotPrime[1] = true;
            for (int i = 2 ; i <= MAX ; i++)
            {
                cumSum[i] = cumSum[i - 1];
                if (!isNotPrime[i])
                {
                    cumSum[i]++;
                    for (int j = i * 2 ; j <= MAX ; j += i)
                    {
                        isNotPrime[j] = true;
                    }
                }
            }

            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int res = 0;
                for (int i = 0 ; i < n ; i++)
                {
                    int[] items = RIntAr();

                    int bottom = items[0] - items[1] < 1 ? 1 : items[0] - items[1];
                    int top = items[0] + items[1] > MAX ? MAX : items[0] + items[1];

                    int primeCnt = cumSum[top] - cumSum[bottom - 1];
                    if (primeCnt == 0) res--;
                    else res += primeCnt - 1;
                }
                Console.WriteLine(res);
            }          
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 20308
#include<stdio.h>
#include<stdlib.h>
void insertionSort(int *,int);
  int main(){
    int i,num;//for loop用 個数用
  int *A;//配列用
  scanf("%d",&num);//個数入力
  A = (int *)malloc(sizeof(int *) * num);//配列生成
  for(i=0;i<num;i++){//配列入力 ＆ 表示
    scanf("%d",&A[i]);
    if(i == num-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  insertionSort(A,num);//並び換え ＆ 表示

  free(A);//解放
  return 0;
}

void insertionSort(int *A,int num){
  int i,v,j,k;// i,j,kはloop用、vは退避用
  for(i = 1; i<=num-1;i++){
    v = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0;k<num;k++){//表示
      if(k == num-1)printf("%d\n",A[k]);
      else printf("%d ",A[k]);
    }
  }
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

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

int main()
{
  i64 h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (i64 i = 0; i < h; i++)
    cin >> s[i];
  i64 ans = 0;
  for (i64 i = 0; i < h; i++)
    for (i64 j = 0; j < w; j++)
      if (s[i][j] == '.')
      {
        vector<vector<i64>> far(h, vector<i64>(w, 1e9));
        queue<pair<i64, i64>> que;
        far[i][j] = 0;
        que.push({i, j});
        while (que.size())
        {
          pair<i64, i64> p = que.front();
          que.pop();
          for (i64 k = 0; k < 4; k++)
          {
            i64 x = p.first + dx[k], y = p.second + dy[k];
            if (0 <= x && x < h && 0 <= y && y < w && far[p.first][p.second] + 1 < far[x][y] && s[x][y] == '.')
            {
              far[x][y] = far[p.first][p.second] + 1;
              que.push({x, y});
            }
          }
        }
        i64 t = 0;
        for (i64 k = 0; k < h; k++)
          for (i64 l = 0; l < w; l++)
            if (s[k][l] == '.')
              t = max(t, far[k][l]);
        ans = max(ans, t);
      }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

int solve(int n, const vector<string> & s) {
    int cnt = 0;
    array<array<int, 2>, 2> edge = {};
    for (auto & s_i : s) {
        REP (j, s_i.size() - 1) {
            cnt += (s_i[j] == 'A' and s_i[j + 1] == 'B');
        }
        ++ edge[s_i.front() == 'B'][s_i.back() == 'A'];
    }
    if (edge[true][true]) {
        cnt += edge[true][true] - 1;
        if (edge[false][true]) {
            -- edge[false][true];
            ++ cnt;
        }
        if (edge[true][false]) {
            -- edge[true][false];
            ++ cnt;
        }
    }
    cnt += min(edge[true][false], edge[false][true]);
    return cnt;
}

int main() {
    int n; cin >> n;
    vector<string> s(n);
    REP (i, n) {
        cin >> s[i];
    }
    cout << solve(n, s) << endl;
    return 0;
}


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

int main(){

char senn, hyaku, juu, iti;
cin >> senn >> hyaku >> juu >> iti;

  if((senn == hyaku && hyaku == juu) || (hyaku == juu && juu == iti)) cout << "Yes" << endl;
  else cout << "No" << endl;

return 0;
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/**
  2 2 3 
4 1 2 3 5
  **/
int main(){
	int n, x; cin >> n >> x;
	if(n == 2){
		if(x == 2){
			cout << "Yes" << endl;
			cout << 1 << endl;
			cout << 2 << endl;
			cout << 3 << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		n = 2 * n - 1;
		if(x != 1 && x != n){
			cout << "Yes" << endl;
			vector<int> a, tk(n + 10, 0);
			tk[x - 1] = 1;
			tk[x - 2] = 1;
		       	tk[x] = 1;
			tk[x + 1] = 1;
			tk[x + 2] = 1;
			for(int i = 1; i <= n; i++) if(!tk[i]) a.push_back(i);
			int len = a.size();
			for(int i = 0; i < len/2; i++) cout << a[i] << endl;
			if(x - 2 >= 1 && x + 2 <= n){
				cout << x + 2 << endl;
				cout << x - 1 << endl;
				cout << x << endl;
				cout << x + 1 << endl;
				cout << x - 2 << endl;
			} else if(x + 2 <= n){
				cout << x + 2 << endl;
				cout << x - 1 << endl;
				cout << x << endl;
				cout << x + 1 << endl;
			} else {
				cout << x - 2 << endl;
				cout << x + 1 << endl;
				cout << x << endl;
				cout << x - 1 << endl;
			}
			for(int i = len/2; i < len; i++) cout << a[i] << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


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

int main() {
  int Ans = 0;  // 回答：
  // string Ans = "Yes";  // 回答：
  int N; cin >> N;  // 偶数の個数
  int M; cin >> M;  // 奇数の個数

  if (N==0 || N==1 ){
    Ans = M * (M-1) / 2;
  } else if (M==0 || M==1 ) {
    Ans = N * (N-1) / 2;
  } else {
    Ans = ( M * (M-1) + N * (N-1) ) / 2 ;
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a,b;

int main()
{
    cin >> a >> b;
    
    if(a < b)
    {
        cout << "a < b" << endl;  
    }
    if(a == b)
    {
        cout << "a == b" << endl;
    }
    if(a > b)
    {
        cout << "a > b" << endl;
    }
    
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Pair[] pairs = new Pair[m];
        for (int i = 0 ; i < m ; i++) {
            Pair ps = new Pair();
            ps.from = sc.nextInt();
            ps.end = sc.nextInt();
            pairs[i] = ps;
        }
        Arrays.sort(pairs);
        int cnt = 0;
        int nowclear = 0;
        for (int i = 0 ; i < m ; i++) {
            int nowFrom = pairs[i].from;
            int nowEnd = pairs[i].end;
            if (nowclear < nowFrom) {
                cnt++;
                nowclear = nowEnd - 1;
            }
        }
        System.out.println(cnt);

    }

}

class Pair implements Comparable {
    int from;
    int end;
    @Override
    public int compareTo(Object other) {
        Pair otherpair = (Pair) other;
        return end - otherpair.end;
    }
}

Measured memory_bytes: 88640
#include<stdio.h>

int main(){

    int N=0;
    int A[21]={};
    int B[21]={};
    int C[20]={};
    int sum=0;
    int kari=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(int i=0;i<N;i++){
        scanf("%d",&B[i]);
    }
        for(int i=0;i<N-1;i++){
        scanf("%d",&C[i]);
    }

    for(int i=0;i<N;i++){
        if(A[i+1]-A[i]==1){
            kari=A[i]-1;
            sum += C[kari];
        }

        sum += B[i];

    }


    printf("%d\n",sum);

    return 0;
}

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

bool check=false;
int a, b, c;

int main() {
	cin >> a >> b >> c;
	for(int i=1; i<=b; i++){
		if((a*i+c)%b==0){
			check=true;
			break;
		}
	}

	if(check){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $n);
  fscanf(STDIN, "%d", $k);
  fscanf(STDIN, "%d", $x);
  fscanf(STDIN, "%d", $y);

  $sum = 0;

  for($i = 0; $i < $n; $i++){
    if($i < $k){
      $sum += $x;
    }else{
      $sum += $y;
    }
  }
    
  echo $sum;

Measured memory_bytes: 4604
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

struct Rect {
	int x0, y0, x1, y1;

	Rect(){}
	Rect(int x0, int y0, int x1, int y1):
		x0(x0), y0(y0), x1(x1), y1(y1)
	{}
};

const int MAX_N = 1000;
int W, H, N;
int xs[2*MAX_N + 2], ys[2*MAX_N + 2];
Rect rects[MAX_N];
const int dy[] = {1,-1,0,0}, dx[] = {0,0,1,-1};
int board[2*MAX_N + 3][2*MAX_N + 3];

bool init() {
	scanf("%d%d", &W, &H);
	if (W == 0 && H == 0) {
		return false;
	}
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d%d%d", &rects[i].x0, &rects[i].y0, &rects[i].x1, &rects[i].y1);
		xs[2*i+0] = rects[i].x0;
		xs[2*i+1] = rects[i].x1;
		ys[2*i+0] = rects[i].y0;
		ys[2*i+1] = rects[i].y1;
	}
	xs[2*N+0] = 0;
	xs[2*N+1] = W;
	ys[2*N+0] = 0;
	ys[2*N+1] = H;

	sort(xs, xs + 2*N+2);
	sort(ys, ys + 2*N+2);

	int LX = 0, LY = 0;
	LX = unique(xs, xs + 2*N+2) - xs;
	LY = unique(ys, ys + 2*N+2) - ys;
	for (int i = 0; i < N; ++i) {
		rects[i].x0 = lower_bound(xs, xs + LX, rects[i].x0) - xs;
		rects[i].x1 = lower_bound(xs, xs + LX, rects[i].x1) - xs;
		rects[i].y0 = lower_bound(ys, ys + LY, rects[i].y0) - ys;
		rects[i].y1 = lower_bound(ys, ys + LY, rects[i].y1) - ys;
	}
	W = LX - 1;
	H = LY - 1;

	return true;
}

int solve() {
	memset(board, 0, sizeof(board));

	for (int i = 0; i < N; ++i) {
		++board[rects[i].y0][rects[i].x0];
		--board[rects[i].y1][rects[i].x0];
		--board[rects[i].y0][rects[i].x1];
		++board[rects[i].y1][rects[i].x1];
	}

	for (int i = 0; i < H; ++i) {
		board[i+1][0] += board[i][0];
	}
	for (int j = 0; j < W; ++j) {
		board[0][j+1] += board[0][j];
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			board[i+1][j+1] += board[i+1][j] + board[i][j+1] - board[i][j];
		}
	}

	int ans = 0;
	vector< pair<int,int> > stack; stack.reserve(W*H);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) if (board[i][j] == 0) {
			stack.clear();
			board[i][j] = 1;
			stack.push_back(make_pair(i, j));
			for (;!stack.empty();) {
				const int y = stack.back().first, x = stack.back().second;
				stack.pop_back();
				for (int k = 0; k < 4; ++k) {
					const int ny = y + dy[k], nx = x + dx[k];
					if ( 0 <= ny && ny < H && 0 <= nx && nx < W && board[ny][nx] == 0) {
						board[ny][nx] = 1;
						stack.push_back(make_pair(ny, nx));
					}
				}
			}
			++ans;
		}
	}
	return ans;
}

int main() {
	for (;init();) {
		printf("%d\n", solve());
	}
	return 0;
}

Measured memory_bytes: 16996
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // include pb_ds

using namespace std;
using namespace __gnu_pbds; // namespace for pb_ds

/* short forms */
#define Accelerate                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define cld(x, y) (((x) / (y)) + ((x) % (y) != 0)) //integer ceil division
#define tc(tt) \
    int tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) // testcase
#define all(cont) (cont).begin(), (cont).end()
#define sz(cont) (int)(cont).size()
#define endl '\n'
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl //print with precision
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)

/* constants */
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;

/* typedefs */
typedef pair<int,int> pii;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;
typedef priority_queue<int, vector<int> > max_heap;
typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> 
    indexed_set; // integer set with indexing / pb_ds

ll int pow_mod(ll int x,ll int n,ll int md) {
    ll int res = 1%md;
    while(n>0) {
        if(n%2==1) res = (res*x)%md;
        x = (x*x)%md;
        n >>= 1;
    }
    return res;
}

/* main program */
int main() {
    Accelerate;
    string s;
    cin >> s;
    int n = sz(s);
    vector<int>v(n,1);
    int i=0,j=0;
    while(i<n) {
        j = i;
        while(j<n && s[j]=='R')j++;
        while(i<j) {
            int r = abs(j-i)%2;
            v[i]--;
            if(r) {
                v[j-1]++;
            }
            else {  
                v[j]++;
            }
            i++;
        }
        j--;
        while(i<n && s[i]=='L') {
            int r = abs(j-i)%2;
            v[i]--;
            if(r) {
                v[j+1]++;
            }
            else {  
                v[j]++;
            }
            i++;
        }
    }
    for(int i=0;i<n;i++) cout << v[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1104
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int D; std::cin >> D;
    std::vector<int> c(26);
    for(int i(0); i < 26; ++i) std::cin >> c[i];
    std::vector<std::vector<int>> s(D+1, std::vector<int>(26, 0));
    for(int i(1); i <= D; ++i){
        for(int j(0); j < 26; ++j){
            std::cin >> s[i][j];
        }
        std::cout << (i-1) % 26 + 1 << "\n";
    }
    return 0;
}


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

int selection(vector<int> &a,int n);

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a.at(i);
    }
    int x=selection(a,n);
    rep(i,n){
        cout<<a.at(i);
        if(i!=n-1){
            cout<<' ';
        }
        else{
            cout<<endl;
        }
    }
    cout<<x<<endl;
    return 0;
}

int selection(vector<int> &a,int n){
    int c=0;
    for(int i=0;i<n-1;i++){
        int min=i;
        for(int j=i+1;j<n;j++){
            if(a.at(j)<a.at(min)){
                min=j;
            }
        }
        if(min!=i){
            swap(a.at(min),a.at(i));
            c++;
        }
    }
    return c;
}
 


Measured memory_bytes: 3108
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    ll sum = 0;
    rep(i,n){
        ll t;
        cin >> t;
        a[i] = t;
        sum += t;
        sum %= mod;
    }
    rep(i,n){
        sum -= a[i];
        if(sum < 0) sum += mod;
        ans += a[i] * sum;
        ans %= mod;
    }
    cout << ans << endl;


    return 0;
}


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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

const int INF = 9e18;
// const int N = 1e9 + 7;
const int N = 998244353;

const auto start_time = std::chrono::high_resolution_clock::now();

void zark() {
  #ifdef ZARK
  auto end_time = std::chrono::high_resolution_clock::now();
  std::chrono::duration<double> diff = end_time - start_time;
  cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}

#ifdef ZARK
#include "/home/aranjan/Desktop/CP/header.h"
#else
#define dbg(args...)
#endif

/* ------------------ Actual Coding Starts ------------------ */

void solve() {
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC\n";
  else cout << "ABC\n";
}

int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif

  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);

  solve();
  zark();
  return 0;
}


Measured memory_bytes: 3644
n,a,b = map(int,input().split())
lis = []
for i in range(n):
    lis.append(i+1)

ans = []
for i in range(n):
    tmp = sum([int(x) for x in list(str(lis[i]))])
    if tmp >= a and tmp <= b:
        ans.append(lis[i])

print(sum(ans))

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






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



}




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

c = H[0]
for i in range(N - 1):
    if c <= H[i + 1] - 1:
        c = H[i + 1] - 1
    elif c <= H[i + 1]:
        c = H[i + 1]
    else:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 14524
#include <stdio.h>

int main()
{
    int a, b;
    char op;

    while(1) {
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?') {
            break;
        } else if(op == '+') {
            printf("%d\n", a + b);
        } else if(op == '-') {
            printf("%d\n", a - b);
        } else if(op == '*') {
            printf("%d\n", a * b);
        } else if(op == '/') {
            printf("%d\n", a / b);
        }
    }

    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int[] line = Array.ConvertAll<string, int>(Console.ReadLine().Trim().Split(' '), int.Parse);
        int n = line[0];
        int time = line[1];
        int cost = 1000;
        bool founded = false;

        for (int i = 0; i < n; i++)
        {
            line = Array.ConvertAll<string, int>(Console.ReadLine().Trim().Split(' '), int.Parse);
            if (line[1]<= time && line[0] <= cost)
            {
                founded = true;
                cost = line[0]; 
            }
        }

        if (!founded)
        { System.Console.WriteLine("TLE"); }
        else
        { System.Console.WriteLine(cost.ToString()); }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

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

        long a = sc.nextLong();
        long b = sc.nextLong();

        int ans = -1;
        for (int i = 0; i < Math.max(a, b); i++) {
            if (Math.abs(a - i) == Math.abs(b - i)) {
                ans = i;
                break;
            }
        }

        System.out.println(ans < 0 ? "IMPOSSIBLE" : ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> ans(s.size(), 0);

  for(int i = 0; i < s.size()-1; i++) {
    if(s[i] == 'R' && s[i+1] == 'L') {
      int cntR = 0;
      for(int j = i; s[j] == 'R'; j--) cntR++;
      int cntL = 0;
      for(int j = i+1; s[j] == 'L'; j++) cntL++;

      if(cntR % 2 != 0) {
        ans[i] += (cntR+1)/2;
        ans[i+1] += (cntR+1)/2-1;
      }else {
        ans[i] += cntR/2;
        ans[i+1] += cntR/2;
      }

      if(cntL % 2 != 0) {
        ans[i+1] += (cntL+1)/2;
        ans[i] += (cntL+1)/2-1;
      }else {
        ans[i+1] += cntL/2;
        ans[i] += cntL/2;
      }
    }
  }

  for(int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int l, r;
    cin >> l >> r;
    ll ans = 2019;
    if (l + 2019 <= r)
        return cout << 0, 0;
    for (int i = l; i <= r; i++)
    {
        for (int j = i + 1; j <= r; j++)
            ans = min(ans, (1LL * i * j) % 2019);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
mint m9 = mint(1)/mint(9);

struct S{
  mint val;
  mint power;
};

S op(S l, S r){
  S res;
  res.power = l.power * r.power;
  res.val = l.val*r.power + r.val;
  return res;
}

S e(){
  S res;
  res.power = 1;
  res.val = 0;
  return res;
}

using F = int;

S mapping(F f, S s){
  if(f == 0) return s;
  S res;
  res.power = s.power;
  res.val = (s.power-1) * m9 * f;
  return res;
}

F composition(F f, F g){
  if(f == 0) return g;
  else return f;
}

F id(){
  return 0;
}

int main(){
  int n, q;
  cin >> n >> q;
  lazy_segtree<S, op, e, F, mapping, composition, id> lsg(n);
  S st;
  st.power = 10;
  st.val = 1;
  rep(i, n){
    lsg.set(i, st);
  }
  cerr << lsg.all_prod().val.val() << endl;
  rep(i, q){
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    lsg.apply(l, r, d);
    S ans = lsg.all_prod();
    cout << ans.val.val() << endl;
  }
  return 0;
}

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

int house[4][3][10]={{{0}}};

void print(int n){
  for(int i=0;i<3;i++){
    for(int j=0;j<10;j++){
      cout<<" "<<house[n][i][j];
    }
    cout<<endl;
  }
}

int main(){
  int n;
  cin>>n;
  while(n--){
    int b,f,r,v;
    cin>>b>>f>>r>>v;
    house[b-1][f-1][r-1]+=v;
  }
  for(int i=0;i<3;i++){
    print(i);
    cout<<"####################"<<endl;
  }
  print(3);
  return 0;
}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 2e3 + 5;

vector < ll > fact(MAXN);

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

ll inv(ll a){
  return pwr(a, mod - 2);
}

ll comb(ll n, ll r){
  if(r > n) return 0;
  return ((((fact[n] * inv(fact[r])) % mod) * inv(fact[n - r])) % mod);
}

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

  fact[0] = 1;
  for(int i = 1; i < MAXN; i++) fact[i] = (i * fact[i - 1]) % mod;

  ll n, k;
  cin >> n >> k;

  vector < ll > ans(k + 1);
  for(int i = 1; i <= k; i++){
    ans[i] = (comb(n - k + 1, i) * comb(k - 1, i - 1)) % mod;
  }

  for(int i = 1; i <= k; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		if(b-a+1 >= k*2) {
            for (int i = a ; i < a + k ; i++) {
                System.out.println(i);
            }
            for (int i = k ; i > 0 ; i--) {
                System.out.println(b - i + 1);
            }
		}else {
			for(int i=a ; i<=b ; i++) {
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,c=1,min;
  int a[200000];
  cin>>n;
  for(i=0;i<n;i++)
  cin>>a[i];
  min=a[0];
  for(i=1;i<n;i++)
  {
    if(a[i]<min)
    {
      c++;
      min=a[i];
    }
    
  }
  cout<<c;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for(int i = 0; i < n; i++) cin >> v.at(i);

  bool f = false;
  for (int j = 0; j < n; ++j) {
    if(v.at(j) == "Y") f = true;
  }

  if (f) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
n, t = gets.chomp.split(' ').map(&:to_i)
c = []
tt = []
n.times do |i|
  tmp = gets.chomp.split(' ').map(&:to_i)
  c << tmp[0]
  tt << tmp[1]
end

ans = 10000
n.times do |i|
  if ans > c[i] && tt[i] <= t
    ans = c[i]
  end
end

if ans == 10000
  puts "TLE"
else 
  puts ans
end


Measured memory_bytes: 1788
#python3
import numpy as np
N = int(input())
A = np.array([int(_) for _ in input().split()])
mod = 10**9 + 7
ans = 0
for b in range(60):
    B = (A >> b) & 1
    M = np.count_nonzero(B)
    ans += 2**b * M * (N - M)
print(ans%mod)


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    int h; cin >> h;
    int w; cin >> w;
    result = (n - h + 1) * (n - w + 1);
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3604
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    num = [True] * (max(A) + 1)
    appear = set()
    for a in A:
        if a not in appear:
            appear.add(a)
        else:
            num[a] = False

    for a in A:
        for i in range(a * 2, len(num), a):
            num[i] = False

    res = 0
    for a in A:
        if num[a]:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


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


#pragma region user_defined
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define CLR0(arr)  memset(arr,0,sizeof(arr))
#define LL long long
#define VECTOR vector<LL>
#define VECTOR_IT vector<LL>::iterator
#define LIST list<LL>
#define LIST_IT list<LL>::iterator
#define A(n) n.begin(),n.end()
#pragma endregion


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 //start time:2016/10/2 14:07:15
void Solve() {
#ifdef LOCAL_DEBUG  
	freopen("A Barricade_input.txt", "r", stdin);
//freopen("A Barricade_output.txt", "w", stdout);
#endif 
	int N; cin >> N;
	int A; cin >> A;
	vector<int> arr(256, 0);
	for (int i = 0; i < N; i++)
	{
		string s; cin >> s;
		arr[s[0]]++;
	}
	multiset<int,greater<int> > _set; 
	for (int i = 0; i < 256; i++)
	{
		if (arr[i]) _set.insert(arr[i]);
	}

	int cnt = 0;
	while (_set.size() >= A) {
		vector<int> tmp;
		for (int i = 0; i < A; i++)
		{
			int ggg = *_set.begin();
			_set.erase(_set.begin());
			ggg--;
			if (ggg) tmp.push_back(ggg);
		}
		cnt++;
		for (int i = 0; i < tmp.size(); i++)
		{
			_set.insert(tmp[i]);
		}
	}


	cout << cnt << endl;





}
 

int main() {
   Solve();
   return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2!=0){
    cout << "No" << endl;
    return 0;
  }
  string s1 = s.substr(0,n/2);
  string s2 = s.substr(n/2);
  if(s1==s2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 100*a + 10*b + c;
  if(ans%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
int main()
{
  int x; cin >> x;
  for (int i = 0; i < 3; i++) {
  	if (x % 10 == 7) {
    	cout << "Yes" << endl;
      return 0;
    }
    x /= 10;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
pair <int,int> dxdy[4] = {{1,0}, {0,1},{-1,0},{0,-1}};
signed main(void){
    int h,w; cin>>h>>w;
    vector <vector<char>> mas(h,vector <char>(w));
    rep(i,h)rep(j,w) {cin>>mas[i][j];}
    vector <vector<bool>> v( h,vector <bool>(w ));
    int ans = 0;
    rep(i,h)rep(j,w){
        if(v[i][j]) continue;
        int black=0, white = 0;
        if(mas[i][j] == '#'){
            queue <tuple<int,int,char>> q; //i,j,#or.
            q.push(make_tuple(i,j,'#'));
            while(!q.empty()){
                int y,x; char c;
                auto tmp = q.front(); q.pop();
                y = get<0>(tmp), x = get<1>(tmp), c = get<2>(tmp);
                if(v[y][x]) continue; else v[y][x] = true;
                if(c == '#') black++; else white++;
                rep(k,4){
                    int ny = y + dxdy[k].F,nx = x + dxdy[k].S;
                    if(ny<0||ny>=h||nx<0||nx>=w) continue;
                    if(mas[ny][nx] != c && !v[ny][nx]) q.push(make_tuple(ny,nx,mas[ny][nx]));
                }
            }
            ans += black*white;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

vl toNSinsu(ll x, ll n) {
	ll cnt = 0;
	ll xx = x;
	while (xx > 0) {
		xx /= n;
		cnt++;
	}
	vl ret(cnt, 0);
	rep(i, cnt) {
		ret[i] = x%n;
		x /= n;
	}
	return ret;
}

int main(void) {
	ll n;
	cin >> n;
	vl ngo = toNSinsu(n, 26);
	string s = "";
	rep(i, ngo.size()) {
		if (i == ngo.size() - 1) {
			if (ngo[i] != 0) s += (char)('a' + ngo[i] - 1);
		}
		else {
			if (ngo[i] <= 0) {
				ngo[i + 1]--;
				ngo[i] += 26;
			}
			s += (char)('a' + ngo[i] - 1);
		}
	}
	reverse(all(s));
	cout << s << endl;
	cin >> s;

	return 0;
}


Measured memory_bytes: 3600
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for(ll i = a; i < (ll)(n); ++i)
#define repr(i, a, n) for(ll i = n - 1; (ll)a <= i; --i)
#define ENDL '\n'
typedef pair<int, int> Pi;
typedef pair<ll, ll> PL;
constexpr ll mod = 999000007;  // 998244353;
constexpr ll INF = 999000099;
constexpr ll LINF = (ll)(1e18 + 99);
const ld PI = acos((ld)-1);
const vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U> inline bool chmin(T& t, const U& u) {
  if(t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U> inline bool chmax(T& t, const U& u) {
  if(t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template <typename T, typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(; n; n >>= 1) {
    if(n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
  for(auto&& x : vec) is >> x;
  return is;
}

template <typename T, typename Y>
ostream& operator<<(ostream& os, const pair<T, Y>& p) {
  return os << "{" << p.fs << "," << p.sc << "}";
}

template <typename T> ostream& operator<<(ostream& os, const V<T>& v) {
  os << "{";
  for(auto e : v) os << e << ",";
  return os << "}";
}

template <typename... Args> void debug(Args&... args) {
  for(auto const& x : {args...}) { cerr << x << ' '; }
  cerr << ENDL;
}

signed main() {
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll h, w, d;
  cin >> h >> w >> d;
  VV<char> ans(h, V<char>(w, 'A'));

  if(d % 2) {
    rep(i, 0, h) rep(j, 0, w) {
      if((i + j) % 2)
        ans[i][j] = 'R';
      else
        ans[i][j] = 'Y';
    }
  } else {
    rep(i, 0, h) rep(j, 0, w) {
      if(((i + j) / (d)) % 2) {
        if(((i - j + 999) / (d)) % 2)
          ans[i][j] = 'R';
        else
          ans[i][j] = 'Y';
      } else {
        if(((i - j + 999) / (d)) % 2)
          ans[i][j] = 'G';
        else
          ans[i][j] = 'B';
      }
    }
  }

  rep(i,0,h){
    rep(j,0,w){
    cout<<ans[i][j];
    }
    cout<<ENDL;
  }
}
//! ( . _ . ) !
// CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int INF = 1 << 30;
const int MAXN = 2005;

int c[MAXN * 2], a[MAXN * 2], pos[2][MAXN * 2], costB[2][MAXN][MAXN], costW[2][MAXN][MAXN], f[MAXN][MAXN];

char ch;

int n, N;

inline int calc(int co, int num, int p, int B, int W)
{
	return (pos[co][num] + costB[co][num][B] + costW[co][num][W] - p);
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	N = (n << 1);
	for (int i = 1; i <= N; i++)
		cin >> ch >> a[i], c[i] = (ch == 'B' ? 0 : 1);
	for (int i = 1; i <= N; i++)
		pos[c[i]][a[i]] = i;
	for (int i = 1; i <= N; i++)
		for (int j = i + 1; j <= N; j++)
			if (c[j] == 0)
				costB[c[i]][a[i]][a[j]]++;
			else
				costW[c[i]][a[i]][a[j]]++;
	for (int i = 0; i < 2; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				costB[i][j][k] += costB[i][j][k - 1], costW[i][j][k] += costW[i][j][k - 1];
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (i == 0 && j == 0)
				continue;
			int &cur = f[i][j];
			cur = INF;
			if (i > 0)
				cur = min(cur, f[i - 1][j] + calc(0, i, i + j, i - 1, j));
			if (j > 0)
				cur = min(cur, f[i][j - 1] + calc(1, j, i + j, i, j - 1));
		}
	}
	cout << f[n][n] << endl;
	return 0;
}


Measured memory_bytes: 78848
data_map = [[0] + [1]*1001 + [0]*3000, [0]*4002, [0]*4002, [0]*4002]
for i in range(1,4):
  for j in range(1,4002):
    k = 0 if j < 1000 else j-1000
    data_map[i][j] = sum(data_map[i-1][k:j+1])

while True:
  try:
    line = int(raw_input())
  except:
    break
  print data_map[3][line+1]

Measured memory_bytes: 4460
import itertools
H, W = [int(_) for _ in input().split()]
Aij = [[0] * (W + 1)] + [[0] + [int(_) for _ in input().split()] for _ in range(H)]

result = []

for i, j in itertools.product(range(1, H + 1), range(1, W)):
    if Aij[i][j] % 2:
        result += [' '.join(map(str, [i, j, i, j + 1]))]
        Aij[i][j + 1] += 1
for i in range(1, H):
    if Aij[i][W] % 2:
        result += [' '.join(map(str, [i, W, i + 1, W]))]
        Aij[i + 1][W] += 1

print(len(result))
[print(_) for _ in result]

Measured memory_bytes: 17012
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

class union_find {
private:
	vector<ll> par, sz, rank;
public:
	union_find(ll n) : par(n), sz(n), rank(n)
	{
		REP(i, n) {
			par[i] = i;
			sz[i] = 1;
			rank[i] = 0;
		}
	}
	ll find(ll x)
	{
		return par[x] == x ? x : par[x] = find(par[x]);
	}
	void unite(ll x, ll y)
	{
		x = find(x);
		y = find(y);
		if (x != y) {
			if (rank[x] < rank[y]) {
				par[x] = y;
				sz[y] += sz[x];
			} else {
				par[y] = x;
				sz[x] += sz[y];
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}
	}
	bool same(ll x, ll y)
	{
		return find(x) == find(y);
	}
	ll size(ll n)
	{
		return sz[find(n)];
	}
};
struct edge { ll from, to, cost; };
signed main()
{
	while (true) {
		ll n = in(); if (n == 0)break;
		ll  m = in();
		vector<edge>es(m);
		REP(i, m) {
			ll a, b, d;
			scanf("%lld,%lld,%lld", &a, &b, &d);
			es[i] = { a,b,d };
		}
		sort(ALL(es), [](const edge&e1, const edge&e2) {return e1.cost < e2.cost; });
		union_find uf(n);
		ll ans = 0;
		REP(i, m) {
			if (!uf.same(es[i].from, es[i].to)) {
				uf.unite(es[i].from, es[i].to);
				ans += es[i].cost / 100 - 1;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3356
// ⣿⣿⣿⣿⣿⣿⣿⡿⡛⠟⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⠿⠨⡀⠄⠄⡘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⠿⠨⡀⠄⠄⡘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⡿⠛⡧⠁⡴⣦⣔⣶⣄⢠⠄⠄⠹⣿⣿⣿⣿⣿⣿⣿⣤⠭⠏⠙⢿⣿⣿⣿⣿⣿
// ⣿⡧⠠⠠⢠⣾⣾⣟⠝⠉⠉⠻⡒⡂⠄⠙⠻⣿⣿⣿⣿⣿⡪⠘⠄⠉⡄⢹⣿⣿⣿⣿
// ⣿⠃⠁⢐⣷⠉⠿⠐⠑⠠⠠⠄⣈⣿⣄⣱⣠⢻⣿⣿⣿⣿⣯⠷⠈⠉⢀⣾⣿⣿⣿⣿
// ⣿⣴⠤⣬⣭⣴⠂⠇⡔⠚⠍⠄⠄⠁⠘⢿⣷⢈⣿⣿⣿⣿⡧⠂⣠⠄⠸⡜⡿⣿⣿⣿
// ⣿⣇⠄⡙⣿⣷⣭⣷⠃⣠⠄⠄⡄⠄⠄⠄⢻⣿⣿⣿⣿⣿⣧⣁⣿⡄⠼⡿⣦⣬⣰⣿
// ⣿⣷⣥⣴⣿⣿⣿⣿⠷⠲⠄⢠⠄⡆⠄⠄⠄⡨⢿⣿⣿⣿⣿⣿⣎⠐⠄⠈⣙⣩⣿⣿
// ⣿⣿⣿⣿⣿⣿⢟⠕⠁⠈⢠⢃⢸⣿⣿⣶⡘⠑⠄⠸⣿⣿⣿⣿⣿⣦⡀⡉⢿⣧⣿⣿
// ⣿⣿⣿⣿⡿⠋⠄⠄⢀⠄⠐⢩⣿⣿⣿⣿⣦⡀⠄⠄⠉⠿⣿⣿⣿⣿⣿⣷⣨⣿⣿⣿
// ⣿⣿⣿⡟⠄⠄⠄⠄⠄⠋⢀⣼⣿⣿⣿⣿⣿⣿⣿⣶⣦⣀⢟⣻⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⡆⠆⠄⠠⡀⡀⠄⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⡿⡅⠄⠄⢀⡰⠂⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
//        ああ、あなたは私に近づいています
// You thought you would find code here? But it was me DIO
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
typedef long long ll;
#define endl '\n'

const ll mod = 1e9 + 7;

int main () {
    cin.tie(0)->sync_with_stdio(0), cin.exceptions(cin.failbit);
// #ifdef BOI
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
// #endif
    string s; cin >> s;
    int cnt = 0, x = 0;
    for(char c : s) if(c == 'R') ++x;
    if (s == "RRR") cnt = 3;
    else if (s == "RRS") cnt = 2;
    else if (s == "SRR") cnt = 2;
    else if (x) cnt = 1;
    cout << cnt << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string s;

	cin >> s;

	cout << s.substr(0, 4) << ' ' << s.substr(4, 8) << endl;

	return 0;
}


Measured memory_bytes: 256
s="abcdefghijklmnopqrstuvwxyz"
import sys
sys.setrecursionlimit(10**6)
def dfs(a,n,m):
    if len(a)==n:
        print(a)
        return
    for i in range(m):
        if i==m-1:
            dfs(a+s[i],n,m+1)
        else:
            dfs(a+s[i],n,m)
n=int(input())
dfs("",n,1)

Measured memory_bytes: 4340