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

int N;
string S;
int cn = 0;

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

  char c = S[0]; int i = 0;
  while(i < N){
    while(c == S[i] && i < N) i++; 
    cn++; c = S[i];
  }

  cout << cn << endl;
  return 0;
    
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
bool n[2250000]={false};
int main(){
  for(int i=2; i<=1500; i++)
    if(!n[i])
      for(int j=i*i; j<2250000; j+=i)      
	n[j] = true;
  int m;
  while(cin >>m,m){
    int i,j;
    for(i=m;n[i];i--);
    for(j=m;n[j];j++);
    cout <<j-i<<endl;
  }
  return 0;
}

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

int main(void){
  int N,M,C,count=0;
  cin>>N>>M>>C;
  vector<vector<int>>a;
  vector<int>b,sum;
  b.resize(M);
  sum.resize(N);
  for(int j=0;j<M;j++)cin>>b[j];
  a=vector<vector<int>>(20,vector<int>(20,0));

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

  for(int n=0;n<N;n++){
    for(int m=0;m<M;m++){
      sum[n]+=a[n][m]*b[m];
    }
  }

  for(int x=0;x<N;x++){
    if(sum[x]+C>0)count++;
  }
  cout<<count;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,ans=0,t;
    cin>>n;
    ll a[n+1];
    for(ll i=0; i<n ; i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<n ; i++)
    {
        if(a[i]<a[i-1])
        {
            t=(a[i-1]-a[i]);
            ans+=t;
            a[i]=a[i]+t;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N,M;
const int maxn = 1e5+5;
vector<int> G[maxn];
//set<int> G2[maxn];

int d[maxn];

unordered_set<int> ss[4];

void dfs(int u,int from,int dd){
    /*
    if(dd == 3 && (d[u] == -1)){
        nex.insert(u);
        return;
    }
    */
    ss[dd].insert(u);
    if(dd == 3) return;

    for(int a:G[u]){
        if(!(ss[dd+1].count(a)))
            dfs(a,from,dd+1);
    }
}

void bfs(int s,int t){
    memset(d,-1,sizeof(d));
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int u = que.front();que.pop();
        ss[3].clear();
        dfs(u,u,0);

        for(auto v:ss[3]){
            if(d[v] == -1){
                d[v] = d[u] + 1;
                if(v == t) return;
                que.push(v);
            }
        }
    }

}

int main()
{
    cin >> N >> M;
    _for(i,0,M){
        int u,v;
        scanf("%d %d",&u,&v);
        G[u].PB(v);
    }
    int S,T;
    scanf("%d %d",&S,&T);
    bfs(S,T);
    printf("%d\n",d[T]);

    return 0;
}


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

int main() {
  int K;
  int A, B;
  cin >> K >> A >> B;
  
  int S = B / K;
  
  if (A <= S * K && S * K <= B) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
}

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

int n, s, x, p;
deque<pair<int, long long> > d;

long long amx(int a) {
	if(s >= d.back().first) {
		return s - d.front().first;
	} else if(s <= d.front().first) {
		return d.back().first - s;
	}
	int na;
	long long D = d.back().first - d.front().first;
	if(d.front().second >= d.back().second) {
		pair<int, long long> t = d.front();
		t.second += d.back().second;
		d.pop_back();
		d.pop_front();
		d.push_front(t);
		na = 0;
	} else {
		pair<int, long long> t = d.back();
		t.second += d.front().second;
		d.pop_front();
		d.pop_back();
		d.push_back(t);
		na = 1;
	}
	return amx(na) + (long long)(a != na) * D;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s;
	for(int i = 1; i <= n; ++i) {
		cin >> x >> p;
		d.push_back({x, p});
	}
	cout << amx(2) << endl;
	return 0;
}


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

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

using namespace std;

/* function */



/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input

  int i;    // subscript
  int comp; // comparison

  int  seq_begin;
  int  seq_count;
  bool plus_flag, minus_flag;


  /* Input, Array_Proclamation */
  cin >> N;
  vector<int> A(N);

  for(i=0; i<N; i++)
  {
    cin >> A.at(i);
  }


  /* Initialize */
  plus_flag  = false;
  minus_flag = false;

  seq_begin  = A.at(0);
  seq_count  = 1;



  /* Calculation */
  for(i=1; i<N; i++)
  {

    if(plus_flag == false && minus_flag == false)
    {
      if ( seq_begin < A.at(i) )
      {
        comp = A.at(i);
        plus_flag = true;
      }
      else if ( seq_begin > A.at(i) )
      {
        comp = A.at(i);
        minus_flag = true;
      }
    }

    if ( comp <= A.at(i) && plus_flag == true )
    {
      comp = A.at(i);
    }
    else if ( comp > A.at(i)  && plus_flag == true )
    {
      seq_begin = A.at(i);
      plus_flag = false;
      seq_count++;
    }
    
    if ( comp >= A.at(i) && minus_flag == true )
    {
      comp = A.at(i);
    }
    else if ( comp < A.at(i)  && minus_flag == true )
    {
      seq_begin = A.at(i);
      minus_flag = false;
      seq_count++;
    }

  } 
  

  /* Output */
  cout << seq_count << endl;


  return 0;

}


/* entity */





Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int N,M;
	cin >> N >> M;
	if(N==1)cout << M << endl;
	else{
		for(int i=M/2;i>0;i--){
			if(M%i==0 && M/i>=N){cout << i << endl;break;}
			
		}

	}
	return 0;
}

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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[100100][3];

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    
    rep(i,n) {
        dp[i+1][0] = max(dp[i][1]+a[i],dp[i][2]+a[i]);
        dp[i+1][1] = max(dp[i][0]+b[i],dp[i][2]+b[i]);
        dp[i+1][2] = max(dp[i][0]+c[i],dp[i][1]+c[i]);
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
    return 0;
}





Measured memory_bytes: 2560
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n, k = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let x = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec split low high = function
  | [] -> (Array.of_list low, Array.of_list @@ List.rev high)
  | x :: xs when x < 0 -> split (-x :: low) high xs
  | x :: xs -> split low (x :: high) xs

let low, high = split [] [] x

let low_len = Array.length low
let high_len = Array.length high

let rec solve1 m = function
  | 0 -> m
  | i -> 
      if k - i > high_len then m
      else let t = if k = i then low.(i - 1) else low.(i - 1) * 2 + high.(k - i - 1) in solve1 (min m t) (i - 1)

let rec solve2 m = function
  | 0 -> m
  | i -> 
      if k - i > low_len then m
      else let t = if k = i then high.(i - 1) else high.(i - 1) * 2 + low.(k - i - 1) in solve2 (min m t) (i - 1)

let () = Printf.printf "%d\n" @@ min (solve1 max_int (min low_len k)) (solve2 max_int (min high_len k))

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        for(int j = 0; j <= x; j++){
            if(i + j == x){
                if(2 * i + 4 * j == y){
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");
    return 0;
}
// Write Here


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a'|| c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int h,w,kk; cin >> h >> w >> kk;
    vc<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    int ans = 0;
    for(int i = 0; i < (1 << (h+w)); i++){
        int cnt = 0;
        rep(j,h){
            rep(k,w){
                if(s[j][k] == '.') continue;
                if(i & (1 << k)) continue;
                if(i & (1 << (w+j))) continue;
                cnt++;
            }
        }
        if(cnt == kk) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	int h, w;
	int hh, ww;

	cin >> h >> w;
	cin >> hh >> ww;

	cout << h * w - (w*hh) - (h*ww) + ww * hh;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void y(bool c) {
	if (c)print("Yes");
	else print("No");
}


vector<int>G[200020];
void solve() {
	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		//G[v].push_back(u);
	}
	REP(i, N) {
		vector<bool>vis(N);
		vector<int>pre(N);
		int s = i;
		pre[s] = s;
		queue<int>que;
		que.push(s);
		vis[s] = true;
		while (true) {
			vector<int>nxt_v;
			while (!que.empty()) {
				int pos = que.front(); que.pop();
				vis[pos] = true;
				bool found = false;
				set<int>ans;
				for (auto nxt : G[pos]) {
					if (nxt == s) {
						//pe(nxt + 1); print(pos+1);

						int tmp = pos;
						while (tmp != s) {
							ans.insert(tmp);
							tmp = pre[tmp];
						}
						ans.insert(s);
						found = true;
						continue;
					}
					else if (vis[nxt]) {
						if (found) {
							if (!ans.count(nxt))continue;
						}
						goto END;
						//if (ans.count(nxt))goto END;
						//else continue;
					}
					pre[nxt] = pos;
					//vis[nxt] = true;
					nxt_v.push_back(nxt);
				}
				if (found) {
					print(ans.size());
					for (auto x : ans)print(x + 1);
					return;
				}
			}
			if (nxt_v.empty())break;
			for (auto x : nxt_v)que.push(x);
		}
	END:;
	}
	print(-1);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 4992
#include <stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1){
        c=c-b;
        if(c<=0){
            printf("Yes\n");
            break;
        }
        a=a-d;
        if(a<=0){
            printf("No\n");
            break;
        }
        
    }
    return 0;
    
}

Measured memory_bytes: 1620
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

#define MAXN 100005

int n,root=-1;
vector <int> E[MAXN];

int dfs(int u,int fa)
{
    bool flag=0;
    int res=0;
    for(int i=0;i<(int)E[u].size();i++)
    {
        int v=E[u][i];
        if(fa==v)
            continue;
        int t=dfs(v,u);
        if(t==0&&flag)
            res++;
        if(t==0&&flag==0)
            flag=1;
        res+=t;
    }
    return res;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        u++,v++;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
        if(E[i].size()>=3)
        {
            root=i;
            break;
        }
    if(root==-1)
    {
        printf("1");
        return 0;
    }
    printf("%d",dfs(root,-1));
}


Measured memory_bytes: 9088
#include<iostream>
#include<iomanip>
#include<iterator>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<stack>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
*/
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x3f3fffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
typedef long long int ll;
typedef double dd;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll MOD=1000000007;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"DEBUG:("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// GLOBAL VARIABLES ////////////////////////////
vector<vector<int>> adj; vector<bool> vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
/////////////////// FUNCT`IONS ////////////////////////////////////
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
bool ispow2(ll x){ return x && (!(x&(x-1)));}
ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

const int SIZE=1e8-1; //Add
bitset<SIZE+1> seive;
/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  cout<<fixed;cerr<<fixed; cout<<setprecision(8); cerr<<setprecision(3);
  srand(time(NULL)); rand();

#ifdef DEBUG
  //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
#endif


  int n,ans=0;
  for(cin>>n;n>0;--n){
    int t; cin>>t;
    while(t%2==0){ ++ans; t>>=1;}
  }
  cout<< ans <<'\n';



#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=2e5+5;
int main()
{
    int i,j;
    ll x;
    cin>>x;
    ll ans=0;
    ll num=1;
    while(x)
    {
        ans+=num;
        num*=2;
        x/=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
    	int a,b,c,t;
    	scanf("%d%d%d",&a,&b,&c);
    	if(a<b){t=a;a=b;b=t;}
    	if(a<c){t=a;a=c;c=t;}
    	if(b<c){t=b;b=c;c=t;}
    	printf("%d\n",a-c);
    	return 0;
    }

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

int a, b, c, x, y;

int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int m = min(x, y), M = max(x, y);
	printf("%d\n",min({x*a+y*b, m*2*c+(x-m)*a+(y-m)*b, M*2*c}));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[11];
	scanf("%s", s);
	int len = strlen(s);
	if(s[0] != 'A')
	{
		printf("WA");
		return 0;
	}
	int cnt = 0;
	for(int i = 2; i < len - 1; ++ i)
		if(s[i] == 'C')
			++ cnt;
		else
			if(s[i] < 'a' || s[i] > 'z')
			{
				printf("WA");
				return 0;
			}
	if(s[1] < 'a' || s[1] > 'z')
	{
		printf("WA");
		return 0;
	}
	if(s[len - 1] < 'a' || s[len - 1] > 'z')
	{
		printf("WA");
		return 0;
	}
	if(cnt != 1)
	{
		printf("WA");
		return 0;
	}
	printf("AC");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
signed main(void){
    int n;cin>>n;
    vector<int>A(n),B(n),C(n);
    rep(i,n)cin>>A[i];rep(i,n)cin>>B[i];rep(i,n)cin>>C[i];
    sort(all(A));sort(all(B));sort(all(C));
    int ans=0;
    rep(i,n){
        int now=B[i];
        int a=lower_bound(all(A),now)-A.begin();
        int b=C.end()-upper_bound(all(C),now);
        ans+=a*b;
    }
    cout<<ans<<endl;
    
}
        


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	for (int i = 0; i < n - 1; i++) {
		int c = 'z' - s[i] + 1;
		if (s[i] == 'a') c = 0;
		if (k >= c) {
			s[i] = 'a';
			k -= c;
		}
	}
	int d = s[n - 1] - 'a';
	d = (d + k) % 26;
	s[n - 1] = d + 'a';
	cout << s << endl;
}

Measured memory_bytes: 592
import Control.Applicative

f [n, m] = judge 
  where
    sstep = div n $ gcd n m
    tstep = div m $ gcd n m
    judge [] [] = lcm n m
    judge s' t' = if head s' == head t' then judge (drop sstep s') (drop tstep t') else (-1)

main = f <$> (map read . words <$> getLine) <*> getLine <*> getLine >>= print

Measured memory_bytes: 8828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  string S, T; cin >> S >> T;
  ll i = 0, ans = 0;
  while (S[i]){
    if (S[i] != T[i])
      ans++;
    i++;
  }
  cout << ans << endl;
}


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

int main(void){
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i, n) cin>>x[i];
    float ave=(float)accumulate(x.begin(), x.end(), 0)/(float)x.size();
    int intave=0;
    float integral_part = 0;
    float fractional_part = std::modf(ave, &integral_part);
    if(fractional_part<0.5) intave=integral_part;
    else intave=integral_part+1;
    vector<int> v(n);
    rep(i, n) v[i]=pow((x[i]-intave), 2);
    cout<<accumulate(v.begin(), v.end() , 0)<<endl;;
}

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

int main() {
  int n;	cin >> n;
  unsigned long long ans=1;
  vector<unsigned long long> data(n);
  for(int i=0;i<n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  
  for(int i=0;i<n;i++){
    if(data.at(i)>1000000000000000000/ans){
      cout << -1;
      return 0;
    }
    ans*=data.at(i);
    if(ans==0){
      cout << 0;
      return 0;
    }
  }
  cout << ans;
}


Measured memory_bytes: 4036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc140/tasks/abc140_f>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> S(1<<N); for(auto& in:S) cin >> in;
    sort(S.rbegin(),S.rend());
    
    vector<ll> slimes,t_slimes;
    slimes.push_back(S[0]);
    
    multiset<ll> T;
    for(int i = 1; i < (1<<N);i++) T.insert(S[i]);
    
    for(int i = 0; i < N;i++){
        t_slimes = slimes;
        for(auto v:slimes){
            auto it = T.lower_bound(v);
            if(it == T.begin()){
                return "No";
            }
            it--;
            t_slimes.push_back(*it);
            T.erase(it);
        }
        slimes = t_slimes;
        sort(slimes.rbegin(),slimes.rend());
    }
    return "Yes";
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 16760
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

void test(priority_queue<pair<ll,ll>> que){
  while(!que.empty()){
    cout<<que.top().first<<" "<<que.top().second<<endl;
    que.pop();
  }
}

int main(){
  double x,y;cin>>x>>y;
  int a=(4*x-y)/2;
  int b=(y-2*x)/2;
  if(a>=0&&b>=0&&2*a+4*b==y&&a+b==x){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3188
N,K=map(int,input().split())
V=list(map(int,input().split()))
c=min(N,K)
p=[0]
for i in range(c+1):
  for j in range(c-i+1):
    a=[0]
    s=0
    for k in range(i):
      s=s+V[k]
      a.append(V[k])
    for l in range(j):
      s=s+V[N-1-l]
      a.append(V[N-1-l])
    for _ in range(K-i-j):
      if min(a) >=0:
        break
      else:
        s=s-min(a)
        a.remove(min(a))
    p.append(s)
print(max(p))

Measured memory_bytes: 43100
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int x, y;
int cnt;
int main(){
	cin >> x >> y;
	cnt = intmax;
	//押さない
	if (x <= y)cnt = min(cnt, y - x);
	//最初だけ押す
	if (-x <= y)cnt = min(cnt, y + x + 1);
	//最後だけ押す
	if (x <= -y)cnt = min(cnt, -y - x + 1);
	//最初と最後に押す
	if (-x <= -y)cnt = min(cnt, -y + x + 2);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
/*********************"ANJAN AGARWALA"************************
***************************@anjn98****************************/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define IO 				ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 			v.begin(),v.end()
#define PR(a) 			cout<<"("<<a<<")";
#define ED 				cout<<'\n';
#define endl 			'\n'
#define loop(j,a,n) 	for(int j=a;j<=n;j++)
#define loop1(j,a,n) 	for(int j=a;j>=n;j--)
#define fr1(j,n) 		for(int j=0;j<n;j++)
#define fr(n) 			for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB 				push_back
#define MP 				make_pair
#define pii 			pair<int,int>
#define pll 			pair<long long int,long long int>
#define F 				first
#define S 				second 
#define binf 			2000000000000000001
#define mod 			1000000007

const int  M=1,N=1e5+9;
ll dp[N],a[N];

int32_t main()
{	
	IO
    int n,k;cin>>n>>k;
    fr(n)cin>>a[i+2];
    fr(N)dp[i]=1e12;
    dp[2]=0;
    loop(i,3,n+1)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j>=2)dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
            else break;
            //PR(abs(a[i]-a[i-j]))PR(dp[i-j])
        }
        
    }
    cout<<dp[n+1]<<endl;


}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

    int ans=0;
    for (int i = 0; i < N; i++) {
      int h = sc.nextInt();

      if(h>=K) ans++;
    }

    System.out.println(ans);


  }


}


Measured memory_bytes: 48232
def resolve():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    A = [list(map(int, input().split())) for i in range(N)]
    
    ans = 0
    for i in range(N):
        calc =[0]*M
        for j in range(M):
            calc[j] = A[i][j]*B[j]
        if sum(calc) + C > 0:
            ans += 1
    
    print(ans)
resolve()

Measured memory_bytes: 38448
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int A[2000006],B[2000006];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  FOR(i,0,n)cin>>A[i];
  int C[11111];
  CLR(C);
  FOR(i,0,n){
    C[A[i]]++;
  }
  FOR(i,0,10101){
    C[i+1] = C[i+1] + C[i];
  }
  FOR(i,0,n){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }
  FOR(i,0,n){
    if(i) cout<<" ";
    cout<<B[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 18756
#include<iostream>

using namespace std;

int GCD(int M, int N) {
	
    while(N != 0) { 
        int r = M % N; 
        M = N; 
        N = r; 
    } 
    return M;
}

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

  int g;
  g = GCD(a, b);
  
  cout << ( a / g + b / g - 1 ) * g + 1 << "\n";
  
}
  return 0;
}


Measured memory_bytes: 2992
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s,s2,s3;
    cin >> s >> s2;
    int n,m; cin >> n >> m;
    cin >> s3;
    if(s3==s)n--;
    else m--;
    cout << n << " " << m << "\n";
    return 0;
}



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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

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

  ll N, L;
  std::cin >> N >> L;
  std::vector< std::string > vs(N, "");
  for (ll i = 0; i < N; i++) {
    std::cin >> vs[i];
  }
  std::sort(vs.begin(), vs.end());

  std::string ans = "";
  for (auto s : vs) {
    ans += s;
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
def solve() :
    ri = raw_input()

    inarr = ri.split(' ')
    a = inarr[0]
    b = inarr[1]

    if a in ['2'] :
        return ( b == '2')
    elif a in ['4','6','9','11'] :
        return ( b in ['4','6','9','11'])
    else :
        return ( b in ['1','3','5','7','8','10','12'])

if __name__ == '__main__':
     if solve() : print 'Yes'
     else : print 'No'

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

using namespace std;

int main()
{
    int K;
    cin >> K;
    long long int ans = 0;

    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            int g_1 = __gcd(i, j);
            for (int k = 1; k <= K; k++)
            {
                ans += __gcd(k, g_1);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

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

    }

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	int x, y; cin >> x >> y;
	x += 8000, y += 8000;
	vector<int> X, Y;
	int len = s.size(), cnt = 0, fw = 0, st = 0;
	for (int i = 0; i < len; i++) {
		if (s[i] == 'T') {
			if (fw != 0) {
				if (cnt == 0) st = fw;
				else if (cnt % 2 == 0) X.push_back(fw);
				else Y.push_back(fw);
			}
			fw = 0, cnt++;
		}
		if (s[i] == 'F') fw++;
	}

	if (fw != 0) {
		if (cnt == 0) st = fw;
		else if (cnt % 2 == 0) X.push_back(fw);
		else Y.push_back(fw);
	}

	vector<vector<bool>> dpx(X.size() + 1, vector<bool>(16001)), dpy(Y.size() + 1, vector<bool>(16001));
	dpx[0][8000 + st] = true;
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j <= 16000; j++) {
			if (dpx[i][j]) {
				if (j + X[i] <= 16000)
					dpx[i + 1][j + X[i]] = true;
				if (j - X[i] >= 0)
					dpx[i + 1][j - X[i]] = true;
			}
		}
	}

	dpy[0][8000] = true;
	for (int i = 0; i < Y.size(); i++) {
		for (int j = 0; j <= 16000; j++) {
			if (dpy[i][j]) {
				if (j + Y[i] <= 16000)
					dpy[i + 1][j + Y[i]] = true;
				if (j - Y[i] >= 0)
					dpy[i + 1][j - Y[i]] = true;
			}
		}
	}

	if (dpx[X.size()][x] && dpy[Y.size()][y]) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 11572
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL q,x,y,z,n,m,a[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <LL> vec[KL];
set <int> s;
map <int,int> M;
string b[KL];
bool ok[KL];

int main()
{
    scl(n);scl(m);
    for(int i=0;i<m;i++)
    {
        scl(a[i]);cin>>b[i];
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]=="AC")vec[a[i]].pb(1);
        else vec[a[i]].pb(0);
    }
    LL sum=0,sum2=0;
    for(int i=1;i<=n;i++)
    {
        LL cnt=0;
        for(int j=0;j<vec[i].size();j++)
        {
            if(vec[i][j]==0)cnt++;
            else {ok[i]=true;break;}
        }
        if(ok[i]){sum++;sum2+=cnt;}
    }
    cout<<sum<<" "<<sum2;
    return 0;
}


Measured memory_bytes: 41984
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;

int n, factn = 1;
double sum;
vector<int> perms;
vector<int> xs(10), ys(10);

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(10);
    

    // 15:53
    cin>>n;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        xs[i] = x; ys[i] = y;
        perms.push_back(i);
        factn *= i + 1;
    }

    // 15:59
    do
    {
        double tmpres = 0;
        rep(i,n-1){
            int dx = xs[perms[i+1]] - xs[perms[i]];
            int dy = ys[perms[i + 1]] - ys[perms[i]];
            tmpres += sqrt( dx*dx + dy*dy );
        }
        sum += tmpres;
    } while (next_permutation(perms.begin(), perms.end()));
    // 16:02

    cout<<sum/(double)factn<<endl;

    return 0;
}


Measured memory_bytes: 3764
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    r = ni()
    print(r*2*3.141592)
    #print(ans)
    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 61848
def solve():
    K = int(input())
    cnt = 0
    n_digit = 1
    numbers = []
    while cnt < K:
        numbers = []
        dfs("", numbers, n_digit)
        cnt += len(numbers)
        n_digit += 1
    
    print(numbers[-(cnt - K + 1)])
    
def dfs(now, numbers, n_digit):
    if len(now) == n_digit:
        numbers.append(now)
        return
    
    if now == "":
        for i in range(1,10):
            dfs(now+str(i), numbers, n_digit)
    else:
        last_num = int(now[-1])
        if last_num - 1 >= 0:
            dfs(now+str(last_num-1), numbers, n_digit)

        dfs(now+str(last_num), numbers, n_digit)

        if last_num + 1 <= 9:
            dfs(now+str(last_num+1), numbers, n_digit)

if __name__ == '__main__':
    solve()

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

int main(){
  long long n;
  long long i;
  int a,b,c;
  long long sum = 0;

  scanf("%lld", &n);

  for(i = 1;i <= n;i++){
    if(i == 1){
      sum += 1;
      continue;
    }

    if(i % 15 != 0 && i % 3 != 0 && i % 5 != 0) sum += i;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 1732
N, A, B, C = map(int, input().split())
L = []
for _ in range(N):
  L.append(int(input()))

def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret

print(rec(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 == M2 ? 0 : 1) << "\n";
    return 0;
}


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

int64_t dp(int64_t N){
  if(N < 10) return N;
  else       return max(dp(N/10)+ N%10, dp(N/10- 1)+ 9);
}

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

  cout << dp(N) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    
    class Program
    {

        const long MOD = 1000000007;

        static long Solve(string S)
        {
            S = string.Join("", S.Reverse());
            int N = S.Length;
            //dp[i, j] := i文字目までの値であまりがjとなるの通り
            long[,] dp = new long[N + 1, 13];
            //0文字目の時は値はないので余り0として1通りとする
            dp[0, 0] = 1;
            int ten = 1;

            //i文字目までの余りは dp[i - 1]
            //追加されるのは値S[i - 1] * 10^(i-1)
            //追加される余りはS[i - 1] * 10^(i-1) % 13 = add
            //i文字目までの全体の余りは add + dp[i - 1, j] (j = 0 ～ 12)
            for (int i = 1; i <= N; i++)
            {
                if (i == 1) ten = 1;
                else ten = (ten * 10) % 13;

                int val = -1;
                if (S[i - 1] != '?') val = S[i - 1] - '0';

                if(val != -1)
                {
                    for(int j = 0; j <= 12; j++)
                    {
                        dp[i, (((val * ten) % 13) + j) % 13] += dp[i - 1, j];
                    }                    
                }
                else
                {
                    //? = val = 0 ～ 9 において更新
                    for(val = 0; val <= 9; val++)
                    {
                        for (int j = 0; j <= 12; j++)
                        {
                            dp[i, ((val * ten) % 13 + j) % 13] += dp[i - 1, j];
                        }
                    }
                }

                for (int j = 0; j <= 12; j++) dp[i, j] %= MOD;

            }


            return dp[N, 5];
        }

        
        static void Main(string[] args)
        {
            //入力1(S)
            string S = Console.ReadLine();

            Console.WriteLine(Solve(S));
            
        }
    }

}

Measured memory_bytes: 24544
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use im_rc::HashMap;
use text_io::*;

fn main() {
    let n: usize = read!();
    if n == 1 {
        println!("0");
        std::process::exit(0);
    } else {
        let vec = trial_division(n);
        let mut ans = 0;
        for (_key, num) in vec {
            ans += f(num);
        }
        println!("{}", ans);
    }
}

fn f(u: usize) -> usize {
    let mut u = u;
    if u == 1 {
        return 1;
    } else {
        for i in 1..u {
            if u - i <= i {
                return i;
            } else {
                u -= i;
            }
        }
    }
    10000
}

fn trial_division(mut n: usize) -> HashMap<usize, usize> {
    let mut primes = HashMap::new();
    let mut i = 2;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            if primes.contains_key(&i) {
                let mut x = primes.get_mut(&i).unwrap();
                *x += 1;
            } else {
                primes.insert(i, 1);
            }
        }
        i += 1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    if n > 1 {
        if primes.contains_key(&n) {
            let mut x = primes.get_mut(&n).unwrap();
            *x += 1;
        } else {
            primes.insert(n, 1);
        }
    }
    primes
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "P" : "Imp") << "ossible" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int field[510][510];
int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	ll cnt = 0;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				if (500 * a + 100 * b + 50 * c == X) { cnt++; }
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256