akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

pair<int, int> f(int x) {
    int a = x % 10;
    int b = 0;
    while(x) {
        b = x;
        x /= 10;
    }
    return make_pair(a, b);
}

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

    map<pair<int, int>, int> mp;
    rep(i, 1, N+1) {
        pair<int, int> p = f(i);
        mp[p]++;
    }

    int ans = 0;
    rep(i, 1, N+1) {
        pair<int, int> q = f(i);
        q = make_pair(q.second, q.first);
        ans += mp[q];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;

int main()
{
	ll p,q,r;
	

	for (int i = 0; i < 3; i++) {
		ll tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	cout << a[0]+a[1] << endl;

	
	
	return 0;
}


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

# define fori(i,n)          for(int i=0;i<n;i++)
# define forl(i,n)          for (ll i=0;i<n;i++)
# define pb                 push_back
# define mp                 make_pair
# define X                  first
# define Y                  second
# define all(v)             v.begin(),v.end()
# define in_ar_int(arr,n)   int arr[n]; fori(i,n) cin >> arr[i];
# define in_ar_ll(arr,n)    ll arr[n]; fori(i,n) cin >> arr[i];
# define endl               "\n"
# define R0                 return 0
# define mod                1000000007
# define pi                 3.1415926536

typedef long long ll;
typedef string str;
typedef unsigned long long ull; 
typedef pair<int, int> pii; 
typedef vector<pii> vpii;
typedef vector<int> vi;

const ll inf=1e18l+5;

void solve(){
    int n,w;
    cin >> n >> w;
    vpii things;
    int sum=0;
    fori(i,n){
        int x,y;
        cin >> x >> y ;
        sum+=y;
        things.pb(mp(x,y));
    }
    vector <ll> dp(sum+1,inf);
    dp[0]=0;
    for(auto i:things){
        for (int j=sum-i.Y;j>=0;--j){
            dp[j+i.Y]=min(dp[j+i.Y],dp[j]+(ll) i.X);
        }
    } 
    for (int i=sum;i>=0;--i){
        if (dp[i]<=w) {
            cout << i << "\n";
            break;
        }
    }

}   

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int chill=1;
    // cin >> chill;
    while(chill--){
    solve();
    }
}



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

user = {}
for i in range(N):
    user[i] = list(map(int,input().split()))

tmp = list(range(1,31))
for k in user.keys():
    user[k].pop(0)
    tmp = list(set(tmp) & set(user[k]))
print(len(tmp))

Measured memory_bytes: 3064
n,m,x=map(int,input().split())
book=[0]*n
for i in range(0,n):
  book[i]=list(map(int,input().split()))
total=[]
for i in range(2**n):
  cost=0
  rikai=[0]*m
  for j in range(n):
    if (i >> j)&1:
      for k in range(m):
        rikai[k] += book[j][k+1]
      cost+=book[j][0]
  if all(l >= x for l in rikai):
    total.append(cost)

if total==[]:
  print("-1")
else:
  print(min(total))

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

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  if(s<t) cout << "Yes"<< endl;
  else cout << "No" << endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int n,m,h,w;
int p[100000];
signed main(){
	int i,j,k;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>p[i];
	sort(p,p+n);
	reverse(p,p+n);
	int ans=0;
	for(i=0;i<n-1;i++){
		if(p[i]==p[i+1]){
			int u=0;
			for(j=i+2;j<n-1;j++)
				if(p[j]==p[j+1]){
					u=p[j];
					break;
				}
			ans=p[i]*u;
			break;
		}
	}
	cout<<ans<<endl;
}

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

#define int long long
typedef pair<int, int> P;

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N;
int X[220000],X_m[220000];

signed main() {
    int l, r;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        X_m[i] = X[i];
    }
    sort(X, X + N);
    l = X[N / 2 - 1];
    r = X[N / 2];
    for (int i = 0; i < N; i++) {
        if (X_m[i] <= l) {
            cout << r << endl;
        } else {
            cout << l << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const ll MOD = 1e9 + 7;
int N, K;
int a[109];
ll dp[100009], pre[100009];

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

    cin >> N >> K;
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    dp[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        for (int used = K; used >= 0; used--)
        {
            int t = dp[used];

            int L = used + 1;
            int R = min(a[i] + used, K);

            pre[L] += t;
            pre[R + 1] -= t;
        }

        // for (int j = 0; j <= K; j++)
        // {
        //     cout << pre[j] << " ";
        // }
        // cout << "\n";

        ll p = 0;
        for (int j = 0; j <= K; j++)
        {
            p += pre[j];
            pre[j] = 0;

            dp[j] += p;
            dp[j] %= MOD;
            dp[j] += MOD;
            dp[j] %= MOD;
        }
    }

    cout << dp[K] << "\n";
}

Measured memory_bytes: 5184
#include <iostream>
using namespace std;
const int MAX = 1000;

void Print(int* A, int N) {
  for (int i = 0; i < N - 1; i++)
    cout << A[i] << " ";
  cout << A[N - 1] << endl;
}

void InsertionSort(int* A, int N) {
  for (int i = 1; i < N; i++) {
    Print(A, N);
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
  }
}

int main() {

  int N, A[MAX];
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> A[i];
  InsertionSort(A, N);
  Print(A, N);

  return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int		max(int a, int b)
{
	if (a < b)
		return b;
	return a;
}

int main()
{
	int N;
	scanf("%d", &N);
	int i = 0;
	int b[N];
	int a[N];
	int sum = 0;
	while (i < N - 1)
		scanf("%d", &b[i++]);
	a[0] = b[0];
	sum = b[0];
	i = 1;
	while (i < N - 1)
	{
		if (b[i] > b[i - 1])
		{
			a[i] = b[i - 1];
			sum += b[i - 1];
		}
		else if (b[i] <= b[i - 1])
		{
			a[i] = b[i];
			sum += b[i];
		}
		i++;
	}
	a[N - 1] = b[N - 2];
	i = 0;
	// while (i < N)
	// 	printf("%d ", a[i++]);
	sum += b[N - 2];
	printf("%d\n", sum);
	return 0;
}

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

#define y1 hasjdnasd
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

#define ll long long
#define oo 1e18 + 7
#define int long long

const int N = 1e4 + 5;
const int VAL = 1e2 + 5;
int n , k , mod = 1e9 + 7;
int dp[N][VAL];
int a[N];
char f[N];

int add(int a , int b , int mod)
{
    return (a + b) % mod;
}

int sub(int a , int b , int mod)
{
    return ((a - b) % mod + mod) % mod;
}

void init()
{
    FOR(i , 0 , 9)
        dp[1][i % k] += 1;
    FOR(i , 2 , n)
        FOR(j , 0 , k)
            FOR(x , 0 , 9)
                dp[i][j] = add(dp[i][j] , dp[i - 1][sub(j , x , k)] , mod);
}

int getdigit(int idx , int tight , int sum , int r)
{
    int ans = 0;
    int lim = (tight == 1) ? a[idx] : 9;
    FOR(i , 0 , lim)
    {
        int x = (tight & (i == a[idx]));
        int y = add(i , sum , k);
        if(idx == r && i == 0 && idx != 1)
            continue;
        if(idx == 1)
            ans += (y % k == 0);
        else
        {
            if(x == 1)
                ans = add(ans , getdigit(idx - 1 , x , y , r) , mod);
            else
                ans = add(ans , dp[idx - 1][sub(k , y , k)] , mod);
        }
    }
    return ans;
}

main()
{
    //freopen("S.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> f;
    n = strlen(f);
    FORD(i , n , 1)
        a[i] = f[i - 1] - 48;
    reverse(a + 1 , a + 1 + n);
    cin >> k;
    init();
    cout << sub(add(getdigit(n , 1 , 0 , n) , dp[n - 1][0] , mod) , 1 , mod);
}


Measured memory_bytes: 9856
#include <stdio.h>

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}

int main(void)
{
    int a, b;

    while (~scanf("%d %d", &a, &b)){
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	vector<int>v(n);
	read(v, n);
	int xr=0;
	for(int i=0;i<n;i++){
		xr^=v[i];
	}
	for(int i=0;i<n;i++)cout<<(xr^v[i])<<" ";
	cout<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3844
#include<stdio.h>
int main()
{
    long long n,sum=0,T,max,min;
    scanf("%lld",&T);
    for(int i=1; i<=T; i++)
    {
        scanf("%lld ",&n);
        if(i==1)
            max=min=n;
        if(max<n)
            max=n;
        else if(min>n)
            min=n;
        sum=sum+n;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
constexpr int N_MAX = 1e5;
int N, M;
int S, T;

struct Node {
  vi l;

  Node()
    : l(3, -1)
  {}
};

vector<Node> nodes(N_MAX);
vvi G(N_MAX);


void bfs() {
  deque<pii> q;
  q.push_back({S,0});
  nodes[S].l[0] = 0;

  int count = 0;

  while(!q.empty() && count <=3*N) {
    const pii pu = q.front(); q.pop_front();
    const int u = pu.first;
    const int l = pu.second;
    const int lnext = l+1;

//cerr << "node " << u << endl;
//for (int i=0; i<2; i++) {
//  cerr << "  " << i << ": " << nodes[u].l[i] << endl;
//}

    for (auto c : G[u]) {
      Node& node = nodes[c];
      if (node.l[lnext%3] != -1 &&
          node.l[lnext%3] <= lnext) {
        continue;
      }

      node.l[lnext%3] = lnext;
      q.emplace_back(c, lnext);
    }

    count++;
  }

}

int main(int argc, char** argv) {
  cin >> N >> M;

  for (int i=0; i<M; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--; // to 0-indexed
    G[u].emplace_back(v);
  }

  cin >> S >> T;
  S--; T--; // to 0-indexed

  bfs();

  int ret = nodes[T].l[0];
  cout << (ret == -1 ? ret : ret/3) << endl;

  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstring>
#define LL long long
using namespace std;

LL n, m, d;

int main()
{
    scanf("%lld%lld%lld", &n, &m, &d);
    double temp;
    if(d==0) temp=n;
    else temp=(n-d)*2;
    printf("%.10lf\n", (double)(m-1)/n*temp/n);
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
    n = int(input())

    ans = (n * (n+1))//2

    for i in range(2, n+1):
        d = (n // i) * i
        sigma = (d * (d+i))//(2*i)
        ans += sigma

    return ans


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<int> A(N - 1);
    for (int i = 0; i < A.size(); i++)
    {
        cin >> A[i];
    }
    vector<int> ans(N, 0);
    for (int i = 0; i < N - 1; i++)
    {
        ans[A[i] - 1]++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }

    return (0);
}

Measured memory_bytes: 4840
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll n, k, a, b;
    ll NMAX=1e5+1;
    ll buckets[NMAX] = {0};
    cin >> n >> k;
    for(ll i=0; i<n; i++) {
        cin >> a >> b;
        buckets[a] += b;
    }

    ll i=0, sum=0;
    while(sum+buckets[i]<k) sum += buckets[i++];
    cout << i << endl;

    return 0;
}


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

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

	if (a == "H" && b == "H" || a == "D" && b == "D")
		cout << "H" << endl;
	else
		cout << "D" << endl;

}



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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll inf = (ll)1e14;
const ll N = (ll)2e5+77;
const ll mod = (ll)1e9+7;

ll n,m,k,a,b;

int main() {
    fast;
    string s;
    cin>>s;
    string t = "";
    forn(i,sz(s)-8){
        t += s[i];
    }
    cout<<t<<endl;
    return 0;
}

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

int main() {
	int N;
	vector<int> p;
	int temp;
	int sum = 0;

	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> temp;
		p.push_back(temp);
		sum += temp;
	}

	vector<int>::iterator maxIt= std::max_element(p.begin(), p.end());
	size_t maxIndex = std::distance(p.begin(), maxIt);

	sum -= (p[maxIndex] / 2);

	cout << sum << endl;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int k;
    cin >> k;
    
    vector<string> board(8,string(8,'.'));
    vector<intpair> queen(k);
    
    rep(i,k){
        cin >> queen[i].first >> queen[i].second;
    }
    
    int a[8];
    rep(i,8) a[i] = i;
    
    do{
        bool ok = true;
        for(auto p : queen){
            ok = false;
            rep(i,8){
                if(p.first == i && p.second == a[i]) ok = true;
            }
            if(!ok) break;
        }
        
        rep(i,8)rep(j,8){
            if(i==j) continue;
            if(i+a[i] == j+a[j]) ok = false;
            if(i-a[i] == j-a[j]) ok = false;
        }
        
        if(ok){
            rep(i,8){
                board[i][a[i]] = 'Q';
            }
            break;
        }
    }while(next_permutation(a, a+8));
    
    for(string s : board){
        cout << s << endl;
    }
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e6 + 5;
const ll MOD = 998244353;

int parent[N];

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

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    char n;
    cin >> n;
    if(n - 97 >= 0) {
        cout << "a" << endl;
    }
    else if(n - 65 >= 0) {
        cout << "A" << endl;
    }   
    return 0; 
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, j, n, m, x, k, ans;
int a[12][12];
int level[12];
int c[12];
int minprice = 1000000000;

void check(int price) {
    bool judge = true;
    rep(0, m) if (level[i] < x) judge = false;
    if (judge) if (price < minprice) minprice = price;
}

void search(int pos, int price) {
    if (pos == n) {
        check(price); return;
    } else {
        rep(0, m) level[i] += a[pos][i];
        search(pos+1, price+c[pos]);
        rep(0, m) level[i] -= a[pos][i];
        search(pos+1, price);
    }
}

int main() {
    scanf(" %d %d %d", &n, &m, &x);
    init(level, n, 0);
    rep(0,n) {
        scanf(" %d", &c[i]);
        repj(0, m) scanf(" %d", &a[i][j]);
    }
    search(0, 0);

    if (minprice == 1000000000) minprice = -1;
    printf("%d\n", minprice);
}

Measured memory_bytes: 3792
package main

import (
  "fmt"
  "strings"
)

func main() {
  var t string
  fmt.Scanf("%s", &t)
  t2 := strings.Replace(t, "?", "D", -1)

  //d := strings.Replace(t2, "P", "", -1)
  
  
  //pd1 := strings.Replace(t2, "PD", "?", -1)
  //pd2 := strings.Replace(pd1, "P", "", -1)
  //pd3 := strings.Replace(pd2, "D", "", -1)
  
  fmt.Println(t2)
  
}

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

#define lint long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"
lint INF = 2e18;
lint MOD = 1e9 + 7;

lint i, j, k, t;

int main() {
    lint N, K, S;
    cin >> N >> K >> S;

    lint M = 1e9;

    vector<lint> ans(N);
    if(S < M) {
        FOR(i, N) {
            if(i < K) {
                ans[i] = S;
            } else {
                ans[i] = S + 1;
            }
        }
    } else {
        FOR(i, N) {
            if(i < K) {
                ans[i] = S;
            } else {
                ans[i] = 1;
            }
        }
    }

    FOR(i, N) { cout << ans[i] << " "; }
    cout << endl;
}

Measured memory_bytes: 4048
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long  n;
    cin>>n;
    long long sum=0;
    int a,b;
    a=n;
    while(a)
    {
        b=a%10;
        a=a/10;
        sum+=b;
    }
    if(n%sum==0) cout<<"Yes";
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 12
using namespace std;

int main() {
	int A, B, T, ans;
	cin >> A >> B >> T;
	ans = (T / A) * B;
	cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
W, V = [], []
for i in range(n):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
A = [0 for j in range(m+1)]
for i in range(n):
    B = []
    for j in range(W[i-1]):
        B.append(A[j])
    for j in range(W[i-1], m+1):
        B.append(max(A[j], A[j-W[i-1]]+V[i-1]))
    A = B
print(A[m])


Measured memory_bytes: 112352
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
unordered_map<int, int> table;
vector<int> v;
int main() {
    int n, k, val;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d", &val);
        table[val]++;
    }
    for (auto it = table.begin(); it != table.end(); it++) {
        v.push_back(it->second);
    }
    sort(v.begin(), v.end(), greater<int>());
    int ret = 0;
    while (v.size() > k) {
        ret += v.back();
        v.pop_back();
    }
    cout << ret << endl;


    return 0;
}

Measured memory_bytes: 10312
#include<cstdio>
#include<algorithm>
using namespace std;
int a, b, c, i, ta, tb ,tc;
int main(){
    scanf("%d%d%d",&a,&b,&c);
    if(a%2||b%2||c%2){printf("0\n");return 0;}
    if(a==b&&b==c){
        printf("-1\n");
    }
    else{
        for(i=0;;i++){
            if(a%2||b%2||c%2)break;
            ta=b/2+c/2,tb=a/2+c/2,tc=a/2+b/2;
            a=ta,b=tb,c=tc;
        }
        printf("%d\n",i);
    }
}

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

// 整数nを与えられた時に、10進法で表したときの各桁の和を返す関数
int digit_sum(int n){
    // 求めたい値を入れる変数
    int dsum = 0;

    // 10進法で表したときの各桁の和は、以下のように求められる
    // nを10で割った余りを加算し、nを10で割る(C++の整数では切り捨て)操作を繰り返せばよい
    while(n > 0){
        dsum += n % 10;
        n /= 10;
    }

    return dsum;
}

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

    // 答えを入れる変数
    int ans = 0;

    // 1以上n以下の整数をすべて調べる
    for(int i = 1 ; i <= n ; i++){
        int d = digit_sum(i);

        // iが条件を満たすとき、ansにiを加算
        if(a <= d && d <= b){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

ll pow2(long long n) {
	ll ret = 1;
	ll x = 2;
    while (n > 0) {
        if (n & 1) ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x *= x;
        n >>= 1;  // n を1bit 右にずらす
    }
    return ret;
}

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> k;
	long double p = 0.0;
	vector<ll> cc;
	for(i=n;i>=1;i--) {
		c = 0;
		a = i;
		while(a<k) {
			c++;
			a *= 2;
		}
		cc.push_back(c);
	}
	x = 0;
	for(i=0;i<cc.size();i++) {
		x += pow2(c-cc[i]);
	}
	//cout << x << ' ' << c << ' ' << pow2(c) << endl;
	p = (long double)x / pow2(c) / n;
	cout << fixed << setprecision(10);
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 4228
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    int cnt = 0;
    bool flag = true;
    rep(i,0,3){
        cnt = 0;
        rep(j,0,3){
            if(s[i]==s[j]) cnt++;
        }
        if(cnt!=2) flag = false;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())

a=[list(map(int,input().split())) for i in range(H)]
ans=[]
for i in range(H):
    for j in range(W-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append(str(i+1)+" "+str(j+1)+" "+str(i+1)+" "+str(j+2))

for i in range(H-1):
    if a[i][W-1]%2==1:
        a[i+1][W-1]+=1
        ans.append(str(i+1)+" "+str(W)+" "+str(i+2)+" "+str(W))    



n=len(ans)
print(n)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 16472
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

typedef long long ll;
ll n, s, sz, ans, a[N], b[N], d[N];
int main()
{
	ll i, j, k, t, t2, t3;
	cin >> n;
	for (i= 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	for (i = 0; i < n; i++) {
		scanf ("%lld", &b[i]);
	}
	for (j = 0; j <= 28; j++) {
		k = 1LL << j;
		for (i = 0; i < n; i++) {
			d[i] = b[i] % (k * 2);
		}
		sort(d, d + n);
		s = 0;
		for (i = 0; i < n; i++) {
			t = a[i] % (k * 2);
			t2 = lower_bound(d, d + n, k * 2 - t) - d;
			t3 = lower_bound(d, d + n, k - t) - d;
			s += t3 - t2;
			t2 = lower_bound(d, d + n, k * 3 - t) - d;
			s += n - t2;
		}
		ans += k * (s & 1);
	}
	cout << ans;
    return 0;
}


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

#define _overload3(_1, _2, _3, name, ...) name
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)

typedef long long int ll;
typedef unsigned long long int ull;

const int MOD=(int)1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll g=gcd(a,b);return a/g*b;}
ll digitsum(ll a){ll x=0;while(a>0){x+=a%10;a/=10;}return x;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(b%a == 0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
}

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

	public static void main(String[] args) {
		Scanner stdIn=new Scanner (System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		int c=stdIn.nextInt();
		int d=stdIn.nextInt();
		int count=0;
		if(a>=c){
			if(b>=d){
				if(a<=d)
				count+=(d-a);
				else
					;
			}
			else
			count+=(b-a);
		}
		else if(b>=d){
			count+=(d-c);
		}
			else if(b>=c)
		count+=(b-c);
			else ;
		
		
		System.out.println(count);
		
			
	}

}


Measured memory_bytes: 20820
#include<stdio.h>

int main(void)
{
   int n, h, w,i;
   int a, b;
   int count=0;

   scanf("%d %d %d",&n,&h,&w);
   
   for(i=1;i<=n;i++)
   {
       scanf("%d %d",&a,&b);
       if(a>=h&&b>=w)
       {
            count+=1;
       }
   }

   printf("%d\n",count);

   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<ll> L(N);
  REP(i,N) cin>>L[i];
  //  sort (L.begin(), L.end());                                                      
  int ans = 0;
  REP(i,N) {
    for(int j = i+1; j < N; j++) {
      for(int k = j+1; k < N; k++) {
        ll a = 2LL * L[i];
        ll b = 2LL * L[j];
        ll c = 2LL * L[k];
	ll s = (a+b+c)/2LL;
	double tmp = s;
        tmp *= (s - a);
        tmp *= (s - b);
        tmp *= (s - c);
	if(tmp > 0) {
          if(a != b && a != c && b != c)
            ans ++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



int main(void) {
	int n, m; cin >> n >> m;
	vint h(n);
	vint f(n);
	rep(i, n) {
		cin >> h[i];
	}
	vvint e(n);
	rep(i, m) {
		int x,y;
		cin >>x >>y;
		x--; y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	int ans = 0;
	rep(i, n) {
			int j;
			for (j = 0; j < e[i].size();j++) {
				if (h[i] <= h[e[i][j]]) {
					break;
				}
				else {
					f[e[i][j]] = 1;
				}
			}
			if (j == e[i].size()) {
				ans++;
			}
		


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


Measured memory_bytes: 9016
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b\n",a,b);
    }else if(a<b){
        printf("a < b\n",a,b);
    }else{
        printf("a == b\n",a,b);
    }
    return 0;
}


Measured memory_bytes: 2112
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
    }
    let mut res = n;
    for i in 0..n+1 {
        let mut cc = 0;
        let mut t = i;
        while t > 0 {
            cc+=t%6;
            t/=6;
        }
        t=n-i;
        while t > 0 {
            cc+=t%9;
            t/=9;
        }
        if res>cc {
            res = cc;
        }
    }
    println!("{}", res);
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        Long output = new Long("0");
        Hashtable<String,Long> ht = new Hashtable<String,Long>();
		// 整数の入力
		int N = sc.nextInt();
		for(int i = 1; i <= N; i++){
          char[] tmp = sc.next().toCharArray();
          Arrays.sort(tmp);
          String tmp2 = new String(tmp);
          if(ht.get(tmp2) == null){
            ht.put(tmp2,new Long("1"));
          }else{
            output += ht.get(tmp2);
            ht.put(tmp2,ht.get(tmp2) + 1);
          }
        }
		System.out.println(output);
		
		// 出力
		
	}
}

Measured memory_bytes: 56696
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
#これを消すとなぜかWAになる呪い
s = 0
for i in range(1,n+1):
    c = 1
    while i < k:
        i*=2
        c*=0.5
    s+=c
print(s/n)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 998244353;
using Graph = vector<vector<int>>;


int dp[3010][3010];
signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N,S;
    cin>>N>>S;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }
    sort(A,A+N);


    dp[0][0]=1;
    rep(i,N){
        rep(j,S+1){
            dp[i+1][j]+=dp[i][j]*2;
            dp[i+1][j]%=MOD;
            if(j+A[i]>3000) continue;
            dp[i+1][j+A[i]]+=dp[i][j];
            dp[i+1][j+A[i]]%=MOD;
        }
    }
    cout << dp[N][S] << endl;
    return 0;
    

    



}


Measured memory_bytes: 74244
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define MOD 1000000007

int main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<int> a(N);
  for(int i=0;i<N;i++){
    a.at(i)=S.at(i)-'0';
  }

  int ans=N,ans2=N;;
  for(int i=0;i<N;i++){
    if(a.at(i)==1){
      ans=min(ans,max(i,N-i-1));
    }else{
      ans2=min(ans2,max(i,N-i-1));
    }
  }

  cout<<max(ans,ans2)<<endl;
}


Measured memory_bytes: 896
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
X = list(map(int, readline().split()))
X_sorted = sorted(X)

# この二つ以外にありえない
small, large = X_sorted[(N-1)//2], X_sorted[(N+1)//2]

for x in X:
    if x <= small:
        print(large)
    else:
        print(small)

Measured memory_bytes: 28888
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {
	// freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	long long a, b;
	cin >> a >> b;

	long long ans = 0;
	long long k = 1;
	while (k < b) {
		++ans;
		k += a - 1;
	}

	cout << ans << "\n";
}


Measured memory_bytes: 256
#require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
puts C(n+m,2)-n*m

Measured memory_bytes: 1788
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a;cin>>a;
  if(a==1){
    cout << "Hello World" << endl;
  }else{
    int b,c;cin>>b>>c;
    cout << b+c << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll X, K, D;
    scanf("%lld", &X);
    scanf("%lld", &K);
    scanf("%lld", &D);

    ll progress = min(abs(X) / D, K);
    ll ans = abs(X) - D * progress;
    K -= progress;
    if (K % 2 == 1)
    {
        ans = abs(ans - D);
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	ll y = (x / 11) * 2;
	ll z = x % 11;

	if (z > 0 && z <= 6) {
		y++;
	}
	else if (z > 6) {
		y += 2;
	}

	cout << y << endl;

	return 0;
}

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

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
	
	return 0;
}



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


int main()
{
   int x,a ;
   cin >> x >> a ;
  
  if(x<a)
   cout << 0 << endl ;
  else
   cout << 10 << endl ;    
      
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict


def sieve(x):
    """
    Sieve of Eratosthenes
    :param x: max value
    :return: list of bool
    """

    is_prime = [True] * (x + 1)
    is_prime[0] = is_prime[1] = False

    for i in range(2, x + 1):
        if is_prime[i]:
            for j in range(i * 2, x + 1, i):
                is_prime[j] = False

    return is_prime


n = int(input())

is_prime = sieve(10 ** 6)
primes = [i for i, e in enumerate(is_prime) if e]

d = defaultdict(int)
for e in primes:
    while n % e == 0:
        n //= e
        d[e] += 1

if n != 1:
    d[n] += 1

ans = 0
for v in d.values():
    mn = 1
    while v >= mn:
        v -= mn
        ans += 1
        mn += 1

print(ans)



Measured memory_bytes: 20332
#include <stdio.h>

int main(void)
{

	int N;

	scanf("%d",&N);

	int a[100];

	for (int j=0; j<N; j++){
		scanf("%d",&a[j]);
	}

	int cng = 0;
	
	for (int k=0; k<N-1; k++){
		if(a[k]==a[k+1]) {
			cng++;
				if(a[k+1]+1==a[k+2]){
					a[k+1]=a[k+1]+2;
				}else {
					a[k+1]++;
				}
			}
		}
	
	printf("%d",cng);

	
	return 0;
}



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

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hw = Console.ReadLine().Split(' ');
            int[] hw_array = hw.Select(int.Parse).ToArray();

            int H = hw_array[0];
            int W = hw_array[1];

            bool[,] map = new bool[H, W];
            int[,] step_table = new int[H, W];
            for (int y = 0; y < H; y++)
            {
                string oneLine = Console.ReadLine();
                for (int x = 0; x < W; x++)
                {
                    if (oneLine[x] == '#') map[y,x] = true;
                }
            }

            step_table[0, 0] = map[0, 0] ? 1 : 0;

            for (int y = 1; y < H; y++)
            {
                if(IsBorder( map[y -1, 0] , map[y, 0] ))
                    step_table[y, 0] = step_table[y - 1, 0] + 1;
                else
                    step_table[y, 0] = step_table[y - 1, 0];
            }

            for (int x = 1; x < W; x++)
            {
                if (IsBorder( map[0, x - 1] , map[0, x]))
                    step_table[0, x] = step_table[0, x - 1] + 1;
                else
                    step_table[0, x] = step_table[0, x - 1];
            }

            for (int y = 1; y < H; y++)
            {
                for (int x = 1; x < W; x++)
                {
                    int a1 = IsBorder( map[y - 1, x    ], map[y, x] ) ? step_table[y - 1, x    ] + 1 : step_table[y - 1, x   ];
                    int a2 = IsBorder( map[y    , x -1 ], map[y, x] ) ? step_table[y    , x - 1] + 1 : step_table[y    , x -1];

                    step_table[y, x] = Math.Min( a1, a2);
                }
            }

            Console.WriteLine(step_table[H -1, W -1]);
        }

        static bool IsBorder( bool a , bool b )
        {
            return !a && b;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9+1;

int main(){
  int n, m;
  cin >> n;
  m = n-1;
  
  vector<vector<int>> aa(n, vector<int>(m));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> aa[i][j];
      aa[i][j]--;
    }
  }

  vector<vector<int>> id(n, vector<int>(n));
  int v = 0;
  for (int i = 0; i < n; i++) 
    for (int j = 0; j < n; j++) if (i < j) id[i][j] = v++; 

  vector<vector<int>> g(v);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m -1 ; j++) {
      int a = i, b = aa[i][j], c = i, d = aa[i][j + 1];
      if (a > b) swap(a, b);
      if (c > d) swap(c, d);
      g[id[a][b]].emplace_back(id[c][d]);
    }
  }
  int k = n * (n - 1) / 2;
  int res = 0;

  vector<int> dp(k,0);
  vector<int> check(k,0);

  auto dfs = [&](auto& f, int u) -> int {

    if (dp[u] != 0) {
      if (!check[u]) return -1;
      return dp[u];
    }

    dp[u] = 1;

    for (auto v : g[u]) {
      int res = f(f, v);
      if (res == -1) return -1;
      dp[u] = max(dp[u], res + 1);
    }

    check[u] = 1;
    return dp[u];
  };
  
  for (int i = 0; i < v; i++) {
    int d = dfs(dfs, i);
    if (d == -1) {
      cout << -1 << endl;
      return 0;
    }
    res = max(res, d);
  }

  cout << res << endl;

  return 0;
} 

Measured memory_bytes: 39424
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <bitset>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_V = 17;
const int INF = 1e9;

int traveling_salesman(int V, int G[MAX_V][MAX_V]){
  int dp[(1 << V)][V];
  REP(i, (1 << V)) REP(j, V) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(i, (1 << V)){
    REP(j, V){
      REP(k, V){
        int mask = (1 << k), cost = G[j][k];
        if((i & mask) || cost < 0) continue;
        dp[(i | mask)][k] = min(dp[(i | mask)][k], dp[i][j] + cost);
      }
    }
  }
  return (dp[(1 << V) - 1][0] == INF ? -1 : dp[(1 << V) - 1][0]);
}

int main() {
  int G[MAX_V][MAX_V];
  int V, E; cin >>V >>E;
  memset(G, -1, sizeof(G));
  REP(i, E){
    int f, t, c; cin >>f >>t >>c;
    G[f][t] = c;
  }
  cout <<traveling_salesman(V, G) <<endl;
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

int k;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k;
	long long sum = 0;
	for(int i = 1; i <= k; i++)
		for(int j = 1; j <= k; j++)
			for(int l = 1; l <= k; l++) sum += gcd(i, gcd(j, l));
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3656