akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,x[MAXN],y[MAXN],p[MAXN];
ll ans[MAXN];
int distx[15][(1<<15)],disty[15][(1<<15)];
void solve(int mask,int submask)
{
    ll res=0;
    for(int i=0;i<n;i++)
    {
        if(!(mask&(1<<i))) 
        {
            int dist=min(max(x[i],-x[i]),max(y[i],-y[i]));
            dist=min(dist,distx[i][submask]);
            dist=min(dist,disty[i][mask^submask]);
            res+=1LL*dist*p[i];
        }
    }
    ans[__builtin_popcount(mask)]=min(ans[__builtin_popcount(mask)],res);
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d%d%d",&x[i],&y[i],&p[i]);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<n);j++)
        {
            distx[i][j]=INF;
            for(int k=0;k<n;k++) if(j&(1<<k)) distx[i][j]=min(distx[i][j],max(x[i]-x[k],x[k]-x[i]));
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<n);j++)
        {
            disty[i][j]=INF;
            for(int k=0;k<n;k++) if(j&(1<<k)) disty[i][j]=min(disty[i][j],max(y[i]-y[k],y[k]-y[i]));
        }
    }
    for(int i=0;i<=n;i++) ans[i]=1000000000000000000LL;
    for(int i=0;i<(1<<n);i++)
    {
        int sub=i;
        do
        {
            solve(i,sub);
            sub=(sub-1)&i;
        }while(sub!=i);
    }
    for(int i=0;i<=n;i++) printf("%lld\n",ans[i]);
    return 0;
}

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

int main(void){
    int lozenge=0;      //ひし形:辺の長さがすべて等しい
    int rectangle=0;    //長方形:内角がすべて等しい
    
    double a,b,c;
    
    while(scanf("%lf,%lf,%lf",&a,&b,&c)==3){
        if(a==b)lozenge++;
        if((pow(a,2)+pow(b,2))==pow(c,2))rectangle++;
    }
    
    printf("%d\n%d\n",rectangle,lozenge);
    
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    double x[n], y[n];
    for(int i=0;i<n;++i){
        cin >> x[i] >> y[i];
    }

    double d[n][n];
    for(int i=0;i<n;++i) {
        for(int j=0;j<n;++j) {
            if(i == j) {
                d[i][j] = 0.0;
                continue;
            }
            d[i][j] = sqrt((x[i]-x[j]) * (x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]));
        }
    }

    double avg = 0.0;
    vector<int> cities(n);
    for(int i=0;i<n;++i) cities[i] = i;
    
    do {
        for(int i=0;i<n-1;++i) {
            avg += d[cities[i]][cities[i+1]];
        }
    } while(next_permutation(cities.begin(), cities.end()));

    for(int i=2;i<=n;++i) {
        avg /= double(i);
    }

    cout << setprecision(10) << fixed << avg << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
# N-1辺表示をグラフ表示に
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def dfs(p, now, ans):
    now.append(p)
    if len(now) == N:
        ans += 1
        return ans
    allchecked = True
    for q in graph[p]:
        new = now[:]
        if not q in new:
            allchecked = False
            ans = dfs(q, new, ans)
    if allchecked:
        now.pop()
    return ans

print(dfs(0, [], 0))

Measured memory_bytes: 3064
#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(void) {
	float N, a, b;
	cin >> N >> a >> b;
	if (N / b <= a) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static class Try{
		int count;
		String str;
		
		public Try(int count, String str) {
			super();
			this.count = count;
			this.str = str;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			String[] from = new String[n];
			String[] to = new String[n];
			
			for(int i = 0; i < n; i++){
				from[i] = sc.next();
				to[i] = sc.next();
			}
			
			final String init = sc.next();
			final String purpos = sc.next();
			
			LinkedList<Try> queue = new LinkedList<Try>();
			queue.add(new Try(0, init));
			
			boolean found = false;
			while(!queue.isEmpty()){
				Try inst = queue.poll();
				
				if(purpos.equals(inst.str)){
					found = true;
					System.out.println(inst.count);
					break;
				}else if(purpos.length() < inst.str.length()){
					continue;
				}
				
				for(int i = 0; i < n; i++){
					final String changed = inst.str.replaceAll(from[i], to[i]);
					
					if(!changed.equals(inst.str)){
						queue.add(new Try(inst.count + 1, changed));
					}
				}
			}
			
			if(!found){
				System.out.println(-1);
			}
		}
		
	}

}

Measured memory_bytes: 66568
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
 
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    for (int i = k-1; i < n-1; i++)
    {
        if (A[i-k+1] >= A[i+1])
        {
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3964
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int count=0;
		int tens=((S/10)-((int)(S/100))*10)*10;
		int ones=S%10;
		
		if((S/100)<=12 && (S/100)!=0) {
			count+=1;
		}
		if((tens+ones)<=12 && (tens+ones)!=0) {
			count+=2;
		}
		
		
		switch(count){
		case 0:
			System.out.print("NA");
			break;
		case 2:
			System.out.print("YYMM");
			break;
		case 1:
			System.out.print("MMYY");
			break;
		case 3:
			System.out.print("AMBIGUOUS");
			break;
		}
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 10005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2){
        cout<<"No";
        return;
    }
    bool p=true;
    int t=n/2;
    rep0(i,n/2){
        if(s[i]!=s[i+t]){
            p=false;
            break;
        }
    }
    if(p) cout<<"Yes";
    else cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


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

#define range 100005
#define mod 1000000007
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long

using namespace std;

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

int dp[200][200000];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n,w;
	cin>>n>>w;
	ii V[n];
	for(int i=0;i<n;i++)
		cin>>V[i].fi>>V[i].se;
	dp[0][V[0].fi] = V[0].se;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=w;j++)
		{
		   dp[i][j] = dp[i-1][j];
		   if(j - V[i].fi>=0)
		   	  dp[i][j] = max(dp[i][j],dp[i-1][j-V[i].fi] + V[i].se);
		}
	}
	int output = 0;
	for(int i=0;i<=w;i++)
		output = max(output,dp[n-1][i]);
	cout<<output;
	return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;
typedef pair<int,ii>    pii;

ll  F[N];

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

    int n;  cin >> n;
    int X;  cin >> X;

    auto cal = [&](pii A)   {
        int c = A.X;
        int l = A.Y.X;
        int r = A.Y.Y;

        return  1ll * r * (X - c) + 1ll * l * c;
    };

    vector<pii> arr;

    ll  Sum = 0;

    for(int i = 0 ; i < n ; ++i)    {
        int b;  cin >> b;
        int l;  cin >> l;
        int r;  cin >> r;

        arr.pb(b,ii(l,r));
        Sum += 1ll * l * b;
    }

    sort(all(arr),[&](const pii&A,const pii&B)  {   return  cal(A) > cal(B);    });

    for(int i = 0 ; i < n ; ++i)    {
        F[i] = cal(arr[i]);
        if (i)
            F[i] += F[i - 1];
    }

    ll  L = 0;
    ll  R = 1ll * n * X;

    while (L < R)   {
        ll  M = (L + R) / 2;
        int cnt = M / X;
        int rem = M % X;

        assert(cnt < n);

        bool ok = 0;

        for(int i = 0 ; i < n ; ++i)    {
            ll  C = F[cnt];

            if (i >= cnt)   C -= cal(arr[cnt]);
            else            C -= cal(arr[i]);

            if (arr[i].X >= rem)    C += 1ll * arr[i].Y.X * (rem - arr[i].X);
            else                    C += 1ll * arr[i].Y.Y * (rem - arr[i].X);

            C -= Sum;
            C += 1ll * arr[i].Y.X * arr[i].X;

            if (C >= 0) {
                ok = 1;
                break;
            }
        }
        if (ok) R = M;
        else    L = M + 1;
    }
    cout << L << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> check(n, 0);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int a;
            cin >> a;
            check[a-1]++;
        }
    } 
    int res = 0;
    for (int i = 0; i < check.size(); ++i) {
        if (check[i] == 0) ++res;
    } 
    cout << res << endl;
    return 0;
}

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

int main(void) {
    char a[10];
    int sum = 0;
    scanf("%s",a);
    for (int i = 0; i < strlen(a); i++) {
        sum += a[i] - '0';
    }
    if (atoi(a) % sum == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#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 _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    string s;
    cin>>s;
    int d[2019];
    memset(d,0,sizeof(d));
    ll now=0;
    ll t=1;
    d[0]+=1;
    for (int i=s.size()-1;i>=0;i--){
        now+=t*(s[i]-'0');
        t*=10;
        t%=2019;
        now%=2019;
        d[now]+=1;
    }
    ll ans=0;
    rep(i,2019){
        ans+=(d[i]*(d[i]-1))/2;
    }
    cout<<ans<<endl;

    return 0;
}

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

const int MOD=1e9+7;
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  vector<int> dp(n+1);
  dp[0]=1;
  vector<bool> visit(n+1);

  while(m--)
    {
      int x;
      scanf("%d",&x);
      visit[x]=true;
    }


  for(int i=1;i<=n;i++)
    {
      if(visit[i]) continue;
      if(i-1>=0) dp[i]=(dp[i-1]+dp[i])%MOD;
      if(i-2>=0) dp[i]=(dp[i-2]+dp[i])%MOD;
    }

  printf("%d",dp[n]);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

//const int mod = 1000000007;
// mint(a).pow(b) -> a^b       mint(a).pow(b).x
// comb.fact[5] -> 5! = 120    comb.fact[5].x
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);
// comb(n,k)ならcomb(n+k+5)とかにしておく

mint f(int n, int k) {
  if (n < 0) return 0;
  mint res = comb(n,k);
  // nPk = nCk * k!
  //res *= comb.fact[k]; // <- nPk求めたいときは必要
  return res;
}
// f(n,k).x で nCk か nPk が計算される

int main () {
  ll n, m;
  cin >> n >> m;

  if (abs(n-m) >= 2) {
    cout << 0 << endl;
    return 0;
  }

  mint ans;
  if (n == m) ans = mint(2)*comb.fact[n]*comb.fact[m];
  else ans = comb.fact[n]*comb.fact[m];

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

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k-1] += 'a'-'A';
  cout << s << endl;
  return 0;
}

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

int main(){
	int n, input, mid;
	ll ans;
	cin >> n;
	vector<int> v(n);
	rep(i, n){
		cin >> input;
		input -= (i+1);
		v.at(i) = input;
	}
	sort(v.begin(), v.end());
	if(n%2 == 1)mid = v.at(n/2);
	else mid = (v.at(n/2) + v.at(n/2 - 1)) / 2;
	
	ans = 0;
	rep(i, n){
		ans += fabs(v.at(i) - mid);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
from collections import Counter
    
n = int(input())
v = list(map(int, input().split()))
odd = v[::2]
even = v[1::2]
    
c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

    
if(c_even[0][0] != c_odd[0][0]):
    print(n - c_even[0][1] - c_odd[0][1])
else:
    if(len(c_even) == 1):
        print(n//2)
    else:
        # second = max[c_even[1][1], c_odd[1][1]]
        # print(n - c_even[0][1] - second)
        print(n - max(c_even[0][1] + c_odd[1][1], c_even[1][1] + c_odd[0][1]))

Measured memory_bytes: 15972
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e5+1;
const char newl = '\n';

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

  cout << "Yes" << newl;
  
  ll n, m, a, b;
  cin >> n >> m;

  vl G[n];
  
  rep(_, m) {
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vl p(n), d(n, -1);
  ql q;

  p[0] = -1;
  d[0] = 0;
  q.push(0);

  while (!q.empty()) {
    ll v = q.front();
    q.pop();
    
    for (int i : G[v]) {
      if (d[i] != -1) continue;
      p[i] = v;
      d[i] = d[v] + 1;
      q.push(i);
    }
  }
  
  rep2(i, n-1) cout << p[i]+1 << newl;
  return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> l(N);
  for(int &i:l)
    cin>>i;
  sort(l.begin(),l.end());
  int j=0;
  for(int i=1;i<=K;i++)
    j+=l[N-i];
  cout<<j<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    scanf("%d", &n);
    int arr[105]={0};
    for(int i=0;i<n;i++){
        scanf("%d", &arr[i]);
    }
    sort(&arr[0], &arr[n]);
    int a=0;
    int b=0;
    for(int i=n-1;i>=0;i-=2){
        a+=arr[i];
    }
    for(int i=n-2;i>=0;i-=2){
        b+=arr[i];
    }
    printf("%d",a-b);
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Mint{
    public:
    int v;
    const long long MOD = 1000000007;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD; if(v<0)v+=MOD;}

    Mint pow(long long k){
        Mint res(1), tmp(v);
        while(k){
            if(k&1)res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }
    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD; return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-(){return v ? MOD-v : v;}
    bool operator==(Mint a)const{return v==a.v;}
    bool operator!=(Mint a)const{return v!=a.v;}

    Mint operator=(Mint a) {v=a.v;return a;}

    friend ostream& operator<<(ostream& os, const Mint& mint){
        os << mint.v;
        return os;
    }
};

class cmbs{
    public:
    vector<Mint> fact, finv, inv;
    cmbs(){
        fact.clear(); finv.clear(); inv.clear();
    }
    void init(int n){
        if(n+1 <= (signed)fact.size())return;
        fact.assign(n+1,1);
        finv.assign(n+1,1);
        inv.assign(n+1,1);

        for(int i=1; i<=n; i++) fact[i] = fact[i-1]*Mint(i);
        finv[n] = Mint(1)/fact[n];
        for(int i=n; i>=1;i--) finv[i-1] = finv[i]*Mint(i);
        for(int i=1; i<=n; i++) inv[i] = finv[i]*fact[i-1];
    }
    Mint comb(long long n, int k){
        if(n<k||k<0)return Mint(0);
        Mint res(1);
        for(int i=0; i<k; i++){
            res *= Mint(n-i);
            res /= Mint(i+1);
        }
        return res;
    }
    Mint C(int n,int k){
        if(n<k||k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k]*finv[k];
    }
    Mint P(int n, int k){
        if(n<k || k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k];
    }
    Mint H(int n, int k){
        if(n<0||k<0)return Mint(0);
        if(!n&&!k)return Mint(1);
        init(n+k-1);
        return C(n+k-1,k);
    }
};

int main(){
    ll n,k;
    cin>>n>>k;
    cmbs cmb;
    cout<<cmb.C(k,n)<<endl;
    return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	ll d;cin>>d;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<ll> r(n);
	r[n-1]=n-1;
	for(int i=n-2;i>=0;i--){
		if(a[r[i+1]]+(r[i+1]-i)*d>a[i]){
			r[i]=i;
		}else{
			r[i]=r[i+1];
		}
	}
	int ri=0;
	ll ra=a[0];
	ll ans=0;
	while(ri!=n-1){
		ans+=ra+a[r[ri+1]]+(r[ri+1]-ri)*d;
		for(int i=ri+1;i<r[ri+1];i++){
			if((i-ri)*d+ra<(r[ri+1]-i)*d+a[r[ri+1]]){
				ans+=a[i]+ra+(i-ri)*d;
			}else{
				ans+=a[i]+(r[ri+1]-i)*d+a[r[ri+1]];
			}
		}
		ra+=(r[ri+1]-ri)*d;
		if(ra>a[r[ri+1]]){
			ra=a[r[ri+1]];
		}
		ri=r[ri+1];
	}
	cout<<ans<<endl;
	return 0;
}



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



int main(){
  ll n,k;
  cin >>n >>k;
  ll q=0;
  vector<pair<int,int>> g(n);
  rep(i,n){
    int a,b;
    cin >> a>>b;
    g[i]=make_pair(a,b);
  }
  sort(g.begin(),g.end());

  rep(i,n){
    q+=g[i].second;
    if(k<=q){cout << g[i].first <<endl; return 0;}
  }
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        String s = ns();
        int K = ni();
        HashSet<String> set = new HashSet<>();
        for (int i = 0; i < s.length(); i++) {
            for (int j = i+1; j < Math.min(i+K+1, s.length()+1); j++) {
                String sb = String.valueOf(s.substring(i,j));
                set.add(sb);
            }
        }
        ArrayList<String> list = new ArrayList<>(set);
        Collections.sort(list);
        // System.out.println(list);
        out.println(list.get(K-1));
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

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

//int check(int A, int B, int C, int X, int ans){
//    if(X == 0) ans++;
//
//}


int main() {
    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;


    int ans = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if(X == 500 * i + 100 * j + 50 * k){
                    ans++;
//                    cout << i << " " << j << " " << k << endl;
                }
            }

        }
    }



    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = eval(input())
a = input()
b = input()
a = list(a.split(' '))
b = list(b.split(' '))
c = []
sum = 0
for i in range(len(a)):
    sum += int(a[i])
    ss = sum
    for j in range(i,len(b)):
        ss += int(b[j])
    c.append(ss)
maxx = 0
for i in c:
    if maxx < i:
        maxx = i
print(maxx)



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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int *A, int n, int g){
    int v, j;
    for(int i=g; i<n; i++){
        v = A[i];
        j = i - g;
        while(j>=0 && A[j]>v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int *A, int n){
    for(int h=1; ; ){
        if(h>n) break;
        G.push_back(h);
        h = 3*h + 1;
    }
    for(int i=G.size()-1; i>=0; i--)
        insertionSort(A, n, G[i]);
}

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i=0; i<n; i++) scanf("%d", &A[i]);
    
    shellSort(A, n);
    
    cout << G.size() << endl;
    for(int i=G.size()-1; i>=0; i--){
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for(int i=0; i<n; i++) printf("%d\n", A[i]);
}


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










vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

















int main () {
    long long N;
    cin >> N;
    auto p = prime_factorize(N);

    long long result = 0;
    for (auto a: p) {
        long long count = 0;
        while (count * (count + 1) / 2 <= a.second){
            count++;
        }
        result += count - 1;
    }

    cout << result << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int [] ryouri = new int[5];
		ryouri[0] = stdIn.nextInt();
		ryouri[1] = stdIn.nextInt();
		ryouri[2] = stdIn.nextInt();
		ryouri[3] = stdIn.nextInt();
		ryouri[4] = stdIn.nextInt();
		
		int [] time = new int[5];
		int cnt = 0;		
			
				for(int k = 1; k <=9; k++) {
					for(int j = 0; j <= 4; j++) {
					if(ryouri[j] % 10 == k) {
						time[cnt++] = ryouri[j];
					}
				}
			}
				for(int i = 0; i < time.length; i++) {
					if(ryouri[i] % 10 == 0) {
						time[cnt++] = ryouri[i];
					}
				}
		
		int ans = 0;
		for(int i = 4; i >= 0; i--) {
			if(i ==0) {
				ans += time[0];
				break;
			}
			while(true) {
				if(time[i]%10==0) {
					break;
				}
				time[i]++;
			}
			
			ans += time[i];
			
			
		}
			
		
		System.out.println(ans);
		
		
		
		
		
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int suma=0, sumb=0, temp;
    for(int i = 0;i<4;i++){
        cin >> temp;
        suma += temp;
    }
    for(int i = 0;i<4;i++){
        cin >> temp;
        sumb += temp;
    }
    cout << max(suma, sumb) << endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >>m;
    vector<int> x(m);
    rep(i,m){
        cin>>x[i];
    }
    sort(x.begin(),x.end());
    
    vector<int> y(m-1);
    rep(i,m-1){
        y[i] = x[i+1]-x[i];
    }
    sort(y.begin(),y.end());
    
    int sum=0;
    rep(i,m-n){
        sum+=y[i];
    }
    cout<<sum<<endl;
    
    return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

    for (int i = 1; i <= 50000; ++i) {
        if ((int)(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }

    puts(":(");
}

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

public class Main {
    static class FastReader
        {
            BufferedReader br;
            StringTokenizer st;

            public FastReader()
            {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next()
            {
                while (st == null || !st.hasMoreElements())
                {
                    try
                    {
                        st = new StringTokenizer(br.readLine());
                    }
                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt()
            {
                return Integer.parseInt(next());
            }

            long nextLong()
            {
                return Long.parseLong(next());
            }

            double nextDouble()
            {
                return Double.parseDouble(next());
            }

            String nextLine()
            {
                String str = "";
                try
                {
                    str = br.readLine();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
                return str;
            }
        }
    public static void main(String[] args) {
        FastReader ob = new FastReader();
        int k =ob.nextInt(),n=ob.nextInt();
        int arr[] =  new int[n];
        int max_diff=-1,start=0,end=0;
        long sum=0;
        arr[0]=ob.nextInt();
        for (int i = 1; i < n; i++) {
            arr[i]=ob.nextInt();
            sum+=(arr[i]-arr[i-1]);
            max_diff=Math.max(arr[i]-arr[i-1],max_diff);
        }
        max_diff=Math.max(k-arr[n-1]+arr[0],max_diff);
        sum+=k-arr[n-1]+arr[0];
        System.out.println(sum-max_diff);



    }
}

Measured memory_bytes: 47904
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

#include <stdio.h>
#include <string.h>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
// #define int long long

const int MAX_V=1000;
// int memo[1000001]={0};
int dist[MAX_V][MAX_V];



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

    int a,b;
    int r,q;
    int t,n,m,s;
    int ts,tr,M;
    int ans;

    while(cin>>a>>b){
        // cin>>a>>b;

        if(a==0&&b==0)break;

        int table[10002][782];
        //782=1262-540

        memset(table,0,sizeof(table));
        

        cin>>r;

        REP(i,r){

            // cout<<"t,n,m,s??\???"<<endl;

            cin>>t>>n>>m>>s;
            t-=540;

            

            if(s==1){
                table[m][t]++;
            }else if(s==0){
                table[m][t]--;
            }

        }

        REP(i,10002){
            REP(j,782){
                if(table[i][j]>=0)table[i][j+1]+=table[i][j];
            }
        }

        cin>>q;

        REP(i,q){
            ans=0;
            // cout<<"ts,tr,M??\???"<<endl;

            cin>>ts>>tr>>M;
            ts-=540;
            tr-=540;

            for(int l=ts;l<tr;l++){

                // cout<<table[M][l]<<" ";
                
                if(table[M][l]>=1)ans++;
            }
            // cout<<endl;
            // cout<<"??????"<<M<<"????????¨?????????"<<ans<<endl;

            cout<<ans<<endl;

        }
        // REP(i,30){
        //     cout<<i<<" ";
        // }cout<<endl;

        // REP(i,5){
        //     REP(j,30){
        //         cout<<table[i][j]<<" ";
        //     }cout<<endl;
        // }

    }






}
    

Measured memory_bytes: 33656
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int x;
    cin >> x;
    int m = 1;
    for (int i = 2; i <x ; ++i) {
        int y = i;
        while(y * i<= x) {
            y *= i;
        }
        if(y != i)
        m = max(m, y);
    }
    cout << m << endl;

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define N 1000000
int a[MAX][MAX];
int d[MAX];
int color[MAX];
void dijkstra(int,int);
int main(){
  int i,j,b,e,c,n;
  scanf("%d",&n);
  for(i = 0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=N;
    }
  }
  for(i = 0;i<n;i++){
    scanf("%d%d",&b,&e);
    for(j=0;j<e;j++){
      scanf("%d",&c);
      scanf("%d",&a[b][c]);
    }
  }
 
  dijkstra(n,0);

  for(i =0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  
}

void dijkstra(int w,int s){
  int mincost,j,i,u;
  for(i =0;i<w;i++){
    d[i] = N;
    color[i]=0;
  }
  d[s] = 0;
  while(1){
    mincost = N;
    for(i = 0;i<w;i++){
      if(color[i]!=1 && d[i]<mincost){
	mincost= d[i];
	u=i;
      }
    }
    if(mincost ==N){
      break;
    }

    color[u]=1;

    for(j = 0;j<w;j++){
      if(color[j]!=1 && d[u] + a[u][j] <d[j]){
	d[j] = d[u]+a[u][j];
  
      }
    }
  }
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

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

  vector<pll> ab(N);
  vector<pll> order(N);
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    ab.at(i) = {a, b};
    order.at(i) = {a + b, i};
  }
  sort(order.begin(), order.end(), [] (pll a, pll b) {
    return a.first > b.first;
  });
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      ans += ab.at(order.at(i).second).first;
    }
    else {
      ans -= ab.at(order.at(i).second).second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void Search(vector<vector<int>>&edge, vector<int>&depth, vector<int>&num, int node) {
	for (auto i : edge[node]) {
		if (depth[node] > depth[i])continue;
		Search(edge, depth, num, i);
		num[node] += num[i];
	}
	return;
}

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

	cin >> N;
	vector<int>s;
	vector<int>t;
	vector<vector<int>>edge(N + 1);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		s.push_back(L);
		t.push_back(R);
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>depth(N + 1, MOD);
	Calculate_Depth(edge, depth, 1);
	vector<int>num(N + 1, 1);
	Search(edge, depth, num, 1);
	vector<long long int>v(N + 1);
	vector<long long int>ans;
	for (int i = 1; i <= N; i++)cin >> v[i];
	for (int i = 0; i < s.size(); i++) {
		long long int box = 0;
		if (depth[s[i]] < depth[t[i]]) {
			box = num[t[i]];
		}
		else {
			box = N - num[s[i]];
		}
		box = box * 2 - N;
		if (!box)ans.push_back(0);
		else ans.push_back((v[s[i]] - v[t[i]]) / box);
	}
	vector<vector<pair<int, long long int>>>eedge(N + 1);
	for (int i = 0; i < ans.size(); i++) {
		eedge[s[i]].emplace_back(t[i], ans[i]);
		eedge[t[i]].emplace_back(s[i], ans[i]);
	}
	for (int i = 0; i < ans.size(); i++) {
		if (ans[i])continue;
		vector<long long int>dis(N + 1, MOD*MOD);
		dis[0] = 0;
		dis[s[i]] = 0;
		queue<int>Q;
		Q.push(s[i]);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto j : eedge[cn]) {
				if (dis[j.first] > dis[cn] + j.second) {
					dis[j.first] = dis[cn] + j.second;
					Q.push(j.first);
				}
			}
		}
		K = accumulate(dis.begin(), dis.end(), 0LL);
		ans[i] = (v[s[i]] - K) * 2 / N;
	}
	for (auto i : ans)cout << i << endl;
	return 0;
}

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


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    { 
        
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int k = s[0];
            int x = s[1];

            var sb = new StringBuilder();

            for (int i = x-k+1; i < x+k; i++)
            {
                sb.Append(i + " ");
            }
            sb.Remove(sb.Length-1,1);
            WriteLine(sb.ToString());
        }
    }
}


Measured memory_bytes: 11348
// 69

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    int k;
    string str;
    cin >> k >> str;
    for(int i=0; i<str.length(); i++){
        if(i<k){
            cout << str.at(i);
        }else{
            cout << "...";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
struct SegmentTree{
  int n_, n = 1;
  int MAX = 2147483647;
  vector<int> v;
  SegmentTree(int n_):n_(n_){
    while(n < n_) n *= 2; // 2の冪乗が扱いやすい
    v.assign(2*n, MAX);
  }
  // k番目の要素をaに変更
  void update(int k, int a){
    k += n - 1; // ノード番号にする
    v[k] = a;
    while(k > 0){
      k = (k - 1) / 2;
      v[k] = min(v[2 * k + 1], v[2 * k + 2]);
    }
  }
  // [a, b)の最小値,kはノード番号
  // query(a,b,0,0,n)を呼ぶ
  int query_(int a, int b, int k, int l, int r){
    if(b <= l || r <= a) return MAX;
    if(a <= l && r <= b) return v[k];
    int vl = query_(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = query_(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }

  int query(int a, int b){
    return query_(a, b, 0, 0, n);
  }

};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin>>n>>q;
  SegmentTree seg(n);
  FOR(i,0,q){
      int com;
      int x, y;
      cin>>com>>x>>y;
      if(com == 0){
          seg.update(x, y);
      } else {
          cout<<seg.query(x, y + 1)<<endl;
      }
  }
  return 0;
}


Measured memory_bytes: 3880
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
s = input()

for i in s.split(","):
	print(i,"", end="")
print()

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define fi first
#define se second
template <typename A, typename B> inline bool chmax(A &a, B b) {if (a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmin(A &a, B b) {if (a > b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/****************************/

int N, M;
vector<int> g[1123];
int col[1123];

bool binary_color(int u, int c) {
	col[u] = c;
	
	REP(i, g[u].size()) {
		int v = g[u][i];
		
		if (col[v] != 0 && col[u] == col[v]) return false;
		if (col[v] == 0 && !binary_color(v, -c)) return false; 
	}
	return true;
}

int main() {
	while (cin >> N >> M, N || M) {
		REP(i, N) g[i].clear();
		memset(col, 0, sizeof(col));
		
		REP(i, M) {
			int u, v;
			scanf("%d %d", &u, &v);
			u--; v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		
		if (!binary_color(0, 1)) {
			cout << 0 << endl;
			continue;
		}
		
		int cnt[2] = {};
		REP(i, N) cnt[col[i]==1]++;
		
		vector<int> ans;
		if (!(cnt[0] & 1)) {
			ans.push_back(cnt[0] / 2);
		}
		if (!(cnt[1] & 1)) {
			ans.push_back(cnt[1] / 2);
		}
		
		sort(ALL(ans));
		ans.erase(unique(ALL(ans)), ans.end());
		
		
		if (debug) printf("@ ");
		cout << ans.size() << endl;
		REP(i, ans.size()) printf("%d\n", ans[i]);
	}
}



Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n,sum;
    sum =0;
    cin >> n;
    vector<int> z(1000001);
    vector<int> y(n);
    rep(i,n){
        int x;
        cin >>x;
        y[i] =x;
        if(z[x]>1){
            continue;
        }
        while(x<=1000000){
            z[x]++;
            x+=y[i];
        }
    }

    rep(i,n){
        if(z[y[i]]>1){
            sum++;
        }
    }
    cout << n-sum << endl;
}

Measured memory_bytes: 7996
<?php
// C
fscanf(STDIN, '%s', $s);
fscanf(STDIN, '%s', $t);
$n = strlen($s);
$ans = 'Yes';
for ($i = 0; $i < $n; $i++) {
    if (isset($g[$t[$i]])) {
        if ($g[$t[$i]] !== $s[$i]) {
            $ans = 'No';
            break;
        }
    } else {
        $g[$t[$i]] = $s[$i];
    }
    if (isset($g2[$s[$i]])) {
        if ($g2[$s[$i]] !== $t[$i]) {
            $ans = 'No';
            break;
        }
    } else {
        $g2[$s[$i]] = $t[$i];
    }
}
echo $ans;

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

int main() {
        int a, b;
        cin >> a >> b;

        string s1 = "", s2 = "";
        
        for (int i = 0; i < a; i++) {
                s1 += to_string(b);
        }

        for (int i = 0; i < b; i++) {
                s2 += to_string(a);
        }

        if (lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end()))
                cout << s1 << endl;
        else cout << s2 << endl;
        return 0;
}

Measured memory_bytes: 256