akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

    int cnt_AB = 0, cnt_begin_B = 0, cnt_end_A = 0, cnt_bB_eA = 0;
    for (int n = 1; n <= N; n++)
    {
        string s; cin >> s;

        if (s[0] == 'B' && s[s.size() - 1] != 'A') cnt_begin_B++;
        else if (s[0] != 'B' && s[s.size() - 1] == 'A') cnt_end_A++;
        else if (s[0] == 'B' && s[s.size() - 1] == 'A') cnt_bB_eA++;

        for (int i = 0; i <= s.size() - 2; i++)
        {
            if (s[i] == 'A' && s[i + 1] == 'B') cnt_AB++;
        }
    }

    int ans;

    if (cnt_begin_B > 0 || cnt_end_A > 0)
    {
        ans = cnt_AB + cnt_bB_eA + min(cnt_begin_B, cnt_end_A);
    }
    else if (cnt_bB_eA > 0)
    {
        // (cnt_begin_B == 0 && cnt_end_A == 0 && cnt_bB_eA > 0)
        ans = cnt_AB + (cnt_bB_eA - 1);
    }
    else // (cnt_begin_B == 0 && cnt_end_A == 0 && cnt_bB_eA == 0)
    {
        ans = cnt_AB;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define FOR(n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int maxi(int a,int b,int c){
	int d=max(a,b);
	return max(d,c);
}

int mini(int a,int b,int c){
	int d=min(a,b);
	return min(d,c);
}

int dp[4001];

int main(){
	int n;
	cin >> n;
	int ar[n+1],sum=0;
	for(int i(1);i<=n;++i){
		cin >> ar[i];
		sum+=ar[i];
	}
	int dp[n+1],ans=101;
	dp[1]=ar[1];
	for(int i(1);i<n;i++){
		dp[i+1]=dp[i]+ar[i+1];
		ans=min(ans,abs(2*dp[i]-sum));
	}
	cout << ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
  unsigned long long n;
  cin >> n;
  unsigned long long c = n / 11;
  unsigned long long r = n % 11;
  if(r < 7 && r != 0){cout << c * 2 + 1 << endl;}
  else if(r == 0){cout << c * 2 << endl;}
  else{cout << c * 2 + 2 << endl;}
}

Measured memory_bytes: 256
s = input()
if s == 'SUN':
    print("7")
elif s == 'MON':
    print("6")
elif s == 'TUE':
    print("5")
elif s == 'WED':
    print("4")
elif s == 'THU':
    print("3")
elif s == 'FRI':
    print("2")
elif s == 'SAT':
    print("1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    int cnt = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt += a % 2;
    }
    YES(cnt % 2 == 0);

    solve();
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  int n;
  complex<double> T[1001];
  T[0] = 0.0; T[1] = 1.0;
  FOR(i,2,1000) T[i] = complex<double>(1.,1./sqrt(i-1))*T[i-1];
  while(cin >> n, n!=-1)
  {
    printf("%lf\n%lf\n",T[n].real(),T[n].imag());
  }
  return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>

using namespace std;

int main(void){
	string s, p;
	cin >> s >> p;
	s = s + s;
	if (s.find(p) != string::npos) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 3196
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
  ll A,B;
  cin >> A >> B;
  if((A-B)%2 == 0) cout << (A+B)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int main()
{
    long N, K;
    cin >> N >> K;
    
    vector<long> h(N);
    rep(i, N) {
        cin >> h.at(i);
    }

    sort(h.begin(), h.end());

    long ans = 0;
    rep(i, N) {
        if (h.at(i) >= K) {
            ans = N - i;
            break;
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int a; cin >> a;
	cout << (a ^ 1) << endl;

	return 0;
}



Measured memory_bytes: 3636
var
	n,m,ans,i,t:Longint;
begin
	read(n,m);
	i:=1;
	while i*i<=m do begin
		if m mod i=0 then begin
			t:=m div i;
			if(t>=n)and(ans<i)then ans:=i;
			if(i>=n)and(ans<t)then ans:=t;
		end;
		inc(i);
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b)
            System.out.println("a < b");
        else if(a > b)
            System.out.println("a > b");
        else
            System.out.println("a == b");
    }
}


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

using namespace std;

int N;

pair <pair<string, int>, int> arr[101];

int main () {
    
    cin >> N;

    for(int i = 0; i < N; i++){
        int point;
        cin >> arr[i].first.first >> point;
        arr[i].first.second = -point;
        arr[i].second = i+1;
    }

    sort (arr,arr+N);

    for(int i = 0; i < N; i++){
        cout << arr[i].second << "\n";
    }



}

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

int main() {
  
  int A,B,C,K,x,y;
  cin >> A >> B >> C >> K;
  x = K-A;
  y = x-B;
  if ( x <0){
    cout << K << endl;
  }else if ( y <0){
    cout << A << endl;
  }else{
    cout << A-y << endl;
  }
  
}


Measured memory_bytes: 3620
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	string S;
	int K;
	cin >> K;
	cin >> S;
	if(S.size() <= K){
		cout << S;
	}else{
		cout << S.substr(0, K) << "...";
	}
	cout << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

vector<pair<char, ll>> RLE(string& s) {
	ll cnt = 0;
	vector<pair<char, ll>> res;
	for (ll i = 0; i < s.size(); i++) {
		cnt++;
		if (i == (ll)s.size() - 1) {
			res.push_back(make_pair(s[i], cnt));
			break;
		}
		if (s[i] != s[i + 1]) {
			res.push_back(make_pair(s[i], cnt));
			cnt = 0;
		}
	}
	return res;
}
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	auto vp = RLE(s);
	ll res = 0;
	for (int i = (int)vp.size() - 2; i >= 0; i--) {
		if (vp[i].first == 'B' and vp[i + 1].first == 'W') {
			res += vp[i].second * vp[i + 1].second;
			if (i > 0) vp[i - 1].second += vp[i + 1].second;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 5508
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  std::string a, b;
  Solver() {
    S002 reader;
    reader >= a >= b;
  }
  void solve() {
    if( a[0] == 'H' ) printf("%c\n", b[0]);
    if( a[0] == 'D' ) printf("%c\n", 'D' + 'H' - b[0]);
  }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

#define PI 3.1415926535

int main() {
    int n;
    std::cin >> n;
    std::vector<long long> x(n), y(n);
    std::vector<double> theta(n - 1), difftheta(n - 1);
    for (auto i = 0; i < n; i++) std::cin >> x[i] >> y[i];

    for (auto i = 0; i < n; i++) {
        for (auto j = 0; j < n; j++) {
            if (j == i) continue;
            theta[j - (j > i)] = std::atan2(y[j] - y[i], x[j] - x[i]);
        }
        std::sort(theta.begin(), theta.end());
        difftheta[0] = 2 * PI + theta[0] - theta[n - 2];
        for (auto j = 1; j < n - 1; j++) {
            difftheta[j] = theta[j] - theta[j - 1];
        }
        auto res = *std::max_element(difftheta.begin(), difftheta.end());
        if (res < PI) std::cout << 0.0 << std::endl;
        else std::cout << (res - PI) / (2 * PI) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define mod 1000000007
typedef long long ll;
ll n,m,a[333333],ans,cnt;
void read(ll &x)
{
	scanf("%lld",&x);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
int main()
{
	cin>>n;
	for(ll i=1;i<=3*n;i++)
		read(a[i]);
	sort(a+1,a+3*n+1);
	for(ll i=3*n-1;i>=1;i-=2)
	{
		cnt++;
		ans+=a[i];
		if(cnt==n)
			break;
	}
	cout<<ans;
}

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

int main(){
    int n ;
    cin >> n ;
    int A[n] ;
    int B[n] ;
    rep(i,n) cin >> A[i] ;
    int count = 0 ;
    ll ans = 0 ;
    int min_abs = 1e9 + 7 ;
    rep(i,n){
        if( A[i] < 0 ){
            count++ ;
            B[i] = - 1 * A[i] ;
        } 
        else B[i] = A[i] ;
        min_abs = min(min_abs,B[i]) ;
    }
    if( count%2 == 0 ){
        rep(i,n) ans += B[i] ;
        cout << ans << endl;
    }
    else{
        rep(i,n) ans += B[i] ;
        cout << ans - 2 * min_abs << endl;
    }
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def f(b,n):
    if(n<b): return n
    return f(b,n//b)+n%b

def resolve():
    n=int(input())
    s=int(input())

    if(s>n):
        print(-1)
        return
    if(s==n):
        print(n+1)
        return

    # 2 <= b <= sqrt(n) を全探索
    k=int(n**.5)
    for b in range(2,k+1):
        if(f(b,n)==s):
            print(b)
            return

    # sqrt(n) < b <= n を考える
    B=[]
    for p in range(1,k+1):
        if((n-s)%p): continue
        b=(n-s)//p+1
        if(b<2): continue
        if(f(b,n)==s):
            B.append(b)

    print(min(B) if(B) else -1)
resolve()

Measured memory_bytes: 42864
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define ld long double
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 100000007;
const int inf = 100005;
const int N = 3e5, M = N;
ll i,j,n,m,idx,cnt;
char d[31][31];
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};

int cal (int x , int y) {
    queue<pair<int,pii>>q;

    if(d[x][y] == '#') return 0;

    int u[31][31];
    int vis[31][31],ii,jj;
    fo(ii,0,31) {
        fo(jj,0,31) vis[ii][jj] = 0 , u[ii][jj] = inf;
    }
    u[x][y] = 0;

    q.push({x,{y,0}});

    while(!q.empty()) {
        pair<int,pii> p = q.front();
        q.pop();

        if(vis[p.ff][p.ss.ff]) continue;

        vis[p.ff][p.ss.ff] = 1;

        fo(idx,0,4) {
            int x1 = p.ff + dx[idx];
            int y1 = p.ss.ff + dy[idx];
            if(x1<0 || x1>=n || y1<0 || y1>=m || vis[x1][y1]) continue;

            if(d[x1][y1] == '#') {
                u[x1][y1] = inf;
                continue;
            }

            u[x1][y1] = min(u[x1][y1] , p.ss.ss+1);

            q.push({x1,{y1,p.ss.ss+1}});
        }

    }
    int ans = 0;

    fo(ii,0,n) {
        fo(jj,0,m) {
            if(u[ii][jj] == inf) continue;
            ans = max(ans , u[ii][jj]);
        }
    }
    return ans;
}

void solve() {

 cin>>n>>m;

 fo(i,0,n) {
    fo(j,0,m) {
        cin>>d[i][j];
    }
 }

 int ans = 0;
 fo(i,0,n) {
    fo(j,0,m) {
        ans = max(ans , cal(i,j));
    }
 }
 cout<<ans<<"\n";
}



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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3664
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;

const double PI = acos(-1.0);
typedef long long LL;
typedef complex<double> Complex;

void FFT(Complex* P, int n, int op) {
	for(int i = 1, j = 0; i < n - 1; i++) {
		for(int s = n; j ^= s >>= 1, ~j&s; );
		if(i < j) swap(P[i], P[j]);
	}
	int log = 0;
	while((1 << log) < n) log++;
	for(int s = 0; s < log; s++) {
		int m = 1 << s;
		int m2 = m << 1;
		Complex wm(cos(PI / m), sin(PI / m) * op);
		for(int i = 0; i < n; i += m2) {
			Complex w(1, 0);
			for(int j = 0; j < m; j++, w *= wm) {
				Complex u = P[i + j];
				Complex t = P[i + j + m] * w;
				P[i + j] = u + t;
				P[i + j + m] = u - t;
			}
		}
	}
	if(op == -1) for(int i = 0; i < n; i++) P[i].real(P[i].real() / n);
}

Complex P[2][1 << 22];

int n;

LL cnt[2100000];

double dist(double x, double y) {
	return sqrt(x * x + y * y);
}

int main()
{
	scanf("%d", &n);
	int sum = 0;
	int offset = (n - 1) * (n * 2 + 1);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			int x; scanf("%d", &x);
			sum += x;
			cnt[0] += (x - 1) * x / 2;
			int id = i * 2 * n + j;
			P[0][id] = x;
			P[1][offset-id] = x;
		}
	}

	int s = 1;
	while(s < offset * 2 + 1) s <<= 1;
	FFT(P[0], s, 1); FFT(P[1], s, 1);
	for(int i = 0; i < s; i++) P[0][i] *= P[1][i];
	FFT(P[0], s, -1);
	
	double ans = 0;
	for(int i = 1; i <= offset; i++) {
		LL t = (LL)(P[0][offset + i].real() + 0.5);
		if(!t) continue;
		int dx = ((i / n) + 1) >> 1;
		int dy = abs(i - dx * n * 2);
		ans += dist(dx, dy) * t;
		cnt[dx*dx+dy*dy] += t;
	}

	ans /= (double)sum * (sum - 1) / 2;
	printf("%.10f\n", ans);

	int num = 0;

	int top = (n - 1) * (n - 1) * 2;
	for(int i = 0; i <= top && num < 10000; i++) if(cnt[i]) {
		printf("%d %lld\n", i, cnt[i]);
		num++;
	}

	return 0;
}

Measured memory_bytes: 150140
#include <stdio.h>
    #define maxn 200010
    int n,k,a[maxn];
    int judge(int x){
    	int i,cnt=0;
    	for(i=1;i<=n;i++)
    		cnt+=(a[i]-1+x)/x-1;//(a[i]-1+x)/x用来统计原木分割的段数((a[i]-1+x)/x此种写法是常见技巧)，切割次数=段数-1
    	if(cnt>k)return 0;//切割次数过多
    	else return 1;//切割次数小于等于k
    }
    int main(){
    	int i,l,r,mid;
    	scanf("%d%d",&n,&k);
    	for(i=1;i<=n;i++)scanf("%d",&a[i]);
    	l=0,r=1000000000;
    	while(l+1<r){
    		mid=(l+r)/2;
    		if(judge(mid))r=mid;
    		else l=mid;
    	}
    	printf("%d\n",r);
    	return 0;
    }

Measured memory_bytes: 2516
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;

ll f(ll b, ll n) {
	ll ret = 0;
	while(n >= b) {
		ret += n % b;
		n = double(n) / b;
	}
	ret += n;
	return ret;
	if(n < b) return n;
	return f(b, floor((double)n / b)) + n % b;
}

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

	ll n, s;
	cin >> n >> s;

	if(n < s) {
		cout << -1 << endl;
		return 0;
	}

	if(n == s) {
		cout << n + 1 << endl;
		return 0;
	}

	for(ll i = 2; i * i <= n; i++) {
		if(f(i, n) == s) {
			cout << i << endl;
			return 0;
		}
	}

	const ll INF = 1LL << 50;
	ll ans = INF;
	for(ll p = 1; p * p <= n; p++) {
		ll b = (n - s) / p + 1;
		if(b >= 2 && f(b, n) == s) ans = min(ans, b);
	}

	if(ans == INF) ans = -1;
	cout << ans << endl;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  string s, t; cin >> s >> t;
  int n = s.size(); int m = t.size();
  vector <vector <int>> dp(n + 1, vector <int> (m + 1, 0));
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
      else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  int x = n; int y = m;
  vector <char> ans;
  while (x != 0 && y != 0){
    if (s[x - 1] == t[y - 1] && dp[x][y] == dp[x - 1][y - 1] + 1){
      ans.push_back(s[x - 1]);
      x--; y--;
    }
    else if (dp[x][y] == dp[x - 1][y]){
      x--;
    }
    else y--;
  }
  reverse(all(ans));
  for (char c : ans) cout << c;
  return 0;
}

Measured memory_bytes: 38556
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  ll x=0;
  ll ans=0;
  rep(i,n){
    if(a[i]<x){
      ans+=x-a[i];
    }else{
      x=a[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  int a;
  cin >> a;
  cout << a+a*a+a*a*a;
  return 0;
}


Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
inf = 10**50
n,m = map(int, input().split())

ea = []
eb = []
cost = []

for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    ea.append(a)
    eb.append(b)
    cost.append(-c)

d = [inf for _ in range(n)]
d[0] = 0
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            update = True
    if not update:
        break

ans = d[n-1]
negative = [False for _ in range(n)]
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            if not negative[b]:
                update = True
            negative[b] = True
        if negative[a] and not negative[b]:
            negative[b] = True
            update = True
    if not update:
        break
# print(d)
if negative[n-1]:
    print("inf")
else:
    print(-ans)


Measured memory_bytes: 3316
#include <stdio.h>

int main() {
    int H, W, i;
    while (scanf("%d%d", &H, &W) == 2 && (H || W)) {
        while (H--) {
            for (i = 0; i < W; i++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
n = int(input())
h = [int(x) for x in input().split()]

ans = 'Yes'
for i in reversed(range(n)):
    if i == n - 1:
        continue
    else:
        if h[i] > h[i + 1] + 1:
            ans = 'No'
            break
        elif h[i] == h[i + 1] + 1:
            h[i] -= 1
print(ans)

Measured memory_bytes: 14252
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ra = [0] * (n + 1)
rb = [0] * (m + 1)
for i in range(n):
    ra[i + 1] = a[i] + ra[i]

for j in range(m):
    rb[j + 1] = b[j] + rb[j]

ans = 0
for i in range(n + 1):
    zan = k - ra[i]
    if zan < 0:
        break
    rbi = bisect.bisect_right(rb, zan) - 1
    if rbi < 0:
        rbi = 0
    ans = max(ans, i + rbi)
print(ans)


Measured memory_bytes: 118636
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

n, k = getlist()
gem = getlist()
ans = 0
tansaku = min(n, k)
for i in range(tansaku):
    for l in range(tansaku+1):
        for r in range(tansaku-l+1):
            gets = gem[:l] + gem[n-r:]
            gets.sort()
            ret = k-l-r
            tmp = sum(gets)
            #print(gets, ret)
            for g in gets:
                if ret > 0 and g <= 0:
                    tmp -= g
                    ret -= 1
                else:
                    break
            #print(tmp)
            if ans < tmp:
                ans = tmp

if k < n:
    res = k-n
    tmp = sum(gets)
    gets = sorted(gets)
    for g in gets:
        if res > 0 and g <= 0:
            tmp -= g
            res -= 1
        else:
            break
    if ans < tmp:
        ans = tmp


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,a,b;
    cin >> k >> a >> b;
    if(a >= k){
        cout << "1\n";
        return 0;
    }
    if(a-b <= 0){
        cout << "-1\n";
        return 0;
    }
    cout << 2 * ((k-a-1)/(a-b)+1) + 1 << "\n";
    return 0;
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXCOL=30;
int n_col,siz,spd[MAXCOL+5][MAXCOL+5];
int tot[3][MAXCOL+5];
int main()
{
	scanf("%d%d",&siz,&n_col);
	for(int i=0;i<n_col;i++)
		for(int j=0;j<n_col;j++)
			scanf("%d",&spd[i][j]);
	for(int i=0;i<siz;i++)
		for(int j=0;j<siz;j++)
		{
			int col;
			scanf("%d",&col);
			tot[(i+j+2)%3][col-1]++;
		}
	int ans=1e9;
	for(int i=0;i<n_col;i++)
	{
		int A=0;
		for(int col=0;col<n_col;col++)
			A+=tot[0][col]*spd[col][i];
		for(int j=0;j<n_col;j++)
			if(i!=j)
			{
				int B=0;
				for(int col=0;col<n_col;col++)
					B+=tot[1][col]*spd[col][j];
				for(int k=0;k<n_col;k++)
					if(i!=k && j!=k)
					{
						int C=0;
						for(int col=0;col<n_col;col++)
							C+=tot[2][col]*spd[col][k];
						ans=min(ans,A+B+C);
					}
			}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(void) {
	int a, b, c,d;
	cin >> a >> b >> c;
	d = c - a + b;
	if (d >= 0) {
		cout << c - (a - b);
	}
	else {
		cout << "0";
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n,k;cin>>n>>k;
    V h(n);rep(i,n)cin>>h[i];
    sort(ALL(h));
    int ans=INF;
    rep(i,n-k+1){
        int tmp=h[i+k-1]-h[i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}




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

using namespace std;

int main()
{
    short n,*l,i;
    int sum=0;
    cin>>n;
    l=new short[2*n];
    for(i=0;i<2*n;i++)
        cin>>l[i];
    sort(l,l+2*n);
    for(i=0;i<2*n;i+=2)
        sum+=l[i];
    cout<<sum;
    return 0;
}


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

int main() {
  int x[5];
  rep (i, 5) {
    cin >> x[i];
    if (x[i] == 0) cout << i+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

int n;
void run(){
    cin >> n;
    DEBUG(n ^ 1);
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 3636
K = int(input())

F = {}
for i in range(10):
    F[(1, i)] = 1


def f(n, d):
    if (n, d) in F:
        return F[(n, d)]
    nf = 0
    for i in [d - 1, d, d + 1]:
        if 0 <= i <= 9:
            nf += f(n - 1, i)
    F[(n, d)] = nf
    return nf


k = 0
p = (1, 0)
for i in range(1, 11):
    for j in range(1, 10):
        fij = f(i, j)
        if k + fij >= K:
            p = (i, j)
            break
        k += fij
        p = (i, j)
    else:
        continue
    break


def g(n, d, index):
    if n == 1:
        return str(d)
    total = 0
    for i in [d - 1, d, d + 1]:
        if not 0 <= i <= 9:
            continue
        if total + f(n - 1, i) >= index:
            break
        total += f(n - 1, i)
    return str(d) + g(n - 1, i, index - total)


print(g(p[0], p[1], K - k))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i=0; i<Q; i++)
    {
        cin >> A.at(i);
    }
    vector<int> B(N);
    for(int i=0; i<N; i++)
    {
        B.at(i)=K;
    }

    for(int i=0; i<Q; i++)
    {
        B.at(A.at(i)-1)++;
    }

    for(int i=0; i<N; i++)
    {
        if(B.at(i)-Q>0)
        {
            cout << "Yes" <<endl;
        }
        else
        {
            cout << "No" <<endl;
        }  
    }
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{
	int n;
    cin>>n;
    int arr[n];
    int zor=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        zor=zor^arr[i];
    }
    for(int i=0;i<n;i++)
    {
        int x=zor^arr[i];
        cout<<x<<" ";
        
    }
    cout<<endl;
}


Measured memory_bytes: 4368
#include<stdio.h>
int i;
#define max(x,y) ((x)>(y)?(x):(y))
#define min(X,Y) ((X)<(Y)?(X):(Y))
int main(){
  int n,sum=0;
  scanf("%d",&n);
  int b[n],a[n+1];
  for(i=1;i<n;i++)
    scanf("%d",&b[i]);
  a[1]=b[1];a[n]=b[n-1];
  for(i=2;i<n;i++)
    a[i]=min(b[i],b[i-1]);
  for(i=1;i<n+1;i++)
    sum=sum+a[i];
  printf("%d\n",sum);
  return 0;}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int a[100][100], dp[100][100], n, m;
string s;
vector<int>v;
void f() {
	v.clear(); s += ','; s = '*' + s;
	int p = 0;
	for (char ch : s) {
		if (ch == ',') { v.push_back(p); p = 0; }
		else if (ch != '*') { p *= 10; p += (int)(ch - '0'); }
	}
	n = v.size();
}
signed main() {
	int k = 0;
	while (cin >> s) {
		f();
		if (k < n) {
			for1(i, n)a[i][v.size() - i + 1] = v[i - 1];
		}
		else {
			for0(i, n)a[m * 2 + 1 - n - (m - i)][m - i] = v[i];
		}
		k = v.size();
		m = max(m, k);
	}
	for1(i, m)for1(j, m)dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
	cout << dp[m][m] << endl;
}


Measured memory_bytes: 3244
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
  int N, M, P[100010], Y[100010];
  vector< vector<int> > p(100010);
  
  scanf("%d %d", &N, &M);
  for(int i = 0;i < M;i++){
    scanf("%d %d", &P[i], &Y[i]);
    p[P[i]].push_back(Y[i]);
  }
  
  for(int i = 1;i <= N;i++) sort(p[i].begin(), p[i].end());
  
  for(int i = 0;i < M;i++) printf("%06d%06d\n", P[i], int(lower_bound(p[P[i]].begin(), p[P[i]].end(), Y[i]) - p[P[i]].begin()) + 1);
  
  return 0;
}

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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
const int INF = 1e9 + 12;
#define int long long
const int N = 1e5 + 10;
int dp[N][3];
signed main(){

	int n , w;
	cin>>n>>w;

	vector<int> dp(w+1);

	dp[0] = 0;

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

		int val , weight;
		cin>>weight>>val;

		for(int j = w-weight ; j >= 0 ; --j)
			dp[j+weight] = max(dp[j+weight] , dp[j] + val);

	}

	int ans = 0;

	for(int i = 0 ; i <= w ; ++i)
		ans = max(ans , dp[i]);

	cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int m, f, r;
    cin >> m >> f >> r;
    while(m!=-1||f!=-1||r!=-1){
         if(m==-1||f==-1) cout<<"F"<<endl;
         else if(m+f<30) cout<<"F"<<endl;
         else if(m+f<50){
             if(r>=50) cout<<"C"<<endl;
             else cout<<"D"<<endl;
         }
         else if(m+f<65) cout<<"C"<<endl;
         else if(m+f<80) cout<<"B"<<endl;
         else cout<<"A"<<endl;
         cin >> m >> f >> r;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main() {
	int n;
	cin >> n;
	int pos = -1, cur = 0;
	for(int i = 0 ; i < 1000005 ; i++){
		cur = (10*cur + 7) % n;
		if(cur == 0){
			pos = i+1;
			break;
		}
	}
	cout << pos;
	return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
const int maxn = 55;
int f(int x){
    int ans = 0;
    while(x){
        ans += x % 10;
        x /= 10;
    }
    return ans;
}
int main(){
    int a;
    cin >> a;
    if(a%f(a) == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using namespace std;

int main()
{
	int N, T;

	cin >> N >> T;

	vector<int> c(N);
	vector<int> t(N);
	int res = 1000;
	int flag = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> c[i] >> t[i];
	}

	for (int i = 0; i < N; i++)
	{
		if (T >= t[i])
		{
			if (res >= c[i])
			{
				res = c[i];
				flag = 1;
			}
		}
	}
	if (flag == 1)
		cout << res << endl;
	else
		cout << "TLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint now=1,ans=0;
    rep(i,N){
        lint able=(A[i]-1)/now;
        ans+=able;
        if(able==0) now=max(now,A[i]+1);
        if(i==0) now=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split();
        var a = (char)(s[0][0] - 0x20);
        var b = (char)(s[1][0] - 0x20);
        var c = (char)(s[2][0] - 0x20);
        Console.WriteLine("{0}{1}{2}", a, b, c);
    }
}


Measured memory_bytes: 13140
H,W,M=map(int,input().split())
row=[0]*H
col=[0]*W
target=set()
for i in range(M):
    h,w=map(int,input().split())
    row[h-1]+=1
    col[w-1]+=1
    target.add((h-1,w-1))
A=max(row)
B=max(col)
a=[x for x in range(H) if row[x]==A]
b=[x for x in range(W) if col[x]==B]
for i in a:
    for j in b:
        if (i,j) not in target:
            print(A+B)
            exit(0)
print(A+B-1)


Measured memory_bytes: 83508
/**
 *    Author:   Sambhu Show(JGEC)
 *    fb    :   https://www.facebook.com/sambhu.show.98
 *              #everyday counts.....(^_^)
**/
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc int t;cin>>t;while(t--)
#define ltc ll t;cin>>t;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define vll vector<ll>
#define sll set<ll>
#define mpll map<ll ,ll>
#define sortd(arr) sort(arr,arr+n,greater<ll>())
#define revs(str) reverse(str.begin(), str.end());
#define memset(arr) memset(arr,0,sizeof(arr));//array elements to 0
//-----------------------#Sambhu.98(CF)-------------------------------//
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,a,b) for(ll i=a;i>=b;i--)
ll const inf=1e18;
//-----------------------#sambhu_98(CC)------------------------//
bool isPrime(ll n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 or n % 3 == 0)  return false;
    ll i = 5;
    while(i * i <= n) { 
        if (n % i == 0 or n % (i + 2) == 0)  
        return false;
        i = i + 6;}
        return true; }

ll gcd (ll a, ll b) {  return b ? gcd (b, a % b) : a;}
ll lcm(ll a, ll b)  {  return (a*b)/gcd(a, b);  }

ll countDivisors(ll n) 
{ ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
            else  
                cnt = cnt + 2; } } 
    return cnt; }
/*/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
int main()
{
ll h,a;
cin>>h>>a;
ll ans=0;
while(h>0)
{
    h-=a;
    ans++;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
n = int(input().rstrip("\n"))

total_yen = 0
total_coin = 0.0
for i in range(n):
  amount, yen_or_coin = input().rstrip("\n").split(" ")
  if yen_or_coin == 'JPY':
    total_yen += int(amount)
  else:
    total_coin += float(amount)

print(total_yen + (total_coin * 380000.0))

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<int> a(n);
    vector<int> v(5000000);

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

    for(int i = 1; i <= 1000000; i++) {
        if(v[i]) {
            for(int j = i + i; j <= 1000000; j += i)v[j] += v[i];
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(v[a[i]] == 1)cnt++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 23584
#include <cstdio>
#include <algorithm>
#define MAXN 100100

using namespace std;

int T[MAXN],X[MAXN],Y[MAXN];
int main(){

	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d%d%d",&T[i],&X[i],&Y[i]);
	int t = 0;
	for(int i = 1;i <= n;i++){
		t = T[i] - T[i - 1];
		int x = X[i] - X[i - 1];
		int y = Y[i] - Y[i - 1];
		int sum = x + y;
		if(sum > t){
			printf("No"); return 0;
		}
		if((sum - t) % 2 != 0) {
			printf("No"); return 0;
		}
	}
	
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1280
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())

win={'r':'p','s':'r','p':'s'}
point={'r':R,'s':S,'p':P}
hand=['']*N
ans=0

for i in range(K):
    w=win[T[i]]
    ans+=point[w]
    hand[i]=w

for i in range(K,N):
    w=win[T[i]]
    if w==hand[i-K]:
        continue
    ans+=point[w]
    hand[i]=w
    
print(ans)

Measured memory_bytes: 4792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    int[][] dp = new int[100][10];
    int K;
    String ans = "";

    Main() {
        Scanner sc = new Scanner(System.in);
        K = sc.nextInt();
        for (int i = 0; i <= 9; i++) {
            dp[1][i] = 1;
        }
        for (int keta = 2; keta < 100; keta++) {
            for (int i = 0; i <= 9; i++) {
                if (i == 0) {
                    dp[keta][i] = dp[keta - 1][i] + dp[keta - 1][i + 1];
                } else if (i == 9) {
                    dp[keta][i] = dp[keta - 1][i] + dp[keta - 1][i - 1];
                } else {
                    dp[keta][i] = dp[keta - 1][i] + dp[keta - 1][i - 1] + dp[keta - 1][i + 1];
                }
            }
        }
        int cnt = 0;
        int keta = -1;
        int i = -1;
        count: for (keta = 1; keta < 100; keta++) {
            for (i = 1; i <= 9; i++) {
                cnt += dp[keta][i];
                if (cnt >= K)
                    break count;
            }
        }
        reduct(keta, i, cnt);
        // for (keta = 1; keta < 10; keta++) {
        //     System.err.println(Arrays.toString(dp[keta]));
        // }
    }

    void reduct(int keta, int i, int cnt) {
        int nex = cnt;
        if (cnt == K) {
            upper(keta, i);
            return;
        }
        ans += i;
        if (i == 0) {
            nex -= dp[keta - 1][i + 1];
            if (nex < K) {
                reduct(keta - 1, i + 1, cnt);
            } else {
                reduct(keta - 1, i, nex);
            }
        } else if (i == 9) {
            nex -= dp[keta - 1][i];
            if (nex < K) {
                reduct(keta - 1, i, cnt);
            } else {
                reduct(keta - 1, i - 1, nex);
            }
        } else {

            nex -= dp[keta - 1][i + 1];
            if (nex < K) {
                reduct(keta - 1, i + 1, cnt);
            } else {
                int neex = nex - dp[keta - 1][i];
                if (neex < K) {
                    reduct(keta - 1, i, nex);
                } else {
                    reduct(keta - 1, i - 1, neex);
                }
            }
        }
    }

    void upper(int keta, int i) {
        if (keta == 0) {
            System.out.println(ans);
            return;
        } else {
            ans += i;
            if (i == 9) {
                upper(keta - 1, i);
            } else {
                upper(keta - 1, i + 1);
            }
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23892
n = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n+1):
    val = str(i)
    s = val[0]
    e = val[-1]
    #print(val, s, e)
    c[int(s)][int(e)] += 1

#print(c)
ans = 0
for s in range(1, 10):
    for e in range(1, 10):
        ans += c[s][e] * c[e][s]
    
print(ans)

Measured memory_bytes: 3064