akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 



 
signed main(){
    int h,w,n;
    cin>>h>>w>>n;
  
    int x,y,x0[h];
    fill(x0,x0+h,MOD);
    int ans=h;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        x0[x-1]=min(x0[x-1],y-1);
    }
    
    int k=0;
    for(int i=0;i<=h;i++){
        if(i>x0[i]+k){
            ans=i;
            break;
        }
        if(i==x0[i]+k)k++;
    }
   
    cout<<ans;

    return 0;
}

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

int main() {
    string N;
    bool flag = false;
    cin >> N;
    if (N[0] == N[1] && N[1] == N[2]) flag = true; 
    else if (N[1] == N[2] && N[2] == N[3]) flag = true; 
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
if a<=6:
    print("1")
    exit()
if a<=11:
    print("2")
    exit()
if a%11==0:
    print(int(a/11)*2)
    exit()
if a%11<=6:
    print(int(a/11)*2+1)
else:
    print(int(a / 11) * 2 + 2)

Measured memory_bytes: 3060
import math
a, b, x = map(int, input().split())
empty = a*a*b - x
ans_1 = 0
ans_2 = 0
if empty <= a*a*b/2:
    y = 2*b - 2*x/(a*a)
    ans_1 = math.degrees(math.atan(y/a))
    print(ans_1)
else:
    y = 2*x / (a*b)
    ans_2 = math.degrees(math.atan(b/y))
    print(ans_2)


Measured memory_bytes: 38384
#include <iostream>
#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 <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
//素数判定
bool is_prime(long long n){
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
    int N, M;
    cin >> N >> M;
    int ans = 0;
    int minlimit=0, maxlimit=N+1;
    rep(i,M){
        int L, R;
        cin >> L >> R;
        minlimit = max(minlimit, L);
        maxlimit = min(maxlimit, R);
    }
    if(maxlimit-minlimit<0){
        cout << 0 << endl;
        return 0;
    }
    cout << maxlimit - minlimit + 1 << endl;
    return 0;
}

Measured memory_bytes: 3608
k,a,b = map(int,input().split())
if a >= b-1 or k-a+1 <= 0:
    print(k+1)
    exit()
if (k-a+1)%2 == 0:
    ans = a + ((k-a+1)//2)*(b-a)
else:
    ans = a +1+((k-a)//2)*(b-a)
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N], y[M];
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> y[i];
  }
  for (int i = 0; i < N; ++i) {
    if (X < x[i]) X = x[i];
  }
  for (int i = 0; i < M; ++i) {
    if (Y > y[i]) Y = y[i];
  }
  if (X < Y) {
    cout << "No War" << "\n";
  }
  else {
    cout << "War" << "\n";
  }

  return 0;
}

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

int main(void)
{
  uint64_t N, T;
  cin >> N >> T;
  uint64_t ans = 0;
  uint64_t until = 0;
  for(int i = 0; i < N; i++){
    uint64_t t;
    cin >> t;
    if(until > t) ans += (t + T) - until;
    if(until <= t) ans += T;
    until = t + T;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int n;
	cin >> n;
	int m = n;
	vl A(n);
	for (int i = 0,j=0; j < n; i++,j++) {
		int x;
		cin >> x;
		if (i > 0) {
			if (x == A[i - 1]) {
				i--;
				m--;
				continue;
			}
		}
		A[i] = x;
	}
	if (n <= 2) {
		cout << "1"<<endl;
		return 0;
	}
	else {
		int ans = 1;
		for (int i = 2; i < m; i++) {
			if (A[i - 2] - A[i - 1] < 0 && A[i - 1] - A[i - 0]>0 || A[i - 2] - A[i - 1]>0 && A[i - 1] - A[i - 0] < 0) {
				ans++;
				i++;
			}
		}
		cout << ans<<endl;
		return 0;
	}
	

}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////
int N;
int main() {
	cin >> N;
	vector<int>V(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
	}
	sort(V.begin(), V.end());
	while (true) {
		int k;
		for (int i = 0; i < N; ++i) {
			if (V[i] != 0) {
				k = i;
				break;
			}
		}
		for (int i = k+1; i < N; ++i) {
			if (V[i] == V[k]) {
				V[i] = 0;
			}
			else {
				V[i] = gcd(V[k], V[i]);
			}
		}
		sort(V.begin(), V.end());
		int count = 0;
		for (int i = 0; i < N; ++i) {
			if (V[i] == 0)count++;
		}
		if (count == N - 1)break;
	}
	cout << V[N - 1] << endl;
	return 0;
}


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

using namespace std;

int main(){
  unsigned long long x;
  // unsigned long long nx;

  int counter = 0;
  unsigned long long now = 100;

  cin >> x;

  while(1){
    now = now * 1.01;
    counter ++;
    if(now >= x) {
      cout << counter << endl;
      break;
    }
  }

  return 0;
}

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

int main(){
    long long n, a, b, count, ans, check;
    bool flag = true;
    cin >> n >> a >> b;
  	if(a==0 && b==0){
      cout << 0 << endl;
      return 0;
    }
    count = n/(a+b);
    ans = count*a;
    check = n-count*(a+b);
    if(check>=a){
        ans += a;
    }else{
        ans += check;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <cstring>
#include <sstream>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define sqr(x) (x)*(x)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2l(x) 64 - __builtin_clzll((x)) - 1
#define inf1 int(1e9+7)
#define inf2 0x3f3f3f3f
#define infll ll(1e18+7)
#define Pi acos(-1.0)
#define mu(x,y) trunc(exp(log((x))*(y)))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

string s;

int main() {
    fastIO;
    //freopen(".inp","r",stdin);
    //freopen(".out","w",stdout);

    cin >> s;
    sort(all(s));
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    string s;
    cin>>n>>k>>s;
    for (int i=0;i<n;i++) {
        char c=s.at(i);
        if (i==k-1) {
            char tmp=c+32;
            cout<<tmp;
        } else {
            cout<<s.at(i);
        }
    }
    cout<<endl;
    
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll N, D;cin >> N >> D;
	vector<double> X(N), Y(N);
	rep(i,N)cin >> X[i] >> Y[i];

	ll ans = 0;
	rep(i,N){
		ll tmp = X[i]*X[i] + Y[i]*Y[i];
		if(tmp <= D * D) ans++;
	}

	cout << ans << endl;
}	

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

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

  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        cout << "No";
        return 0;
      }
    } else {
      if (S[i] == 'R') {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define Zero(dp) memset(dp,0,sizeof(dp))
#define pb push_back
using namespace std;
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{			
	int n;cin>>n;
	double sm=0.0;
	int a[n];for(int i=0;i<n;i++)cin>>a[i],sm+=a[i];
	int r1=ceil((sm*1.0)/n),r2=floor((sm*1.0)/n),ans1=0,ans2=0;
	for(int i=0;i<n;i++)
	{
		ans1+=(a[i]-r1)*(a[i]-r1);
		ans2+=(a[i]-r2)*(a[i]-r2);
	}
	cout<<min(ans1,ans2);

}
}


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

int main(){
   string s;
   cin >> s;
   
   for(int i=0;i<s.size();i++){
       if(s[i]=='h'){
           if(s[i+1]=='i'){
               i++;
           }else{
               cout << "No" << endl;
           return 0;
           }
       }else{
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>

using namespace std;

int main(){
  long long n, m, t;
  map<long long, long long> d;
  
  cin >> n;
  for (long long i=0;i<n;i++) {
    long long dd;
    cin >> dd;
    if (d.find(dd)==d.end()) {
      d[dd] = 1;
    } else {
      d[dd]++;
    }
  }

  cin >> m;
  for (long long i=0;i<m;i++) {
    long long t;
    cin >> t;
    if (d.find(t) == d.end()) {
      cout << "NO" << endl;
      return(0);
    } else if (d[t] == 0) {
      cout << "NO" << endl;
      return(0);
    } else {
      d[t]--;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int n;
ll k;
ll a[100010];
ll dp[50][2][2];
vector<ll> b,onecnt;
int main()
{
  cin >> n >> k;
  rep(i,n) cin >> a[i];

  while(k != 0){
    b.push_back(k%2);
    k /= 2;
  }
  
  while(1){
    ll cnt = 0;
    bool f = true;
    rep(i,n){
      if(a[i]!=0) f = false;
      cnt += a[i]%2;
      a[i] /= 2;
    }
    if(f) break;
    onecnt.push_back(cnt);
  }
  
  int bs = b.size(),os = onecnt.size();
  
  if(bs<os) rep(i,os-bs) b.push_back(0);
  else rep(i,bs-os) onecnt.push_back(0);

  reverse(onecnt.begin(),onecnt.end());
  reverse(b.begin(),b.end());

  
  bs = b.size();

  ll bit[50];
  ll x = 1;
  rep(i,bs){
    bit[bs-1-i] = x;
    x *= 2;
  }
  
  rep(i,bs+1) rep(j,2) rep(l,2) dp[i][j][l] = 0;
  dp[0][0][0] = 1;
  
  rep(i,bs) rep(j,2) rep(l,2){
    int bi = *(b.begin()+i);
    ll ol = *(onecnt.begin()+i);
    rep(jj,(l?2:bi+1)){
      if(dp[i][j][l]>0) dp[i+1][jj][l||jj<bi] = max(dp[i+1][jj][l||jj<bi],dp[i][j][l]+bit[i]*(jj?(ll)n-ol:ol));
    }
  }

  ll res = 0;
  rep(j,2) rep(l,2) res = max(res,dp[bs][j][l]);

  cout << res-1 << "\n";
  
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*3 for _ in range(n)]
for i in range(3): dp[0][i] = abc[0][i]
for i in range(1, n):
    for j in range(3): dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])+abc[i][j]
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

Measured memory_bytes: 74072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int x, y, u, v;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> x >> y >> u >> v;
	string s = "";
	FOR(i, u-x) s += "R";
	FOR(i, v-y) s += "U";
	FOR(i, u-x) s += "L";
	FOR(i, v-y+1) s += "D";
	FOR(i, u-x+1) s += "R";
	FOR(i, v-y+1) s += "U";
	s += "LU";
	FOR(i, u-x+1) s += "L";
	FOR(i, v-y+1) s += "D";
	s += "R";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

vector<ll> divisors(ll n){
    vector<ll> S, T;
    ll MAX = sqrt(n);
    rep(i, 1, MAX + 1) if(n % i == 0){S.push_back(i); T.push_back(n / i);}
    if(S.back() == T.back()) T.pop_back();
    S.insert(S.cend(), T.crbegin(), T.crend());
    return S;
}

void solve(){
    ll n; cin >> n;
    vector<ll> A(n);
    unordered_map<ll, ll> C;
    rep(i, n){
        cin >> A[i];
        C[A[i]]++;
    };

    ll ans = 0;
    rep(i, n){
        ll a = A[i];
        if(C[a] >= 2) continue;
        bool flag = true;
        for(ll d : divisors(a)){
            if(d == a) continue;
            if(C.find(d) != C.end()) flag = false;
        }
        ans += flag;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12964
# coding: utf-8


(n,m,x,y) = [int(i) for i in input().rstrip().split(" ")]

xlist = [int(i) for i in input().rstrip().split(" ")]
ylist = [int(i) for i in input().rstrip().split(" ")]

xlist.append(x)
ylist.append(y)

xlist = sorted(xlist)
xlist.reverse()

ylist = sorted(ylist)

if xlist[0] < ylist[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	vector<pair<int, int>> a(n);
	rep(i, n)scanf("%d%d", &a[i].first, &a[i].second);
	double sum = 0;
	double aa = 1;
	for (int i = 1; i <= n; ++i)aa *= i;
	rep(i, n) {
		for(int j = i + 1; j < n; ++j) {
			sum += sqrt(pow(a[i].first - a[j].first, 2) + pow(a[i].second - a[j].second, 2)) * (2 * aa / n);
		}
	}
	printdb(sum / aa);

	Please AC;
}


Measured memory_bytes: 888
#!/usr/bin/env python3
h, _ = map(int, input().split())
i = 0
for _ in range(h):
    a = input()
    c = a.count("#")
    if a.replace("#" * c, "").replace(".", "") != "" or a[i:i + c] != "#" * c:
        print("Impossible")
        exit()
    else:
        i += c - 1
print("Possible")


Measured memory_bytes: 9164
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	rep(i, n / r + 1) {
		rep(j, (n - i * r) / g + 1) {
			if ((n - i * r - j * g) % b == 0)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 10/07/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

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

	#ifndef ONLINE_JUDGE
	freopen("/home/dinesh_verra/cpp/input.txt","r",stdin);
	// freopen("/home/dinesh_verra/cpp/output.txt","w",stdout);
	#endif

	ll n;
	cin>>n;
	ll a[n+5],x;
	for(ll i=0;i<=n;i++) a[i]=0;
	for(ll i=1;i<101;i++)
	{
		for(ll j=1;j<101;j++)
		{
			for(ll k=1;k<101;k++)
			{
				x=i*i+j*j+k*k+i*j+j*k+k*i;
				if(x>n) cu;
				a[x]++;
			}
		}
	}
	for(ll i=1;i<=n;i++) prn(a[i]);
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

std::vector<int> parse() {
  int n;
  std::cin >> n;

  std::vector<int> ls{};
  ls.reserve(n);

  for (int i = 0; i < n; ++i) {
    int l;
    std::cin >> l;
    ls.push_back(l);
  }

  std::sort(ls.begin(), ls.end());

  return ls;
}

inline int64_t count(const int *begin, const int *end, int boundary) noexcept {
  const auto len = end - begin;

  if (len == 0)
    return 0;

  if (boundary <= *begin)
    return 0;

  if (*(end - 1) < boundary)
    return len;

  const auto *mid = begin + (len / 2);

  return count(begin, mid, boundary) + count(mid, end, boundary);
}

int main() {
  const auto ls = parse();
  const auto n = static_cast<int>(ls.size());

  int64_t ret = 0;
  const int *end = ls.data() + n;

  for (int i = 0; i < (n - 2); ++i) {
    for (int j = i + 1; j < (n - 1); ++j) {
      int boundary = ls[i] + ls[j];
      const int *begin = ls.data() + (j + 1);
      ret += count(begin, end, boundary);
    }
  }

  std::cout << ret << std::endl;

  return 0;
}


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

typedef  long long int ll;
#define ent cout << "\n"
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define pair < ll, ll > pp
#define f(a, b) for(auto i = a;i < b;i++)
#define rev_f(a, b) for(auto i = b;i >= a;i--)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define st(x) sort(x.begin(), x.end()) 
#define rv(x) reverse(x.begin(), x.end()) 
#define cintc() ll tc;while(tc--) 
#define deb(x) cout << x << "\n";
#define cin() ll a; cin >> a;
#define cin2() ll a, b; cin >> a >> b
#define cin3() ll a, b, c; cin >> a >> b >> c
#define cinn(vect, n) def_v vect(n); f(0, n) cin >> vect[i]
#define coutn(vect, n)  f(0, n) {cout << vect[i] << " ";}ent;

typedef vector < ll > def_v;
typedef tuple< ll, ll, ll> def_tuple;
ll mod = 1e9 + 7,cnt = 0;

vector < ll > bfs(vector < ll > graph[], vector < ll > vect, ll start, ll flag, ll n)
{

    ll vis[n + 1] = {0};
    vis[start] = 1;
    queue < ll > q;
    q.push(start);
    while(!q.empty())
    {

        ll start = q.front();
        q.pop();
        auto size = ll(graph[start].size());
        for(ll j = 0;j < size;j++)
        {
            ll x = graph[start][j];
            if(!vis[x])
            {
                vis[x] = 1;
                if(x == 1 && flag == 2)
                {
                    flag = 2;
                }
                else
                    q.push(x);
                vect[x] = flag;
            }
        }
    }

    return vect;
}

vector < ll > int_binary(ll n, ll size)
{
    ll cnt = 0;
    def_v str(size);
    while(n > 0)
    {
        str[cnt++] = n%2;
        n = n/2;
    }
    return str;
}
void solve()
{   

    string str, arr;
    cin >> str >> arr;
    
    ll i = 0;
    while(str[i] != '\0')
    {
        if((str[i] != arr[i] && arr.size() + 1 > str.size()) || (str.size() > arr.size()))
        {
            cout << "No\n";
            return ;
        }
        i++;
    }

    cout << "Yes\n";



    return ;
}
int main()
{
    fastio();
    ll tc = 1;
    // cin >> tc;
    while(tc--)
        solve();
    return 0;
}

Measured memory_bytes: 3652
#include <string>
#include <iostream>
#include <vector>
#include <climits>

int f (std::vector<int> const & a, int A) {
  int sum = 0;
  for (int i = 0; i < a.size(); ++i) {
    sum += (a[i] - A) * (a[i] - A);
  }
  return sum;
}

int main () {
  std::string line;
  std::getline(std::cin, line);

  char * p;
  p = &*line.begin();
  int N = std::strtol(p, &p, 10);

  std::vector<int> a(N);

  std::getline(std::cin, line);
  p = &*line.begin();
  for (int i = 0; i < N; ++i) {
    a[i] = std::strtol(p, &p, 10);
  }

  int min = INT_MAX;

  for (int A = -100; A <= 100; ++A) {
    min = std::min(min, f(a, A));
  }

  std::cout << min << std::endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define MOD 1000000007
#define f(i,a,n) for(lli i = a; i < n; i++)
#define pb push_back
#define mp make_pair

bool mycomp(pair<lli,lli>s1, pair<lli,lli>s2 )
{
	if(s1.second!=s2.second)
	{
		return s1.second>s2.second;
	}
	else
		return s1.first>s1.second;
}

bool mycomp1(lli a,lli b)
{
	return a>b;
}

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

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    lli n,m;
    cin>>n>>m;
    lli arr[n];
    for(lli i=0;i<n;i++)
    {
    	cin>>arr[i];
    }

    sort(arr,arr+n);

    pair<lli,lli>arr1[m];
    lli total = 0;
    for(int i=0;i<m;i++)
    {
    	lli a,b;
    	cin>>a>>b;
    	arr1[i]=make_pair(a,b);
    	total +=a;
    }

    sort(arr1,arr1+m,mycomp);

    lli merge[n];
    for(lli i=0;i<n;i++)
    	merge[i]=0;
    if(total<=n)
    {
    	int index = total-1;
    	for(int i=0;i<m;i++)
    	{
    		lli a = arr1[i].first;
    		while(a--)
    		{
    			merge[index]=arr1[i].second;
    			index--;
    		}
    	}
    }
    else
    {
    	int index = n-1;
    	bool flag = true;
    	for(int i=0;i<m;i++)
    	{
    		lli a = arr1[i].first;
    		while(a--)
    		{
    			merge[index]=arr1[i].second;
    			index--;
    			if(index<0)
    			{
    				flag = false;
    				break;
    			}
    		}
    		if(!flag)
    			break;
    	}

    }

    sort(merge,merge+n,mycomp1);

    for(int i=0;i<n;i++)
    {
    	if(arr[i]<merge[i])
    		arr[i]=merge[i];

    }

    

    // for(int i=0;i<n;i++)
    // 	cout<<merge[i]<<" ";

    lli cum = 0;
    for(int i=0;i<n;i++)
    	cum +=arr[i];
    cout<<cum;


return 0;
}

Measured memory_bytes: 3328
/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX   XXXXXXXXX  XXXXXXXXXXXXXXXX  XXXXXXXXXXXXXXXXXXXXXXXXX X
X XXX XX   XXXX XXXX    X XXX XXX XXXX   XXXX XXXX   XXXXXX X
X XXXXXXXXX XXX XXX XXXXX XXX XXX XXXXXXX XX   XX XXX XX    X
X XXXXX     XXX XXX XXXXX XXX XXX XXX     XXX XXX     X XXX X
X XXX X XXX XXX XXX XXXXX XXX XXX XXX XXX XXX XXX XXXXX XXX X
XX   XXX    XX   XXX    XX    XX   XXX    XXX  XXX    XX    X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX   XXXX   XX  X XXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXX XXXXXX X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX     XX     X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXXXXX XXX X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX    XXX    X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <chrono>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <array>
#include <set>
#include <list>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <map>
#include <iterator>
#include <cstring>
using namespace std;

#define loop(i,start,end) for(auto i = start; i < end; i++)
#define loopi(end) loop(i,0,end)
#define loopj(end) loop(j,0,end)
#define loopk(end) loop(k,0,end)
#define get_i(n) int n; cin >> n;
#define get_ch(n) char x; cin >> x;
#define get_doub(n) double n; cin >> n;
#define pb push_back
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vb vector<bool>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define clear(a) memset(a, 0, sizeof(a))
#define all(a) (a).begin(), (a).end()
const long long modulo = 1e18+3;
const ll INF = 1e18;
const int inf = 2e9;
const double PI = 3.141592653589793238463;

//#define FILE "substrcmp"
#define FAST_IO
#define FSOL

#ifdef FSOL
void solve() {
	get_i(n);
	vi h(n); loopi(n) cin >> h[i];
	vi dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	loop(i, 2, n) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	cout << dp[n - 1];
}
#else 
void solve() {
	
}
#endif

int main() {
#ifdef FAST_IO
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#endif
#ifdef DEBUG
	freopen("debug.in", "r", stdin);
	auto timestamp = std::chrono::system_clock::now();
#else 
#ifdef FILE
	freopen(FILE".in", "r", stdin);
	freopen(FILE".out", "w", stdout);
#endif
#endif
	solve();
#ifdef DEBUG 
	cout << endl << "Time elapsed: " << chrono::duration_cast<chrono::milliseconds>(std::chrono::system_clock::now() - timestamp).count() << " ms" << endl;
#endif
	return 0;
}

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

#define m(a, b) memset(a, b, sizeof(a))
#define py(b, a) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & (-x))

const int maxn = 1e5 + 10;
const int inf = 1e9;
typedef long long LL;
typedef pair<int, int> PII;

char a[maxn], b[maxn];
int main(){
	cin >> a >> b;
	int len1 = strlen(a);
	bool ans = false;
	for(int i = 0; i < len1; i ++){
		for(int j = 0; j < len1; j ++){
			if(a[i] == b[j]){
				int k = 1;
				for(k = 1; k < len1; k ++){
					if(a[(i + k) % len1] == b[(j + k) % len1])
						continue;
					else break;
				}
				if(k == len1) ans = true;
			}
			if(ans) break;
		}
		if(ans) break;
	}
	if(ans) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a[] = {0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    int x, y;

    scanf("%d%d", &x, &y);

    if (a[x-1] == a[y-1])
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = (int)1e9+7;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

int n;
string s;
int cnt[100000];
set<int> record;

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(0); 
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> s;
	n = sz(s);
	memset(cnt, 0, sizeof(cnt));
	rep(i,0,n-1) {
		if(s[i] == 'R' && s[i+1] == 'L') {
			record.insert(i+1);
		}
	}

	rep(i,0,n) {
		if(s[i] == 'R') {
			auto it = record.upper_bound(i);
			int right = *it;
			if((right-i)%2) {
				cnt[right-1]++;
			} else {
				cnt[right]++;
			}
		}
	}

	rep(i,0,n) {
		if(s[i] == 'L') {
			auto it = record.upper_bound(i);
			it--;
			int left = (*it)-1;
			if((i-left)%2) {
				cnt[left+1]++;
			} else {
				cnt[left]++;
			}
		}
	}

	rep(i,0,n) {
		cout << cnt[i] << ' ';
	}
	return 0;
}


Measured memory_bytes: 3280
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

int x,y;

int main(){
  scanf("%d%d",&x,&y);
  
  
  if(y%2==0 && y>=2*x && y<=4*x){
    printf("Yes\n");}
  else{
    printf("No\n");}
  
  return 0;
}


Measured memory_bytes: 1656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double S = r*r*Math.PI;
        double C = 2*r*Math.PI;
        System.out.println(String.format("%.8f", S) + " " + String.format("%.8f", C));
    }
}


Measured memory_bytes: 28156
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstdlib>
#include <cstdio>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
stack<int> st;
string S;
int cul(string s){
  int b=st.top();st.pop();
  int a=st.top();st.pop();
  if(s=="+"){
    return a+b;
  }else if(S=="-"){
    return a-b;
  }else if(S=="*"){
    return a*b;
  }else{
    return a/b;
  }
}
int main(){
  while(cin>>S){
    if(S=="+"||S=="-"||S=="*"||S=="/"){
      st.push(cul(S));
    }else{
      st.push(atoi(S.c_str()));
    }
    if(getchar()=='\n'){
      cout<<st.top()<<endl;
      return 0;
    }
  }
  return 0;
}


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

int main(){
    int a,b,m=0;
    while(cin>>a>>b){
        if(!(a||b))break;
        if(m>0)cout<<endl;
        m++;
        
        int c=0;
        for(int i=a;i<=b;i++)
            if((i%4==0)&&(i%100!=0||i%400==0)){cout<<i<<endl;c++;}
        if(!c)cout<<"NA"<<endl;
    }
}

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

int main() {
	double n, i, ans = 100000;
	cin >> n;
	for (i = 1; i <= n; i++) {
		ans = ans*1.05;
		if (int(ans) % 1000 != 0) ans = ans - int(ans) % 1000 + 1000;
	}
	printf("%d\n", int(ans));
	return 0;
}

Measured memory_bytes: 3048
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)


type Scanner struct {
	innerScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := new(Scanner)
	innerScanner := bufio.NewScanner(os.Stdin)
	innerScanner.Split(bufio.ScanWords)
	sc.innerScanner = innerScanner
	return sc
}

func (sc Scanner) scan() {
	sc.innerScanner.Scan()
}

func (sc Scanner) next() string {
	sc.scan()
	return sc.innerScanner.Text()
}

func (sc Scanner) nextInt() int {
	i, _ := strconv.Atoi(sc.next())
	return i
}

func (sc Scanner) nextFloat() float64 {
	f, _ := strconv.ParseFloat(sc.next(), 64)
	return f
}
func main() {
	sc := NewScanner()
	s := sc.next()
	k := sc.nextInt() - 1
	for i := 0; i < len(s); i++ {
		if s[i] == '1' {
			if i == k {
				fmt.Println(string(s[i]))
				break
			}
		} else {
			fmt.Println(string(s[i]))
			break
		}
	}
}

Measured memory_bytes: 640
N, *A = map(int, open(0).read().split())

MOD = 10 ** 9 + 7
ctr = [0] * 3
ans = 1
for a in A:
    ans *= sum(a == v for v in ctr)
    for j in range(3):
        if ctr[j] == a:
            ctr[j] += 1
            break

print(ans % MOD)


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

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

  string s;cin>>s;
  int n=s.size();
  int c=0;
  for(int i=2;i<n-1;i++){
    if(s[i]=='C')c++;
  }
  int sl=0;
  for(int i=0;i<n;i++){
    if('a'<=s[i]&&s[i]<='z')sl++;
  }
  if(s[0]=='A'&&c==1&&sl==n-2){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;

  }

  return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    string s1,s2,s3; cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[0] << s3[0] << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int64_t>> xyz(n, {0, 0, 0});
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> xyz.at(i).at(j);
        }
    }

    int64_t res = 0;
    for (int p = 0; p < 8; p++)
    {
        vector<int64_t> s;
        for (int i = 0; i < n; i++)
        {
            int64_t v = 0;
            for (int j = 0; j < 3; j++)
            {
                if ((p / (1 << j)) % 2 == 0)
                {
                    v += xyz.at(i).at(j);
                }
                else
                {
                    v -= xyz.at(i).at(j);
                }
            }
            s.push_back(v);
        }
        sort(s.begin(), s.end(), greater<int64_t>());
        int64_t tmp = 0;
        for (int i = 0; i < m; i++)
        {
            tmp += s.at(i);
        }
        if (res < tmp)
        {
            res = tmp;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <bits/stdc++.h>

#define ll long long

int main(){
    int K, X;
    cin >> K >> X;
    for ( int i = X - K + 1; i < X + K; i ++ ){
        if ( i > -1000001 && i < 1000001 ) cout << i << " ";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct pii {
	int S, F;
} a[100005];
int n, nw;
ll ans[100005];
bool cmp(pii x, pii y) {
	return x.F > y.F || (x.F == y.F && x.S < y.S);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i].F);
	for (int i = 1; i <= n; i ++) a[i].S = i;
	sort(a + 1, a + n + 1, cmp);
	a[n + 1].S = n + 1;
	int nw = a[1].S;
	for (int i = 1; i <= n; i ++, nw = min(nw, a[i].S))
		ans[nw] += 1ll * (a[i].F - a[i + 1].F) * i;
	for (int i = 1; i <= n; i ++) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int n;
vector<string> ans;

void dfs(string s){
	if(s.size()==n){
		ans.push_back(s);
		return;
	}
	
	set<char> cset;
	for(auto x:s) cset.insert(x);
	
	char c;
	for(auto x: cset){
		dfs(s+x);
		c = x;
	}
	c = (char)((int)c+1);
	dfs(s+c);
	
	return;
}

int main(){
	cin >> n;
	
	dfs("a");
	
	for(auto s:ans){
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7356
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

typedef pair <int, int> pii;
typedef pair <int, pii> ppi;

const int MAX_N = 5e4 + 20, MAX_M = 2e5 + 10, SQRT = 230, inf = 1000000000;
int n, cnt;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		for (int j = i + 1; j < s.size(); j++)
			if (s[i] == s[j]) {
				cnt++;
			}

	if (cnt == 2) {
		cout << "Yes\n";
	}
	else
		cout << "No\n";
	return 0;
}

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

using namespace std;

int main() {
    int n, m;
    int a, b;
    long long ans = 0;
    cin >> n >> m;
    vector<vector<long long> > v(m);
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a > m) continue;
        v[m-a].push_back(b);
    }

    priority_queue<long long> q;
    for (long long i = m-1; i >= 0; --i) {
        for (auto b: v[i]) q.push(b);
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5632
CS = ["012".to_i(4), "102".to_i(4), "021".to_i(4)]
CS2 = ["132".to_i(4), "112".to_i(4), "212".to_i(4), "312".to_i(4)]

IS = (0..63).to_a

def init3
  IS.map do |i| CS.include?(i) ? 0: 1 end
end

def f(m, xs)
  if (m == 0)
    sum(xs) % 1000000007
  else
    f(m-1, IS.map do |i| g(xs, i) end)
  end
end

def g(xs, i)
  ab = i / 4
  case i
  when *CS then 0
  when *CS2 then h(xs, ab, [16,32,48])
  else h(xs, ab, [0,16,32,48])
  end
end

def h(xs, ab, js)
  sum(js.map do |j| xs[ab + j] end) % 1000000007
end

def sum(xs)
  xs.inject(0) {|c,x| c + x }
end

n = gets.chomp.to_i

p(f(n-3, init3))


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define int long long

int fans=0;
vector<int> tmp(10,0);
int dp1[100],dp2[100];

int g(int now){
  if(~dp1[now])return dp1[now];
  int res=1;
  int A=now+now;
  while(A>9){
    A=A%10+A/10;
    res++;
  }
  dp1[now]=res;
  dp2[now]=A;
  return res;
}

int h(int now){
  if(~dp2[now])return dp2[now];
  int res=1;
  int A=now+now;
  while(A>9){
    A=A%10+A/10;
    res++;
  }
  dp1[now]=res;
  dp2[now]=A;
  return A;
}


void f(int K,int L){//LがK個ある時に何が起きるか
  //tmpに何が入ってfansに何回足されるのか
  int now=L;
  while(K){
    if(K&1)tmp[now]++;
    fans+=K/2*g(now);//g(now):now二つを合成させるときにかかるコスト
    now=h(now);//now二つからできるもの
    K>>=1;
  }
  return;
}


signed main(){
  memset(dp1,-1,sizeof(dp1));memset(dp2,-1,sizeof(dp2));
  int n;cin>>n;
  vector<int> c(n),d(n);
  for(int i=0;i<n;i++)cin>>d[i]>>c[i];
  vector<int> m(10,0);
  for(int i=0;i<n;i++)m[d[i]]+=c[i];
  bool fl=true;
  while(fl){
    fl=false;
    fill(tmp.begin(),tmp.end(),0);
    for(int i=0;i<10;i++)f(m[i],i);
    for(int i=0;i<10;i++)m[i]=tmp[i];
    for(int i=0;i<10;i++)if(m[i]>1)fl=true;
  }
  queue<int> que;
  for(int i=0;i<10;i++)if(m[i])que.push(i);
  int res=que.front();que.pop();
  while(que.size()){
    int p=que.front();que.pop();
    res+=p;fans++;
    while(res>9){
      res=res/10+res%10;
      fans++;
    }
  }
  cout<<fans<<endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<math.h>
int so(int);
int main(){
  int n,i,num,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num);
    if(num==2){
      sum++;
      continue;
    }else if(num%2==0){
      continue;
    }
    if(so(num)==1){
      sum++;
    }
  }
  printf("%d\n",sum);
}

int so(int num){
  int i,a;
  a=sqrt(num);
  for(i=3;i<=a;i=i+2){
    if(num%i==0){
      return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 2064
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    n = int(input())
    edge = [[0]*n for i in range(n)]

    for i in range(n):
        u, k, *vs = [int(j) - 1 for j in input().split()]
        # debug(vs, locals())
        for v in vs:
            edge[u][v] = 1

    for i in range(n):
        print(*edge[i])

    pass

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8420
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  if(n%2 == 0) cout << n << endl;
  else cout << n*2 << endl;
  return 0;
}

Measured memory_bytes: 256