akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=1e6+9;
	inline bool Lucas(int n,int m){
		if(m==0) return 1;
		return (m&1)<=(n&1) && Lucas(n/2,m/2);
	}
	int n,a[N];
	inline bool check(){
		int ret=0;
		for(int i=1;i<=n;i++)
			if(Lucas(n-1,i-1) && a[i]&1) ret^=1;
		return ret;
	}
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++){
			char c;cin>>c;
			a[i]=c-'0';
		}
		for(int i=1;i<n;i++) a[i]=abs(a[i]-a[i+1]);
		n--;

		if(check()) puts("1"),exit(0);
		else{
			for(int i=1;i<=n;i++)
				if(a[i]&1) puts("0"),exit(0);
			for(int i=1;i<=n;i++) a[i]>>=1;
			if(check()) puts("2");
			else puts("0");
		}
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int w, h;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  for(;;) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    vector<vector<vector<P>>> g(h, vector<vector<P>>(w));
    rep(i,2*h-1) {
      if(i%2) {
        rep(j,w) {
          int c;
          cin >> c;
          if(!c) g[i/2][j].push_back({i/2+1, j}), g[i/2+1][j].push_back({i/2, j});
        }
      }
      else {
        REP(j,1,w) {
          int c;
          cin >> c;
          if(!c) g[i/2][j-1].push_back({i/2, j}), g[i/2][j].push_back({i/2, j-1});
        }
      }
    }
    queue<P> q;
    q.push({0, 0});
    vector<vector<int>> dst(h, vector<int>(w, -1));
    dst[0][0] = 0;
    while(!q.empty()) {
      int y = q.front().first, x = q.front().second; q.pop();
      for(P v : g[y][x]) {
        int ny = v.first, nx = v.second;
        if(ny < 0 || h <= ny || nx < 0 || w <= nx || dst[ny][nx] != -1) continue;
        dst[ny][nx] = dst[y][x]+1;
        q.push({ny, nx});
      }
    }
    int ans = dst[h-1][w-1]+1;
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

const int N=30;
int n,m,c,ans;
int b[N];

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
int main(){
	n=readint(),m=readint(),c=readint();
	rep(i,1,m)b[i]=readint();
	rep(i,1,n){
		int cur=0,a;
		rep(j,1,m)a=readint(),cur+=a*b[j];
		if(cur+c>0)++ans;
	}
	printf("%d",ans);
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	if (x < y) {
		cout << min(y - x, abs(x + y) + 1) << endl;
	}
	else {
		cout << min(abs(x + y) + 1, x - y + 2) << endl;
	}
}


Measured memory_bytes: 256
# require 'prime'
# N = gets.to_i
# pd = N.prime_division
# ns = [1] + pd.flat_map { |n, e| [n] * e }.sort
# while ns.size > 2
#   a = ns.shift
#   b = ns.shift
#   c = a * b
#   ns = (ns + [c]).sort
# end

# x, y = ns
# ans = (x - 1) + (y - 1)
# puts ans

N = gets.to_i
ans = 1 << 60
(1..(Math.sqrt(N))).each do |n|
  if N % n == 0
    m = N / n
    step = (n - 1) + (m - 1)
    ans = step if step < ans
  end
end
puts ans


Measured memory_bytes: 1916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
int n, tot;
int a[2][(int)8e5+5], b[2][(int)8e5+5];
struct node {
	int L, R, x0, x1, y0, y1;
} ;
bool operator < (const node t1, const node t2) {
	if (t1.y0 != t2.y0) return t1.y0 > t2.y0;
	return t1.y1 > t2.y1; 
}
priority_queue <node> q;

void input (int k, int l, int r) {
	if (l == r) { 
		if (l & 1) scanf ("%d", &a[1][k]), b[1][k] = l;
		else scanf ("%d", &a[0][k]), b[0][k] = l;
		return ;
	}
	int mid = l+r >> 1;
	input (k<<1, l, mid), input (k<<1|1, mid+1, r);
	if (a[0][k<<1] < a[0][k<<1|1]) a[0][k] = a[0][k<<1], b[0][k] = b[0][k<<1];
	else a[0][k] = a[0][k<<1|1], b[0][k] = b[0][k<<1|1];
	if (a[1][k<<1] < a[1][k<<1|1]) a[1][k] = a[1][k<<1], b[1][k] = b[1][k<<1];
	else a[1][k] = a[1][k<<1|1], b[1][k] = b[1][k<<1|1];
}

pair<int, int> query (int k, int l, int r, int L, int R, int ty) {
	if (L<=l && r<=R) { return make_pair (b[ty][k], a[ty][k]); }
	int mid = l+r >> 1;
	pair<int, int> t1(0, 0x7fffffff), t2(0, 0x7fffffff);
	if (L <= mid) t1 = query (k<<1, l, mid, L, R, ty);
	if (R > mid) t2 = query (k<<1|1, mid+1, r, L, R, ty);
	if (t1.second < t2.second) return t1;
	else return t2;
}

node Query (int L, int R) {
	pair<int, int> t1 = query (1, 1, n, L, R-1, L&1);
	pair<int, int> t2 = query (1, 1, n, t1.first+1, R, (t1.first+1)&1);
	return (node) { L, R, t1.first, t2.first, t1.second, t2.second };
}

int main() {
	int i,j,k;
	memset (a, 127, sizeof (a));
	memset (b, 127, sizeof (b));
	scanf ("%d", &n);
	input(1, 1, n);
	q.push ( Query (1, n) );
	while (q.size()) {
		node t1 = q.top(); q.pop();
		printf ("%d %d ", t1.y0, t1.y1);
		if (t1.L != t1.x0) q.push ( Query (t1.L, t1.x0-1) );
		if (t1.x0 + 1 != t1.x1) q.push ( Query (t1.x0+1, t1.x1-1) );
		if (t1.x1 != t1.R) q.push ( Query (t1.x1+1, t1.R) );
	}
	return 0;
} 

Measured memory_bytes: 15092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int n, m, a;
    scan2Int(n, m);
    rep(i, m) {
        scanInt(a);
        n -= a;
    }
    if (n < 0)
        printInt(-1);
    else
        printInt(n);
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 500003
typedef long long ll;
inline ll mod(ll x,ll n)
{
    if(x<n)
    {
        return x;
    }
    return x-n;
}
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

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


 ll sum=0,act=0,k,q,f;

string s,t;
cin>>s>>t;
ll n=s.length(),m=t.length();
ll dp[n+1][m+1];
forr(i,0,n+1)
{
    forr(j,0,m+1)
    {
        dp[i][j]=0;
    }
}
forr(i,1,n+1)
{
    forr(j,1,m+1)
    {
        if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
        else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }
}
// forr(i,0,n+1)
// {
//     forr(j,0,m+1)cout<<dp[i][j]<<" ";
//     cout<<endl;
// }
ll i=n,j=m;
string p="";
while(i>0 && j>0)
{
    if(dp[i][j]==1+dp[i-1][j-1] && s[i-1]==t[j-1])
    {
        p+=s[i-1];
        i--;j--;
    }
    else
    {
        if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
}
reverse(all(p));
cout<<p<<endl;
return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=1e9+7;


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

    ll n,m,x;
    cin>>n>>m>>x;
    vector<ll> c(n);
    vector<vector<ll>> a(n,vector<ll>(m));
    for(ll i=0;i<n;i++){
        cin>>c[i];
        for(ll j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    ll ans=INF;
    for(ll i=0;i<1<<n;i++){
        vector<ll> b(m);
        ll sum=0;
        for(ll j=0;j<n;j++){
            if(1<<j&i){
                sum+=c[j];
                for(ll k=0;k<m;k++)
                    b[k]+=a[j][k];
            }
        }
        ll f=1;
        for(ll j=0;j<m;j++){
            if(b[j]<x){
                f=0;
                break;
            }
        }
        if(!f) continue;
        ans=min(ans,sum);
    }
    if(ans==INF)
        cout<<-1;
    else
        cout<<ans;


    return 0;
}


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

int main() {
  int a, b, c, h, w, n;
  cin >> h >> w >> n;
  a = max(h, w);
  b = n / a;
  c = n * 100 / a % 100;
  if (c != 0) {
    b += 1;
  }
  cout << b << endl;
}


Measured memory_bytes: 256
import Data.List
 
main = do
  [n, p] <- readNums
  as <- readNums
  print $ f p (g as)
 
readNums = map read . words <$> getLine
 
g as = (x, y)
  where 
    x = length . filter even $ as
    y = length . filter odd $ as
 
f p (x, 0) = (2 ^ x) * (1 - p)
f p (x, y) = 2 ^ (x + y - 1)

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string W[100];
  cin >> N;
  string ans = "Yes";
  for(int i = 0; i < N && ans == "Yes"; i++){
    cin >> W[i];
    for(int j=0;j<i;j++){
      if(W[i]==W[j]){
        ans = "No";
        break;
      }
    }
  }
  for(int i = 1; i < N && ans == "Yes"; i++){
    if(W[i-1][W[i-1].size()-1]!=W[i][0]){
      ans = "No";
      break;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n,k,r,s,p;
	cin >> n >> k >> r >> s >> p;
	string t;
	cin >> t;
	int ans = 0;
	for(int i=0;i<k;i++){
		int pre = 0;
		int now = 0;
		for(int j=i;j<(int)t.size();j+=k){
			if(j==i){
				if(t[j]=='r'){
					now += p;
					pre = 0;//p
				}else if(t[j]=='s'){
					now += r;
					pre = 1;//r
				}else{
					now += s;
					pre = 2;//s
				}
			}else{
				if(t[j]=='r'){
					if(pre==0) pre = 3;
					else{
						pre = 0;
						now += p;
					}
				}else if(t[j]=='s'){
					if(pre==1) pre = 3;
					else{
						pre = 1;
						now += r;
					}
				}else{
					if(pre==2) pre = 3;
					else{
						pre = 2;
						now += s;
					}
				}
			}
		}
		ans += now;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int N = 1e3+5;
const int MOD = 1e9+7;

int n, m;
int dp[N][N];
string arr[N];

int solve(int i, int j){
	if(i >= n || j >= m || arr[i][j] == '#')
		return 0;
	if(i == n-1 && j == m-1)
	    return 1;
	int & cur = dp[i][j];
	if(~cur)
		return cur;
	return cur  = (solve(i+1, j)%MOD + solve(i, j+1)%MOD)%MOD;
}

int main()
{
    cin >> n >> m;
	clr(dp, -1);
    lp(i, n)
    	cin >> arr[i];
    cout << solve(0, 0);
    return 0;
}

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

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

  int ca = 0;
  int cb = 0; 
  int cc = 0;
  for (int i = 0; i < s.size(); i++) {
    switch (s[i])
    {
    case 'a':
      ca++;
      break;
    
    case 'b':
      cb++;
      break;
    
    case 'c':
      cc++;
      break;
    
    default:
      break;
    }
  }

  string r;
  if (abs(ca - cb) < 2 && abs(cb - cc) < 2 && abs(cc - ca) < 2) {
    r = "YES";
  } else {
    r = "NO";
  }

  cout << r << endl;
  return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

string S;

signed main() {
    cin >> S;
    int ans = 0;
    int black = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'B')black++;
        else ans += black;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long int ll;

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

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

    vector<ll> a(n);
    for (auto &x : a) {
        cin >> x;
    }

    vector<bool> dp(k + 1);
    dp[0] = false;

    for (ll j = 1; j <= k; j++) {
        bool allWinning = true;

        for (auto step : a) {
            if (step <= j) {
                if (!dp[j - step]) {
                    allWinning = false;
                    break;
                }
            }
        }

        dp[j] = !allWinning;
    }

    cout << (dp[k] ? "First" : "Second") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示
		int N= sc.nextInt();
      
		//N=1だったら表示
        //N=2だったら計算をする
		if(N==1) {
			System.out.println("Hello World");
			
		}else if(N==2) {
			int A= sc.nextInt();
			int B= sc.nextInt();
			System.out.println(A+B);
		}
	}
}

Measured memory_bytes: 20948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC084A
{
    class Program
    {
        static void Main(string[] args)
        {
            int M;
            M = int.Parse(Console.ReadLine());
            Console.WriteLine(48 - M);
        }
    }
}


Measured memory_bytes: 11092
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n;
void solve()
{
    cin>>n;ll ar[n];
    for(ll i=0;i<n;i++)
        cin>>ar[i];
    ans=maxval;
    for(ll i=1;i<=100;i++)
    {
        ll teans=0;
        for(ll j=0;j<n;j++)
            teans+=pow(abs(ar[j]-i),2);
        ans=min(teans,ans);
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

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

Measured memory_bytes: 3124
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int d, n;
    cin >> d >> n;

    int u = 1;
    for (int i = 0; i < d; ++i)
        u *= 100;

    if (n % 100 == 0)
        ++n;
    cout << (u * n) << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline

def Main():
    N = int(input())
    A = list(map(int, input().split()))

    if A.count(0):
        print(0)
        return

    ans = 1
    for a in A:
        ans = ans * a
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)

Main()

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

int gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}


int main(){
  long long A,B;
  cin >> A >> B;
  
  long long AB = A * B;
  long long ans = AB / gcd(A,B);
  cout << ans << endl;

}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=100010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
ll n,m;
ll sume[100010]={};
ll toe[100010]={};
ll memo[100010]={};
vector<vector<ll> >e(100005);
ll dfs(ll now){
  if(memo[now]>0)return memo[now];
  for(int i=0;i<e[now].size();i++){
    memo[now]=max(memo[now],dfs(e[now][i])+1);
    // cout<<now<<" "<<e[now][i]<<" "<<memo[now]<<endl;
  }
  return max(memo[now],0LL);
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    a--;b--;
    sume[a]++;sume[b]++;
    toe[a]++;
    e[a].pb(b);
  }
  ll ans=0;
  for(int i=0;i<n+10;i++)memo[i]=-1;
  for(int i=0;i<n;i++){
    if(sume[i]==toe[i]){
      dfs(i);
    }
  }
  for(int i=0;i<n+1;i++){
    ans=max(ans,memo[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,m,k;

int main() {
	cout << fixed << setprecision(18);
    cin>>n>>m>>k;
    if(n+m+k>=22){cout<<"bust";}
    else{cout<<"win";}
    
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<pair<int, int> > a;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a.emplace_back(make_pair(y, x));
    }
    sort(a.begin(), a.end());
    int time = 0;
    for (int i = 0; i < n; i++) {
        time += a[i].second;
        if (time > a[i].first) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
}

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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  cout << a[n-1]-a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl
#define V <<" "<<

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[200010];
vector<ll> va,vb,vc,vd,ve;
set<int> st;

int main(){
    cin>>a>>b;
    C max(0LL,a-b*2) E;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

# 整数の入力
N = int(input())

nn = np.sqrt(N)
ni = int(nn)

lis = []
for i in range(1, ni+1):
  if(N % i == 0):
    lis.append(i)

ii = lis[-1]
jj = int(N / ii)
step = (ii-1) + (jj-1)
# 出力
print("{}".format(step))


Measured memory_bytes: 12508
/**
 * Created by kagawa on 2017/07/29.
 */
function main(input){
    var num = [1, 2, 4, 8, 16, 32, 64];
    for(var i = num.length-1; i>=0; i--){
        if(input >= num[i]){
            console.log(num[i]);
            return;
        }
    }

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<stdio.h>
#include<string.h>

int main(){
  int n,m,i,j,lk=1,f;
  char dict[256][16],try[16];
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%s",dict[i]);}
  scanf("%d",&m);
  for(i=0;i<m;i++){
    f=0;
    scanf("%s",try);
    for(j=0;j<n;j++){
      if(strcmp(dict[j],try)==0){f=1;break;}
    }
    if(f==0){printf("Unknown %s\n",try);continue;}
    lk=1-lk;
    if(lk==0){printf("Opened by %s\n",try);}
    else{printf("Closed by %s\n",try);}
  }
  return 0;
}



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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int k,x;
    cin>>k>>x;
    puts(500*k>=x ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int k;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        int ans = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                for (int l = 1; l <= k; l++) {
                    ans += gcd(i, gcd(j, l));
                }
            }    
        }
        System.out.println(ans);
    }
    
    private int gcd(int a, int b) {
        int r = 0;
        if (a < b) {
            int tmp;
            tmp = a;
            a = b;
            b = tmp;
        }
        r = a % b;
        while (r != 0) {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }
}

Measured memory_bytes: 35740
l = int(input())
aList = [int(input()) for _ in range(l)]

INF = 10 ** 6

dp = [[INF] * (l + 1) for _ in range(5)]
for i in range(5):
    dp[i][0] = 0
for i in range(l):
    for state in range(5):
        if state == 4:
            dp[state][i + 1] = min(dp[j][i] for j in range(state + 1)) + aList[i]
        elif state == 3:
            dp[state][i + 1] = min(dp[j][i] for j in range(state + 1)) + (aList[i] % 2 if aList[i] != 0 else 2)
        elif state == 2:
            dp[state][i + 1] = min(dp[j][i] for j in range(state + 1)) + (aList[i] - 1) % 2

        elif state == 1:
            dp[state][i + 1] = min(dp[j][i] for j in range(state + 1)) + (aList[i] % 2 if aList[i] != 0 else 2)
        else:
            dp[state][i + 1] = min(dp[j][i] for j in range(state + 1)) + aList[i]
            
ans = INF
for i in range(5):
    ans = min(ans, dp[i][l])
print(ans)

Measured memory_bytes: 76252
import sys
from collections import deque
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    tree = [[] for _ in range(n)]
    parcount = [-1]*n
    for i in range(n+m-1):
        a, b = map(int, input().split())
        tree[a-1].append(b-1)
        parcount[b-1] += 1
    
    for i in range(n):
        if parcount[i] == -1:
            root = i
            break
    
    par = [0]*n
    dist = [0]*n
    not_yet = deque([root])
    while not_yet:
        key = not_yet.popleft()
        for v in tree[key]:
            if parcount[v]:
                parcount[v] -= 1
                continue
            par[v] = key+1
            dist[v] = dist[key]+1
            not_yet.append(v)
    
    for p in par:
        print(p)
 
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 31472
// AOJ 2882: Generalized Leap Years
// 2018.7.11 bal4u

#include <stdio.h>
#include <string.h>

int year[4001];
int A[50];

int main()
{
	int i, j, n, l, r, k, v, ans;
	
	while (scanf("%d%d%d", &n, &l, &r) && n) {
		for (i = 0; i < n; i++) scanf("%d", A+i);
		memset(year, 0, sizeof(year));
		v = 2 - (n&1);	// v = 1 if n is odd
		j = n;
		while (j--) {
			for (i = l/A[j]*A[j]; i <= r; i += A[j]) year[i] = v;
			v = 3-v;
		}
		ans = k = 0;
		for (i = l; i <= r; i++) {
			if (!year[i]) k++;
			else if (year[i] == 1) ans++;
		}
		if (!(n & 1)) ans += k;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>

#include <math.h>

typedef long long ll;

using namespace std;

 

ll dp[55][55][2551];

 

int main()

{

    int x[2550],n,a,i,j,k;

 

    cin>>n>>a;

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

 

    dp[0][0][0]=1;

 

    for(i=1;i<=n;i++)

    {

        for(j=i;j>=0;j--)

        {

            for(k=a*n+1;k>=0;k--)

            {

                dp[i][j][k]+=dp[i-1][j][k];

                if(k>=x[i-1] && j>=1)

                    dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]];

            }

        }

    }

    ll ans=0;

 

    for(i=1;i<=n;i++)ans+=(dp[n][i][i*a]);

 

    cout<<ans<<endl;

 

    return 0;

}


Measured memory_bytes: 55552
import java.util.*;

public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int a = scanner.nextInt();
      int b = scanner.nextInt();

      if (a <= 8 && b <= 8) {
        System.out.println("Yay!");
      } else {
        System.out.println(":(");
      }
    } finally {
      scanner.close();
    }
  }
}


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

int main() {
  int K, T; cin >> K >> T;
  vector<int> a(T);
  for (int i = 0; i < T; i++) cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());
  if (T == 1) { cout << K - 1 << endl; return 0; }
  for (int i = 1; i < T; i++) {
    a.at(i) = max(a.at(i-1), a.at(i)) - min(a.at(i-1), a.at(i)); 
  }
  cout << max(a.at(T-1) - 1, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll N,M;
string S="";
ll A[13],B[13];

int main(){
    string S,T;
    vector<string> V;
    cin >> S >> T;
    rep(i,S.size()-T.size()+1){
        ll F=0;
        Rep(j,i,i+T.size()){
            if(S[j]!=T[j-i] && S[j]!='?'){
                F=1;
                break;
            }
        }
        if(F==0){
            string K;K=S;
            Rep(j,i,i+T.size()){
                if(S[j]=='?'){
                    K[j]=T[j-i];
                }
            }
            rep(j,K.size()){
                if(K[j]=='?'){
                    K[j]='a';
                }
            }
            V.pb(K);
        }
    }
    if(V.size()==0){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(ALL(V));
    cout << V[0] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m,x;
    cin>>n>>m>>x;
    vi c(n);
    vvi a(n,vi(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m)cin>>a[i][j];
    }
    int ans=inf;
    rep(bit,1<<n){
        int t=0;
        vi b(m);
        rep(i,n){
            if(bit>>i&1){
                t+=c[i];
                rep(j,m)b[j]+=a[i][j];
            }
        }
        bool f=true;
        rep(i,m)f&=b[i]>=x;
        if(!f)continue;
        ans=min(ans,t);
    }
    cout<<(ans==inf?-1:ans)<<endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5+10;
#define ll long long
#define F first
#define S second

main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;cin>>s;
	int n=s.length();
	for(int i=2;i<n;i++)
		if(s[i]==s[i-1]&&s[i-1]==s[i-2])
			return cout<<"Yes",0;
	cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,x,y,result=0,ng=0;
  char a[100][100],b[100][100];
  
  scanf("%lld %lld",&n,&m);
  rep(i,n) scanf("%s",a[i]);
  rep(i,m) scanf("%s",b[i]);
  
  rep(x,n-m+1){
    rep(y,n-m+1){
      ng=0;
      rep(i,m){
        rep(j,m){
          if(a[y+j][x+i]!=b[j][i]){
            ng=1;
            break;
          }
        }
        if(ng==1) break;
      }
      if(ng==0){
        result=1;
        break;
      }
    }
    if(result==1) break;
  }
  if(result==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}



Measured memory_bytes: 128
S = input()
N = len(S)

if N == 2 and S[0] == S[1]:
    print(1, 2)
    exit()

for i in range(N-2):
    if len(set(S[i:i+3])) == 3:
        pass
    else:
        print(i+1, i+3)
        exit()

print(-1, -1)

Measured memory_bytes: 3188
N, M = map(int, input().split()) 

def comb(n, r):
    a = 1; b = 1
    for i in range(r):
        a *= (n-i)
        b *= (i+1)
    return a // b 


facts = []

i = 2
m = M
while i * i <= M:
    cnt = 0
    while m % i == 0:
        m //= i
        cnt += 1
    if cnt:
        facts.append(cnt)
    i += 1
if m > 1:
    facts.append(1)
D = 1000000007
res = 1
for f in facts:
    res = (res * comb(f + N - 1, f)) % D 
print(res)

Measured memory_bytes: 3064
S =input()
T =input()
mint=10000

for i in range(len(S)-len(T)+1):
    con = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            con += 1
            
    mint =min(con,mint)
    
    if mint == 0:
        break


print(mint)


Measured memory_bytes: 9052
#include <stdio.h>
int main(){
  int n,count,count2,temp;
  int mountain[10];
  for(n=0;n<10;n++){
    scanf("%d",&mountain[n]);
  }
  for(count=0;count<n;count++){
    for(count2=count;count2<n;count2++){
      if(mountain[count2]>mountain[count]){
        temp=mountain[count];
        mountain[count]=mountain[count2];
        mountain[count2]=temp;
      }
    }
  }
  for(n=0;n<3;n++) printf("%d\n",mountain[n]);
  return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;

    cout << n / 3 << endl;

    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cou<<""<<endl;

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






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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 3e5 + 100;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

ll a[20][20],c[1LL<<18],dp[1LL << 18];
int main(){
	fastio;
	ll tc,x,n,m;
	tc = 1;
	cin >> n;
	f(i,0,n) f(j,0,n) cin >> a[i][j];
	f(mask,1,1LL<<n){
		ll aux = 0;
		f(i,0,n) f(j,0,n) if( (mask &  (1LL<<i) )  &&  ( mask &  (1LL<<j)  ) ) aux +=a[i][j];
		c[mask] = aux>>1; 
	}
	f(mask,1,1LL << n){
		for(ll submask = mask; submask > 0; submask = (submask-1)& mask)
			dp[mask] = max(dp[mask],c[submask] + dp[mask^submask]);
	}
	cout << dp[(1LL << n) - 1]<< endl;
	return 0;
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
int n,k;
char s[100005];
int main(){
	scanf("%d%d%s",&n,&k,s+1);
	s[0]='R';s[n+1]='L';
	int cnt=0;
	for(int i=0;i<=n;i++){
		if(s[i]=='R'&&s[i+1]=='L')	cnt++;
	}
	cnt-=k;
	int ans=n-cnt*2;
	if(s[1]=='L')	ans++;
	if(s[n]=='R')	ans++;
	cout<<min(ans,n-1)<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cntw = 0;
  int cnte = 0;
  vi w(n);
  vi e(n);
  rep(i,n) {
    w.at(i) = cntw;
    if(s.at(i) == 'W') cntw++;
  }
  for(int i = n-1; i >= 0; i--) {
    e.at(i) = cnte;
    if(s.at(i) == 'E') cnte++;
  }
  int ans = INT_MAX;
  rep(i,n) {
    int cnt = w.at(i)+e.at(i);
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3076
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}
 
int main(){
  int n;
  cin >> n;
  string in;
  cin >> in;
  int r = 0, b = 0;
  rep(i,n){
    if (in[i] == 'R')r++;
    else b++;
  }
  if (r > b)cout <<"Yes" << endl;
  else cout <<"No" << endl;
  return 0;
}
 
 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n;
string s[DMAX];
map<string,ll> ma;
int main(){
	ll ans=0;
	read(n);
	for(ll i=1;i<=n;i++){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
		ans+=ma[s[i]];
		ma[s[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int H, W, N; cin >> H >> W >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  vector<vector<int>> ans(H);
  
  rep(i, N) {
    while(a[i] > 0) {
      rep(j, H) {
        while(W-ans[j].size() > 0 && a[i] > 0) {
          ans[j].push_back(i+1);
          a[i]--;
        }
      }
    }
  }
  
  rep(i, H/2) reverse(all(ans[2*i+1]));
  
  rep(i, H) {
    rep(j, W) cout << ans[i][j] << " ";
    cout << endl;
  }

}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int k;
  for(k = 0; k < s.size(); k++){
    for(char c = 'a'; c <= 'z'; c++){
      bool flag = false;
      for(int i = 0; i < s.size() - k; i++){
        bool exist = false;
        for(int j = i; j - i <= k; j++){
          if(s[j] == c){
            exist = true;
            break;
          }
        }
        if(!exist){
          flag = true;
          break;
        }
        if(i == s.size() - k - 1){
          cout << k << endl;
          return 0;
        }
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256
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;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

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;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    readln();
    string s = sread();
    long[] l = s.map!(c => c == 'I' ? 1 : -1)
        .array
        .to!(long[]);
    l = 0 ~ l;
    long m;
    foreach (i; 1 .. l.length)
    {
        l[i] += l[i - 1];
        m = max(m, l[i]);
    }
    writeln(m);
}


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

const int INF = 99999999;

int H, W;
vector<vector<char>> s(51, vector<char>(51));

int black = 0;
vector<vector<int>> dist(51, vector<int>(51, INF));
queue<pair<int,int>> q;

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

int main(){
  cin >> H >> W;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> s[i][j];
      if (s[i][j] == '#') black++;
    }
  }

  q.push(make_pair(0,0));
  dist[0][0] = 1;

  while(!q.empty()){
    pair<int,int> cur = q.front(); q.pop();
    if (cur.first == H-1 && cur.second == W-1) break;

    for (int i=0; i<4; i++){
      int nx = cur.first + dx[i], ny = cur.second + dy[i];
      if (0 <= nx && nx < H && 0 <= ny && ny < W){
        if (s[nx][ny] == '.' && dist[nx][ny] == INF){
          dist[nx][ny] = dist[cur.first][cur.second] + 1;
          q.push(make_pair(nx, ny));
        }
      }
    }
  }

  if (dist[H-1][W-1] == INF){
    cout << -1 << endl;
  } else {
    cout << H*W - dist[H-1][W-1] - black << endl;
  }
}

Measured memory_bytes: 256