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

using namespace std;

int main(void){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int> > a(n, vector<int>(m));
  
  for(int i = 0; i < n; ++i){
    cin >> c[i];
    for(int j = 0; j < m; ++j){
      cin >> a[i][j];
    }
  }

  bool can1 = false;
  int min = 0;
  for(int tmp = 0; tmp < (1 << n); ++tmp){
    bitset<12> s(tmp);
    bool can2 = true;
    for(int i = 0; i < m; ++i){
      int und = 0;
      for(int j = 0; j < n; ++j){
	if(s.test(j)){
	  und += a[j][i];
	}
      }
      if(und < x){
	can2 = false;
	break;
      }
    }
    if(can2){
      can1 = true;
      int cost = 0;
      for(int i = 0; i < n; ++i){
	if(s.test(i)){
	  cost += c[i];
	}
      }
      if(min > cost || min == 0){
	min = cost;
      }
    }
  }

  if(can1){
    cout << min << endl;
  }else{
    cout << "-1" << endl;
  }
}


Measured memory_bytes: 3600
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,h):
    for i in range(2, len(h)+1):
        if judge(h) : return print("Yes")
        if h[-i] - h[-i+1] >= 2 : return print("No")
        if h[-i] - h[-i+1] == 1 : h[-i] -= 1
    print("Yes" if judge(h) else "No")
    return
            

def judge(h):
    for i in range(len(h)-1):
        if h[i] > h[i+1] : return False
    return True

n = ii()
h = mi()
main(n,h)

Measured memory_bytes: 14588
#include<bits/stdc++.h>   
#define ll long long
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int n,m;
pair<pair<int,int>,int>a[100005];

int  sizea(int x){
    int d=x;
    int cnt=0;
    while(d){
        d/=10;
        cnt++;
    }
    return cnt;
}

bool cuunt(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b){
    return a.sc<b.sc;
}

signed main(){
    ios_base::sync_with_stdio(0);  cin.tie(); cout.tie();
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >> a[i].fr.fr >> a[i].fr.sc ;
        a[i].sc=i;
    }
    sort(a+1,a+m+1);
    int cnt[100005],ans[100005];
    for(int i=1;i<=m;i++){
        cnt[a[i].fr.fr]++;
        ans[a[i].sc]=cnt[a[i].fr.fr];
    }
    sort(a+1,a+m+1,cuunt);
    for(int i=1;i<=m;i++){
        int x=sizea(a[i].fr.fr);
        for(int i=1;i<=6-x;i++) cout<<0;
        cout<<a[i].fr.fr;
        x=sizea(ans[i]);
        for(int i=1;i<=6-x;i++) cout<<0;
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 5504
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int N, W, dummy;
	dummy = scanf("%d %d", &N, &W);

	int shinaWV[101][2];

	long long * dpNW[101];
	for (int i = 0; i < 101; i++) {
		dpNW[i] = new long long[100001];
	}

	int tmp1, tmp2;
	for (int i = 1; i <= N; i++) {
		dummy = scanf("%d %d", &tmp1, &tmp2);
		shinaWV[i][0] = tmp1;
		shinaWV[i][1] = tmp2;
	}

	int n, w, tmpW, tmpV;
	n = 1;
	tmpW = shinaWV[n][0];
	tmpV = shinaWV[n][1];
	for (int w = 0; w <= W; w++) {
	if (tmpW > w)
			dpNW[n][w] = 0;
		else
			dpNW[n][w] = tmpV;
	}
	for (int n = 2; n <= N; n++) {
		tmpW = shinaWV[n][0];
		tmpV = shinaWV[n][1];
		for (int w = 0; w <= W; w++) {
			// 1～n番までの品の中で、総重量w以下でのMAXVALUEを求める
			long long kouho1 = dpNW[n-1][w];
			long long kouho2 = (w - tmpW >= 0) ? dpNW[n-1][w-tmpW] + tmpV : 0;

			dpNW[n][w] = max(kouho1, kouho2);
		}
	}

	printf("%lld\n", dpNW[N][W]);
	
	return 0;
}


Measured memory_bytes: 78592
#include <iostream>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int N, K, A[200000], a[200000] = {0}, ans = 0, I = 1;

	cin >> N >> K;

	for (int n = 0,i = 0; n < N; n++) {
		cin >> A[n];
	}

	sort(A, A + N);

	a[0] = 1;
	for (int n = 1; n < N; n++) {
		if (A[n] != A[n - 1]) {
			a[I]++;
			I++;
		}
		else a[I - 1]++;
	}

	sort(a, a + I, greater<int>());

	for (;;) {
		if (I <= K)break;
		else if (I > K) {
			for (int i = I; i > 0; i--) {
				if (a[i] > 0) {
					a[i]--;
					a[0]++;
					if(!a[i])I--;
					ans++;
					break;
				}
			}
		}
	}

	cout << ans;

	return 0;
}

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

int main(){
	int n;
	int ans = 0;
	pair<int,int> a[100],b[100];
	bool flag[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i].first,&a[i].second);
		flag[i] = true;
	}
	for(int i=0;i<n;i++){
		scanf("%d%d",&b[i].first,&b[i].second);
	}
	sort(b,b+n);
	for(int i=0;i<n;i++){
		int k = 1000;
		for(int j=0;j<n;j++){
			if(a[j].first<b[i].first&&a[j].second<b[i].second&&flag[j]&&(k==1000||a[k].second<a[j].second)) k = j;
		}
		if(k!=1000){
			flag[k] = false;
			ans++;
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = 810;
int n, m, k;

char s[maxn][maxn];

int read() {
  if (scanf("%d%d%d", &n, &m, &k) < 3) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  return 1;
}

bool inside(int x, int y) {
  return 0 <= x && x < n && 0 <= y && y < m;
}

const int gox[] = {1, 0, -1, 0};
const int goy[] = {0, 1, 0, -1};

int dist[maxn][maxn];

pair<int, int> st[maxn * maxn];

void solve() {
  int x0 = -1, y0 = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == 'S') {
        s[i][j] = '.';
        x0 = i, y0 = j;
      }
    }
  }
  assert(x0 != -1);

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      dist[i][j] = inf;
    }
  }
  int r = 0;
  st[r++] = mp(x0, y0);
  dist[x0][y0] = 0;

  for (int l = 0; l < r; ++l) {
    int x = st[l].first, y = st[l].second;
    for (int dir = 0; dir < 4; ++dir) {
      int nx = x + gox[dir], ny = y + goy[dir];

      if (!inside(nx, ny) || dist[nx][ny] <= dist[x][y] + 1) {
        continue;
      }
      if (s[nx][ny] == '#') {
        continue;
      }
      dist[nx][ny] = dist[x][y] + 1;
      st[r++] = mp(nx, ny);
    }
  }

  r = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      auto &cur = dist[i][j];
      if (cur <= k) {
        //eprintf("start %d %d\n", i, j);
        cur = 0;
        st[r++] = mp(i, j);
      } else {
        cur = inf;
      }
    }
  }

  int res = inf;
  for (int l = 0; l < r; ++l) {
    int x = st[l].first, y = st[l].second;
    for (int dir = 0; dir < 4; ++dir) {
      int nx = x + gox[dir], ny = y + goy[dir];

      if (!inside(nx, ny)) {
        res = min(res, (dist[x][y] + k - 1) / k + 1);
      }

      if (!inside(nx, ny) || dist[nx][ny] <= dist[x][y] + 1) {
        continue;
      }
      dist[nx][ny] = dist[x][y] + 1;
      st[r++] = mp(nx, ny);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}

int main()
{
  int x;

  cin >> x;
  while (!is_prime(x))
    x++;
  cout << x << endl;
}

Measured memory_bytes: 3564
import java.io.*;
   
class Main{
    public static void main(String[] args) throws IOException{
 
        int x,y,d,r;
        double f;
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[] = br.readLine().split(" ");
        x = Integer.parseInt(str[0]);
        y = Integer.parseInt(str[1]);
 
        d = x / y;
        r = x % y;
        f = 1.0 * x / y;
 
        System.out.printf("%1d %1d %1.5f",d, r, f);
        }
}

Measured memory_bytes: 24832
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

namespace BF {

llong go(llong N, llong K) {
   if (N < K)
      return N;
   if ((N % K) == 0)
      return go(N / K, K);
   else
      return go(N % K, K);
}

vector<llong> solve(llong N) {
   vector<llong> res;
   for (llong K = 2; K <= N; ++K) {
      if (go(N, K) == 1) {
         res.push_back(K);
      }
   }
   return res;
}

}

namespace NT {

vector<llong> solve(llong N) {
   set<llong> S;

   // candidates below sqrt(N)
   for (llong k = 2; k*k <= N; ++k) {
      llong x = N;
      while (x >= k && (x % k) == 0)
         x /= k;
      if ((x % k) == 1)
         S.insert(k);
   }

   // candidates above sqrt(N)
   S.insert(N);
   const llong N1 = N-1;
   for (llong d = 1; d*d <= N1; ++d) {
      if ((N1 % d) == 0) {
         S.insert(N1 / d);
      }
   }
   S.erase(1);
   
   return vector<llong>(S.begin(), S.end());
}

}


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   llong N;
   cin >> N;
   auto V = NT::solve(N);
   cout << V.size() << endl;

/*
   for (llong N = 2; N <= 10000; ++N) {
      auto V1 = BF::solve(N);
      auto V2 = NT::solve(N);
      if (V1 != V2) {
         cerr << "Failed for N = " << N << endl;
         for (llong k : V1)
            cerr << k << ' ';
         cerr << endl;
         for (llong k : V2)
            cerr << k << ' ';
         cerr << endl;
      }
   }
*/

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int n,p;
int a1[40],a2[40];
 
void solve(int l,int r){
  if(l>r)return;
  if(l==r){
    if(a2[l]==a1[0])printf("%d",a2[l]);
    else printf("%d ",a2[l]);
    p++;
    return;
  }
 
  int x=a1[p],i;
  p++;
  for(i=l;i<=r;i++){
    if(a2[i]==x)break;
  }
  solve(l,i-1);
  solve(i+1,r);
   
  if(x==a1[0])printf("%d",x);
  else printf("%d ",x);
}
 
int main(){
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a1[i]);
  for(i=0;i<n;i++)scanf("%d",&a2[i]);
  p=0;
  solve(0,n-1);
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#5
N,M,C = map(int,input().split())
Bn = list(map(int,input().split()))
Sum,cou= 0,0

for i in range(N):
    An = list(map(int,input().split()))
    Sum = 0
    for j in range(M):
        Sum += An[j]*Bn[j]
        
    if Sum+C>0:
        cou += 1
        
print(cou)
        
    

Measured memory_bytes: 9168
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;
 
 
int main(){
 
  int k;
  cin >> k;
  
  int num[100010];
  REP(i,k) cin >> num[i];
  
  ll min = 2,max = 2;
  REP(i,k){
    
    min = num[k-1-i]* ceil((double)min/num[k-1-i]); //端数切り上げ
  //  debug(min);
    
    if(min > max) {
      cout << -1 << endl;
      return 0;
    }    
    

    max = num[k-1-i]* (max/num[k-1-i] + 1) - 1;
   // debug(max);
    
  }
  
  cout << min << " " << max << endl;
    
 return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
//template
int ans[530][530];
int N,k=1;
int line(int u,int v,int color){
  u%=k;v%=k;
  if(u>v)swap(u,v);
  if(ans[u][v])return -1;
  ans[u][v]=color;return 0;
}
void f(int s,int M,int d,int cnt){
  for(int j=1;j<=M/2;j+=2)
    for(int i=0;i<k;i+=d)
      if(line(s+i,s+i+j*d,cnt)<0)return;
  if(M==2){
    line(s+d/2,s+3*d/2,cnt);
    return;
  }
  f(s,M/2,d*2,cnt+1);
  f(s+d,M/2,d*2,cnt+1);
}
//main
signed main(){
  cin>>N;
  while(k<N)k<<=1;
  f(0,k,1,1);
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++)cout<<ans[i][j]<<" ";cout<<endl;
  }
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>

int main(void){
	
	double dis,p1[2],p2[2];

	scanf("%lf %lf %lf %lf",&p1[0],&p1[1],&p2[0],&p2[1]);
	
	dis=sqrt((p2[0]-p1[0])*(p2[0]-p1[0])+(p2[1]-p1[1])*(p2[1]-p1[1]));
	
	printf("%lf\n",dis);
	return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  string s[h];
  REP(i, h)
  {
    cin >> s[i];
  }

  REP(i, h)
  {
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

int main(){
    int h, w;
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw;
    int dh, dw;
    cin >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> maze(h);
    for (int i = 0; i < h; ++i) {
        cin >> maze[i];
    }

    int res[1010][1010];
    for (int i = 0; i < 1010; ++i) {
        for (int j = 0; j < 1010; ++j) {
            res[i][j] = INF;
        }
    }

    queue<pair<pii, int>> que;
    queue<pair<pii, int>> que2;
    res[ch][cw] = 0;
    que.push(make_pair(pii(ch, cw), 0));
    while(!que.empty()){
        pair<pii, int> p = que.front();
        que.pop();
        int x = p.first.first;
        int y = p.first.second;
        if (p.second > res[x][y]) continue;

        // 移動A
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (maze[nx][ny] == '#') continue;

            if (res[x][y] >= res[nx][ny]) continue;
            res[nx][ny] = res[x][y];
            que.push(make_pair(pii(nx, ny), res[nx][ny]));
        }
        // 移動B
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                if (i == 0 && j == 0) continue;
                int nx = x + i;
                int ny = y + j;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (maze[nx][ny] == '#') continue;

                if (res[x][y] + 1 >= res[nx][ny]) continue;
                res[nx][ny] = res[x][y] + 1;
                que2.push(make_pair(pii(nx, ny), res[nx][ny]));
            }
        }

        if (que.empty()){ // 歩き優先で
            while(!que2.empty()){
                pair<pii, int> p = que2.front();
                que2.pop();
                que.push(p);
            }
        }
    }

    cout << (res[dh][dw] == INF ? -1 : res[dh][dw]) << endl;
}


Measured memory_bytes: 9452
colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
cnt = 0
ip, jp, kp = -1, -1, -1

for i in range(a_max + 1):
    b_max = (n - a * i) // b
    d = n - a * i
    flag = 0
    for j in range(b_max + 1):
        c_max = (n - a * i - b * j) // c
        for k in range(c_max, c_max + 2):
            if a * i + b * j + c * k == n:
                cnt += 1
                if ip == i:
                    dj = j - jp
                    cnt += ((d // b - j) // dj)
                    flag = 1
                    break
                else:
                    ip, jp, kp = i, j, k
            elif a * i + b * j + c * k > n:
                break
        if flag == 1:
            break
print(cnt)

Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	int ans = 0;
	long long int a = 1;
	ans = (N-1)*(N)/2+(M-1)*(M)/2;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for _ in range(n)]
ans = 0
for k in range(n):
    ct = c
    for l in range(m):
        ct += a[k][l] * b[l]
    if ct > 0:
        ans += 1
    ct = 0
print(ans)


Measured memory_bytes: 3060
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    int r = 0;
    int A = N;
    while (true)
    {
        r += A % 10;
        A /= 10;
        if (A == 0)
            break;
    }
    if (N % r == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define ll long long

int func(int n){	//素数判定
	
	if(n==2)return 1;
	else{
		
		int i;
		for(i=2;i<=sqrt(n);i++){
			
			if(n%i==0)return 0;
			
		}
		return 1;
				
	}
	
}

int main(){
	
	int N,A[60];
	
	scanf("%d",&N);
	
	int num=11,cnt=0;
	while(cnt<=58){
		
		if(func(num)){
			
			A[cnt]=num;
			cnt++;
			
		}
		
		num+=10;
		
	}
	for(int i=0;i<N-1;i++){
		
		printf("%d ",A[i]);
		
	}
	printf("%d\n",A[N-1]);
	
return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()



struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i, h) cin >> c[i];
    i64 ans = 0;
    rep(i, (1LL)<<h){
        rep(j, (1LL)<<w){
            i64 cnt = 0;
            rep(x, h){
                rep(y, w){
                    if((i & ((1LL)<<x)) || (j & (1LL<<y))) continue;
                    if(c[x][y] == '#') ++cnt;
                }
            }
            if(cnt == k) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> botton(N);
  int A=1; //ボタン番号
  int number=0; //回数
  for(int i=0; i<N; i++){
    cin >> botton.at(i) ;
  }
  
  for(int i=0; i<N; i++){
    A = botton.at(A-1);
    number++ ;
   if(A==2) {
     cout << number << endl;
     break;
   } 
  }
  
  if(A!=2){
    cout << -1 << endl;
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

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

signed main() {
  INIT;

  VAR(int, n);
  VAR(string, s);
  int ans = 0, cnt = 0;
  EACH(si, s) {
    cnt += (si == 'I' ? 1 : -1);
    ans = max(ans, cnt);
  }
  OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n;; cin >> n;
    ll x; cin >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);

    ll sum = 0;
    for(int i=0; i<n-1; i++){
        int tmp = a.at(i);
        int tmp2 = a.at(i+1);
        if(tmp>x){
            sum += a.at(i) - x;
            a.at(i) = x; 
        }
        if(a.at(i)+tmp2>x){
            sum += a.at(i+1) - (x - a.at(i)); 
            a.at(i+1) = x - a.at(i);
        }
    }

    cout << sum << endl;
    return 0;
}


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

const int INF = 1001001001;

int main(void){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  
  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i & 1){
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if(d[j] < x) ok = false;
    if(ok) ans = min(ans,cost);
  }
  
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
using namespace std;
#define dff 1e-9
int main(){
  double x[10],va,vb;
  for(;;){
    if(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&x[1],&x[2],&x[3],&x[4],&x[5],&x[6],&x[7],&x[8],&x[9],&va,&vb) == EOF) break;
    double l = 0,t,ll = 0;
    for(int i=0; i<10; i++) l+=x[i];
    t = l/(va+vb);
    l = t*va;
    for(int i=0; i<10; i++){
      ll+=x[i];
      if(ll>l || (-dff<ll-l && ll-l<dff)){
	cout <<i+1<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H,W,h,w;
    while (1) {
        scanf("%d %d",&H,&W);
        if (H == 0 && W == 0) {
            break;
        } else {
            for(h=0;h<H;h++){
                for(w=0;w<W;w++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 572
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

long manhattan(long x1, long y1, long x2, long y2)
{
    return abs(x2 - x1) + abs(y2 - y1);
}

void main()
{
    long n, l;
    scan(n, l);
    long sumf, minf = bignum;
    foreach (i; 0 .. n)
    {
        long f = l + i;
        minf = min(abs(minf), abs(f));
        sumf += f;
    }
    if (sumf >= 0)
        (sumf - minf).writeln();
    else
        (sumf + minf).writeln();
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

int main(){
	vi v(3);
	rep(i,3) v[i] = in.nextInt();
	sort(all(v));
	cout<<(v==vi{5,5,7}?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
//dream,dreamer,erase,eraser

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main(){
	string s,s5,s6,s7;
	cin>>s;
	
	while(s.size()>=5){
		if(s.size()>=7){
			s5=s.substr(s.size()-5);
			s6=s.substr(s.size()-6);
			s7=s.substr(s.size()-7);
		}else if(s.size()==6){
			s5=s.substr(s.size()-5);
			s6=s.substr(s.size()-6);
			s7="0";
		}else if(s.size()==5){
			s5=s.substr(s.size()-5);
			s6="0";
			s7="0";
		}
		if(s5=="erase"||s5=="dream")s.erase(s.size()-5);
		else if(s6=="eraser")s.erase(s.size()-6);
		else if(s7=="dreamer")s.erase(s.size()-7);
		else break;
	}
  
	if(s.size()==0)cout<<"YES"<<"\n";
	else cout<<"NO"<<"\n";

	 return 0; 
}


Measured memory_bytes: 512
N,K=map(int,input().split())
mod=10**9+7
kaijo=[1]*(N+1)
for i in range(1,N+1):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*(N+1)
gyaku[N]=pow(kaijo[N],mod-2,mod)
for i in range(N,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
for i in range(1,K+1):
    if N-K+1<i:
        print(0)
        continue
    bunbo=gyaku[i]*gyaku[N-K+1-i]*gyaku[i-1]*gyaku[K-i]%mod
    bunsi=kaijo[N-K+1]*kaijo[K-1]%mod
    print(bunbo*bunsi%mod)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int m = t.length(), tmp = 0;
    int sl = s.length(), tl = t.length();
    for(int i = 0; i < sl - tl + 1;i++){
        tmp = 0;
        for(int j = 0; j< tl;j++){
            if(s[i+j] != t[j]) tmp += 1;
        }
        m = min(m,tmp);
    }
    cout<<m<<endl;
    return 0;
}  


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

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N; cin >> N;
    map<int, int> smp;
    REP(i, N){
        int D; cin >> D;
        ++smp[D];
    }
    int M; cin >> M;
    REP(i, M){
        int T; cin >> T;
        if(smp[T]) --smp[T];
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
while(1):
    [a,b,c,d,e]=[int(x) for x in raw_input().split()]
    if a==0:
        break
    else:
        [na,nb,nc]=[int(x) for x in raw_input().split()]
        if nc>=d:
            price=nc*e+nb*b+na*a
        else:
            if nb>=d-nc:
                price=min(d*e+(nb+nc-d)*b+na*a,nc*c+nb*b+na*a)
            elif na>=d-nc-nb:
                price=min(d*e+(na+nb+nc-d)*a,nc*c+nb*b+na*a)
            else:
                price=min(d*e,nc*c+nb*b+na*a)
        print price

Measured memory_bytes: 4240
#include<bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;
int main() {
    int n;
    cin>>n;
    int h[n];
    for(int i = 0;i<n;i++){
        cin>>h[i];
    }
    int ans[n];
    ans[0] = 0;
    ans[1] = abs(h[0] - h[1]);
    for(int i = 2;i<n;i++){
        ans[i] = min(ans[i-1]+abs(h[i] - h[i-1])
                ,ans[i-2] + abs(h[i] -h[i-2]));
    }
    cout<<ans[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=100000;

int main(){
    
    ll ans[maxn+1]={0};
    bool can[maxn+1]={0};
    int n,m;
    ll mod=INF;
    cin >> n>>m;
    
    rep(i,m){
        int a;cin >> a;
        can[a]=true;
    }
    
    ans[0]=1;
    if(!can[1])ans[1]=1;
    
    for(int i=2;i<=n;i++){
        if(can[i-2]&&can[i-1]){
            continue;
        }else if(can[i-1]){
            ans[i]=ans[i-2];
        }else if(can[i-2]){
            ans[i]=ans[i-1];
        }else{
            ans[i] = (ans[i-1]+ans[i-2])%mod;
        }
    }
    
    cout << ans[n]<<endl;
    
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    int x,y;
    cin >> x >> y;

    cout << x + y / 2 << endl;
    

    return 0;
}


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

using namespace std;
typedef long long ll;

bool pal (string s)
{
    for (int i = 0; i < s.length(); i++)
        if (s[i] != s[s.length()-1-i])
            return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);

    string S; cin >> S;

    int N = S.length();
    if (pal (S) && pal (S.substr(0, (N - 1) / 2)))
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
S = input()
l = len(S)-1

if (l % 2 == 0):
    ls = l/2
else: 
    ls = l//2 + 1
ls = int(ls)
    
n = 0
for x in range(ls):
    if (S[x] != S[l-x]):
        #S = S.replace(S[l-x],S[x])
        n = n + 1
        #print(n)
        
print(n)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <algorithm>
#define For(i,x,y) for(int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll a[maxn],b[maxn];
ll pre1[maxn],pre2[maxn];
int main()
{
    int n,m,k,x,pos;
    int ans=0;
    cin>>n>>m>>k;
    For(i,1,n)cin>>a[i];
    For(i,1,m)cin>>b[i];
    For(i,1,n)pre1[i]=pre1[i-1]+a[i];
    For(i,1,m)pre2[i]=pre2[i-1]+b[i];
    For(i,0,n)
    {
        if(pre1[i]<=k)
        {
            x=k-pre1[i];
            pos=lower_bound(pre2+1,pre2+1+m,x)-pre2;
            //cout<<i<<' '<<pos<<endl;
           // cout<<x<<' '<<b[pos]<<endl<<endl;
            if(pre2[pos]!=x&&pos>0)pos--;
            ans=max(i+pos,ans);
        }
        else break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
ll calc(ll x,ll bit) {
	x++; // 0の処理がうまくいかない
	ll res = 0;
	ll beki = pow(2, bit);
	ll cycle = beki * 2;
	res += x / cycle * beki;
	x %= cycle;
	x -= beki;
	res += max((ll)0, x);
	return res;
}
int main(){
	ll a, b;
	cin >> a >> b;
	if (a != 0) a--;
	VL bit(60, 0);
	VL minus(60, 0);
	int i;
	for (i = 0; i <= 59; i++) {
		bit[i] += calc(b, i);
		minus[i] += calc(a, i);
	}
	ll ans = 0;
	for (i = 0; i <= 59; i++) {
		if ((bit[i] - minus[i]) % 2) ans += pow(2, i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll K = input();
  
  ll N = input();

  vector<ll> A;

  for(ll i=0;i<N;i++){
    A.push_back(input());
  }

  vector<ll> diff;
  for(ll i=1;i<N;i++){
    diff.push_back(A[i] - A[i - 1]);
  }
  diff.push_back(A[0] + (K - A[A.size()-1]));

  ll sum = 0;
  ll max = 0;
  for(auto iter:diff){
    sum += iter;
    chmax(max, iter);
  }
  
  output(sum - max);
 
  return 0;
}


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

int main()
{
	int num1, num2, sum;

	while(cin >> num1 >> num2){
		
		int count = 0;
		sum = num1 + num2;
		
		while(sum != 0){
			sum /= 10;
			count++;
		}
		
		cout << count << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N;
		double M,SUM;

		try {
			while((N = Integer.parseInt(br.readLine())) != 0){

				String input[] = br.readLine().split("\\s+");
				double array[] = new double[input.length];

				SUM = 0;

				for(int i = 0; i < input.length; i++){
					array[i] = Double.parseDouble(input[i]);
					SUM += array[i];
				}

				M = SUM/(double)N;
				SUM = 0;

				for(int i = 0; i < array.length; i++){
					SUM += (array[i]-M)*(array[i]-M);
				}

				System.out.printf("%.10f\n", Math.sqrt(SUM/(double)N));
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 27536
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    int N;
    cin >> N;
    map<int, int> ans;
    FOR(x, 1, 101){
    FOR(y, 1, 101){
    FOR(z, 1, 101){
        int key = x*x + y*y + z*z + x*y + y*z + z*x;
        ans[key]++;
    }}}
    FOR(i, 1, N+1) out(ans[i]);
}
int main() {
    INCANT;
    solve();
    return 0;
}




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

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

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


int main (){
    int N;
    cin>>N;
    int keta=1;
    int TempN=N;
    while(TempN>9){
        TempN/=10;
        keta ++;
    }
   //cout<<keta<<endl;
    int sum =0;
    for(double i=0; i<(keta)/2; i ++){
        sum +=9*pow(10, i*2);
    }
  	if(keta%2==1){
      sum+=N-pow(10, keta-1)+1;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
//--------O&Oo&oO&O---------------

#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

using in=long long int;

void SOLVE()
{
	
   int n,k;
   cin>>k>>n;
   vector<int> v(n);
   for(int i=0;i<n;i++)
   	cin>>v[i];
int mn=1e9;
for(int i=0;i<n;i++)
{
	int l,r;
	if(i-1<0)
		l=v[n-1]-v[0];
	else
		l=k-v[i]+v[i-1];
	if(i+1>=n)
		r=v[n-1]-v[0];
	else
		r=k-v[i+1]+v[i];
	//cout<<l<<" "<<r<<"\n";
	mn=min(mn,min(l,r));

}

cout<<mn<<"\n";

}

int main()
{
	FAST_IO
	
	SOLVE();

	return 0;
}


Measured memory_bytes: 1024
import sys

n = int(input())

words = {}
latest = ''

for i in range(n):
    text = input()
    if latest != '':
        if latest[len(latest) -1] != text[0]:
            print("No")
            sys.exit()
    latest = text
    if text in words:
        print("No")
        sys.exit()
    words[text] = 1

print("Yes")

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

struct Rect {
    int h, w, d;
    Rect(int _h, int _w) : h(_h), w(_w) {
        d = _h * _h + _w * _w;
    }
    bool operator>(const Rect y) const {
        return (this->d > y.d) || (!(this->d > y.d) && (this->h > y.h));
    }
    bool operator<(const Rect y) const {
        return (this->d < y.d) || (!(this->d < y.d) && (this->h < y.h));
    }
};

int main() {
    vector<Rect> List;
    for (int h = 1; h <= 150; ++h) {
        for (int w = h + 1; w <= 150; ++w) {
            List.push_back(Rect(h, w));
        }
    }
    sort(List.begin(), List.end());

    /*
    for (auto &p : List) {
        cout << p.h << " " << p.w << " " << p.d << endl;
    }
    */

    while (true) {
        int h, w;
        cin >> h >> w;
        if (h == 0) break;

        for (int i = 0; i < List.size(); ++i) {
            if (h == List[i].h && w == List[i].w) {
                cout << List[i + 1].h << " " << List[i + 1].w << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  if(A+B<24) {
cout<<A+B<<endl;
  }
  else {
cout<<A+B-24<<endl;
  }
}

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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int MOD = 1e9 + 7;



int main(){
  int n; cin >> n;
  vi A(n); REP(i, n) cin >> A.at(i);
  sort(A.begin(), A.end());
  int s = A.size();
  int hd = A.front(), tl = A.back();
  ll ans = tl - hd;
  for(int i = 1; i < s/2;i++){
    if(i % 2 == 1){
      ans += tl - A[i];
      tl = A[i];
      ans += A[s - i - 1] - hd;
      hd = A[s - i - 1];
    }
    else{
      ans += hd - A[i];
      hd = A[i];
      ans += A[s - i - 1] - tl;
      tl = A[s - i - 1];
    }
  }
  if(s % 2 == 1) ans += MAX( abs(A[s/2] - hd), abs(A[s/2] - tl));
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    sort(a.rbegin(), a.rend());
    priority_queue<pair<ll, ll> > pq;
    pq.push(make_pair(a[0], a[0]));
    for (int i = 1; i < n; i++) {
        pair<ll, ll> p = pq.top();
        pq.pop();
        ans += p.first;
        pq.push(make_pair(a[i], p.first));
        pq.push(make_pair(a[i], p.second));
    }
    cout << ans << endl;
}


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

struct second_order {
    bool operator()(const pair<string, int>& x, const pair<string, int>& y) const {
        return x.second < y.second;
    }
};

int main() {
    map<string, int> table;
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        table[s]++;
    }
    int M; cin >> M;
    for (int i = 0; i < M; i++) {
        string s;
        cin >> s;
        table[s]--;
    }
    priority_queue<pair<string, int>, vector<pair<string, int>>, second_order> que;
    for (auto p : table) {
        que.push(p);
    }
    if (que.top().second < 0) {
        cout << 0 << endl;
    } else {
        cout << que.top().second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
	int H, W, N;
	cin >> H >> W >> N;

	int SR, SC;
	cin >> SR >> SC;

	string S, T;
	cin >> S >> T;

	vector<char> dirs(4);
	dirs[0] = 'U', dirs[1] = 'R', dirs[2] = 'D', dirs[3] = 'L';

	vector<char> dirt(4);
	dirt[0] = 'D', dirt[1] = 'L', dirt[2] = 'U', dirt[3] = 'R';

	bool flag = false;
	for (int j = 0; j < 4 && !flag ; j++) {
		int sr = SR, sc = SC;
		for (int i = 0; i < N; i++) {
			if (S[i] == dirs[j]) {
				if (S[i] == 'U') sr--;
				if (S[i] == 'R') sc++;
				if (S[i] == 'D') sr++;
				if (S[i] == 'L') sc--;
			}
			if (sr<=0 || sr>H || sc<=0 || sc>W) {
				flag = true;
				break;
			}
			if (T[i] == dirt[j]) {
				if (T[i] == 'U' && sr != 1) sr--;
				if (T[i] == 'R' && sc != W) sc++;
				if (T[i] == 'D' && sr != H) sr++;
				if (T[i] == 'L' && sc != 1) sc--;
			}
		}
	}

	if (!flag)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 776
#include<stdio.h>

int main(void)
{
	unsigned long int a, b, c[1000], temp;
	unsigned long int sum = 0;
	int i, j;

	scanf("%ld%ld", &a, &b);

	for (i = 0; i < a; i++) {
		scanf("%ld", &(c[i]));
	}

	for (i = a - 1; i > 0; i--) {
		for (j = 0; j < i; j++) {
			if (c[j] > c[j + 1]) {
				temp = c[j];
				c[j] = c[j + 1];
				c[j + 1] = temp;
			}
		}
	}

	for (i = 0; i < b; i++) {
		sum = sum + c[i];
	}

	printf("%ld", sum);

	return 0;
}

Measured memory_bytes: 1744
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{	
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MAX_N 5001
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

double x[10], y[10];

int main(){
	while (cin>>x[0]>>y[0]){
		FOR(i, 1, 4) cin >> x[i] >> y[i];
		if (abs((x[1] - x[0])*(x[3] - x[2])
			+ (y[1] - y[0])*(y[3] - y[2])) < EPS){
			cout << "YES\n";
		}
		else cout << "NO\n";
	}
}

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

const long long mod = 1000000007;
const long long M = 1000000007;

vector<ll> fact(1e7, 1);

inline long long mpow(long long b, long long ex){
    if (b==1)return 1;
    long long r = 1;
    while (ex ){
        if (ex&1)r=(r * b)%mod;
        ex = ex >> 1;
        b = (b * b)%mod;}
    return r;
}

// To compute x^y under modulo m 
ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 


  
// Function to find modular inverse of a under modulo m 
// Assumption: m is prime 
ll modInverse(ll a, ll m) 
{
    return power(a, m-2, m); 
}


int main() {
    ll x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
    } else {
        ll m = (2 * x - y) / 2;
        ll n = (y - m) / 2;

        if ( 2*x < y or 2*y < x or (2*x-y)%3!=0 or (2*y-x)%3!=0) {
            cout << 0 << endl;
        } else {
            for (int i = 2; i <= n + m; i++) {
                fact[i] = (i * fact[i - 1]) % M;
            }

            cout << (fact[(x+y)/3] * ((modInverse(fact[(2*x-y)/3], M) * modInverse(fact[(x+y)/3-(2*x-y)/3], M)) % M )) % M << endl;
        }
    }
}

Measured memory_bytes: 78336