akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

const int N = 2100, M = N * 3;
int n, P, f[M][M << 1];
void upd(int &x, int v) { (x += v) >= P ? x -= P : 0; }
signed main() {
	scanf("%d %d", &n, &P), n *= 3;
	f[0][0 + M] = 1; int ans = 0;
	for(int i = 0; i < n; i++)
		for(int j = -i; j <= i; j++) {
			upd(f[i + 1][j + 1 + M], f[i][j + M]);
			upd(f[i + 2][j - 1 + M], 1ll * f[i][j + M] * (i + 1) % P);
			upd(f[i + 3][j + M], 1ll * f[i][j + M] * (i + 1) % P * (i + 2) % P);
		}
	for(int i = 0; i <= n; i++) upd(ans, f[n][i + M]);
	printf("%d\n", ans);
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

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

int main()
{
  while (1)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    int sum = 0, square_sum = 0;
    for (int i = 0; i < n; i++)
    {
      int s;
      cin >> s;
      sum += s;
      square_sum += pow(s, 2);
    }
    double mean = sum / double(n);
    double a = sqrt(square_sum / double(n) - pow(mean, 2));
    printf("%.8f\n", a);
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin>>n;

  if(599>=n){cout<<"8";}
  if(799>=n && n>=600){cout<<"7";}
  if(999>=n && n>=800){cout<<"6";}
  if(1199>=n && n>=1000){cout<<"5";}
  if(1399>=n && n>=1200){cout<<"4";}
  if(1599>=n && n>=1400){cout<<"3";}
  if(1799>=n && n>=1600){cout<<"2";}
                       if(1999>=n && n>=1800){cout<<"1";}
                                              


  
  
}


Measured memory_bytes: 3620
#include <cstdio>
#include <functional>
#include <vector>

#include <cstdint>

constexpr bool parity64(std::uint_fast64_t c) noexcept {
  c ^= c >> 1;
  c ^= c >> 2;
  return ((c & 0x1111111111111111) * 0x1111111111111111 >> 60 & 0x1) != 0;
}

int scan() {
  int r = 0;
  int c;
  while ((c = getchar_unlocked() - '0') >= 0)
    r = r * 10 + c;
  return r;
}

int main() {
  const int n = scan();
  std::vector<std::vector<int>> t(n);
  for (int i = 0; i != n - 1; i += 1) {
    const int a = scan() - 1;
    const int b = scan() - 1;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  const int m = scan();
  const int s = 1 << m;
  std::vector<int> z(s, 0);
  {
    std::vector<int> x(n, 0);
    for (int i = 0; i != m; i += 1) {
      const int u = scan() - 1;
      const int v = scan() - 1;
      x[u] ^= 1 << i;
      x[v] ^= 1 << i;
    }
    std::function<void(int, int)> dfs = [&](int v, int p) {
      for (int e : t[v]) {
        if (e == p)
          continue;
        dfs(e, v);
        z[x[e]] += 1;
        x[v] ^= x[e];
      }
    };
    dfs(0, n);
  }
  for (int w = 1; w != s; w <<= 1) {
    for (int i = 0; i != s; i += w << 1) {
      const int end = i + w;
      for (int j = i; j != end; j += 1) {
        z[j + w] += z[j];
      }
    }
  }

  long long ans = 0;
  for (int i = 0; i != 1 << m; i += 1) {
    auto res = 1LL << z[s - 1 ^ i];
    if (parity64(i))
      res = -res;
    ans += res;
  }
  printf("%lld", ans);
}

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

//A

int main() {
	// your code goes here
	int p,q,r;
	cin >> p >> q >> r;
	if(p>q) swap(p,q);
	if(q>r) swap(q,r);
	cout << p+q << endl;
	return 0;
}

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

vector<int> a, ans;
vector<int> to[MAX_N];
int dp[MAX_N];
void dfs(int v, int p=-1){
  int i = lower_bound(dp, dp+MAX_N, a[v]) - dp;
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = i;
  if(p != -1) ans[v] = max(ans[v], ans[p]); //exclude first turn
  
  	for(int u : to[v]){
       if(u == p) continue;  //parent
       dfs(u, v);
  	}
  //roll back
  	dp[i] = old;
}

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

  rep(i, n-1){
    int u, v;
    cin >> u >> v;
    --u, --v;
    to[u].push_back(v);
    to[v].push_back(u);
  }

  rep(i ,MAX_N) dp[i] = INF;
  dp[0] = -INF;
  
  dfs(0);  
  rep(i, n){
    cout << ans[i] << endl;
  }      
    return 0;
  }
    
    

Measured memory_bytes: 30772
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if X == i * 500 + j * 100 + k * 50:
        cnt += 1
        
print(cnt)

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

int n;
int num[101][101];
int p[101];

void matrixChainMultiplication(){
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      num[i][j]=INT_MAX;
      for(int k=i;k<=j-1;k++)
	num[i][j]=min(num[i][j],num[i][k]+num[k+1][j]+p[i-1]*p[k]*p[j]);
    }   
  }
  cout<<num[1][n]<<endl;
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++) cin>>p[i-1]>>p[i];
 
  for(int i=1;i<=n;i++)num[i][i]==0;
  
  matrixChainMultiplication();
      
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <queue>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

class Student {
public:
	Student(int i, int o) : index(i), order(o) {}
	int index, order;
};

bool operator <(const Student &lhs, const Student &rhs) { return lhs.order > rhs.order; }

int main()
{
	priority_queue<Student> q;
	int N, A;
	cin >> N;
	rep(i, N){
		cin >> A;
		q.push(Student(i + 1, A));
	}

	rep(i, N) {
		cout << q.top().index << ' ';
		q.pop();
	}
  
	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n,k,h[100000],m=0;
    cin >> n>>k;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (h[i] >= k) m++;
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
As = list(map(int, input().split()))

res = 0
while True:
	odd = list(filter(lambda x: x % 2 == 1, As))
	if odd:
		break
	else:
		As = list(map(lambda x: x // 2, As))
		res += 1
print(res)


Measured memory_bytes: 9052
# n=int(input())
x, y, z = map(int, input().split())
# l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans = x // (y + z)
if x - ans*(y + z) < z:
    ans = max(0, ans-1)
print(ans)

Measured memory_bytes: 8956
N = int(input())
S_1 = input()
S_2 = input()
MOD = 10**9 + 7

if N == 1:
    print(3)
    exit()

ans = 3 if S_1[0] == S_2[0] else 6

for i in range(1, N):
    if S_1[i-1] == S_1[i]:
        continue
    if S_1[i-1] == S_2[i-1]:
        ans = ans * 2 % MOD
    elif S_1[i] != S_2[i]:
        ans = ans * 3 % MOD
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    string s,ans;
    lli i,j,k;
    char t;
    map<char,lli> map;
    cin>>s;
    rep(i,0,s.size()){
        map[s[i]]++;
    }
    if(s.size()!=26){
        rep(i,0,26){
            t='a'+i;
            if(map[t]==0){
                ans=s+t;
                cout<<ans<<endl;
                exit(0);
            }
        }
    }
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<"-1"<<endl;
            exit(0);
        }
        else{
            rep(i,0,26){
                j=25-i;
                string y;
                y=s.substr(j,i+1);
                rep(k,1,26){
                    if(y.find(y[0]+k)!=string::npos){
                        y=y[0]+k;
//                        cout<<y<<endl;
                        ans=s.substr(0,j)+y;
                        cout<<ans<<endl;
                        exit(0);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 384
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

arr=[int(arr_data[1][x]) for x in range(n)]

cnt=0
for i in range(0,n-1):
    
    if arr[i]==arr[i+1]:
        
        arr[i+1]=0
        cnt+=1
        
print(cnt)

Measured memory_bytes: 3064
n=int(input())
a,b=map(int,input().split())
p=sorted(list(map(int,input().split())))

l1=[]
l2=[]
l3=[]

for i in range(n):
    if p[i]<=a:
        l1.append(p[i])

for i in range(n):
    if a+1<=p[i]<=b:
        l2.append(p[i])
        
for i in range(n):
    if b<p[i]:
        l3.append(p[i])
        
print(min(len(l1),len(l2),len(l3)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#include "lib/mydebug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    string s;
    int q;

    void solve(){
        cin >> s >> q;
        int l=(int)s.size();
        vector<vector<int>> dp (l,vector<int>(27,INF)), emp (l,vector<int>(20,INF));
        for(int i=l-1; i>=0; --i){
            dp[i][s[i]-'a']=i+1;
            for(int j=s[i]-'a'+1; j<27; ++j){
                if(dp[i][j-1]<l)dp[i][j]=dp[dp[i][j-1]][j-1];
            }
            for(int j=0; j<s[i]-'a'; ++j){
                if(dp[i][26]<l)dp[i][j]=dp[dp[i][26]][j];
            }
        }
        for(int i=0; i<l; ++i){
            emp[i][0]=dp[i][26];
        }
        for(int i=1; i<20; ++i){
            for(int j=0; j<l; ++j){
                if(emp[j][i-1]<l)emp[j][i]=emp[emp[j][i-1]][i-1];
            }
        }
        for(int i=0; i<q; ++i){
            int ql,qr;
            cin >> ql >> qr;
            ql--;
            int ans =ql;
            for(int j=19; j>=0; --j){
                if(ans<qr && emp[ans][j]<=qr){
                    ans=emp[ans][j];
                }
            }
            if(ans==qr)cout << "Yes" <<"\n";
            else cout << "No" << "\n";
        }
    }
};


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;

    Problem p;
    p.solve();
    return 0;
}



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

int main(){
  int a=0,b=0;
  for(int i=0;i<4;i++){
    int c;
    cin>> c;
    a+=c;
  }

  for(int i=0;i<4;i++){
    int c;
    cin>> c;
    b+=c;
  }

  cout<< max(a,b)<< endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int N;
    cin >> N;
    vector<pair<ll, ll>> pos(N);
    REP(i, N) { cin >> pos[i].first >> pos[i].second; }

    int par = (abs(pos[0].first) + abs(pos[0].second)) % 2;
    REP(i, N) {
        int par2 = (abs(pos[i].first) + abs(pos[i].second)) % 2;
        pos[i] = pair<ll, ll>(pos[i].first + pos[i].second, pos[i].first - pos[i].second);
        if (par2 != par) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<ll> d;
    for (int i = 35; i >= 0; --i)
        d.push_back(1LL << i);
    if (par % 2 == 0)
        d.push_back(1);
    cout << d.size() << endl;
    for (int j = 0; j < d.size(); j++) {
        cout << d[j] << " ";
    }
    cout << endl;

    for (int i = 0; i < N; i++) {
        int xdir, ydir;
        ll xsum = 0, ysum = 0;
        for (int j = 0; j < (int)d.size(); j++) {
            if (xsum <= pos[i].first)
                xdir = 1, xsum += d[j];
            else
                xdir = -1, xsum -= d[j];
            if (ysum <= pos[i].second)
                ydir = 1, ysum += d[j];
            else
                ydir = -1, ysum -= d[j];

            if (xdir == 1 && ydir == 1)
                cout << "R";
            else if (xdir == 1 && ydir == -1)
                cout << "U";
            else if (xdir == -1 && ydir == 1)
                cout << "D";
            else if (xdir == -1 && ydir == -1)
                cout << "L";
        }
        cout << endl;
    }

    return 0;
}


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

typedef long long int ll;

int main() {
	ll tmp,ans = 0;
	for(int i=0; i<3; i++) {
		scanf("%lld",&tmp);
		ans+=tmp;
	}
	if(ans >= 22) printf("bust");
	else printf("win");
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

bool pres(vector<int> &a, int x)
{
	for (int i = 0; i < a.size(); ++i)
	{
		if(a[i] == x)
			return 1;
	}

	return 0;
}


int32_t main()
{
	c_p_c();

	int n,x; cin>>x>>n;


	vector<int> a(n);

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

	if(n==0)
	{
		cout << x;
		return 0;
	}
	// sort(a.begin(), a.end());

	int ans;

	// int i=0;



	for (int i = 0; ; ++i)
	{
		if(!pres(a, x-i))
		{
			ans=x-i;
			break;
		}else if(!pres(a, x+i))
		{
			ans=x+i;
			break;
		}
	}


	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3620
using System;
using System.Linq;

namespace ABC159 {
    public class A {
        static void Main(string[] args) {
            var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var totalBall = inputs[0] + inputs[1];
            var totalC = (totalBall * (totalBall - 1)) / 2;
            var oddC = inputs[0] * inputs[1];
            Console.WriteLine(totalC - oddC);
        }
    }
}


Measured memory_bytes: 13268
i,k,m,t,a[100];main(n){while(scanf("%d%d",&n,&m),n|m){for(i=0;i<n*m;scanf("%d",&t),a[i++%m]+=t);n=m;while(n--){for(t=i=0;i<m;++i)t=t<a[i]?a[k=i]:t;printf("%d%c",k+1,n?32:10),t=a[k]=0;}}}

Measured memory_bytes: 0
class Ex(Exception):
    pass
n=int(input())
for i in range(n):
    try:
        snk=input()
        l=len(snk)
        head=snk[:2]
        body=snk[2:l-1]
        tail=snk[l-1]
        if tail!='~' or snk[0]!='>':
            print("NA")
            continue
        spl_a=body.split('#')
        if len(spl_a)==2 and spl_a[0]==spl_a[1] and len(spl_a[0])!=0:
            for char in spl_a[0]:
                if char!='=':
                    print("NA")
                    raise Ex()
            if head[1]=='\'':
                print('A')
                raise Ex()
            else:
                print("NA")
                raise Ex()
        bars=body.split('=')
        if len(bars)==1:
            print("NA")
            continue
        for j in range(len(bars)-1):
            if bars[j]!='Q':
                print("NA")
                raise Ex()
        if head[1]=='^'and bars[len(bars)-1]=='~':print('B')
        else:print("NA")
    except Ex:pass      

Measured memory_bytes: 7780
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

class Dice {
public:
  int a[6];
  Dice(){
    for(int i = 0; i < 6; i++)
      cin >> a[i];
  }
  void Roll(string s){
    int temp;
    // cout << s[0] << " " << typeid(s[0]).name() << endl;
    // return;

    for(string::size_type i = 0; i < s.length(); i++){
      if(s[i] == 'E'){
        temp = a[3];
        a[3] = a[5];
        a[5] = a[2];
        a[2] = a[0];
        a[0] = temp;
      }else if(s[i] == 'W'){
        temp = a[2];
        a[2] = a[5];
        a[5] = a[3];
        a[3] = a[0];
        a[0] = temp;
      }
      else if(s[i] == 'S'){
        temp = a[4];
        a[4] = a[5];
        a[5] = a[1];
        a[1] = a[0];
        a[0] = temp;
        // printCurrent();
      }else if(s[i] == 'N'){
        temp = a[1];
        a[1] = a[5];
        a[5] = a[4];
        a[4] = a[0];
        a[0] = temp;
      }
    }
    
  }
  void printCurrent(){
    cout << "現在の状態" << endl;
    for(int i = 0; i < 6; i++)
      cout << a[i] << endl;
    cout << endl;
  }
};

int main(){
  Dice dice1;
  string s;

  cin >> s;
  dice1.Roll(s);
  

  cout << dice1.a[0] << endl;
  // cout << dice1.a[1] << endl;
  // cout << dice1.a[2] << endl;
  // cout << dice1.a[3] << endl;
  // cout << dice1.a[4] << endl;
  // cout << dice1.a[5] << endl;

  

}


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

int N;

string solve(int* a) {
    if ( ((a[0]*a[0]) + (a[1]*a[1])) == (a[2]*a[2]) ) {
        return "YES";
    }
    return "NO";
}

int main() {
    cin >> N;

    int a[3] = {0};
    while (cin >> a[0]) {
        cin >> a[1];
        cin >> a[2];
        sort(a, a+3);
        string res = solve(a);
        cout << res << endl;
    }

    return 0;
}



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

using namespace std;

const int N = 2005;
int n, k, q, a[N], ans = 1e9 + 5, t[N], b[N], c[N];

void cal(int mn) {
	int l = 1, r = 1;
	b[0] = 0;
	while (l <= n) {
		c[0] = 0;
		while (a[l] < mn && l <= n)  l++;
		r = l;
		while (a[r] >= mn && r <= n) r++;
		for (int i = l; i < r && i <= n; i++)
			c[++c[0]] = a[i];
		if (c[0] >= k) {
			sort(c + 1, c + c[0] + 1);
			for (int i = 1; i <= c[0] - k + 1; i++)
				b[++b[0]] = c[i];
		}
		l = r;
	}
	sort(b + 1, b + b[0] + 1);
	if (b[0] >= q)   ans = min(ans, b[q] - b[1]);
}

int main() {
	cin >> n >> k >> q;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		t[i] = a[i];
	}
	sort(t + 1, t + n + 1);
	for (int i = 1; i <= n; i++)
		cal(t[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
String S = sc.next();
int d=1000;
for(int i=0;i<=S.length()-3;i++){
  String result = S.substring(i,i+3);
  if(Math.abs(Integer.parseInt(result)-753)<d){
    d = Math.abs(Integer.parseInt(result)-753);
  }
}
System.out.println(d);
}
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n;
	cin >> n;
	cout << "AB" << (n < 1000 ? 'C' : 'D');

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [tuple([int(x) for x in input().split()]) for _ in range(M)]

d = dict()
cp = 0
n = 1
for p,y in sorted(PY):
    if p != cp:
        cp = p
        n = 1
    d[(p, y)] = n
    n += 1

for p, y in PY:
    print("%06d%06d" % (p, d[(p,y)]))

Measured memory_bytes: 34848
import bisect
N = int(input())
L = sorted(map(int, input().split()))

cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ab = L[i] + L[j]
        c_index = bisect.bisect_left(L, ab)
        cnt += c_index - 1 - j
print(cnt)

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X){
    if(500*K>=X) cout<<YES<<endl;
    else cout<<NO<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


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

int intsort(const void *a, const void *b);

int main(void)
{
  char arr[10];
  int n;
  int a[850000];
  unsigned long long int  ans=0;

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &n);

  for (int i=0; i < n*3; ++i) {
    scanf("%d", &a[i]);
  }
  qsort(a, n*3, sizeof(int), intsort);

  for (int i=1,j=0; j < n; i += 2, j++) {
     ans += a[i]; 
  }
  printf("%lld\n", ans);
  return 0;
}

int intsort(const void *a, const void *b)
{
  if (*(int*)a > *(int*)b){
    return -1;
  }else if (*(int*)a < *(int*)b) {
    return 1;
  } else {
    return 0;
  }
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }


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

  int ans = C;
  chmin(ans, B / A);
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <set>
using namespace std;

const int INF = 1 << 28;

int main()
{
  vector<vector<int> > table(13);
  table[0].push_back(2);
  table[1].push_back(2);
  table[1].push_back(5);
  table[2].push_back(0);
  table[2].push_back(1);
  table[2].push_back(3);
  table[2].push_back(6);
  table[3].push_back(2);
  table[3].push_back(7);
  table[4].push_back(5);
  table[5].push_back(1);
  table[5].push_back(4);
  table[5].push_back(6);
  table[5].push_back(9);
  table[6].push_back(2);
  table[6].push_back(5);
  table[6].push_back(7);
  table[6].push_back(10);
  table[7].push_back(3);
  table[7].push_back(6);
  table[7].push_back(8);
  table[7].push_back(11);
  table[8].push_back(7);
  table[9].push_back(5);
  table[9].push_back(10);
  table[10].push_back(6);
  table[10].push_back(9);
  table[10].push_back(11);
  table[10].push_back(12);
  table[11].push_back(7);
  table[11].push_back(10);
  table[12].push_back(10);

  vector<vector<int> > MH(13, vector<int>(13, INF));
  for (unsigned int i = 0; i < table.size(); ++i) {
    for (unsigned int j = 0; j < table[i].size(); ++j)
      MH[i][table[i][j]] = 1;
  }

  for (int i = 0; i < 13; ++i)
    MH[i][i] = 0;

  for (int k = 0; k < 13; ++k) {
    for (int i = 0; i < 13; ++i) {
      for (int j = 0; j < 13; ++j)
	MH[i][j] = min(MH[i][j], MH[i][k]+MH[k][j]);
    }
  }

  vector<int> p(13);
  while (cin >> p[0]) {
    if (p[0] == -1)
      break;

    for (unsigned int i = 1; i < p.size(); ++i)
      cin >> p[i];

    string s;
    const string g = "0123456789AB0";
    for (unsigned int i = 0; i < p.size(); ++i) {
      if (p[i] == 10)
	s += "A";
      else if (p[i] == 11)
	s += "B";
      else
	s += ('0' + p[i]);
    }

    int ans = -1;
    queue<pair<int, string> > que;
    que.push(make_pair(0, s));
    set<string> visited;
    while (!que.empty()) {
      const pair<int, string> st = que.front();
      que.pop();

      if (st.first > 20)
	continue;

      if (st.second == g) {
	ans = st.first;
	break;
      }

      visited.insert(st.second);
      vector<int> zero;
      for (unsigned int i = 0; i < st.second.size(); ++i) {
	if (st.second[i] == '0')
	  zero.push_back(i);
      }

      for (unsigned int i = 0; i < zero.size(); ++i) {
	for (unsigned int j = 0; j < table[zero[i]].size(); ++j) {
	  s = st.second;
	  swap(s[zero[i]], s[table[zero[i]][j]]);

	  int cost = 0;
	  for (unsigned int k = 0; k < s.size(); ++k) {
	    if (s[k] == '0')
	      cost += min(MH[0][k], MH[12][k]);
	    else if (s[k] == 'A')
	      cost += MH[10][k];
	    else if (s[k] == 'B')
	      cost += MH[11][k];
	    else
	      cost += MH[s[k]-'0'][k];
	  }
	  cost /= 2;
	  if (cost + st.first > 20)
	    continue;

	  if (visited.find(s) == visited.end()) {
	    visited.insert(s);
	    que.push(make_pair(st.first+1, s));
	  }
	}
      }
    }

    if (ans == -1)
      cout << "NA" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4208
import sys
a = input()

for bit in range(2**3):
    p_m = ["-","-","-"]
    b = []
    for i in range(len(p_m)):
        if ((bit>>i) & 1):
            p_m[i] = "+"
        b.append(a[i] + p_m[i])
    b.append(a[3])
    c = "".join(b)
    if eval(c) == 7:
        print(c+"=7")
        sys.exit()

Measured memory_bytes: 3064
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [a,b] <- r'
    let f = if 6 <= a && a <= 12 then (`div` 2)
            else if a < 6 then (const 0)
            else id
    print $ f b


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K, C;
	string S;
	cin >> N >> K >> C >> S;
	vector<int> a(N), b(N);
	for (int i = 0, j = 0; i < N && j < K; ) {
		if (S[i] == 'o') {
			a[i] = ++ j;
			i += C+1;
		} else {
			++ i;
		}
	}
	for (int i = N-1, j = 0; i >= 0 && j < K; ) {
		if (S[i] == 'o') {
			b[i] = ++ j;
			i -= C+1;
		} else {
			-- i;
		}
	}
	for (int i = 0; i < N; ++ i) {
		// cerr << a[i] << " " << b[i] << endl;
		if (a[i] && b[i] && a[i]+b[i] == K+1) {
			cout << i+1 << endl;
		}
	}
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int n,a[404];
long long dp[404][404];
long long sum(int l,int r){
    long long sum=0;
    for(int i=l;i<=r;i++) sum+=a[i];
    return sum;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int l=n-1;l>=0;l--)
        for(int r=l;r<n;r++){
            if(r==l) dp[r][l]=0;
            else{
                long long s=sum(l,r);
                dp[l][r]=1e15;
                for(int k=l;k<r;k++){
                    dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]+s);
                }
            }
        }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 1536
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll Mf = 0, Df =0, Ms =0, Ds =0;
    cin(Mf);cin(Df);cin(Ms);cin(Ds);

    //vll X(N);
    //REP(i,N) cin(X.at(i));
    if(Mf<Ms) cout << 1 << endl;
    else cout << 0 << endl;




    //出力
    //cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N, K; cin >> N >> K;
  vector<pair<ll,ll>> XY(N); rep(i,N) cin >> XY[i].first >> XY[i].second;
  ll ans = 4e18+1e15;
  rep(i,N){
    rep(j,N){
      rep(k,N){
        rep(l,N){
          ll x1 = XY[i].first;
          ll x2 = XY[j].first;
          ll y1 = XY[k].second;
          ll y2 = XY[l].second;
          ll xmin = min(x1, x2);
          ll xmax = max(x1, x2);
          ll ymin = min(y1, y2);
          ll ymax = max(y1, y2);
          ll S = (xmax-xmin)*(ymax-ymin);
          int cnt = 0;
          rep(n,N){
            ll xn = XY[n].first;
            ll yn = XY[n].second;
            if(xmin<=xn && xn<=xmax && ymin<=yn && yn<=ymax) cnt++;
          }
          if(cnt >= K) ans = min(ans,S);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> nrd(n+1, 1);
    FOR1(d, n){
        for(int x = 2*d; x <= n; x += d)
            nrd[x]++;
    }

    ll sol = 0;
    FOR1(k, n) sol += 1LL * k * nrd[k];
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> n >> a;
  //vector<int> v(n), c(n);
  //if(1) {}
  while(n) {
    n /= a;
    ans++;
  }
  //for(int i = 0; i < n; i++){}
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def dfs(s):
    if int(s)>n:return 0
    ret=1 if all(s.count(c)>0 for c in '753') else 0
    for c in '753':
        ret+=dfs(s+c)
    return ret
def main():
    global n
    n=int(input())
    print(dfs('0'))

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

g = [[] for _ in range(n)]
indeg = [0 for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    g[x-1].append(y-1)
    indeg[y-1] += 1

dp = [-1 for _ in range(n)]


def LP(v):
    if dp[v] != -1:
        return dp[v]
    ans = 0
    for w in g[v]:
        ans = max(ans, LP(w)+1)
    dp[v] = ans
    return dp[v]


for i in range(n):
    LP(i)

print(max(dp))


Measured memory_bytes: 148976
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[17][17];
int main(){
	int w,h,n,x,y;
	while(true){
	cin>>w>>h;
	if(!w&&!h)break;
	cin>>n;
	rep(i,h)rep(j,w)dp[i][j]=1;
	rep(i,n){cin>>x>>y;dp[y-1][x-1]=0;}
	dp[0][0]=2;
	rep(i,h){
		rep(j,w){
			if(dp[i][j]){
				if(i)dp[i][j]+=dp[i-1][j];
				if(j)dp[i][j]+=dp[i][j-1];
				dp[i][j]--;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2992
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
mod = 10**9 + 7
ans = 1
cnt = [0] * N
for a in A:
    if a > 0:
        ans *= (cnt[a - 1] - cnt[a])
    else:
        ans *= (3 - cnt[a])
    cnt[a] += 1
    ans %= mod
print(ans)

Measured memory_bytes: 14396
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if(A + B >= X && A <= X) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

using namespace std;

vector<string> vec;

int main()
{
    int n, l;
    cin>>n>>l;
    string s;
    for(int i=0; i<n; i++)
    {
        cin>>s;
        vec.emplace_back(s);
    }
    sort(vec.begin(), vec.end());
    for(auto i:vec)
    {
        cout<<i;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int N = sc.nextInt();
			if(N == 0)break;
			int x = 0;
			int y = 0;
			boolean ab = true;
			for(int i = 0; i < N; i++){
				x = sc.nextInt();
				if(x > 0)y++;
				if(x > 1)ab = false;
			}
			if(ab)System.out.println("NA");
			else System.out.println(y+1);
		}
	}
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n-1),b(n-1);
    for (int i = 0; i < n-1; i++)
    {
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    vector<ll> c(n);
    for (int i = 0; i < n; i++)
    {
        cin>>c[i];
    }
    sort(all(c));
    reverse(all(c));

    

    vector<ll> cnt(n);
    for (int i = 0; i < n-1; i++)
    {
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    vector<ll> g[n];
    for (int i = 0; i < n-1; i++)
    {
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    bool used[n];
    m0(used);
    ll ma = 0;
    ll su=0;
    for (int i = 0; i < n; i++)
    {
        if(cnt[ma]<cnt[i]) ma=i;        
    }
    ll cmax=0;
    for (int i = 0; i < n; i++)
    {
        su+=c[i];
        cmax=max(cmax,c[i]);
    }
    su-=cmax;

    vector<ll> ansls(n);
    ll pqcnt=0;
    pll pma = make_pair(-cnt[ma],ma);
    priority_queue<pll> pq;
    pq.push(pma);
    used[ma] = true;

    while(pq.size()>0)
    {
        pll now = pq.top();
        pq.pop();
        ansls[now.second]=c[pqcnt];
        //cout<<now.second<<" "<<pqcnt <<" "<<c[pqcnt]<<endl;
        pqcnt++;

        for (int i = 0; i < g[now.second].size(); i++)
        {
            ll next = g[now.second][i];
            if(used[next]) continue;
            used[next] = true;
            pq.push(make_pair(-cnt[next],next));
        }
    }

    cout<<su<<endl;
    for (int i = 0; i < n; i++)
    {
        if(i>0) cout<<" ";
        cout<<ansls[i];
    }
    cout<<endl;

    return 0;
}

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

int main(){

  int N1,N2,a;
  cin >> N1;
  N2 = N1;
  while(1 <= N1){
  	a += N1 % 10;
    N1 /= 10;
  }
  if(N2 % a == 0){
  cout << "Yes";
  }else{
  cout << "No";
  }
}



Measured memory_bytes: 256
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

char S[4010];
int R[4010];
int G[4010];
int B[4010];
int N;

void f(int *C, char c) {
  int sum = 0;
  C[0] = sum;
  for (int i = 0; i < N; ++i) {
    if (S[i] == c)
      ++sum;
    C[i+1] = sum;
  }
}

int main(void) {
  scanf("%d", &N);
  scanf("%s", &S[0]);

  f(R, 'R');
  f(G, 'G');
  f(B, 'B');
  // for (int i = 0; i <= N; ++i)
  //   printf("%d ", R[i]);

  uint64_t ans = 0;
  for (int i = 1; i < N - 1; ++i) {
    for (int l = 0; l < i; ++l) {
      if (S[i] == S[l])
        continue;
      char rc;
      if (S[i] == 'R')
        rc = S[l] == 'G' ? 'B' : 'G';
      else if (S[i] == 'G')
        rc = S[l] == 'R' ? 'B' : 'R';
      else
        rc = S[l] == 'G' ? 'R' : 'G';
      int *A;
      switch (rc) {
      case 'R': A = R; break;
      case 'G': A = G; break;
      case 'B': A = B; break;
      }
      int cnt = A[N] - A[i+1];
      int r = i * 2 - l;
      if (r < N && S[r] == rc)
        --cnt;
      ans += cnt;
    }
  }
  printf("%llu\n", ans);
}

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

#define N 100000

int main(void){
	vector<bool> isprime(N+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	isprime[1]=false;
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	int n;
	while(cin>>n,n){
		int c=0;
		for(int i=2;i<=n/2;++i){
			if(isprime[i]&&isprime[n-i])++c;
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<float.h>
#include<math.h>

int main(void){
    int d,n;
    scanf("%d %d",&n,&d);
    int pos[n][d];
    for(int i = 0;i < n;i++)for(int j = 0;j < d;j++)scanf("%d",&pos[i][j]);
    int cnt = 0;
    long sum = 0;
    for(int p1 = 0;p1 < n;p1++)for(int p2 = 0;p2 < n;p2++){
        sum = 0;
        for(int i = 0;i < d;i++)sum += (pos[p1][i] - pos[p2][i]) * (pos[p1][i] - pos[p2][i]);
        long double lds = sum;
        if(sqrtl(lds) - (long)sqrtl(lds) < LDBL_EPSILON)cnt++;
    }
    printf("%d",(cnt-n)/2);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int N; cin >> N; ll K; cin >> K;
    ll sum = 0;
    ll data[N];
    F0R(i, N) cin >> data[i];
    F0R(i, N) sum += data[i];
    vl facs;
    FOR(i, 1, 25000) {
        if (sum % i == 0) {
            ll A = i;
            ll B = sum / i;
            facs.pb(A);
            facs.pb(B);
        }
    }

    ll ans = 1;
    F0R(i, sz(facs)) {
        multiset<ll> vals;
        ll totalCost = 0;
        ll used = 0;

        F0R(j, N) {
            vals.insert(data[j] % facs[i]);
            totalCost += facs[i] - (data[j] % facs[i]);
        }
        for (auto it = vals.begin(); it != vals.end(); it++) {
            used += *it;
            totalCost -= facs[i] - *it;
            if (used == totalCost && used <= K) ans = max(ans, facs[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343
// license: https://github.com/bqi343/USACO/blob/master/LICENSE

Measured memory_bytes: 256
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    r = ni()
    
    print(2 * math.pi * r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9740
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;*/
typedef pair<pair<int ,int>, int> P;
vector<pair<pair<int ,int>, int> > v_ans;
vector<int>v_taro;
vector<int>v_hana;
/*taro tenn,hanako_ten,sum*/

bool cmp(P h, P r){
  return h.second < r.second;
}
int main(){

  int n,m;
  cin >>n>>m;

  while(n != 0 and m != 0){
    int tp_sum = 0,hp_sum = 0;
    for(int i = 0; i< n;i++){
      int x ;
      cin >>x;
      tp_sum += x;
      v_taro.push_back(x);
    }
    for(int i = 0; i< m;i++){
      int x ;
      cin >>x;
      hp_sum += x;
      v_hana.push_back(x);
    }
    int def = tp_sum-hp_sum;

    for(int i = 0; i<n; i++){
      for (int j = 0;j < m; j++){
        if(2*(v_taro[i]-v_hana[j])==def){
          v_ans.push_back(make_pair(make_pair(v_taro[i],v_hana[j]),v_taro[i]+v_hana[j]));
        }
      }
    }
    sort(v_ans.begin(),v_ans.end(),cmp);
    if(v_ans.empty() != true){
    cout <<v_ans[0].first.first<<' '<<v_ans[0].first.second<<endl;
    }
    else{
      cout <<-1<<endl;
    }
    v_ans.clear();
    v_taro.clear();
    v_hana.clear();
    cin >>n>>m;
  }
  return 0;
}



Measured memory_bytes: 3180
def palindrome(s):
    return s == "".join(list(reversed(s)))

S = input()
N = len(S)

s1 = S[:(N-1)//2]
s2 = S[(N+3)//2 -1:]
print("Yes" if palindrome(s1) and palindrome(s2) and palindrome(S) else "No")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
  int n,wt,i,j,w[100],v[100];
  long int dp[100][100005]={},a,b;
  cin >> n >> wt;
  for (i=0;i<n;i++) cin >> w[i] >> v[i];
  for (i=w[0];i<=wt;i++) dp[0][i]=v[0];
  for (i=1;i<n;i++){
    for (j=1;j<=wt;j++){
      if (j<w[i]) dp[i][j]=dp[i-1][j];
      else{
        a=dp[i-1][j-w[i]]+v[i];
        b=dp[i-1][j];
        dp[i][j]=(a>b)? a:b;
      }
    }
  }
  cout << dp[n-1][wt] << '\n';
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  vector<int> coin = { 25, 10, 5, 1 };
  int ans = 0;

  int n; cin >> n;

  rep(i,coin.size()) {
    ans += n / coin[i];
    n %= coin[i];
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3104