akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define INF ll_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    int n;
    cin >> n;

    bool ans = false;
    vector<int> a(n);
    map<int,int> mp;

    int c_zero = 0;
    REP(i,n){
        cin >> a[i];
        mp[a[i]]++;
        if(a[i] == 0)c_zero++;
    }

    //全ての帽子に書かれた数が０
    if(c_zero == n){
        cout << "Yes" << endl;
        return 0;
    }

    //xが書かれた帽子が(2N)/3枚、０が書かれた数がN/3枚
    if(n%3 == 0 && c_zero == n/3){
        for(auto p: mp){
            if(p.second == 2*n/3){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    //x⊕y⊕z=0が成立するような３つの相異なる整数x,y,zが書かれた帽子がそれぞれN/3枚
    //x_0 == x_3より、xの種類が３より大きい場合は不成立
    // cout << mp.size() << endl;
    if(mp.size() == 3){
        int xyz = 0;
        bool f_xyz = true;
        for(auto p : mp){
            xyz ^= p.first;
            if(p.second != n/3)f_xyz = false;
        }
        if(f_xyz && xyz == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 4224
#include <stdio.h>

char str[10001];
int a[3];
int b[3];

void receive_input() {
	for (size_t i = 0; i < 3; i++) {
		fgets(str, sizeof(str), stdin);
		sscanf(str, "%d %d", &a[i], &b[i]);
	}
}

void initialize() {
	// nop
}

int check() {
	int flag[5] = {};

	for (size_t i = 0; i < 3; i++) {
		flag[a[i]]++;
		flag[b[i]]++;
	}

	for (size_t i = 1; i <= 4; i++) {
		if (flag[i] == 0 || flag[i] > 2) {
			return 0;
		}
	}
	return 1;
}

int main(void) {
	receive_input();
	initialize();

	printf("%s\n", check() ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 128
import sys
a = []
judge = [None,None,None]
for i in range(3):
    a.append(input().split())

n = int(input())

for i in range(n):
    b = input()
    for i in a:
        if b in i:
            i[i.index(b)] = None

for i in a:
    if i == judge:
        print('Yes')
        sys.exit()

for i in range(3):
    if [a[0][i],a[1][i],a[2][i]] == judge:
        print('Yes')
        sys.exit()

if [a[0][0],a[1][1],a[2][2]] == judge:
    print('Yes')
    sys.exit()

if [a[0][2],a[1][1],a[2][0]] == judge:
    print('Yes')
    sys.exit()

print('No')



Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>


using namespace std;


using namespace std;

int main() {
   int A,P;
   cin>>A>>P;

   int B;
   B=3*A;

   cout<<(B+P)/2<<endl;


   }


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


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

  set<int> adj[N];
  int count[N][2] = {};
  rep(i,M) {
    int a, b; cin >> a >> b; a--; b--;
    adj[a].insert(b);
    adj[b].insert(a);
  }

  rep(i,N) {
    for (auto x: adj[i]) {
      if (s[x]=='A') count[i][0]++;
      else count[i][1]++;
    }
  }

  stack<int> ng;
  bool use[N] = {}; fill_n(use,N,true);
  rep(i,N) if (!(count[i][0]&&count[i][1])) ng.push(i);

  while(ng.size()) {
    int now = ng.top(); ng.pop();
    // cout << endl << now << "->";
    use[now] = false;
    for (auto x: adj[now]) {
      // cout << x << " ";
      adj[x].erase(now);
      if (s[now]=='A') count[x][0]--;
      else count[x][1]--;
      if (!(count[x][0]&&count[x][1])) ng.push(x);
    }
    adj[now].clear();
  }
  // debug(use,use+N);
  // rep(i,N) cout << count[i][0] << " " << count[i][1] << endl;

  bool ok = false;
  rep(i,N) ok |= use[i];
  string result = ok ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 29188
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int r,g,b;
  C3(r,g,b);
  
  int a = (r*100) + (g*10) + b;
  if(a%4 == 0)
    YES;
  else
    NO;
  ret 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n;
	cin>>n;
	vi a(n);
	int res=1;
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			res=0;
		}
	}
	if(res==0)
	{
		cout<<0;
		return 0;
	}
	int N=1e18;
	for(int i=0;i<n;++i)
	{
		//cin>>a[i];
		if(a[i] > N/res)
		{
			cout<<-1;
			return 0;
		}
		res*=a[i];
	}
	cout<<res;
	return 0;
}

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a * c, a * d, b * c, b * d}) << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>

using namespace std;
int main(void){
    // Your code here!
    string s,t,u;
    int a=0,b,c;
    cin>>s;
    for(int i;i<s.length();i++){
        if(s[i]=='1'){
            a++;
        }
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> P;
  tools::read(P, N);
  std::transform(P.begin(), P.end(), P.begin(), [](const i64& P_i) { return P_i - 1; });

  std::vector<i64> inv_P(N);
  for (i64 i = 0; i < N; ++i) {
    inv_P[P[i]] = i;
  }

  std::vector<std::pair<i64, i64>> invalid_pairs;
  for (i64 i = 0; i + 1 < N; ++i) {
    if (inv_P[i] > inv_P[i + 1]) {
      invalid_pairs.push_back(std::make_pair(i, i + 1));
    }
  }

  i64 longest_length;
  if (invalid_pairs.empty()) {
    longest_length = N;
  } else {
    longest_length = 0;
    longest_length = std::max(longest_length, invalid_pairs.front().first - 0 + 1);
    longest_length = std::max(longest_length, (N - 1) - invalid_pairs.back().second + 1);
    for (auto it1 = invalid_pairs.begin(), it2 = ++invalid_pairs.begin(); it2 != invalid_pairs.end(); ++it1, ++it2) {
      longest_length = std::max(longest_length, it2->first - it1->second + 1);
    }
  }

  std::cout << N - longest_length << std::endl;
  return 0;
}

Measured memory_bytes: 9456
def merge(cnt, A, left, mid, right):
    L = A[left:mid] + [1e+99]
    R = A[mid:right] + [1e+99]
    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    cnt.append(right - left)

            
def mergeSort(cnt, A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(cnt, A, left, mid)
        mergeSort(cnt, A, mid, right)
        merge(cnt, A, left, mid, right)
        
        
import sys
def input():
    return sys.stdin.readline()[:-1]
    
n = int(input())
S = list(map(int, input().split()))

from collections import deque
cnt = deque()
mergeSort(cnt,S,0,n)

print(*S)
print(sum(cnt))



Measured memory_bytes: 61668
#pragma GCC optimize("Ofast") 
#include<algorithm>
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long 
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
  SYNC
    int n;
    in(n);
    int dp[n+1],ar[n+1];
    l(i,1,n+1)
    in(ar[i]);
    dp[1]=0;
    if(n!=1)
    dp[2]= abs(ar[2]-ar[1]);
    l(i,3,n+1)
    {
       dp[i]=min (dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    o(dp[n]);
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

        int roopCount = input.length() - 1;// 文字の間の数だけbit全探索する
        long ans = 0;

        for (int i = 0; i < Math.pow(2.0, (double)roopCount); i++) {

            StringBuilder sb = new StringBuilder(input);

            for (int j = roopCount - 1; j >= 0; j--) {
                if ((1 & i >> j) == 1) {// 順番にビットが1になってる箇所を探していく
                    sb.insert(j+1, "+");
                }
            }

            String[] str = sb.toString().split("\\+", 0);
            for (int j = 0; j < str.length; j++) {
                ans += Long.parseLong(str[j]);
            }
        }

        System.out.println(ans);
    }
}


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

// class Solve {
// private:
// 	bool isCat

// public:
// 	bool is_last_query{};
// 	Solve()
// 	{
// 		if (hashFunc == ".")
// 		{
// 			is_last_query = true;
// 			return;
// 		}
// 	}
// };

std::string S;

bool isCat(int&);

int main()
{
	// while (!Solve().is_last_query);
	std::cin >> S;
	int s_i{};
	if (isCat(s_i) && s_i == (int)S.size())
		puts("Cat");
	else
		puts("Rabbit");

	return 0;
}

bool isCat(int& s_i)
{
	if (s_i == (int)S.size()) return false;
	if (S[s_i] != 'm') return true;
	s_i++;
	if (!isCat(s_i)) return false;
	if (s_i == (int)S.size() || S[s_i] != 'e') return false;
	s_i++;
	if (!isCat(s_i)) return false;
	if (s_i == (int)S.size() || S[s_i] != 'w') return false;
	s_i++;
	return true;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    
    long long ans = 1e+18;
    REP(i, N){
        long long X = A[i];
        vector<int> tmp;
        priority_queue<int, vector<int>, greater<int>> q;
        REP(j, N+1){
            if(A[j] < X or j == N){
                int m = q.size();
                REP(i, m-(K-1)){
                    tmp.push_back(q.top());
                    q.pop();
                }
                q = decltype(q)();
            }else q.push(A[j]);
        } 
        if(tmp.size() >= Q){
            sort(tmp.begin(), tmp.end());
            ans = min(ans, tmp[Q-1]-X);
        }
        //cout << i << " " << ans << " " << tmp.size() << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;
const int maxn=2e5+10;
const int mod=1e9+7;
ll a[maxn];
int main(){
	a[1]=0;
	a[2]=0;
	a[3]=1;
	for(int i=4;i<maxn;i++){
		a[i]=(a[i-1]+a[i-3])%mod;
	}
	int n;
	cin>>n;
	cout<<a[n]<<endl;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
const int N = 605;

int main() {
    int n , res = 1 << 30;
    cin >> n;
    for (int x = 1 ; x <= n - x ; ++ x) {
        int sum = 0 , i = x , j = n - x;
        while (i) sum += i % 10 , i /= 10;
        while (j) sum += j % 10 , j /= 10;
        res = min(res ,sum);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int N;
bool flag;
ll A[100000];
vector<int> G[100000];
int used[100000];
 
map<P, ll> dp;
 
ll dfs(P n) {
	if (dp[n]) {
		return dp[n] - 1;
	}
	int from = n.first, to = n.second;
	used[to] = 1;
	bool f = true;
	ll res = A[to] * 2;
	for (int v : G[to]) {
		if (used[v] == 0) {
			res -= dfs(P(to, v));
			f = false;
		}
	}
	if (res < 0) {
		flag = false;
	}
	if (f) {
		res /= 2;
	}
	used[to] = 0;
	dp[n] = res + 1;
	return res;
}
 
 
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0, a, b; i < N - 1; i++) {
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	flag = true;
	for (int i = 0; i < N; i++) {
		if (G[i].size() > 2) {
			ll sum = 0;
			for (int v : G[i]) {
				sum += A[v];
			}
			sum -= A[i] * 2;
			for (int v : G[i]) {
				if (A[v] > A[i]) {
					sum -= A[v] - A[i];
				}
			}
			if (sum < 0) {
				flag = false;
				break;
			}
		}
		else if (G[i].size() == 2 && (A[G[i][0]] < A[i] || A[G[i][1]] < A[i])) {
			flag = false;
			break;
		}
		else if (G[i].size() == 1 && A[G[i][0]] < A[i]) {
			flag = false;
			break;
		}
	}
	for (int i = 0; i < N; i++) {
		used[i] = 1;
		ll val = A[i] * 2;
		for (int v : G[i]) {
			val -= dfs(P(i, v));
		}
		used[i] = 0;
		if ((G[i].size() == 1 && val != A[i]) || (G[i].size() > 1 && val != 0)) {
			flag = false;
		}
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 27392
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}


int main(){
    int A,B;

    scanf("%d %d%*c",&A,&B);
    printf("%d\n",(A+B)%24);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define INF (1<<29)
using namespace std;

struct Node{
	int y,x,foot,cost;
	Node(){}
	Node(int a,int b,int c,int d):y(a),x(b),foot(c),cost(d){}
	bool operator <(const Node &a)const{return cost>a.cost;}
};

int main(){
	int w,h;
	char map[60][30];
	int dp[60][30][2];
	priority_queue<Node> pq;
	Node a,b;
	while(cin>>w>>h&&(w||h)){
		int ans = -1;
		while(!pq.empty())pq.pop();
		fill_n((int*)dp,sizeof(dp)/sizeof(int),INF);
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>map[i][j];
				if(map[i][j]=='S'){
					pq.push(Node(i,j,0,0));
					pq.push(Node(i,j,1,0));
					dp[i][j][0]=dp[i][j][1]=0;
				}
			}
		}
		while(!pq.empty()){
			int sx,ddx;
			a=pq.top();
			pq.pop();
			if(dp[a.y][a.x][a.foot] < a.cost)continue;
			if(map[a.y][a.x]=='T'){
				ans = a.cost;
				break;
			}
			if(a.foot==0){
				sx=ddx=1;
			}
			else{
				sx=ddx=-1;
			}
			for(int dx=sx;abs(dx)<=3;dx+=ddx){
				for(int dy=-2;dy<=2;dy++){
					if(3<abs(dy)+abs(dx))continue;
					int cost;
					b = Node(a.y+dy,a.x+dx,a.foot^1,a.cost);
					if(b.y<0||h<=b.y||b.x<0||w<=b.x||map[b.y][b.x]=='X')continue;
					if(map[b.y][b.x]=='S'||map[b.y][b.x]=='T')cost = 0;
					else cost = map[b.y][b.x]-'0';
					b.cost += cost;
					if(b.cost < dp[b.y][b.x][b.foot]){
						dp[b.y][b.x][b.foot] = b.cost;
						pq.push(b);
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 940
local n=io.read("n")
local map={}
for i=1,n do
    local itos=tostring(i)
    local first=itos:byte(1)
    local last=itos:byte(#itos)
    map[first]=map[first] or {}
    map[first][last]=(map[first][last] or 0)+1
end

local counter=0
for first,_ in pairs(map) do
    for last,_ in pairs(map[first]) do
        if map[last] and map[last][first] then
            counter=counter+map[first][last]*map[last][first]
        end
    end
end
print(counter)

Measured memory_bytes: 2676
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  int ans = 0;
  for (int i = 0; i < (int)(10); ++i) for (int j = 0; j < (int)(10); ++j) for (int k = 0; k < (int)(10); ++k) {
    vector<char> c = {i + '0', j + '0', k + '0'};
    int m = -1;
    for (int l = 0; l < (int)(3); ++l) {
      ++m;
      while (m < N && S[m] != c[l]) ++m;
    }
    ans += (m < N);
  };
  cout << ans << endl;

  return 0;
}


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

using namespace std;


long long absolute(long long int  num)
{
    if(num<0)
    return -1*num;
    else
    return num;
}


int main()
{
    long long int x,k,d;
    cin>>x>>k>>d;
    if(x<0)
    x*=-1;
    long long int alpha=x/d;
    
    
    if(alpha>=k)
    cout<<x-k*d;
    else{
            
            if((k-alpha)%2==0)
            cout<<absolute(x-alpha*d);
            else
            cout<<absolute(x-(alpha+1)*d);
    }
    
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int dx[4] = {0,0, 1,-1};
int dy[4] = {1,-1,0,0};
int main(void){
    // Your code here!
    int H,W;
    cin >> H >> W;
    char mp[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> mp[i][j];
        }
    }
    bool l = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(mp[i][j] == '.') continue;
            else{
                
                bool a = 0;
                for(int d = 0; d < 4; d++){
                    int di = i + dx[d];
                    int dj = j + dy[d];
                    if(0 <= di && di < H && 0 <= dj && dj < W){
                        if(mp[di][dj] == '#'){
                            a = 1;
                        }
                    }
                }
                
                if(a == 0) l = 0;
            }
            
        }
    }
    if(l){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
/*why so serious?*/
#include<bits/stdc++.h>
using namespace std;
#define   int      long long
#define   fast()   ios_base::sync_with_stdio(0);cin.tie(0)
#define   all(x)   x.begin(),x.end()
#define   pb       push_back
#define   F        first
#define   S        second

int32_t main()
{int n,q,i,l,r;
 string s;
 fast();
 cin>>n>>q>>s;

 vector<int>a(n+1);

 a[0]=a[1]=0;
 char prev=s[0];
 for(i=1;i<n;++i)
 {if(prev=='A' && s[i]=='C')
  a[i+1]=a[i]+1;
  else
  a[i+1]=a[i];
  prev=s[i];
 }

 //for(auto x:a)
 //cout<<x<<" ";
 //cout<<"\n";

 for(;q;--q)
 {cin>>l>>r;
  cout<<a[r]-a[l]<<"\n";
 }
 return 0;
}


Measured memory_bytes: 1872
#include <stdio.h>
 
int main()
{
    int a, b, c;
 
    scanf("%d %d %d", &a, &b, &c);
 
    if (a < b && b < c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
 
    return 0;
}

Measured memory_bytes: 580
module FenwickTree: sig
    type t
    val make: int -> t
    val add:  t -> int -> int -> unit
    val sum:  t -> int -> int -> int
end= struct
    type t = int array

    let make n = Array.make n 0
    let add data p x =
        let n = Array.length data in
        let rec loop p =
            if p <= n then (
                data.(p - 1) <- data.(p - 1) + x;
                loop (p + (p land -p))
            )
        in
        loop (p + 1)

    let sum data l r =
        let sum' r =
            let rec loop r s =
                if r <= 0 then s else
                    loop (r - (r land -r)) (s + data.(r - 1))
            in
            loop r 0 
        in
        sum' r - sum' l
end ;;
Scanf.scanf "%d %d" (fun n q ->
    let ft = FenwickTree.make n in

    for i = 0 to n - 1 do
        Scanf.scanf " %d" (fun a -> FenwickTree.add ft i a)
    done;

    for i = 1 to q do
        Scanf.scanf " %d %d %d" (fun z p x ->
            if z = 0 then FenwickTree.add ft p x else
                Printf.printf "%d\n%!" @@ FenwickTree.sum ft p x
        )
    done
)

Measured memory_bytes: 10904
#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 pb(a) push_back(a)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
    if (b > a)
    {
        ll tmp = a;
        a = b;
        b = tmp;
    }

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int main()
{
    int N;
    ll X;
    cin >> N >> X;

    vector<ll> data(N);
    REP(i, N)
    {
        ll x;
        cin >> x;
        data.at(i) = abs(X - x);
    }

    ll g = data.at(0);
    FOR(i, 1, N)
    {
        g = gcd(data.at(i), g);
    }

    cout << g;
}

Measured memory_bytes: 1024
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/

void build(){

}
string ss = "CODEFESTIVAL2016" , in;
void init(){
  cin >> in;
}
void solve(){
  int dif = 0;
  for( int i = 0 ; i < (int)in.length() ; i ++ )
    if( in[ i ] != ss[ i ] )
      dif ++;
  cout << dif << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
#define PN() {cout << "No" << endl; return 0;}
#define PY() {cout << "Yes" << endl; return 0;}

int main(){
  int n; cin >> n;
  vector<long long int> a(n); for(int i=0;i<n;i++) cin >> a[i];
  int m = 1;
  long long int ans=0;
  ans += a[0] - 1;
  for(int i=1;i<n;i++){
    if(a[i] == (m+1)){
      m = a[i];
    }
  	else if(a[i] % (m+1) == 0){
      long long int t = (a[i] / (m+1)) - 1;
      ans = ans + t;
    }
    else {
      ans = ans + ( a[i] / (m+1) );
      a[i] = a[i] % (m+1);
    }
  }
 // for(int i=0;i<n;i++) cout << i+1 << ":" << a[i] << endl;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N,K;
  int dsp=1;
  cin >> N;
  cin >> K;

  for(;N;N--){
    if(dsp*2<dsp+K)
      dsp *= 2;
    else
      dsp += K;
  }
  cout << dsp << endl;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var x = cin.ReadInt();
            var y = cin.ReadInt();
            var z = cin.ReadInt();
            var t = x / (y + z);
            for (int i = t; i > 0; --i)
            {
                if (i * (y + z) + z <= x) { WriteLine(i); return; }
            }
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double ans;
    double ns = n;
    if (n%2==0) {
        ans = 1.0/2;
    }
    else {
        ans = ((n/2)+1.0)/ns;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {

	N := oneInt()
	var edges []int
	for i := 0; i < N; i++ {
		edges = append(edges, oneInt())
	}
	edges = sortDesc(edges)

	var ans int
	for i := 0; i < len(edges)-2; i++ {
		for j := i + 1; j < len(edges)-1; j++ {
			kijun := (edges[i] - edges[j])
			if kijun < 0 {
              ans += len(edges) - (j+1)
			  break
			}
			for k := j + 1; k < len(edges); k++ {
				if kijun < edges[k] {
					ans++
				} else {
					break
				}
			}
		}
	}
	fmt.Print(ans)

}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,M;
vector<pll> abv[101010];
ll mk[101010],mk2[101010];
ll ct[101010];
ll par[101010];
vector<pll> ansv;
queue<ll> qq;
ll i,j,k;

void dfs(ll a){
    
    ll i, j = 0;
    fornum(i,0,abv[a].size()){
        pll b = abv[a][i];
        if(mk[b.second])
            continue;
        mk[b.second] = 1;
        if(par[b.first]==0){
            mk2[a]++;
            par[b.first] = a;
            dfs(b.first);
        }else{
            ansv.push_back({a,b.first});
            ct[a]++;
        }
    }
    if(mk2[a]==0)
        qq.push(a);
}


int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,M){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        abv[a].push_back({b,i});
        abv[b].push_back({a,i});
    }
    if(M%2){
        printf("-1");
        return 0;
    }
    par[1] = -1;
    dfs(1);
    //cout << qq.size();
    while(qq.size()){
        ll qa = qq.front();
        qq.pop();
        //printf("%lldo ", qa);
        if(qa==1)
            break;
        if(ct[qa]%2){
            ansv.push_back({qa,par[qa]});
            ct[qa]++;
        }else{
            ansv.push_back({ par[qa],qa});
            ct[par[qa]]++;
        }
        mk2[par[qa]]--;
        if(mk2[par[qa]]==0){
            qq.push(par[qa]);
        }
    }
    fornum(i,0,ansv.size()){
        printf("%lld %lld\n", ansv[i].first, ansv[i].second);
    }

    return 0;
}

Measured memory_bytes: 18032
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	ll l, r;
	cin >> l >> r;
	ll m = 2019;
	for(ll i = l; i <= min(r,l + 2019LL); i++){
		for(ll j = i+1; j <= min(r,l + 2019LL); j++){
			m = min(m, ((ll) i*j)%2019);
		}
	}
	cout << m << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
void tansaku(int x,int y,int *n,int d[21][21]){
	if(d[y][x]==1){
		*n=*n-1;
		d[y][x]=0;
	}
	
}
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int d[21][21]={0};
		int a,b;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			d[b][a]=1;
		}
		int m;
		int x=10,y=10;
		cin>>m;
		int k;
		string s;
		for(int i=0;i<m;i++){
			cin>>s>>k;
			for(int j=0;j<k;j++){
			if(s=="N")
				y++;
			else if(s=="S")
				y--;
			else if(s=="E")
				x++;
			else
				x--;
			tansaku(x,y,&n,d);
	}
		}
		if(n!=0)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
		
	}
}

Measured memory_bytes: 1200
def calculate_mean(data):
        s = sum(data)
        n = len(data)
        mean = s/n
        return mean

def find_difference(data):
    mean = calculate_mean(data)
    diff = []

    for num in data:
        diff.append(num - mean)
    return diff

def calculate_variance(data):
    diff = find_difference(data)
    #差の２乗を求める
    squared_diff = []
    for d in diff:
        squared_diff.append(d ** 2)

    #分散を求める
    sum_squared_diff = sum(squared_diff)
    variance = sum_squared_diff / len(data)
    return variance
    
while True:
    num = int(input())
    if num == 0:
        break
    
    if __name__ == '__main__':
        data = [int(i) for i in input().split()]
        variance = calculate_variance(data)
        std = variance**0.5
        print(std)


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

using ll = long long;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), l(N), r(N);
    rep(i, N) cin >> A[i];
    l[0] = A[0];
    rep(i, N - 1) l[i + 1] = gcd(l[i], A[i + 1]);
    r[0] = A[N - 1];
    rep(i, N - 1) r[i + 1] = gcd(r[i], A[N - 2 - i]);
    ll ans = max(l[N - 2], r[N - 2]);
    rep(i, N - 2) {
        ans = max(ans, gcd(l[i], r[N - 3 - i]));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;


int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h.at(i);

	int count = 0;
	rep(i, n) {
		if (h.at(i) >= k) ++count;
	}

	cout << count << endl;
}

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

struct Vertex{
	int key;
	int parent;
	int left;
	int right;
};

vector<Vertex> V;
int root=-1;

void Preorder(int r){
	cout <<" "<< V[r].key;
	if(V[r].left!=-1) Preorder(V[r].left);
	if(V[r].right!=-1) Preorder(V[r].right);
	return;
}

void Inorder(int r){
	if(V[r].left!=-1) Inorder(V[r].left);
	cout <<" "<< V[r].key;
	if(V[r].right!=-1) Inorder(V[r].right);
	return;
}

void Postorder(int r){
	if(V[r].left!=-1) Postorder(V[r].left);
	if(V[r].right!=-1) Postorder(V[r].right);
	cout <<" "<< V[r].key;
	return;
}

void insert(int k){
	Vertex z;
	z.key=k;
	z.left=-1;
	z.right=-1;
	
	int y=-1;
	int x=root;
	while(x!=-1){
		y=x;
		if (z.key<V[x].key){
			x=V[x].left;
		}else{
			x=V[x].right;
		}
	}
	z.parent=y;
	V.push_back(z);
	
	if(y==-1){
		root = 0;
	}else if(z.key < V[y].key){
		V[y].left=V.size()-1;
	}else{
		V[y].right=V.size()-1;
	}
}

void printVertex(int i){
	cout << V[i].key <<" " <<V[i].parent <<" " << V[i].left << " " << V[i].right <<endl;
}

void print(){
	Inorder(root);
	cout <<endl;
	Preorder(root);
	cout <<endl;
}

bool find(int k){
	int v=root;
	while(1){
		if(k == V[v].key){
			return true;
		}else if(k < V[v].key){
			if(V[v].left==-1){
				return false;
			}else{
				v=V[v].left;
			}
		}else{
			if(V[v].right==-1){
				return false;
			}else{
				v=V[v].right;
			}
		}
	}
}

int main(){
	int n,k;
	string s;
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> s;
		if(s=="insert"){
			cin >> k;
			insert(k);
		}else if(s=="find"){
			cin >> k;
			if(find(k)){
				cout <<"yes"<<endl;
			}else{
				cout << "no" <<endl;
			}
		}else{
			print();
		}
	}
	/*
	for(int i=0;i<n;i++){
		printVertex(i);
		cout <<endl;
	}
	*/
	return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());

            int[] amida = new int[w];
            for (int i = 1; i <= w; i++)
            {
                amida[i - 1] = i;
            }

            for (int j = 0; j < n; j++)
            {
                string[] array = Console.ReadLine().Split(',');
                int a = int.Parse(array[0]);
                int b = int.Parse(array[1]);
                int tmp = amida[a - 1];
                amida[a - 1] = amida[b - 1];
                amida[b - 1] = tmp;

            }

            foreach (int am in amida)
            {
                Console.WriteLine(am);
            }

        }
    }
}

Measured memory_bytes: 5596
function Main(input){
var r = input.split(" ")[0];
var D = input.split(" ")[1];
var x2000 = input.split(" ")[2];
r = parseInt(r,10);
D = parseInt(D,10);
x2000 = parseInt(x2000,10);
for(i=1;i<=10;i++){
  if(i==1){
  var a=0;
  a = (r*x2000)-D;
  console.log(a);
  }else{
    a = (r*a)-D;
    console.log(a);
  }
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));



Measured memory_bytes: 7628
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = 16714589;
const int N = 1e5 + 555; // TL MB
const double PI = acos(-1.0);
double eps = 1e-6;

void solve()
{
	string s;
	cin >> s;
	cout << (s == "ABC" ? ("ARC") : "ABC");
}


 
 
int main()
{
	Red;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
  	int T = 1; 
  	//cin >> T; 
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n){
    //rep(j,m) cin >> a[i][j]; 
  //}
 
int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i]; 
  vector<ll> AB;
  rep(i,x) rep(j,y) AB.push_back(a[i]+b[j]);
  sort(AB.begin(),AB.end());
  reverse(AB.begin(),AB.end()); 
  vector<ll> ABC;
  for(int i=0; i<min(k,(int)AB.size()); i++){
    rep(j,z) ABC.push_back(AB[i]+c[j]);
  }
  sort(ABC.begin(),ABC.end());
  reverse(ABC.begin(),ABC.end());
  rep(i,k) cout << ABC[i] << endl;
} 

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

set<int> adj[29];

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0; i < n; ++i)
		adj[s[i] - 'a'].insert(i + 1);
	int q;
	cin >> q;
	while(q--) {
		int t;
		cin >> t;
		if(t == 1) {
			int left; char c;
			cin >> left >> c;
			for(int i = 0; i < 27; ++i) {
				if(adj[i].find(left) != adj[i].end()) {
					adj[i].erase(left);
				}
			}
			adj[c - 'a'].insert(left);
		}
		else {
			int left, right, answer = 0;
			scanf("%d%d", &left, &right);
			set<int> :: iterator it;
			for(int i = 0; i < 27; ++i) {
				it = adj[i].lower_bound(left);
				answer += (it != adj[i].end() && *it <= right && *it >= left);
			}
			cout << answer << '\n';
		}
	}
}


Measured memory_bytes: 27212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionA
	{
		public static void Main(string[] args)
		{
			var nd = Console.ReadLine().Split(" ").Select(s => long.Parse(s)).ToArray();
			var n = nd[0];
			var d = nd[1];

			var count = 0L;

			for(int i = 0; i < n; i++) {
				var xy = Console.ReadLine().Split(" ").Select(s => long.Parse(s)).ToArray();
				var x = xy[0];
				var y = xy[1];

				if(CheckDistance(x, y, d)) {
					count++;
				}
			}

			Console.WriteLine(count);
		}

		public static bool CheckDistance(long x, long y, long distance)
		{
			var d = (x * x) + (y * y);

			return d <= (distance * distance);
		}
	}
}


Measured memory_bytes: 41232
import java.nio.charset.IllegalCharsetNameException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String s = in.next();
        String t = in.next();

        int n = s.length();
        int m = t.length();

        int[][] dp = new int[n + 1][m + 1];



        for (int i = 0; i <= n; i++) {

            for (int j = 0; j <= m; j++) {


                if (i == 0 || j == 0) dp[i][j] = 0;

                else if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    //System.out.println(s.charAt(i-1)+" "+t.charAt(j-1)+" "+i+" "+j);
                    dp[i][j] = dp[i-1][j-1]+1;
                } else {

                    dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);

                }


            }


        }


//        for (int i = 0; i <= n; i++) {
//            for (int j = 0; j <= m; j++) {
//                System.out.print(dp[i][j] + " ");
//            }
//
//            System.out.println();
//
//        }

        StringBuffer lcs = new StringBuffer("");
        int i=n, j = m;
        while(i>0 && j>0) {
            if(s.charAt(i-1) == t.charAt(j-1)) {
                i--;j--;
                lcs.append(s.charAt(i));
            }
            else if(dp[i-1][j] > dp[i][j-1]) i-- ;
            else j--;
        }
        System.out.println(lcs.reverse().toString());
    }
}

Measured memory_bytes: 83020
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    long int Y; cin >> Y;
    int a; long int b;int c;
    a = 0; b = Y/5000; c = (Y-b*5000)/1000;
    int r = N-b-c; 
    if (r<=0){
        a = -r;
        b -= 2*a;
        if(b>=0) cout << a <<" "<< b << " " << c <<"\n";
        else cout << -1 <<" "<< -1 << " " << -1 <<"\n";
    }
    else {
        c += ((r+3)/4)*5;
        b -= (r+3)/4;
        a = -(N-b-c);
        b -= 2*a;
        if(b>=0) cout << a <<" "<< b << " " << c <<"\n";
        else cout << -1 <<" "<< -1 << " " << -1 <<"\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define MOD 1000000007
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define END system("PAUSE");return 0
int par[111111], ran[111111], siz[111111];
void init(int n) {
	rep(i, n) {
		par[i] = i;
		siz[i] = 1;
		ran[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
		siz[y] += siz[x];
	}
	else {
		par[y] = x;
		siz[x] += siz[y];
		if (ran[x] == ran[y])ran[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int size(int f) {
	return siz[find(f)];
}
int n, m, a[111111], b[111111], c[111111];
signed main() {
	cin >> n >> m;
	init(n);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	int ans = n * (n - 1) / 2;
	c[m - 1] = ans;
	for (int i = m - 2; i >= 0; i--) {

		if (!same(a[i + 1], b[i + 1])) {
			ans += size(a[i + 1]) * (size(a[i + 1]) - 1) / 2;
			ans += size(b[i + 1]) * (size(b[i + 1]) - 1) / 2;
			ans -= (size(a[i + 1]) + size(b[i + 1])) * (size(a[i + 1]) + size(b[i + 1]) - 1) / 2;
		}
		c[i] = ans;

		unite(a[i + 1], b[i + 1]);
		
	}
	rep(i, m)cout << c[i] << endl;
	END;
}


Measured memory_bytes: 6392
import Data.List(intercalate)
import Control.Applicative
main = do
  v <- map (map (read::String->Int) . words) . lines <$> getContents
  let u = map aux . map leap $ takeWhile (\x->x/=[0,0]) v  
  putStrLn $ intercalate "\n\n" u
  where
    aux::[Int] -> String
    aux [] = "NA"
    aux xs = intercalate "\n" $ map show $ xs

leap::[Int]->[Int]
leap (st:ed:_) = [y|y<-[st..ed], isleap y]
  where
    isleap y = (y `mod` 4 ==0 && y `mod` 100 /= 0) || y `mod` 400 == 0

Measured memory_bytes: 4364