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


#define ll              long long int
#define fo(i,n)         for(int i=0;i<n;i++)
#define rfo(i,n)        for(int i=n-1;i>=0;i--)
#define Ull             unsigned long long
#define pb              push_back
#define F               first
#define S               second
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl

const int N = 2;
const ll MOD = 1e9 + 7;


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


bool comp(const pll &p1, const pll &p2)
{
	if (p1.first == p2.first)
		return p1.second > p2.second;

	else
		return p1.first > p2.first;
}

bool isPrime(ll x)
{
	if (x < 2)
		return false;

	if (x <= 3) return true;

	if (x % 2 == 0 || x % 3 == 0) return false;

	for (ll i = 5; i <= sqrt(x); i += 6)
	{
		if (x % i == 0 || x % (i + 2) == 0)
			return false;
	}

	return true;
}
















void Solve()
{



	int n;
	cin >> n;
	int a[n];
	fo(i, n) cin >> a[i];

	sort(a, a + n);
	int maxy = a[n - 1];
	int ans = 0;
	int vis[maxy + 1];
	for (int i = 0; i <= maxy; i++)
		vis[i] = 1;
	fo(i, n)
	{
		if (vis[a[i]])
		{
			for (int j = a[i]; j <= maxy; j += a[i])
				vis[j] = 0;

			if (a[i] != a[i + 1])
				ans++;
		}
	}

	cout << ans << "\n";







}







int main()
{

	FastRead;
	int T = 1;
	//cin >> T;

	while (T--)
	{
		Solve();
	}


	return 0;
}







Measured memory_bytes: 8336
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<lli,pi>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 5;
int n;
lli dp[N];

int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		cin >> n;
		lli a[n];
		lli ans = 0;
		for(int i=1;i<=n;i++)
		{	
			cin >> a[i];
			if(a[i]-1 + i <= n) dp[a[i]-1 + i]++;
		}
		// for(int i=1;i<=n;i++) cout << dp[i] << " ";
		// cout << endl;
		for(int i=1;i<=n;i++)
		{
			if(i - a[i] - 1 >= 0) ans = ans + dp[i - a[i] - 1];
			// cout << ans << endl;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    bool ok = false;
    for(int i = 1; i < 1001; i++){
        int t = k * i;
        if(t > b){
            break;
        }else if(a <= t && t <= b){
            ok = true;
            break;
        }else{
            continue;
        }
    }
    
    if(ok){
        cout << "OK\n";
    }else{
        cout << "NG\n";
    }
}

Measured memory_bytes: 3544
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)
for i in range(N-1):
    if A[i]+1 == A[i+1]:
        AAA = A[i]
        ans += C[AAA-1]

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int[] A=new int[N+1];
	int[] B=new int[N];
	for(int i=0;i<N+1;i++) {
		A[i]=sc.nextInt();
	}
	long ans=0;
	for(int i=0;i<N;i++) {
		B[i]=sc.nextInt();
	}
	for(int i=0;i<N;i++) {
		if(B[i]<=A[i]) {
			ans+=B[i];
		}else if(B[i]<=A[i]+A[i+1]) {
			ans+=B[i];
			A[i+1]-=B[i]-A[i];
		}else {
			ans+=A[i]+A[i+1];
			A[i+1]=0;
		}
	}
	System.out.println(ans);

}
}


Measured memory_bytes: 87276
import heapq

# O(MlogN)
n,m = map(int,input().split())
a_list = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a_list)

for _ in range(m):
    tmp_min = heapq.heappop(a_list)
    heapq.heappush(a_list, (-1)*(-tmp_min//2)) 

print(-sum(a_list))

Measured memory_bytes: 14380
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

inline int ceiling(int n, int d) {
	return n % d == 0 ? n / d : n / d + 1;
}

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int count = 0, max_count = 0;
	for (size_t i = 0; i < s.length(); i++) {
		if (s[i] == 'I')++count;
		else --count;
		max_count = max(max_count, count);
	}
	cout << max_count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef int64_t in;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll n; cin >> n;
    ll sum=0;
    rep(i,n+1){
        sum += i;
    }
    cout << sum << "\n";
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b);
  if (a >= 13) {
    out(b);
  } else if (a >= 6) {
    out(b / 2);
  } else {
    out(0);
  }
}


Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
vector<map<P,int>> m;
int c[4][6]={
    {3,0,1,2,4,5},
    {1,2,3,0,4,5},
    {4,1,5,3,2,0},
    {5,1,4,3,0,2}
};

string s;

void rec(int k,int i,int y,int x,vector<int> v){
    m[i][{y,x}]=v[0];
    if(s.length()==k) return;
    vector<int> t(6);
    if(s[k]=='L'){
        for (int j = 0; j < 6; j++) {
            t[j]=v[c[0][j]];
        }
        rec(k+1,i,y,x-1,t);
    }
    else if(s[k]=='R'){
        for (int j = 0; j < 6; j++) {
            t[j]=v[c[1][j]];
        }
        rec(k+1,i,y,x+1,t);
    }
    else if(s[k]=='F'){
        for (int j = 0; j < 6; j++) {
            t[j]=v[c[2][j]];
        }
        rec(k+1,i,y-1,x,t);
    }
    else{
        for (int j = 0; j < 6; j++) {
            t[j]=v[c[3][j]];
        }
        rec(k+1,i,y+1,x,t);
    }
}



int main(){
    int n;
    while(cin >> n,n){
        m.clear();
        m.resize(n);
        for (int i = 0; i < n; i++) {
            int x,y;cin >> x >> y;
            vector<int> u(6);
            cin >> u[3] >> u[1] >> u[4] >> u[5] >> u[0] >> u[2];
            cin >> s;
            rec(0,i,y,x,u);
        }
        vector<int> dp(1<<n,-INF);
        dp[0]=0;
        int ans=-INF;
        for (int bit = 0; bit < 1<<n; bit++) {
            ans=max(ans,dp[bit]);
            for (int i = 0; i < n; i++) {
                if(bit&(1<<i)) continue;
                int sum = 0;
                for (auto p:m[i]) {
                    P t=p.first;
                    bool f=true;
                    for (int j = 0; j < n; j++) {
                        if(bit&(1<<j)){
                            if(m[j].find(t)!=m[j].end()){
                                f=false;
                                break;
                            }
                        }
                    }
                    if(f) sum+= p.second;
                }
                int nx = bit|(1<<i);
                dp[nx]=max(dp[nx],dp[bit]+sum);
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3312
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
using namespace std;
const int num = 2000001, num1 = 10000;
int main() {
	int n, a[num], c[num1 + 1], b[num];
	cin >> n;
	for (int i = 0; i <= num1; i++) c[i] = 0;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) c[a[i]]++;
	for (int i = 1; i <= num1; i++) c[i] += c[i - 1];
	for (int i = 0; i < n; i++) b[(c[a[i]]--)-1] = a[i];
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 18604
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.range;

void main() {
  long a, b, k;
  readf("%d %d %d", &a, &b, &k);

  foreach_reverse (i; 1..min(a, b)+1) {
    if (a % i == 0 && b % i == 0) {
      k--;
      if (k == 0) {
        writeln(i);
        break;
      }
    }
  }
}


Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())
    if a==0 and b==0: break

    line=[]
    kei=[]
    i=0
    
    for _ in range(a):line.append(int(input()))
    
    for j in range(0,b):i += line[j]
    
    for I in range(b,a):
        i += line[I]-line[I-b]
        kei.append(i)
        
    print(max(kei))
    


Measured memory_bytes: 11520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int n, i = 1, j;
		
		Scanner scan = new Scanner(System.in);
		
		n = scan.nextInt();
		
		while(i <= n) {
			if(i % 3 == 0) {
				System.out.printf(" %d", i);
			} else if(i % 10 == 3) {
				System.out.printf(" %d", i);
			} else {
				for(j = 10; j < 100000; j*=10) {
					if(i / j == 3 || i / j % 10 == 3) {
						System.out.printf(" %d", i);
						break;
					}
				}
			}
			
			i++;
			
		}
		System.out.println();
	}

}


Measured memory_bytes: 37156
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
int arr[maxn];
ll suf[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	cin >> arr[1];
	for(int i=2;i<=n;i++) {
		char op;
		cin >> op >> arr[i];
		if(op == '-')	arr[i] *= -1;
	}
	for(int i=n;i>=1;i--)
		suf[i] = suf[i+1] + abs(arr[i]);
	ll ans = -1e18 , sum = 0;
	for(int i=1;i<=n;i++) {
		sum += arr[i];
		if(arr[i] < 0) {
			ll tem = 0;
			int j = i + 1;
			while(j <= n && arr[j] > 0)		tem += arr[j] , j++;
			ans = max(ans,sum - tem + suf[j]);
			sum += tem;
			i = j - 1;
		}
	}
	ans = max(ans,sum);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int H, W;
    cin >> H >> W;
    vector<string> mass(H);
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        mass[i] = s;
    }
    vector<vector<int*>> count_row(H, vector<int*>(W));
    vector<vector<int*>> count_col(H, vector<int*>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            count_row[i][j] = new int;
            count_col[i][j] = new int;
        }
    }
    int* zero = new int;
    *zero = 0;
    int* count;
    for (int i = 0; i < H; i++) {
        count = new int;
        *count = 0;
        for (int j = 0; j < W; j++) {
            // cout << "(" << i << ", " << j << ")" << endl;
            if (mass[i][j] == '#') {
                count_row[i][j] = zero;
                count = new int;
                // values_row.push_back(count);
                *count = 0;
            } else {
                *count += 1;
                count_row[i][j] = count;
            }
        }
    }
    // for (auto c_row: count_row) {
    //     for (auto c: c_row) {
    //         cout << *c << " ";
    //     }
    //     cout << endl;
    // }
    for (int j = 0; j < W; j++) {
        count = new int;
        *count = 0;
        // values_col.push_back(count);
        for (int i = 0; i < H; i++) {
            // cout << "(" << i << ", " << j << ")" << endl;
            if (mass[i][j] == '#') {
                count_col[i][j] = zero;
                count = new int;
                // values_col.push_back(count);
                *count = 0;
            } else {
                *count += 1;
                count_col[i][j] = count;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, *count_row[i][j] + *count_col[i][j] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int dp[1001][8];
char sc[1001];
int mod=10007;
int main(){
    int n,b;
    cin>>n>>sc;
    char s=sc[0];
    if(s=='J') b=1;
    else if(s=='O') b=2;
    else b=4;
    for(int i=1;i<8;++i) if((i&b)&&(i&1)) dp[0][i]=1;
    for(int i=1;i<n;++i){
        s=sc[i];
        if(s=='J') b=1;
        else if(s=='O') b=2;
        else b=4;
        for(int j=1;j<8;++j){
            if(!(j&b)) continue;
            for(int k=1;k<8;++k){
                if(k&j){
                    dp[i][j] +=dp[i-1][k];
                    dp[i][j] %=mod;
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<8;++i) ans +=dp[n-1][i];
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

long long mid(long long a, long long b, long long c) {

}

void solve(long long n, std::vector<long long> p){
  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    if (p[i] < p[i+1] && p[i+1] < p[i+2]) {
      ans++;
    } else if (p[i] > p[i+1] && p[i+1] > p[i+2]) {
      ans++;
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long n;
  scanf("%lld",&n);
  std::vector<long long> p(n);
  for(int i = 0 ; i < n ; i++){
    scanf("%lld",&p[i]);
  }
  solve(n, std::move(p));
  return 0;
}


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

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

/*-------------------------------------------*/

ll n;
char a[500][500];
bool b[500];

int main(){
    cin>>n;
    bool ok=false;
    rep(i,n)rep(j,n){
        cin>>a[i][j];
        if(a[i][j]=='#')ok=true,b[j]=true;
    }
    
    if(!ok){
        cout<<"-1\n";
        return 0;
    }

    int num=0;
    rep(i,n){
        bool w=false;
        rep(j,n){
            if(a[j][i]=='.')w=true;
        }
        if(w)num++;
    }

    int ans=100000;
    rep(i,n){
        int x=0;
        rep(j,n){
            if(a[i][j]=='.')x++;
        }
        chmin(ans,x+num+(b[i]?0:1));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,d;cin>>n>>d;
  rep(i,0,n){
    ll x,y;cin>>x>>y;
    if(x*x+y*y<=d*d)res++;
  }
  cout<<res<<endl;
  return 0;
}

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

int main()
{
  int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  // now we have to check the multiples...
  int temp = a/k;
  int temp1 = (temp+1)*k;
  if(temp1>=a && temp1<=b || temp*k == a)
    cout<<"OK"<<"\n";
  else
    cout<<"NG"<<"\n";
  
  
  return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
xx = inpl()
L = int(input())

K = N.bit_length()
db_r = [[0]*K for i in range(N)]
for i,x in enumerate(xx):
    ind = bisect.bisect_right(xx,x+L)
    db_r[i][0] = ind-1

for k in range(1,K):
    for i in range(N):
        db_r[i][k] = db_r[db_r[i][k-1]][k-1]

def check(a,b,d):
    L = d.bit_length()
    for k in range(L):
        if d & (1<<k):
            a = db_r[a][k]
    return a >= b

Q = int(input())
for i in range(Q):
    a,b = inpl()
    a -= 1
    b -= 1
    a,b = min(a,b),max(a,b)
    OK = N
    NG = 0
    while OK-NG>1:
        mid = (OK+NG)//2
        if check(a,b,mid): OK = mid
        else: NG = mid
    print(OK)


Measured memory_bytes: 99860
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N;
int x[10] = {0};
int y[10] = {0};
vector<double> L;
vector<int> towns;

double dist(int i, int j){
	double ret = 0;
	int dx = abs(x[i] - x[j]);
	int dy = abs(y[i] - y[j]);
	ret = sqrt(dx*dx + dy*dy);
	return ret;
}

// v1:訪問済の町
// v2:訪問未の町
void dfs(vector<int> v1, vector<int> v2){
	if(v1.size() > N){ return; }
	if(v1.size() == N){
		double u = 0;
		for(int i = 0; i < v1.size() -1 ; i++){
			u += dist(v1[i], v1[i + 1]);
		}
		L.push_back(u);
		return;
	}

	for(int i = 0; i < v2.size(); i++){
		vector<int> u1 = v1;
		vector<int> u2 = v2;
		u1.push_back(u2[i]);
		u2.erase(u2.begin() + i);
		dfs(u1, u2);
	}
	return;
}

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

	
	cin >> N ;

	int NA = 1;
	for(int i=1; i<=N; i++){
		cin >> x[i] >> y[i] ;
		NA *= i;
		towns.push_back(i);
	}
	vector<int> v1;
	dfs(v1, towns);

	double ans = 0;
	for(int i = 0; i < L.size(); i++){
		ans += L[i];
	}
	ans /= NA;
	printf("%.6lf\n", ans);
	return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();

		if (n % 500 <= a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 12, M = 1e3 + 5;
const ll LINF = 1e18 + 5;
int n, m;
int dp[1<<N], a[M], b[M], c[M];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	for(int i=1; i<=m; i++)
 	{
 		cin >> a[i] >> b[i];
 		for(int j=0, x; j<b[i]; j++)
 		{
 			cin >> x;
 			c[i] |= (1<<(x-1));
 		}
 	}
 	for(int j=1; j<(1<<n); j++)
 		dp[j] = INF;
 	for(int i=1; i<=m; i++)
 	{
 		for(int j=0; j<(1<<n); j++)
 		{
 			dp[j|c[i]] = min(dp[j|c[i]], dp[j]+a[i]);
		}
	}
	int ans = dp[(1<<n)-1];
	if(ans==INF) ans = -1;
	cout << ans;
	return 0;
}


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

void solve(long long n, vector<string> S){
	vector<int> ans(26);
	for(int i = 0 ; i < 26 ; i++) ans[i] = 1e9;
	for(int i = 0 ; i < S.size() ; i++){
		vector<int> subans(26);
		for(auto j : S[i] ){
			subans[j-'a']++;
		}
		for(int j = 0 ; j < 26 ; j++)
			ans[j] = min(ans[j],subans[j]);
	}
	for(int i = 0 ; i < 26 ; i++){
		cout << string(ans[i],i+'a');
	}
	cout << endl;
}

int main(){	
	long long n;
	scanf("%lld",&n);
	vector<string> S(n-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		cin >> S[i];
	}
	solve(n, S);
	return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

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

    if (c - (a - b) <= 0)
        cout << 0 << endl;
    else
        cout << c - (a - b) << endl;

    return 0;
}

Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
"""
D - Even Relation
https://atcoder.jp/contests/abc126/tasks/abc126_d

"""
import sys

from heapq import heappush, heappop


def dijkstra(adj, s):
    N = len(adj)
    WHITE, GRAY, BLACK = 0, 1, 2
    color = [WHITE] * N
    d = [float('inf')] * N
    d[s] = 0
    pq = []
    heappush(pq, (0, s))
    while pq:
        cost, u = heappop(pq)
        color[u] = BLACK
        if d[u] < cost:
            continue
        for v, cost in adj[u]:
            if color[v] == BLACK:
                continue
            if d[v] > d[u] + cost:
                d[v] = d[u] + cost
                heappush(pq, (d[v], v))
                color[v] = GRAY
    return d


def solve(N, path):
    adj = [[] for _ in range(N+1)]
    for f, t, w in path:
        adj[f].append([t, w])
        adj[t].append(([f, w]))
    dist = dijkstra(adj, 1)
    ans = []
    for d in dist[1:]:
        if d%2 == 0:
            ans.append(0)
        else:
            ans.append(1)
    return ans


def main(args):
    N = int(input())
    path = [[int(i) for i in input().split()] for _ in range(N-1)]
    ans = solve(N, path)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 61664
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    int n, m, s, c;
    cin >> n >> m;
    vector<int> a(n, -1);
    bool ans = true;

    rep(i, m){
        cin >> s >> c;
        s--;
        if(a[s] == -1) a[s] = c;
        else if(a[s] != c) ans = false;
    }
    if(a[0] == 0 && n >= 2) ans = false;
    if(ans){
        for(int i=0; i<n; i++){
            if(a[i] == -1){
                if(i == 0 && n >= 2) cout << "1";
                else cout << "0";
            }
            else cout << a[i];
        }
    }
    else cout << "-1";

    cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
 long long int N,ans;
 scanf("%lld",&N);
 if(N%2!=0){ans=0;}
 else{
 ans=N/10;
 N/=10;
 for(int i=1;;i++)
 {
	ans+=(N/5);
	N/=5;
	if(N==0){break;}
 }
 }
 printf("%lld",ans);
}



Measured memory_bytes: 3748
#include<iostream>

using namespace std;


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

    while(true){
        if(N == 111 || N == 222 || N == 333 || N == 444 || N == 555 || N == 666 || N == 777 || N == 888 || N == 999){
            cout << N << endl;
            return 0;
        }
        N++;
    }

    return 0;
}

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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <=d || abs(b-a) <= d && abs(c-b) <= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

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

int main(){
    int i;
    //入力
    long n,k;
    cin>>n>>k;
    long a[n];
    long long b=0;
    rep(i,n){
        cin>>a[i];
    }
    //処理
    sort(a,a+n);
    rep(i,n-k){
        b+=a[i];
    }
    //出力
    cout<<b<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N,Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<int> L(Q), R(Q);
	for(int i=0; i<Q; i++){
		cin >> L.at(i) >> R.at(i);
	}
	
	
	vector<int> flag_AC(N);
	flag_AC.at(0) = 0;
	for(int i=1; i<N; i++){
		flag_AC.at(i) = flag_AC.at(i-1);
		if(s.at(i)=='C' && s.at(i-1)=='A'){
			flag_AC.at(i)++;;
		}
	}
	//回答生成
	for(int i=0; i<Q; i++){
		cout << flag_AC.at(R.at(i)-1)-flag_AC.at(L.at(i)-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

int main() {

	int n;
	cin >> n;

	int *Input = new int[n];

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

	vector<int> ans;
	ans.clear();
	ans.push_back(Input[0]);

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

		if(ans[ans.size()-1] != Input[i])
		ans.push_back(Input[i]);

	}
	
	for (int i = 0; i < ans.size() - 1; i++)
		cout << ans[i] << " ";

	cout << ans[ans.size() - 1] << "\n";

	return 0;

}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  string s;
  cin >> n >> s >> k;
  for(int i = 0;i<n;i++){
    if(s.at(i) != s.at(k-1)){
      s.at(i) = '*';
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int a;
  string s;
  cin >> n;
  for(i=1;i<=n;i++){
    cin >> a;
    if(a%2==1 && i%2==1) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-48;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int main()
{   
    fast;
    int n;
    cin>>n;
    int a[200005];
    int m=0;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        m=max(a[i],m);
        sum+=(m-a[i]);
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 4432
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;
const LL Mod = 1000000007LL;

LL a[MAXN+1],N,N2; LL s[MAXN+1];
LL f[2][621][621]; 
inline void Add(LL &x,LL y){ x=(x+y>=Mod?x+y-Mod:x+y); }

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N2=read(); LL fac=1,ft=0; N=N2*2;
	for(int i=1;i<=N;i++){ a[i]=read(); if(a[i]>0) a[i]=N-a[i]+1; if(a[i]>0) s[a[i]]=i; }
	for(int i=1;i<=N;i+=2) ft+=(a[i]==-1&&a[i+1]==-1);
	for(int i=1;i<=ft;i++) fac=fac*i%Mod;
	f[(N+1)&1][0][0]=1; 
	for(int i=N+1;i>=2;i--){
		int d=(i&1);
		memset(f[d^1],0,sizeof(f[d^1]));
		for(int j=0;j<=(N+1)-i;j++){
			for(int k=0;k+j<=N2;k++){
				if(!f[d][j][k]) continue;
				LL n=f[d][j][k];
				if(s[i-1]){
					int y=((s[i-1]-1)^1)+1;
					if(a[y]==-1){
						if(k) Add(f[d^1][j][k-1],n*k%Mod);
						Add(f[d^1][j+1][k],n);
					} else{
						Add(f[d^1][j][k],n);
						continue;
					}
				} else{
					Add(f[d^1][j+1][k],n);
					Add(f[d^1][j][k+1],n);
					if(j) Add(f[d^1][j-1][k],n);
				}
			}
		}
	}
	printf("%lld\n",f[1][0][0]*fac%Mod);
	return 0;
}




Measured memory_bytes: 6528
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
else:
    a = []
    b = []
    for i in range(n):
        if i % 2 == 0:
            a.append(v[i])
        else:
            b.append(v[i])
    c_a = Counter(a).most_common()
    c_b = Counter(b).most_common()

    if c_a[0][0] != c_b[0][0]:
        ans = n - c_a[0][1] - c_b[0][1]
    else:
        ans = min(n - c_a[0][1] - c_b[1][1], n - c_a[1][1] - c_b[0][1])
    
    print(ans)


Measured memory_bytes: 21084
a,b,c,d = map(int,input().split())
if a%d == 0:
    takahashi_turn = a//d
else:
    takahashi_turn = a//d+1
if c%b == 0:
    aoki_turn = c//b
else:
    aoki_turn = c//b+1
#print(takahashi_turn, aoki_turn)
print('Yes' if takahashi_turn >= aoki_turn else 'No')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    rep(i, 0, 1000) {
        int d[3] = {i / 100, (i / 10) % 10, i % 10};
        int tmp = 0;
        rep(j, 0, n) {
            if (s[j] - '0' == + d[tmp]) tmp++;
            if (tmp == 3) break;
        }
        if (tmp == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	string s[50];
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
	const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') continue;
			int num = 0;
			for (int k = 0; k < 8; k++) {
				const int ni = i + dy[k];
				const int nj = j + dx[k];

				if (ni < 0 || h <= ni) continue;
				if (nj < 0 || w <= nj) continue;
				if (s[ni][nj] == '#') num++;
			}
			s[i][j] = char(num + '0');
		}
	}
	for (int i = 0; i < h; i++) {
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int x;
    scanf("%d", &x);
    int ans = 1;
    for(int i = 2; i * i <= x; i++){
        int pw = i;
        while(pw * i <= x){
            pw *= i;
        }
        if (pw > ans) {
            ans = pw;
        }
    }
    printf("%d\n", ans);
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, ch = "";
  cin >> s;

  for (int i = s.length() - 1; i >= 0; --i) {
    ch.push_back(s[i]);
    if (ch == "maerd" || ch == "remaerd" || ch == "esare" || ch == "resare")
      ch = "";
  }

  cout << (ch == "" ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
char str[100005];
int  num[100005];
int main()
{

    int n,m;
    cin>>n>>m;
    cin>>str;
    int t=0;
    int len=strlen(str);
    num[0]=0;
    for(int i=1;i<len;i++)
    {
        if(str[i]=='C'&&str[i-1]=='A')
            t++;
        num[i]=t;
    }
    while(m--){
        int a,b;
        cin>>a>>b;
        int k=num[b-1]-num[a-1];
        cout<<k<<endl;

    }

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n;cin>>n;
  vector<int> p(n), q(n);
  fr(i, n) {
    int a; cin>>a;
    p[i] = q[i] = a; 
  }
  sort(q.begin(), q.end());
  int c = 0;
  fr(i, n) if(p[i] != q[i]) c++;
  cout << (c <= 2? "YES" : "NO") << endl;
  return 0;
}

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

int main(){
    string t;
    cin >> t;
    int n = t.size();
    for(int i=0; i<n; i++){
        if(t[i]=='?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
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 ll INF = 1LL << 60;

int main() {
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }
  ll MAX_V = N * 1000 + 1;
  
  vector<vector<ll>> dp(N+1, vector<ll>(MAX_V, INF));
  dp[0][0] = 0;
  
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < MAX_V; ++j) {
      if (j - v[i] >= 0) {
        chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
      }
      chmin(dp[i+1][j], dp[i][j]);
    }
  }
  ll res;
  for (int j = 0; j < MAX_V; ++j) {
	if (dp[N][j] <= W) res = j;
  }
  cout << res << endl;
}

Measured memory_bytes: 80256
k = int(raw_input())
a = map(int,raw_input().split(" "))

if a[-1] != 2:
  print "-1"
  exit(0)

r = [2,3]
ainv = a[::-1]

for now in ainv[1:]:
  lower = (r[0]/now)*now
  if lower < r[0]:
    lower += now
  upper = (r[1]/now)*now

  q = [lower,upper]

  if q[0] > r[1]:
    print "-1"
    exit(0)
  #print r,q
  q[1] = q[1] + now - 1
  r = q

print "%d %d" % (r[0],r[1])


Measured memory_bytes: 11316
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int d;
vector< int > c( 30 ), last( 30, 0 );
vector< vector< int > > arr( 400, vector< int >( 30, 0 ) );

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

	srand( time( 0 ) );	
	cin >> d;
	for( int i = 1; i <= 26; ++i )
	{
		cin >> c[ i ];
	}
	for( int i = 1; i <= d; ++i )
	{
		for( int j = 1; j <= 26; ++j )
		{
			cin >> arr[ i ][ j ];
		}
	}
	for( int i = 1; i <= d; ++i )
	{
		cout << ( rand() % 26 + 1 ) << "\n";
	}
	return 0;
}

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

long long dp[100] = {};

long long lucas_num(int N) {
  if (dp[N] > 0) return dp[N];
  if (N == 0) return 2;
  if (N == 1) return 1;
  return dp[N] = lucas_num(N - 1) + lucas_num(N - 2);
}

int main() {
  int N; cin >> N;
  cout << lucas_num(N) << endl;
  return 0;
}

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

int main() {
	string S;
	static int N, B, Bcount[200010] = {}, Wcount[200010] = {}, ans = 100000000;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == '#') Bcount[i + 1] = Bcount[i] + 1, Wcount[i + 1] = Wcount[i], B++;
		else Bcount[i + 1] = Bcount[i], Wcount[i + 1] = Wcount[i] + 1;
	}
	for (int i = 1; i <= N; i++) {
		if (S[i - 1] == '#') {
			int X = Bcount[i] - 1 + Wcount[N] - Wcount[i];
			ans = min(ans, X);
		}
	}
	if (ans == 100000000) ans = 0;
	ans = min(B, ans);
	cout << ans;
}

Measured memory_bytes: 2180
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);

    if((a+b)%2 == 1) Console.WriteLine("IMPOSSIBLE");
    else Console.WriteLine((a+b)/2);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N;
    cin >> N;
    if (N < 1000) {
        printf("ABC\n", N);
    } else {
        printf("ABD\n", N-999);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int val1 = sc.nextInt();
            int val2 = sc.nextInt();
            int val3 = sc.nextInt();
            int result = val1 + val2 + val3;
            if (result >= 22) {
                System.out.println("bust");
            } else {
                System.out.println("win");
            }
        }
    }

}


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

  bool ans = false;
  
   for(int c = 0; c <= N/4; c++){
     for(int d = 0; d <= N/7; d++){
        if(4*c + 7*d == N){
          ans = true;
        }
      }
    }
  
  if(ans == false){
  cout << "No" << endl;
  }
  
  else{
  cout << "Yes" << endl;
  }
  
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> a(n); rep(i, n)cin >> a[i];
	sort(all(a));
	if (a[0] == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	ll res = 1;
	ll UL = 1e18;
	rep(i, n)
	{
		if (res > res*a[i] || res * a[i] > UL)
		{
			cout << -1 << endl;
			return 0;
		}
		else res *= a[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 3992
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  int N;
  cin >> N;
  vector<ll> A(N+1);
  rep(i,N+1) cin >> A[i];
  vector<ll> B(N);
  rep(i,N) cin >> B[i];
  
  ll ans = 0;
  rep(i,N){
    if(B[i]>=A[i]){
        ans += A[i];
        B[i] -= A[i];
        A[i] = 0;
    }
    else{
        ans += B[i];
        A[i] -= B[i];
        B[i] = 0;
    }
    if(B[i]>=A[i+1]){
      	ans += A[i+1];
      	B[i] -= A[i+1];
      	A[i+1] = 0;
   	}
    else{
      	ans += B[i];
      	A[i+1] -= B[i];
      	B[i] = 0;
    }
  }
  cout << ans << endl;
  return;     
}

int main()
{
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,t,x,y;
    vector<pair<ll,pair<ll,ll> > >v;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>t>>x>>y;
        v.pb(mp(t,mp(x,y)));
    }
    v.pb(mp(0,mp(0,0)));
    sort(all(v));
    ll dis,flag=1,tdis;
    for(ll i=1;i<=n;i++){
        dis=abs(v[i].ss.ff-v[i-1].ss.ff)+abs(v[i].ss.ss-v[i-1].ss.ss);
        tdis=v[i].ff-v[i-1].ff;
        if(tdis<dis)
            flag=0;
        else if(tdis%2&&dis%2==0)
            flag=0;
        else if(tdis%2==0&&dis%2)
            flag=0;
    }
    if(flag)
        cout<<"Yes";
    else cout<<"No";


    return 0;
}



Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 k;
  cin >>k ;
  ll ans=0 ;

  for(int a=1 ;a<k+1 ;a++){
    for(int b=1 ; b<k+1 ; b++){
      for(int c=1 ; c<k+1 ; c++){
        ans += gcd(a, gcd(b,c)) ;
      }
    }
  }
  cout << ans <<endl ;
  
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

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

  cout<<"A"<<s[0]<<"C"<<endl;

  return 0;
}


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

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

unsi gojoho(unsi A, unsi B) {
	unsi R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	}
	else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

uni gojoho(uni A, uni B) {
	uni R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	}
	else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

unli gojoho(unli A, unli B) {
	unli R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	}
	else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

int gojoho(int A, int B) {
	int R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	}
	else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}



int main() {
	int R, G, B, N;
	int r_max;
	//int gcdRB;
	int	ans = 0;
	bool b = false;
	scanf("%d", &R);
	scanf("%d", &G);
	scanf("%d", &B);
	scanf("%d", &N);
	r_max = N / R;
	//gcdRB = gojoho(R, B);
	for (int i = 0; i <= r_max; i++) {
		int t = N - i * R;
		int b_max = t / B;
		for (int j = 0; j <= b_max; j++) {
			int s = t - j * B;
			if (s%G == 0) {
				ans = ans + 1;
			}
		}

	}
	printf("%d", ans);
	return(0);
}






Measured memory_bytes: 128
import java.util.*;

public class Main {

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

        int inputA = sc.nextInt();
        int inputB = sc.nextInt();

        if (canDivide(inputA, inputB)) {
            System.out.printf("Possible");
        } else {
            System.out.printf("Impossible");
        }
    }

    private static boolean canDivide(int inputA, int inputB) {
        if ((inputA % 3) == 0) {
            return true;
        } else if ((inputB % 3) == 0) {
            return true;
        }

        return (((inputA + inputB) % 3) == 0);
    }
}


Measured memory_bytes: 21204
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int n;
	while(cin>>n,n){
		vector<int> v(n); FOR(i,n) cin>>v[i];
		int ans = 0;
		FOR(i,n) for(int j = 0; j+1 < n-i; j++){
			if(v[j] > v[j+1]){ 
				swap(v[j],v[j+1]); 
				ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1196