akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define INF 10000
int **adj;//2D array of cost between each adj
int *cost;
int *status;
int n;//the number of vertices
void init(void);
void prim(void);
int sumCost(void);
int main(void)
{
  int i,j;//counter
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      scanf("%d",&adj[i][j]);
  prim();
  printf("%d\n",sumCost());
  return 0;
}
void init(void)
{
  int i;//counter
  adj=(int**)malloc(sizeof(int*)*n);
  cost=(int*)malloc(sizeof(int)*n);
  status=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) adj[i]=(int*)malloc(sizeof(int)*n);
}
void prim(void)
{
  int i;//counter
  int minCost;
  int current=0;
  int next;
  for(i=0;i<n;i++)
    {
      cost[i]=INF;
      status[i]=0;
    }
  cost[0]=0;
  status[0]=1;
  for(;;)
    {
      minCost=INF;
      for(i=0;i<n;i++)
	{
	  if(status[i]==0)
	    {
	      if(current!=i&&adj[current][i]!=-1&&adj[current][i]<cost[i])
		{
		  //printf("%d <-> %d: cost=%d\n",current,i,adj[current][i]);
		  cost[i]=adj[current][i];
		}
	      if(cost[i]!=-1&&cost[i]<minCost)
		{
		  minCost=cost[i];
		  next=i;
		}
	    }
	}
      //printf("minCost=%d\n",minCost);
      if(minCost==INF) break;
      status[current]=1;
      current=next;
      //printf("next->%d\n",current);
    }
}
int sumCost(void)
{
  int i;//counter
  int sum=0;
  for(i=0;i<n;i++)
    {
      //printf("[%d] %d\n",i,cost[i]);
      sum+=cost[i];
    }
  return sum;
}



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

int main(){
	string S,T;
	cin >> S >> T;
	vector<int> c1(26, -1), c2(26, -1);
	for(int i(0);i<S.size();++i){
		int s = S[i] - 'a';
		int t = T[i] - 'a';
		if(c1[s] != -1 || c2[t] != -1){
			if(c1[s] != t || c2[t] != s){
				cout << "No" << endl;
				return 0;
			}
		}
		c1[s] = t;
		c2[t] = s;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin>>a[i];
  b=a;
  sort(a.begin(),a.end());
  bool f=false;
  if(a[n-1]==a[n-2]) f=true;
  if(f){
    for(int i=0;i<n;i++){
      cout<<a[n-1]<<endl;
    }
  }else{
    for(int i=0;i<n;i++){
      if(b[i]==a[n-1])cout<<a[n-2]<<endl;
      else cout<<a[n-1]<<endl;
    }
  }
}

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

using namespace std;
typedef unsigned long long ull;


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

    vector<int> T_r(N), A_r(N);
    for (int i = 0; i < N; i++) {
        cin >> T_r[i] >> A_r[i];
    }

    ull T_c = 1, A_c = 1;
    for (int i = 0; i < N; i++) {
        ull k = max((T_c + T_r[i] - 1) / T_r[i], (A_c + A_r[i] - 1) / A_r[i]);
        T_c = T_r[i] * k;
        A_c = A_r[i] * k;
        // cout << k << " " << T_c << " " << A_c << endl;
    }

    cout << T_c + A_c << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    string s; cin >> s;
    cout << ((s == "AAA" || s == "BBB") ? "No" : "Yes") << endl;

return 0;
}

Measured memory_bytes: 3664
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

count = int(input())
for c in range(count):
    b,f,r,v = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r),end='')

        print()
    if bi < 3:
        print('#' * 20)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

ll g(ll n) { return n * (n + 1) / 2; }

int main() {
  ll n, ans = 0;
  cin >> n;
  // vector<ll> a(n + 1, 0);
  // for (int i = 1; i <= n; ++i) {
  //   int j = i;
  //   while (j <= n) a[j]++, j += i;
  // }
  // rep(i, n + 1) ans += a[i] * i;

  for (int i = 1; i <= n; ++i) ans += i * g(n / i);

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


Measured memory_bytes: 3620
while True:
    n, m, a = list(map(int, input().split()))
    if n == 0:
        break
    hpq = []
    for i in range(m):
        h, p, q = list(map(int, input().split()))
        hpq.append([h, p, q])
    hpq = sorted(hpq, key=lambda x: x[0], reverse=True)
    for i in reversed(range(1, hpq[0][0] + 1)):
        for j in range(m):
            if hpq[j][0] > i:
                continue
            elif hpq[j][0] < i:
                break
            elif hpq[j][0] == i and hpq[j][1] != a and hpq[j][2] != a:
                continue
            elif hpq[j][0] == i and hpq[j][1] != a and hpq[j][2] == a:
                a = hpq[j][1]
                break
            elif hpq[j][0] == i and hpq[j][1] == a and hpq[j][2] != a:
                a = hpq[j][2]
                break
    print(a)


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    ll dp[n];
    dp[n-1]=0;
    dp[n-2]=abs(a[n-1]-a[n-2]);
    for(int i=n-3; i>=0; i--)
    {
    	dp[i]=min(abs(a[i]-a[i+1])+dp[i+1], abs(a[i]-a[i+2])+dp[i+2]);
    }
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;


struct Edge {
  int from;
  int to;
  LL cost;
};

// detect closed-loop -> return false,  else return true.
bool belman_ford(int s, int g, int V, const vector<Edge>& es, vector<LL>* d) {
  d->resize(V, LLONG_MAX);
  d->at(s) = 0;

  for (int i = 0; i < V; ++i) {
    bool update = false;
    for (const Edge& e : es) {
      if (d->at(e.from) == LLONG_MAX) continue;
      if (d->at(e.to) > d->at(e.from) + e.cost) {
        d->at(e.to) = d->at(e.from) + e.cost;
        update = true;
        if (i == V-1 && e.to == g) return false;
      }
    }
    // finish
    if (!update) {
      break;
    }
  }
  return true;
}

int main() {
  int N, M; cin >> N >> M;
  vector<Edge> es;
  for (int i = 0; i < M; ++i) {
    int a, b, c; cin >> a >> b >> c;
    --a, --b;
    es.push_back({a, b, -c});
  }

  vector<LL> d;
  if (belman_ford(0, N-1, N, es, &d)) {
    cout << -d[N-1] << endl;
  } else {
    cout << "inf" << endl;
  }
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int x = 0;
   for (int i = 1; i < N+1; i++) {
     int y = 0;
     y = i/10000 + (i/1000 - i/10000 * 10) + 
       (i/100 - i/1000 * 10) + (i/10 - i/100 *10) +
       (i - i/10 * 10);
       if (y >= A && y <= B)
         x += i;
   }
  cout << x << endl;
}

Measured memory_bytes: 3556
/* Atcoder abc169c
 * See tasks at: https://atcoder.jp/contests/abc169/tasks/abc169_c
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    ll a;
    cin >> a;

    string bs;
    cin >> bs;
    bs.replace(bs.find_first_of('.'), 1, ""sv);
    ll b = stoll(bs);
    
    cout << (a * b) / 100;
    
    return 0;
}


Measured memory_bytes: 3608
s = list(input())
t = list(input())
for i in range((len(s))-(len(t)),-1,-1):
    for j in range(len(t)):
        if s[i+j] == "?":
            continue
        if s[i+j] != t[j]:
            break
    else:
        for k in range(len(t)):
            s[i+k] = t[k]
        for l in range(len(s)):
            if s[l] == "?":
                s[l] = "a"
        print("".join(s))
        break
else:
    print("UNRESTORABLE")

Measured memory_bytes: 9012
#include <stdio.h>

typedef struct{
  char suit;
  int value;
} Card;

void BubbleSort(Card C[],int N)
{

  int i, j;
  Card a;
  
  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(C[j].value < C[j-1].value){
	a = C[j];
	C[j] = C[j-1];
	C[j-1] = a;
      }
    }
  }

}

void SelectionSort(Card C[],int N)
 {

   int i, j, minj;
   Card a;
   
   for(i=0;i<N;i++){
     minj = i;
     for(j=i;j<N;j++){
       if(C[j].value < C[minj].value){
	 minj = j;
       }
     }
     a = C[i];
     C[i] = C[minj];
     C[minj] = a;
   }
   
 }

int isStable(Card in[],Card out[],int N)
{

  int i, j, a, b;

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(in[i].value==in[j].value){
	    if(in[i].suit==out[b].suit && in[i].value==out[b].value){
	      if(in[j].suit==out[a].suit && in[j].value==out[a].value){
	    return 0;
	      }
	    }
	  }
	}
      }
    }
  }

  return 1;

}

int main()
{

  int N, i;
  
  scanf("%d",&N);
  Card C1[N], C2[N];
  
  for(i=0;i<N;i++){
    scanf(" %c%d",&C1[i].suit,&C1[i].value);
  }

  for(i=0;i<N;i++){
    C2[i] = C1[i];
  }

  BubbleSort(C1,N);
  SelectionSort(C2,N);

  for(i=0;i<N;i++){
    if(i!=N-1) printf("%c%d ",C1[i].suit,C1[i].value);
    else printf("%c%d\n",C1[i].suit,C1[i].value);
  }
  printf("Stable\n");

  for(i=0;i<N;i++){
    if(i!=N-1) printf("%c%d ",C2[i].suit,C2[i].value);
    else printf("%c%d\n",C2[i].suit,C2[i].value);
  }
  if(isStable(C1,C2,N)==1) printf("Stable\n");
  else printf("Not stable\n");

  return 0;

}



Measured memory_bytes: 2108
int main(void){char*r,t[8][18];int i=0,j,a,b,c;for(;~scanf("%s",t[i++&7]);)if(i%8==0){for(j=0;j<8;j++){a=strtol(t[j],0,2);if(a){b=a&-a;c=strtol(t[j+1],0,2)*2/b;switch(a/b){case 1:switch(c){case 2:r="B";break;case 3:r="F";break;case 6:r="D";break;}break;case 3:switch(c){case 6:r="A";break;case 3:r="E";break;case 12:r="G";break;}break;case 15:r="C";break;}puts(r);break;}}}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){    
    int N, M;
    cin >> N >> M;
    vector<P> rel(M);
    for(int i=0; i<M; i++){
        cin >> rel[i].second >> rel[i].first;
        rel[i].first--;
        rel[i].second--;
    }
    sort(rel.begin(), rel.end());

    vector<bool> remove(N-1);
    fill(remove.begin(), remove.end(), false);
    for(int i=0; i<M; i++){
        int a = rel[i].second,  b = rel[i].first;
        for(int j=a; j<b; j++){
            if(remove[j]) break;
            if(j==b-1) remove[b-1] = true;
        }
    }

    int ans = 0;
    for(int i=0; i<N-1; i++){
        if(remove[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
a0 = int(input())

rem = 1
res = a0 - 1

for _ in range(N - 1):
    a = int(input())
    if a >= rem + 2:
        res += (a - 1) // (rem + 1)
    elif a == rem + 1:
        rem = a
    else:
        pass

print(res)

Measured memory_bytes: 3188
a, b = map(int, input().split(' '))

ans = 1
for i in range(2, int(min(a, b)**0.5)+1):
    if a%i == 0 and b%i == 0:
        ans += 1
    while a%i==0:
        a //= i
    while b%i==0:
        b //= i

if (a==b) and (a!=1):
    ans += 1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<queue>
#include<ctime>
#include<string>
#include<string.h>
#include<cstring>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<cassert>
#include<complex>
#include<deque>
#include<stdio.h>
using namespace std;
int c[11][11]={0},h,k,a[200][200],number[10]={0},magic=1000000000,ans=0;
bool b[11]={0};
void dfs(int x,int now,int l){
	if (x==1||x==-1){
		magic=min(magic,now);
		return ;
	}
	if (now>l) return ; 
	for (int i=0;i<=9;i++) if (b[i]==0&&i!=x&&c[x][i]<=l){
		b[i]=1;
		dfs(i,now+c[x][i],l);
		b[i]=0;
	}
}
int main()
{
	cin>>h>>k;
	for (int i=0;i<=9;i++)
		for (int j=0;j<=9;j++)
			cin>>c[i][j];
	for (int i=0;i<h;i++)
		for (int j=0;j<k;j++)
			cin>>a[i][j];
	number[1]=0;
	for (int i=0;i<h;i++)
		for (int j=0;j<k;j++){
			memset(b,0,11);
			magic=1000000000;
			if (number[a[i][j]]==0){
				dfs(a[i][j],0,c[a[i][j]][1]);
				number[a[i][j]]=magic;
			}
			ans+=number[a[i][j]];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

#define MOD 1000000007
#define INF 1050000000

int main() {
	int n; cin >> n;
	int a[100000 + 2];
	memset(a, 0, sizeof(a));
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
	}

	int b[100000 + 2];
	memset(b, 0, sizeof(b));
	for (int i = 1; i < n + 2; i++) {
		b[i] = abs(a[i] - a[i - 1]) + b[i - 1];
	}

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


}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int A, B;
  cin >> A >> B;

  for(int i = 1; i <= 100000; i++) {
    if((i * 8) / 100 == A && i / 10 == B) {
      cout << i;
      return 0;
    }
  }

  cout << "-1";
return 0;
}

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

int main()
{
	int n;	int k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int w; cin >> w;
		if(w >= k)
		{
			ans += 1;
		}
	}
	cout << ans;
	return 0;
}

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

int main(){
  int a,b,c,d,ans=0;
  cin >> a >> b >> c >> d;
  
  ans = (a+b) - (c+d);
  if(ans == 0){
    cout << "Balanced" << endl;
  }else if(ans > 0){
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
def main():
    W, H, N = (int(i) for i in input().split())
    seen = [[True]*W for _ in range(H)]
    for i in range(N):
        X, Y, a = (int(i) for i in input().split())
        if a == 1:
            for h in range(H):
                for x in range(X):
                    seen[h][x] = False
        elif a == 2:
            for h in range(H):
                for x in range(X, W):
                    seen[h][x] = False
        elif a == 3:
            for w in range(W):
                for y in range(Y):
                    seen[y][w] = False
        else:
            for w in range(W):
                for y in range(Y, H):
                    seen[y][w] = False
    # print(*seen, sep="\n")
    ans = 0
    for h in range(H):
        for w in range(W):
            if seen[h][w]:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41968
#include <bits/stdc++.h>
using namespace std;
#define N 710

int n,m,s1,s2,flag=1;
int a[N][N],t1[N],t2[N],c[N];

void dfs(int x,int col) {
	if (c[x]) {
		if (c[x]!=col) flag=0;
		return;
	}
	c[x]=col;
	s1+=(col==2);
	s2+=(col==3);
	for (int i=1;i<=n;i++)
		if (a[x][i])
			dfs(i,col^1);
}

int x,y;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++)
			a[i][j]=a[j][i]=1;
	while (m--) {
		scanf("%d%d",&x,&y);
		a[x][y]=a[y][x]=0;
	}
	t1[0]=1;
	for (int i=1;i<=n;i++) if (!c[i])
	{
		s1=0; s2=0;
		dfs(i,2);
		memset(t2,0,sizeof(t2));
		for (int j=0;j<n;j++) if (t1[j])
			t2[j+s1]=t2[j+s2]=1;
		memcpy(t1,t2,sizeof(t1));
	}
	if (!flag) return puts("-1"),0;
	int ans=1<<30;
	for (int i=1;i<n;i++)
		if (t1[i]) ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	printf("%d\n",ans);
	return 0;
}

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

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

    int ans=0;
    int tmp=0;
    for(int i=0; i<S.size(); i++){
        if(S[i]=='A'|| S[i]=='C'|| S[i]=='G'|| S[i]=='T'){
            tmp++;
            ans=max(tmp, ans);
        } else {
            tmp=0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
    t1, x1, y1 = [int(j) for j in input().split()]
    if t1 - t >= abs(x1 - x) + abs(y1 - y):
        if (t1 - t - abs(x1 - x) - abs(y1 - y)) % 2 == 1:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t, x, y = t1, x1, y1
print("Yes")

Measured memory_bytes: 3188
N = int(input())
p = list(map(int, input().split()))
dic = {}
for i in range(1, N+1):
    dic[i] = p[i-1]
 
cnt = 0
for key,val in dic.items():
    if key!=val:
        cnt += 1
 
if cnt==2 or cnt==0:
    print("YES")
else:
    print("NO")

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


int main(){
    string s;
    cin >> s;
    if(s[s.size()-1] == 's'){
        s += "es";
    }
    else{
        s += "s";
    }
    cout << s << endl;
    return 0; 
}


Measured memory_bytes: 3620
from collections import defaultdict
n, p = map(int, input().split())

s = input()
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
else:
    tmp = 0
    d = defaultdict(int)
    d[0] = 1
    for i in range(n)[::-1]:
        tmp += int(s[i]) * pow(10, n - i - 1, p)
        tmp %= p
        ans += d[tmp]
        d[tmp] += 1
print(ans)

Measured memory_bytes: 42956
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    if k % 2 == 1:
        mod_k = n // k
        # 順番変えたものは同一視するなら modkH3 = 3+modk-1C3 だけど
        print(mod_k ** 3)
    else:
        mod_k_0 = n // k
        mod_k_div2 = n // k + (n % k) // (k // 2)
        print(mod_k_0 ** 3 + mod_k_div2 ** 3)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
using System;
using System.CodeDom;
using System.Linq;
using System.Text;

namespace paizaTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var line = string.Empty;
            var count = 0;
            while ((line = Console.ReadLine()) != "0")
            {
                Console.WriteLine("Case " + ++count + ": " + line);
            }
        }
    }
}

Measured memory_bytes: 9080
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

ll a[N], dp[3030][3030][2];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i]; 
	}

	for(int l = n; l > 0; l--) {
		for(int r = l; r <= n; r++) {
			dp[l][r][0] = max(dp[l + 1][r][1] + a[l], dp[l][r - 1][1] + a[r]);
			dp[l][r][1] = min(dp[l + 1][r][0] - a[l], dp[l][r - 1][0] - a[r]); 
		}
	}

	cout << dp[1][n][0];
}

Measured memory_bytes: 143616
use std::io;
use std::vec::Vec;
fn main() {
    let mut l1 = String::new();
    let mut l2 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    stdin.read_line(&mut l2).unwrap();
    let trimed = l1.trim_right();
    let n = trimed.parse::<usize>().unwrap();
    let mut v: std::vec::Vec<i32> = Vec::with_capacity(n);

    let mut iter = l2.split_whitespace();
    for i in &mut iter {
        let num: i32 = i.parse().unwrap();
        v.push(num);
    }
    v.sort();
    let mut ans = 0;
    for a in 0..101 {
        let mut result = 0;
        for i in &v {
            result = result + ((a - i) * (a - i));
        }

        if a == 0 {
            ans = result
        } else {
            if ans > result {
                ans = result;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main()
{
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][][] f = new int[n][5][2];
		int[][] p = new int[n][11];
		int max = -1000000001;
		boolean flag = false;
		for(int i=0;i<n;i++){
			for(int j=0;j<5;j++){
				for(int k=0;k<2;k++){
					f[i][j][k] = sc.nextInt();
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<11;j++){
				p[i][j] = sc.nextInt();
			}
		}
		int x = (int)Math.pow(2,10);

		for(int i=1;i<x;i++){
			int[] count = new int[n];
			int[] counter = new int[10];
			int y = i;
			for(int j=9;j>=0;j--){
				if(y>=(int)Math.pow(2,j)){
					y -= (int)Math.pow(2,j);
					counter[j] = 1;
				}
			}
			for(int j=0;j<10;j++){
				if(counter[j]==1){
					for(int k=0;k<n;k++){
						if(f[k][j/2][j%2]==1){
							count[k]++;
						}
					}
				}
			}
			int ans = 0;
			for(int j=0;j<n;j++){
				ans += p[j][count[j]];
			}
			max = (int)Math.max(max,ans);
		}

		System.out.println(max);

	}
}


Measured memory_bytes: 26280
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;





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

    //
    char A[N][N], B[M][M];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < M; ++j) {
            cin >> B[i][j];
        }
    }

    //
    int num = 0;
    for (int i = 0; i < N-M+1; ++i) {
        for (int j = 0; j < N-M+1; ++j) {

            //
            bool is_same = true;
            for (int k = 0; k < M; ++k) {
                for (int l = 0; l < M; ++l) {
//                    cout << B[k+i][l+j];
                    if(A[k+i][l+j] != B[k][l]) {
                        is_same = false;
                        break;
                    }
                }
//                cout << endl;
            }
//            cout << "-- -- --" << endl;

            if(is_same)
                num++;
        }
    }

    if(num > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}

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

const int MAX = 200000;

int main() {
  using namespace std;
  int n, R[MAX];

  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];
  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 3856
N = gets.strip.to_i
A = gets.strip.split.map(&:to_i)
B = gets.strip.split.map(&:to_i)
C = gets.strip.split.map(&:to_i)
ans=0
(0..N-1).each do |i|
    ans+=B[A[i]-1]
end
t=A[0]
a=C[0]
(1..N-1).each do |i|
    if A[i]-t==1
        ans+=C[t-1]
        #puts t
        #puts C[t]
    end


    t=A[i]
    a=C[i]
end

puts ans


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

int n;
long long curr=0, total=0;
long long a[100005], cnt[100005];
bool possible=1;

// number of vertices in the i-th depth has to be in range [0..2^i]
// dari atas -> kebanyakan vertex
// dari bawah -> yaa gagal
// pretty sure its greedy

int main(){
	cin >> n;
	for (int i=0;i<=n;i++) cin >> a[i];
	for (long long i=n;i>=0;i--){
			long long l=a[i], r=a[i]+curr;
//			if (i>0 && i<64) r=min(r,((1ll<<(i-1))-a[i-1])*2);
//			if (i<64 && ((1ll<<i)-a[i])<(r)) ans=0;
			if (i<32) r=min(r,(1ll<<i));
//			cout << i << " " << l << " " << r << "\n";
			if (l>r) possible=0;
			curr=r;
			cnt[i]=curr;
	}
	for (long long i=0;i<=n;i++){
		if (i>0) cnt[i]=min(cnt[i],2*(cnt[i-1]-a[i-1]));
		if (cnt[i]<a[i]) possible=0;
//		cout << i << " " << cnt[i] << "\n";
		total+=cnt[i];
	}
	cout << (possible ? total : -1) << "\n";
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,s1,s2,s3;
    cin>>a>>b>>c>>d;
    s1=abs(a-b);
    s2=abs(a-c);
    s3=abs(b-c);
    if(s2<=d){
        cout<<"Yes";
    }
    else{
        if(s1<=d &&  s3<=d){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
}


Measured memory_bytes: 3576
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<sstream>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=100010;
const int p=1000000007;
int pow(int a,int b,int c)
{
    if (a==0)return 0;
    int d=a,e=1;
    while (b)
    {
        if (b&1) e=(1LL*e*d)%c;
        d=1LL*d*d%c;
        b>>=1;
    }
    return e;
}
int random(int n) { return 1LL*rand()*rand()%n+1;}
int n,m,d,q;
LL f[N];
int a[N],b[N];
int main()
{
	scanf("%d%d%d",&n,&m,&d);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	{
		int x;scanf("%d",&x);
		a[x]=i;b[x]=j;
	}
	for (int i=d+1;i<=n*m;i++)
		f[i]=f[i-d]+abs(a[i]-a[i-d])+abs(b[i]-b[i-d]);
	scanf("%d",&q);
	while (q--)
	{
		int x,y;scanf("%d%d",&x,&y);
		LL ans=f[y]-f[x];
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        long res = 0;
        
        for(int i = 1; i <= N; ++i){
            if(!(i % 3 == 0 && i % 5 == 0) && !(i % 3 == 0) && !(i % 5 == 0)){
                res += i;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 27192
#include <stdio.h>

typedef struct {
    int top;
    int bottom;
    int right;
    int left;
    int front;
    int back;
} Dice;

void roll(Dice *d, char direction)
{
    int present_top = d->top;
    int present_bottom = d->bottom;
    int present_right = d->right;
    int present_left = d->left;
    int present_front = d->front;
    int present_back = d->back;

    if (direction == 'N') {
        d->top = present_front;
        d->bottom = present_back;
        d->front = present_bottom;
        d->back = present_top;
    } else if (direction == 'S') {
        d->top = present_back;
        d->bottom = present_front;
        d->front = present_top;
        d->back = present_bottom;
    } else if (direction == 'E') {
        d->top = present_left;
        d->bottom = present_right;
        d->right = present_top;
        d->left = present_bottom;
    } else {
        d->top = present_right;
        d->bottom = present_left;
        d->right = present_bottom;
        d->left = present_top;
    }
}

void revolve(Dice *d, char direction)
{
    int present_top = d->top;
    int present_bottom = d->bottom;
    int present_right = d->right;
    int present_left = d->left;
    int present_front = d->front;
    int present_back = d->back;

    if (direction == 'R') {
        d->front = present_right;
        d->back = present_left;
        d->right = present_back;
        d->left = present_front;
    } else {
        d->front = present_left;
        d->back = present_right;
        d->right = present_front;
        d->left = present_back;
    }
}

void show_right(Dice *d, int top, int front)
{
    if (d->back == front) {
        if (d->top == top) {
            revolve(d, 'R');
            revolve(d, 'R');
        } else {
            roll(d, 'S');
            roll(d, 'S');
        }
    }
    else if (d->top == front)
        roll(d, 'S');
    else if (d->bottom == front)
        roll(d, 'N');
    else if (d->right == front)
        revolve(d, 'R');
    else if (d->left == front)
        revolve(d, 'L');

    if (d->bottom == top) {
        roll(d, 'E');
        roll(d, 'E');
    }
    else if (d->right == top)
        roll(d, 'W');
    else if (d->left == top)
        roll(d, 'E');

    printf("%d\n", d->right);
}

int main(void)
{
    Dice dice;
    int i;

    for (i = 0; i < 6; i++) {
        switch (i) {
            case 0 : scanf("%d", &dice.top); break;
            case 1 : scanf("%d", &dice.front); break;
            case 2 : scanf("%d", &dice.right); break;
            case 3 : scanf("%d", &dice.left); break;
            case 4 : scanf("%d", &dice.back); break;
            case 5 : scanf("%d", &dice.bottom); break;
        }
    }

    int q;
    scanf("%d", &q);

    for (i = 0; i < q; i++) {
        int top, front;
        scanf("%d %d", &top, &front);

        show_right(&dice, top, front);
    }

    return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	int cnt=0;
	
	while(cin>>a>>b){
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		
		cout<<ans<<endl;
		
		cnt++;
	}
	
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC155
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var aas = ReadIntArray();

            Console.WriteLine(aas.Where(a => a % 2 == 0).All(a => a % 5 == 0 || a % 3 == 0) ? "APPROVED" : "DENIED");
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13396
s, t = input(), input()

if len(s) < len(t):
    print('UNRESTORABLE')
    exit(0)

ans,tmp = "", ""

for i in range(len(s)):
    if len(s[i:]) < len(t):
        ok = False
        break
    ok = True
    for j in range(len(t)):
        if s[i:][j] != t[j] and s[i:][j] != "?":
            ok = False
    if ok:
        tmp = (s[:i]+ t + s[i+len(t):]).replace("?", "a")
        if tmp < ans or ans == "":
            ans = tmp

if ans:
    print(ans)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  vector<int> v(3), x(4);
  while (cin >> v[0] >> v[1] >> v[2]) {
    sort(all(v));
    int a = v[0], b = v[1], c = v[2];
    if (a + b <= c) break;
    x[0]++;
    if (a * a + b * b == c * c) x[1]++;
    if (a * a + b * b > c * c) x[2]++;
    if (a * a + b * b < c * c) x[3]++;
  }
  cout << x << endl;
}



Measured memory_bytes: 3132
s1=[int(i) for i in input().split()]
N=s1[0]
M=s1[1]
s2=[int(i) for i in input().split()]
a=sorted(s2)


sabun=[]
for i in range(len(a)-1):
  sabun.append(a[i+1]-a[i])

s_sabun=sorted(sabun)

trysum=0
for i in range(M-N):
  trysum=trysum+s_sabun[i]

if N>=M:
  print(0)
else:  
  print(trysum)


Measured memory_bytes: 13840
#include<stdio.h>

class dice{
    private:
        int curface;
        int faces[6] = {};
    
    public: int GetCurface(){return curface;}
    public: int GetFace(int n){return faces[n-1];}
    public: int GetRight(){return GetFace(3);}
    public: int GetLeft(){return GetFace(4);}
    public: int GetFront(){return GetFace(2);}
    public: int GetBack(){return GetFace(5);}
    
    dice(){
        for(int i = 0;i < 6;i++) scanf("%d",&faces[i]);
        curface = faces[0];
    }
    
    public: bool Move(char toward){
        switch(toward){
            case 'N':
                faces[0] = faces[1];
                faces[1] = faces[5];
                faces[5] = faces[4];
                faces[4] = curface;
                break;
            case 'E':
                faces[0] = faces[3];
                faces[3] = faces[5];
                faces[5] = faces[2];
                faces[2] = curface;
                break;
            case 'S':
                faces[0] = faces[4];
                faces[4] = faces[5];
                faces[5] = faces[1];
                faces[1] = curface;
                break;
            case 'W':
                faces[0] = faces[2];
                faces[2] = faces[5];
                faces[5] = faces[3];
                faces[3] = curface;
                break;
        }
        curface = faces[0];
        return 1;
    }
    public: bool Rotate(){
        this -> Move('W');this -> Move('S');this ->Move('E');
        return 1;
    }
    
    
};


int main(){
    int n,x,y;
    dice d1,d2;
    if(d1.GetRight() == d2.GetCurface()) d1.Move('W');
    if(d1.GetLeft() == d2.GetCurface()) d1.Move('E');
    for(int i = 1;i <= 4;i++){
        d1.Move('N');
        if(d1.GetCurface() == d2.GetCurface()) break;
    }
    for(int i = 1;i <= 4;i++){
        d1.Rotate();
        if(d1.GetFront() == d2.GetFront()) break;
    }
    for(int i = 1;i <= 6;i++){
        if(d1.GetFace(i) != d2.GetFace(i)){
            printf("No\n");
            break;
        }
        if(i == 6){
            printf("Yes\n");
        }
    }
    
  
}





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

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


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

vector<pair<char, int> > RLE(const string& S){
  vector<pair<char, int> > res;
  rep(i, S.size()){
    int count = 0;
    reps(j, i, S.size()){
      if (S[i] != S[j]) break;
      count++;
    }
    res.push_back(make_pair(S[i], count));
    i += count - 1;
  }
  return res;
}

int main()
{
  string inp;
  const char *table[] = {
    "',.!?",
    "abcABC",
    "defDEF",
    "ghiGHI",
    "jklJKL",
    "mnoMNO",
    "pqrsPQRS",
    "tuvTUV",
    "wxyzWXYZ"
  };
  while (cin >> inp){
    vector<pair<char, int> > rle;
    rle = RLE(inp);
    rep(i, rle.size()){
      char c = rle[i].first;
      int len = rle[i].second;
      if (c == '0'){
        rep(i, len - 1) putchar(' ');
      }
      else {
        putchar(table[c - '1'][len - 1]);
      }
    }
    puts("");
  }
  return 0;
}

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

int main(){
 int a,b;
  
    cin>>a>>b;
  int d =0;
  for(int i=a;i<=b;i++){
  
    if((i/10000 == i%10)&&((i%10000)/1000 ==(i%100)/10)){
        d ++;
    }
  }
  
  cout << d << endl;
}
     
  
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

const int N=int(1e5)+5;

int n;
int a[N*3];
ll ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n*3;i++) scanf("%d",&a[i]);
	sort(a+1,a+n*3+1);
	for(int i=1;i<=n;i++) ans+=a[n*3-i*2+1];
	cout << ans << endl;
}


Measured memory_bytes: 1408
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import bisect
import heapq
# from math import *
from collections import defaultdict as dd  # defaultdict(<datatype>) Free of KeyError.
from collections import deque  # deque(list) append(), appendleft(), pop(), popleft() - O(1)
from collections import Counter as c  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()


def out(var): sys.stdout.write(var)


def l(): return list(map(int, data().split()))


def sl(): return list(map(str, data().split()))


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]


n, a, b = sp()
answer = min(a, n % (a+b))
temp = n - (n % (a+b))
answer += a * (n // (a+b))
out(str(answer))


Measured memory_bytes: 38384
#include <iostream>

using namespace std;


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

    while(true){
        cin >> a >> op >> b;

        if(op=='+'){
            cout << a + b << endl;
        }else if(op=='-'){
            cout << a - b << endl;
        }else if(op=='*'){
            cout << a * b << endl;
        }else if(op=='/'){
            cout << a / b << endl;
        }else if(op=='?'){
            break;
        }    
    }

    return 0;
}




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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int A,B;
	cin >> A >> B;
	if (A == B){
		cout << 0 << endl;
		return 0;
	}else{
		if ((A+B) % 2 == 0){
			cout << (A+B)/2 << endl;
		}else{
			cout << "IMPOSSIBLE" << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;
int main(void)
{
	char a[100];
	char b[100];
	char c[100];
	cin >> a >> b >> c;
	int d = strlen(a);
	int e = strlen(b);
	if (a[d-1]==b[0]&&b[e-1]==c[0])
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
	return 0;
}

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

 int main()
 {
 	int a, b, c, x;
 	cin >> a >> b >> c >> x;
 	int ans = 0;
 	for(int i = 0; i <= a; i++){
 		for(int j = 0; j <= b; j++){
 			for(int k = 0; k <= c; k++){
 				if(500*i + 100*j + 50*k == x){
 					ans++;
 				}
 			}
 		}
 	}
 	cout << ans << endl;
 	
 	return 0;
 }

Measured memory_bytes: 256