akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
int main()
{
    int i,j,k,n,u,v,a,min;
    int A[100][100],d1[100],d2[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)    A[i][j]=100009;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++)
        {
            scanf("%d %d",&v,&a);
            A[u][v]=a;
        }
    }
    for(i=0;i<n;i++)
    {
        d1[i]=100009;
        d2[i]=0;
    }
    d1[0]=0;
    d2[0]=2;
    while(1)
    {
        min=100009;
        u=-1;
        for(i=0;i<n;i++)
        {
            if(min > d1[i] && d2[i] != 1)
            {
                u=i;
                min=d1[i];
            }
        }
        if(u==-1) break;
        d2[u]=1;
        for(i=0;i<n;i++)
        {
            if(d2[i] != 1 && A[u][i] != 100009)
            {
                if(d1[i] > d1[u]+A[u][i])
                {
                    d1[i]=d1[u]+A[u][i];
                    d2[i]=2;
                }
            }
        }
    }
    for(i=0;i<n;i++)
    {
        if(d1[i]==100009)    printf("%d -1\n",i);
        else    printf("%d %d\n",i,d1[i]);
    }
    return 0;
}


Measured memory_bytes: 2052
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct{
    char name[11];
    int p;
    int label;
}set;
    set a[101];
int compare(const void *a,const void *b){
    return strcmp(a,b);/*メチャ危険!
    多分構造体の最初がcharだからこの比較関数でも動作する?*/
}
int main()
{   int n;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%s %d",a[i].name,&a[i].p);
        a[i].label=i+1;
    }
    qsort(a,n,sizeof(set),compare);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(strcmp(a[i].name,a[j].name)==0&&a[i].p<a[j].p){
                set tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    for(int i=0;i<n;i++)printf("%d\n",a[i].label);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

#include <string>
#include <queue>

using namespace std;

int main(){
	int w,h;
	int data[30][30];
	int flag[30][30];
	int dx[4] ={0,1,0,-1};
	int dy[4] ={1,0,-1,0};

	while(1){
		cin>>w>>h;
		if(w==0 && h==0)break;

	for(int i=0;i<30;i++){
		for(int j=0;j<30;j++){
			data[i][j]=-1;
			flag[i][j]=0;
		}
	}

	char tmp;
	int startX;
	int startY;
	int cnt=0;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>tmp;
			if(tmp=='.')data[i][j] = 0;
			else if(tmp=='@'){
				startX = j;
				startY = i;
			}
		}
	}

	queue<int> qX,qY;
	qX.push(startX);
	qY.push(startY);

	while(qX.size()!=0){
		int topX = qX.front();
		int topY = qY.front();
		qX.pop();
		qY.pop();
		cnt++;

		for(int i=0;i<4;i++){
			int nowX = topX + dx[i];
			int nowY = topY + dy[i];

			if(data[nowY][nowX] ==0 && flag[nowY][nowX] == 0){
				qX.push(nowX);
				qY.push(nowY);
				flag[nowY][nowX]=1;
			}
		}
	}

	cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(ll i=0;i<n;i++)  cin>>h[i];
    ll dp[n];
    for(ll i=2;i<n;i++) dp[i]=1e9;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(ll i=2;i<n;i++)
    {
        for(int j=i-1, jump=0; j>=0 && jump<k; j--, jump++)
        {
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
        }
    }cout<<dp[n-1];
}

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

int main() {
    long long ht;
    long long st;
    long long ha;
    long long sa;
    cin >> ht >> st >> ha >> sa;
    bool find = false;
    while (true) {
        ha -= st;
        if (ha <= 0) {
            find = true;
            break;
        }
        ht -= sa;
        if (ht <= 0) {
            break;
        }
    }
    if (find == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
sx , sy , tx , ty = map(int,input().split())
xx = tx - sx
yy = ty - sy
ans = ''
ans = ans + 'U' * yy
ans = ans + 'R' * (xx + 1)
ans = ans + 'D' * (yy + 1)
ans = ans + 'L' * (xx + 1)
ans = ans + 'U'
ans = ans + 'L'
ans = ans + 'U' * (yy + 1)
ans = ans + 'R' * (xx + 1)
ans = ans + 'D' * (yy + 1)
ans = ans + 'L' * xx
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    set<int> st;
    rep(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    ll a2 = 0, a1 = 0;
    for(auto e:st)
    {
        if(mp[e] >= 4){
            a1 = e;
            a2 = e;
        }else if(mp[e] >= 2){
            a2 = a1;
            a1 = e;
        }
    }
    cout << a2 * a1 << "\n";
}

Measured memory_bytes: 9984
using System;
using System.Linq;

namespace diverta2019ProgrammingContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToList();
            Console.WriteLine($"{NK[0]-NK[1]+1}");            
        }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;

int check_bipartite_graph(vector<vector<int> > const & g) {
    int n = g.size();
    vector<char> used(n, -1);
    function<bool (int, int)> dfs = [&](int i, int parent) {
        for (int j : g[i]) {
            if (used[j] != -1) {
                if (used[j] == used[i]) {
                    return false;
                }
            } else {
                used[j] = used[i] ^ 1;
                if (not dfs(j, i)) return false;
            }
        }
        return true;
    };
    used[0] = 0;
    if (not dfs(0, -1)) {
        return -1;
    } else {
        return count(whole(used), 0);
    }
}

int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<vector<int> > g(n);
    repeat (i, m) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // solve
    int k = check_bipartite_graph(g);
    ll result = k == -1 ?
        n *(ll) (n - 1) / 2 - m :
        k *(ll) (n - k) - m;
    // output
    printf("%lld\n", result);
    return 0;
}


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

int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >>D;
  L=A+B;
  R=C+D;
  if(L<R){
    cout << "Right" << endl;
  }else if(L>R){
    cout << "Left" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

int main() {
  ll n, k;
  cin >> n >> k;
  vl p(n);
  cin >> p;

  sort(all(p));
  ll ans = 0;
  rep(i, k) {
    ans += p[i];
  }
  cout << ans << el;
}


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

int main(){
    int k;
    cin >> k;
    vector<int> n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << n.at(k-1);
}

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

int main() {
	int height, width;
	while (true) {
		cin >> height >> width;
		if (height == 0 && width == 0)
			break;
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if ((i + j) % 2 == 0)
					cout << '#';
				else
					cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-19 07:24:21
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  int odd = 0, even = 0;

  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a & 1) {
      ++odd;
    } else {
      ++even;
    }
  }

  debug(even, odd);

  if (odd & 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}

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

#define F first
#define S second
#define x1 privet1
#define x2 privet2
#define y1 privet3
#define y2 privet4
#define left privet6

using namespace std;
typedef long long ll;

const int max_n = 200011, log_n = 32, max_m = 111, mod = 1000000007, inf = 1000111222;

int n, a[max_n], k;

int main() {
    // freopen("input.txt", "r", stdin);
    cin >> n >> k;
    for (int i =0 ; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = n - 1; i >= n - k; --i) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    int ans;
    ans=C-(A-B);

    if(ans<0){
        cout<<0<<endl;
    }else{
        cout<<ans<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import math
import bisect
# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

def isOK(index,key):
    if l[index] <= key:
        return True
    else:
        return False

def binary_search(key):
    left=len(l)-1
    right=-1
    
    while abs(right - left) >1:
        mid=(right+left)//2
        
        if isOK:
            right=mid
        else:
            left=mid
    return right

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

primes=callIsPrime(10**5)
l=[]

for i in range(len(primes)):
    if (primes[i]+1)//2 in primes:
        l.append(primes[i])
        
Q=int(input())
for i in range(Q):
    L,R=map(int,input().split())
    L=bisect.bisect_left(l,L)
    R=bisect.bisect_right(l,R)
    
    print(R-L)
    
    


    



Measured memory_bytes: 56540
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

ll Q, H, S, D;

ll N;

int main() {
    cin >> Q >> H >> S >> D >> N;

    H = min(H, Q + Q);
    S = min(S, H + H);
    D = min(D, S + S);

    cout << (N / 2) * D + (N % 2) * S << endl;
    return 0;
}


Measured memory_bytes: 256
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

void solve() {
	int h, w;
	cin >> h >> w;
	char a[h][w];
	ll dp[h + 1][w + 1] = {0};
	memset(dp, 0, sizeof dp);
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j)
			cin >> a[i][j];
	}

	dp[1][1] = 1;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (a[i][j] == '.') {
				if (i > 0) {
					dp[i + 1][j + 1] += (dp[i][j + 1])%MOD;
				}
				if (j > 0)
					dp[i + 1][j + 1] += (dp[i + 1][j])%MOD;
				dp[i + 1][j + 1] = dp[i + 1][j + 1]%MOD;
			}
		}
	}
	cout << dp[h][w];
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

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

int main() {
    string str;cin>>str;
    int a=0,b=0,c=0;
    for(int i=0;i<3;++i){
        if(str[i]=='a')a++;
        if(str[i]=='b')b++;
        if(str[i]=='c')c++;
    }
    int ans=a*b*c;
    if(ans==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>

int main(){
  int n;
  std::cin >> n;
  
  std::string s;
  s.reserve(n);
  std::cin >> s;
  
  auto it = s.begin();
  while(it != s.end()){
  	if(*it == *(it + 1)){
    	s.erase(it);
    }else{
    	it++;
    }
  }
  
  std::cout << s.length() << std::endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
int main()
{
   int x[3],y[3],nMax,nMin;
   char str[3][32] = { NULL };
   for( int i=0; i<3; i++ ){
      scanf( "%s", str[i] );
      x[i] = atoi( str[i] );
      y[i] = atoi( str[i] );
   }
 
   if( x[0] > x[1] ){
     nMax = x[0];
     nMin = x[1];
   }
   else{
     nMax = x[1];
     nMin = x[0];
   }
   if( nMax < x[2] ){
     nMax = x[2];
   }
   if( nMin > x[2] ){
     nMin = x[2];
   }

   int fMax = 0, fMin = 0;
   for( int i=0; i<3; i++ ){
      if( nMax == x[i] && fMax==0){
         y[2] = nMax;
         fMax = 1;
      }
      else if( nMin == x[i] && fMin==0){
         y[0] = nMin;
         fMin = 1;
      }
      else
         y[1] = x[i];
   }
   
   printf( "%d %d %d\n", y[0], y[1], y[2] );
 
   return 0;
}


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

using namespace std;

int n;
char x[5];

int main() {
	scanf("%s", x);
	int ans = 0, cur = 0;
	for (int i = 0; x[i]; i++)
		if (x[i] == 'R')
			ans = max(ans, ++cur);
		else
			cur = 0;
	printf("%d\n", ans);
}

Measured memory_bytes: 3824
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

void bubbleSort(string[], int);
void selectionSort(string[], int);
void displayCards(string[], int);
bool isStable(string[], string[], int);
void arrayCopy(string[], string[], int);

int main() {
  string cards_in[36], cards_out_b[36], cards_out_s[36];
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) cin >> cards_in[i];
  arrayCopy(cards_out_b, cards_in, n);
  arrayCopy(cards_out_s, cards_in, n);
  // memcpy(cards_out_b, cards_in, sizeof(cards_in));
  // memcpy(cards_out_s, cards_in, sizeof(cards_in));
  bubbleSort(cards_out_b, n);
  displayCards(cards_out_b, n);
  printf("Stable\n");
  selectionSort(cards_out_s, n);
  displayCards(cards_out_s, n);
  if( isStable(cards_out_b, cards_out_s, n) ) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}

void bubbleSort(string cards[], int n) {
  for(int i = 0; i < n; i++) {
    for(int j = n-1; j > i; j--) {
      if(cards[j][1] < cards[j-1][1]) swap(cards[j], cards[j-1]);
    }
  }
}

void selectionSort(string cards[], int n) {
  int minj;
  for(int i = 0; i < n; i++) {
    minj = i;
    for(int j = i; j < n; j++) {
      if(cards[j][1] < cards[minj][1]) minj = j;
    }
    swap(cards[i], cards[minj]);
  }
}

void displayCards(string cards[], int n) {
  printf("%s", cards[0].c_str());
  for(int i = 1; i < n; i++) printf(" %s", cards[i].c_str());
  printf("\n");
}

bool isStable(string cards_b[], string cards_s[], int n) {
  for(int i = 0; i < n; i++) {
    if(cards_b[i][0] != cards_s[i][0]) return false;
  }
  return true;
}

void arrayCopy(string array1[], string array2[], int n) {
  for(int i = 0; i < n; i++) array1[i] = array2[i];
}


Measured memory_bytes: 3348
from math import floor

A, B = map(int, input().split())

def calc(A, B):
	i = 0
	while True:
		ta = floor(i * 0.08)
		tb = floor(i * 0.10)
		if ta == A and tb == B:
			return i
		if ta > A and tb > B:
			return -1
		i += 1

print(calc(A, B))


Measured memory_bytes: 3060
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define f0(s,a,b) for(lli s=a;s<b;s++)
#define f1(s,a,b) for(lli s=a;s<=b;s++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define print(x) cout<< #x <<"=" <<x<<"\n";
#define out(x) cout<<x;
#define  Y cout<<"YES\n";
#define N cout<<"NO\n";

int main()
{
    lli a,b,c,d,ct=0;
    cin>>a>>b>>c>>d;
    while(1)
    {
        if(ct%2==0)
        {
                c=c-b;
                if(c<=0)
    {
        cout<<"Yes";
        break;
    }
        }
        else
        {
                a=a-d;
                 if(a<=0)
    {
        cout<<"No";
        break;
    }
        }
        

        ct++;
    }


}
//a+b=a⊕b+2∗(a &b)
//__builtin_popcount(number)
//cout<<fixed<<setpricision(8)<<output<<"\n";

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s; cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){

  int a=0,b=0,c=0,x=0,y=0,z=0;
  scanf("%d %d %d",&a,&b,&c);

  if(a>b){x=a;a=b;b=x;};
  if(b>c){y=b;b=c;c=y;};
  if(a>b){z=a;a=b;b=z;};

  printf("%d %d %d\n",a,b,c);

  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define csanf scanf

int main(){
	string s;cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 768
s = input()
n = len(s) - 1  # スキマの数
sum_ = 0
keep = 0
for i in range(2**n):  # +かつなげるか
    p_or_no = ["no"] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            p_or_no[n-1-j] = "+"

    for k in range(n):
        if p_or_no[k] == "+":
            sum_ += int(s[k]) + keep
            keep = 0
        else:
            keep = int(s[k]) * 10 + keep * 10
        if k == n-1:
            sum_ += int(s[-1]) + keep
            keep = 0
if len(s) == 1:
    sum_ = int(s)
print(sum_)

Measured memory_bytes: 40048
use std::io;

fn main() {
    loop {
        let exp: (i32, char, i32) = input();

        let ans = match exp {
            (_, '?', _) => None,
            (a, '+', b) => Some(a + b),
            (a, '-', b) => Some(a - b),
            (a, '*', b) => Some(a * b),
            (a, '/', b) => Some(a / b),
            _ => None
        };

        if ans == None {
            break;
        } else {
            println!("{}", ans.unwrap());
        }
    }
}

fn input() -> (i32, char, i32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let a:i32 = iter.next().unwrap().parse().unwrap();
    let op:char = iter.next().unwrap().chars().nth(0).unwrap();
    let b:i32 = iter.next().unwrap().parse().unwrap();

    (a, op, b)
}



Measured memory_bytes: 5024
N = int(input())

abc = []
for i in range(N):
    tmp = list(map(int, input().split()))
    abc.append(tmp)
    
dp = [[0]*3 for i in range(N+1)]
for i in range(N):
    a, b, c = abc[i]
    dp[i+1][0] += max(dp[i][1] + a, dp[i][2] + a)
    dp[i+1][1] += max(dp[i][0] + b, dp[i][2] + b)
    dp[i+1][2] += max(dp[i][0] + c, dp[i][1] + c)
                
print(max(dp[N]))

Measured memory_bytes: 47388
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n,m = s.nextInt
		val c = Array.fill(100001)(0)
		for(_ <- 1 to n)
			c(s.nextInt) += 1
		val a,b = Array.fill(m)(0)
		for(i <- 1 to 100000) {
			a(i % m) += c(i) % 2
			b(i % m) += c(i) / 2
		}
		//println(a.mkString(" "))
		//println(b.mkString(" "))
		var r = 0
		for(i <- 0 until m) {
			if(i * 2 % m == 0) {
				r += a(i) / 2
				a(i) %= 2
			} else {
				{
					val t = math.min(a(i),a(m - i))
					r += t
					a(i) -= t
					a(m - i) -= t
				}
				{
					val t = math.min(a(i) / 2,b(m - i))
					r += t * 2
					a(i) -= t * 2
					b(m - i) -= t
				}
			}
		}
		for(i <- 0 until m) {
			r += b(i)
			b(i) = 0
		}
		//println(a.mkString(" "))
		//println(b.mkString(" "))
		println(r)
	}
}

Measured memory_bytes: 51988
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N, A, B;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  ll turn = N / (A + B);
  ll ans = A * turn;
  ans += min(N % (A + B), A);

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


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

int main()
{
  string a, b;
  cin >> a >> b;
  
  if (a.size() == b.size()) {
    if (a == b) cout << "EQUAL" << endl;
    else if (a < b) cout << "LESS" << endl;
    else cout << "GREATER" << endl;
  }
  else if (a.size() < b.size())
    cout << "LESS" << endl;
  else
    cout << "GREATER" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
  x=0; int ch=getchar(),f=0;
  while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
  while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
  if(f)x=-x;
}
const int inf=0x3f3f3f3f;
double l;
int main()
{
  cin>>l;
  l/=3.0;
  double ans=l*l*l;
  printf("%.10lf\n",ans);
  return 0;
}

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

namespace ALDS1_11_D_ConnectedComponents
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			Gragh graph = new Gragh (inputNum[0]);

			for (int lp = 0; lp < inputNum[1]; lp++)
			{
				int[] adjacencyPair = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				graph.GetPath (adjacencyPair[0], adjacencyPair[1]);
			}

			graph.SetRoot ();

			int judgeCount = int.Parse (Console.ReadLine ());
			StringBuilder output = new StringBuilder (3 * judgeCount);

			for (int lp = 0; lp < judgeCount; lp++)
			{
				int[] adjacencyPair = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				if (graph.IsAdjacency (adjacencyPair[0], adjacencyPair[1]))
				{
					output.AppendLine ("yes");
				}
				else
				{
					output.AppendLine ("no");
				}
			}
			Console.Write (output);
		}
	}

	class Gragh
	{
		public Gragh ( int size )
		{
			this.Size = size;
			this.AdjacencyList = new List<int>[this.Size];

			for (int lp = 0; lp < this.Size; lp++)
			{
				this.AdjacencyList[lp] = new List<int> ();
			}

			this.Group = new int[this.Size];
		}

		private List<int>[] AdjacencyList { set; get; }
		private int Size { set; get; }
		private int[] Group { set; get; }
		private const int Initialize = 0;

		public void GetPath ( int beginPoint, int adjacencyPoint )
		{
			AdjacencyList[beginPoint].Add (adjacencyPoint);
			AdjacencyList[adjacencyPoint].Add (beginPoint);
		}

		public void SetRoot ()
		{
			int groupNumber = Initialize + 1;

			for (int lp = 0; lp < Size; lp++)
			{
				if (Group[lp] == Initialize)
				{
					BreathFirstSearch (lp, groupNumber);
					groupNumber++;
				}
			}
		}

		private void BreathFirstSearch ( int beginSearchPoint, int groupNumber )
		{
			//initialize
			Queue<int> searchPoint = new Queue<int> ();

			//process
			searchPoint.Enqueue (beginSearchPoint);
			Group[beginSearchPoint] = groupNumber;

			while (searchPoint.Count != 0)
			{
				int element = searchPoint.Dequeue ();

				foreach (var item in AdjacencyList[element])
				{
					if (Group[item] == Initialize)
					{
						searchPoint.Enqueue (item);
						Group[item] = groupNumber;
					}
				}
			}
		}

		public bool IsAdjacency ( int beginPoint, int adjacencyPoint )
		{
			return Group[beginPoint] == Group[adjacencyPoint];
		}
	}
}

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

int main() {
  int A,B,j;
  j=0; //カウンタ
  cin>>A>>B;
  for (int i=A;i<=B;i++){
  int a=i/10000; //万の位
  int b=(i%10000)/1000; //千の位
  // int c=(i%1000)/100; //百の位  
  int d=(i%100)/10; //十の位
  int e=i%10; //一の位
  if(a==e&&b==d){
    j++;
  }
  }
  cout<<j<<endl;
}

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

const ll INF = 1e18;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    a.push_back(a[i]);
  }

  ll nk = n * k;
  int lognk = 0;
  for (int i = 0; i < 64; i++) {
    if (nk >> i & 1) lognk = max(lognk, i);
  }
  
  map<int, int> lst;
  vector<vector<ll>> nxt(lognk + 1, vector<ll>(n, INF));
  for (int i = 2 * n - 1; i >= 0; i--) {
    if (i < n) nxt[0][i] = lst[a[i]] - i + 1;
    lst[a[i]] = i;
  }

  for (int k = 0; k < lognk; k++) {
    for (int i = 0; i < n; i++) {
      if (nxt[k][i] == INF) continue;
      nxt[k + 1][i] = nxt[k][i] + nxt[k][(i + nxt[k][i]) % n];
      if (nxt[k + 1][i] > INF) nxt[k + 1][i] = INF;
    }
  }
  
  ll p = 0;
  for (int k = lognk - 1; k >= 0; k--) {
    if (p + nxt[k][p % n] > nk) continue;
    p += nxt[k][p % n];
  }

  vector<int> ans;
  set<int> st;
  for (; p < nk; ++p) {
    int x = a[p % n];
    if (st.find(x) != end(st)) {
      while (st.find(x) != end(st)) {
        st.erase(ans.back());
        ans.pop_back();
      }
    } else {
      ans.push_back(x);
      st.insert(x);
    }
  }

  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i] << ((i + 1 == (int)ans.size()) ? '\n' : ' ');
  }
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(1,1);
const D tpie = 2*pie;

string vow = "aeiou";

void solve( int test_case )
{
    string s;
    cin >> s;

    int n = s.size();

    if ( s.size()==2 && s[0]==s[1] ) { cout << "1 2\n"; R; }

    for ( int i=0 ; i<n-2 ; i++ )
    {
        if ( s[i]==s[i+1] )
        {
            cout << i+1 << " " << i+2 ;
            R;
        }

        if ( s[i+1]==s[i+2] )
        {
            cout << i+2 << " " << i+3 ;
            R;
        }

        if ( s[i]==s[i+2] )
        {
            cout << i+1 << " " << i+3;
            R;
        }
    }

    cout << -1 << " " << -1;
}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 512
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, x = MAP()
cnt = 0
#for i in range(a, b+1):
#    if not i % x:
#        cnt += 1
#print(cnt)
#0->b  kara 0->a-1 wo hiku 
# kangae chuu
c = (a - 1) // x
d = b // x
print(d - c)


Measured memory_bytes: 5188
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int main() {
  ll n; cin >> n;
  string res = "";
  while (n) {
    --n;
    res += 'a' + (n % 26);
    n /= 26;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
}


Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {

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

        long[] la = new long[121];
        for (int i = 0; i <= 120; i++) {
            la[i] = (long) i * i * i * i * i;
        }
        out:
        for (int i = 0; i < la.length; i++) {
            for (int j = 0; j < la.length; j++) {
                if (la[i] - la[j] == X) {
                    System.out.println(i + " " + j);
                    break out;
                } else if (la[i] + la[j] == X) {
                    System.out.println(i + " -" + j);
                    break out;
                }
            }
        }
    }
}

Measured memory_bytes: 38716
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	int res=0;
	for(int i=1;i<n;i++){
		int rem=n-i;
		if(rem<=i)
			continue;
		res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }

#define SIZE 300005
#define MOD 998244353
 
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(ll a,ll b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

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

    ll N, A , B, K; cin >> N >> A >> B >> K;
    ll ans = 0;
    make();
    for(int x = 0; x <= N; x++) {
        if(K - A * x >= 0 and (K - A * x) % B == 0) ans += comb(N, x) * comb(N, (K - A * x) / B );
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7296
S = [input() for _ in range(3)]
t = 0
i = [0, 0, 0]
while len(S[t]) > i[t]: 
    tmp = t
    if S[t][i[t]] == "a":
        t = 0
    elif S[t][i[t]] == "b":
        t = 1
    else:
        t = 2
    i[tmp] += 1
if t == 0:
    ans = "A"
elif t == 1:
    ans = "B"
else:
    ans = "C"
print(ans)


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a[5];
    for(int i = 0; i < 5; ++i) {
        cin >> a[i];
        if(a[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
    using namespace std;
    using Int = long long;
    template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
    template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
     
    //INSERT ABOVE HERE
    signed main(){
      Int n;
      cin>>n;
      vector<Int> xs(n),ys(n);
      for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i];
     
      using D = double;
      D ans=0;
      for(Int i=0;i<n;i++){
        Int gx=xs[i],gy=ys[i];
        for(Int k=0;k<4;k++){
          {
            Int nx=-gy,ny=gx;
            gx=nx;
            gy=ny;
          }
     
          Int sx=0,sy=0;
          Int px=0,py=0;
          Int qx=0,qy=0;
     
          auto dot=[&](Int x1,Int y1,Int x2,Int y2){return x1*x2+y1*y2;};
          auto cross=[&](Int x1,Int y1,Int x2,Int y2){return x1*y2-x2*y1;};
          for(Int j=0;j<n;j++){
            Int res=dot(xs[j],ys[j],gx,gy);
            if(res<0) continue;
            if(res>0){
              sx+=xs[j];
              sy+=ys[j];
              continue;
            }
            if(cross(xs[j],ys[j],gx,gy)>0){
              px+=xs[j];
              py+=ys[j];
            }else{
              qx+=xs[j];
              qy+=ys[j];
            }
          }
     
          for(Int t=0;t<4;t++){
            D bx=sx,by=sy;
            if(t&1) bx+=px,by+=py;
            if(t&2) bx+=qx,by+=qy;
            chmax(ans,bx*bx+by*by);
          }
        }
      }
     
      cout<<fixed<<setprecision(12)<<sqrt(ans)<<endl;
      return 0;
    }


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
   
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans += a[i] * a[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n;
	st s;
	cin >> n >> s;
	vi sums1(n + 1), sums2(n + 1);
	sums1[0] = 0; sums2[n] = 0;
	int ans = ll_INF;
	f(i, 0, n) {
		if (s[i] == 'W') {
			sums1[i + 1] = sums1[i] + 1;
		}
		else {
			sums1[i + 1] = sums1[i];
		}
		if (s[n - 1 - i] == 'E') {
			sums2[n - 1 - i] = sums2[n - i] + 1;
		}
		else {
			sums2[n - 1 - i] = sums2[n - i];
		}
	}
	f(i, 0, n + 1) {
		ans = min(ans, sums1[i] + sums2[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5396
from collections import deque
 
h, w = map(int, input().split())
a = ''.join(input() + '#' for _ in range(h))
n = len(a)
b = ['#'] * w
q = deque()
r = 0
for i in range(n):
  if a[i] == '.':
    b[:-w] = a
    b[i] = 0
    q.append(i)
    while(q):
      i = q.popleft()
      r = max(r, b[i])
      for j in (i - 1, i + 1, i - w - 1, i + w + 1):
        if b[j] == '.':
          b[j] = b[i] + 1
          q.append(j)
print(r)

Measured memory_bytes: 3316
N = int(input())
A = 0
B = 0
BA = 0
ans = 0
for i in range(N):
  s = input()
  ans += s.count("AB")
  if s[0] == "B" and s[-1] == "A":
    BA += 1
  elif s[0] == "B":
    B += 1
  elif s[-1] == "A":
    A += 1

while A > 0 or BA > 0:
  if A > 0:
    A -= 1
  elif BA > 0:
    BA -= 1
  else:
    break
  if BA > 0:
    BA -= 1
    A += 1
    ans += 1
  elif B > 0:
    B -= 1
    ans += 1
  else:
    break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
int main(){
  ll n,d;
  while(cin>>n>>d,n){
    ll used[11111]={};
    ll cost[11111]={};
    ll cnt=0;
    priority_queue<P> q1,q2;
    ll mi=11111111;
    for(int i=0;i<n;i++){
      ll m;
      cin>>m;
      ll sum=0;
      for(int j=0;j<m;j++){
	cin>>cost[cnt];
	sum+=cost[cnt];
	cnt++;
      }
      mi=min(mi,sum);
      q1.push(P(sum,cnt-1));
      q2.push(P(sum-cost[cnt-1],cnt-1));
    }
    if(q1.top().first-mi>d){
      cout<<"No"<<endl;
      return 0;
    }
    ll f=1;
    cnt=1;
    while(!q1.empty()||!q2.empty()){
      //cout<<cnt<<" "<<q1.size()<<" "<<q2.size()<<" "<<q1.top().first<<endl;
      cnt++;
      while(!q2.empty()){
	ll sum = q2.top().first;
	ll k = q2.top().second;
	if(used[k]||q1.top().second==k){
	  q2.pop();
	  continue;
	}
	if(q1.top().first-sum<=d){
	  q2.pop();
	  used[k]=1;
	  if(sum-cost[k-1]>=0){
	    q2.push(P(sum-cost[k-1],k-1));
	    q1.push(P(sum,k-1));
	  }
	  // cout<<"q2 "<<sum<<" "<<k<<endl;
	  continue;
	}
	break;
      }
      while(!q1.empty()&&used[q1.top().second]){
	q1.pop();
      }
      if(q1.empty())break;
      ll ma=q1.top().first;
      ll nm=q1.top().second;
      //cout<<"q1 "<<ma<<" "<<nm<<endl;
      q1.pop();
      while(!q1.empty()&&used[q1.top().second]){
	q1.pop();
      }
      if(q1.top().first-(ma-cost[nm])>d){
	f=0;
	break;
      }
      if(ma-cost[nm]>0){
	q1.push(P(ma-cost[nm],nm-1));
	q2.push(P(ma-cost[nm]-cost[nm-1],nm-1));
      }
      used[nm]=1;
    }
    cout<<(f?"Yes":"No")<<endl;;
  }
  return 0;
}



Measured memory_bytes: 3260
def length(s):
    return False if len(s)<6 else True

def inNum(s):
    for c in s:
        if c.isdigit():
            return True
    return False

def inUpper(s):
    for c in s:
        if c.isupper():
            return True
    return False

def inLower(s):
    for c in s:
        if c.islower():
            return True
    return False

s=raw_input()
print 'VALID' if length(s) and inNum(s) and inUpper(s) and inLower(s) else 'INVALID'

Measured memory_bytes: 4228
var
	N,K,i:Longint;
	inv:Array[1..2002]of Longint;
	B,R,M:int64;
begin
	read(N,K);
	inv[1]:=1;
	M:=1000000007;
	for i:=2 to K+2 do begin
		inv[i]:=M-M div i*inv[M mod i] mod M;
	end;
	B:=1;
	R:=N-K+1;
	for i:=0 to K-1 do begin
		writeln(B*R mod M);
		B:=B*(K-i-1)mod M*inv[i+1]mod M;
		if R<>0 then R:=R*(N-K-i)mod M*inv[i+2]mod M;
	end;
end.


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

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

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

const ll mod=998244353;

#define pb push_back

int main() {
	ll n;
	cin >> n;
	ll ans=0;
	for(ll d=1; d*d<=n; d++)
	{
		if(n%d==0) ans=d;
	}
	if(ans==0) cout << ans-1 << endl;
	else cout << ans+(n/ans)-2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;

struct UnionFind {
private:
  vector<ll> child, tree;
  vector<vector<ll>> list;

public:
  //頂点数v
  UnionFind(ll v) {
    tree.resize(v);
    list.resize(v);
    for(ll i = 0; i < v; i++) {
      tree[i] = i;
      list[i].push_back(i);
    }
  }

  //木の根を求める
  ll root(ll x) {
    if(x == tree[x]) {
      for(ll i = 0; i < child.size(); i++) {
        tree[child[i]] = x;
      }
      child.clear();
      return x;
    } else {
      child.push_back(x);
      return x = root(tree[x]);
    }
  }
  //xの所属するグループの大きさ
  ll size(ll x) { return list[root(x)].size(); }

  vector<ll> nodes(ll no) { return list[root(no)]; }

  //xとyの集合を合わせる
  bool unit(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) {
      return false;
    }
    if(list[x].size() < list[y].size()) {
      swap(x, y);
    }
    for(int no : list[y]) {
      list[x].emplace_back(no);
    }
    tree[y] = x;
    return true;
  }

  //xとyが同じグループに所属するか
  bool isUnit(ll x, ll y) { return root(x) == root(y); }
};
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  UnionFind uf(n + 1);
  for(int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    uf.unit(x, y);
  }
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(p[i] != (i + 1) && uf.isUnit(i + 1, p[i])){
      cnt++;
    }
  }
  for(int i = 0; i < n; i++) {
    if(p[i] == (i + 1)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 14448
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    ll x;cin>>x;
    bool p=0;
    ll ansa=0;ll ansb=0;
    for(ll a=-1000;a<1001;a++){
        for(ll b=-1000;b<1001;b++){
            if((a-b)*(a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b)==x)
            {p=1;ansa=a;ansb=b;break;}
        }
        if(p)break;
    }

    cout<<ansa<<" "<<ansb<<endl;
}

Measured memory_bytes: 3588