akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
int K, N;
int main(){
  int Lj4PdHRW, now=1;
  rd(N);
  rd(K);
  for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
    now =min_L(2*now, now+K);
  }
  wt_L(now);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20171023-1 [beta]

// --- original code ---
// int N, K;
// {
//   int now = 1;
//   rd(N,K);
//   rep(N) now = min(2now, now+K);
//   wt(now);
// }


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int a, b, c, d, sum=0;
	cin >> a >> b >> c >> d;
	if (a > b){
		sum += b;
	}
	else{
		sum += a;
	}
	if (c > d){
		sum += d;
	}
	else{
		sum += c;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
long long n,j,ans=1<<30;
inline long long count(int x) {
	int cnt=0;
	while(x) {
		cnt++;
		x/=10;
	}
	return cnt;
}
int main() {
	scanf("%lld",&n);
	for(long long i=1; i<=sqrt(n); i++) {
		if(!(n%i)) {
			j=n/i;
			ans=min(ans,max(count(j),count(i)));
		}
	}
	printf("%lld\n",ans);
}

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

int main(){
	int w, h;
	int i, j;
	
	while (1){
		scanf("%d %d", &h ,&w);
		if (w == 0 && h == 0) break;


		for (i = 0;i < h; i++){
			for (j = 0; j < w; j++){
				if ((i + j)%2==0){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}

		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
int main() {
	int n, m;
	cin>>n>>m;
	vi v[m];
	for(int i = 0; i < m; i++) {
		int t;
		cin>>t;
		rep(j, 0, t) {
			int p;
			cin>>p;
			v[i].pb(p);
		}
	}
	int A[m];
	rep(i, 0, m)
		cin>>A[i];
	int ans = 0;
	for(int i = 0; i < pow(2, n); i++) {
		string tem = bitset<10>(i).to_string();
		string s = "";
		s += &tem[10 - n];
		int t = 1;
		rep(j, 0, m) {
			int cnt = 0;
			for(int tt : v[j]) {
				if(s[tt - 1] == '1')
					cnt++;
			}
			if(cnt % 2 != A[j]) {
				t = 0;
				break;
			}
		}
		if(t)
			ans++;
		
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
string s;

int main() {
    cin >> n >> a >> b;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'c') cout << "No" << endl;
        else if (s[i] == 'a') {
            if (a || b) {
                if (a) a--;
                else b--;
                cout << "Yes" << endl;
            } else cout << "No" << endl;
        } else {
            if (b) {
                b--;
                cout << "Yes" << endl;
            } else cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=c)cout<<0<<endl;
    else if((a+b)<c)cout<<"NA"<<endl;
    else if((a+b)>=c)cout<<c-a<<endl;
    return 0;
}


Measured memory_bytes: 3108
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int x) {
	return x * x;
}

void solve() {
	int p;
	while(cin >> p) {
		int acc = 0;
		rep(i, 600 / p - 1) acc += f(p * (i + 1)) * p;
		cout << acc << endl;
	}
}

Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    while (cin >> a >> b) {
        ll x = abs(a - b);
        cout << (x > 1 ? "Alice" : "Brown") << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,x;
	cin>>a>>b>>x;
	long long count=b/x-a/x;
	
		if(a%x==0)
		{
			count++;
		}
	
	printf("%lld",count);
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define INF 100000000

int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vint l(N);
  rep(i,N) cin >> l[i];
  auto min3 = [&](int a,int b,int c){
    int ans = a <= b && a <= c
      ? a 
      : b <= a && b <= c
        ? b 
        : c;
    return ans;
  };
  auto min4 = [&](int a,int b,int c,int d){
    int ans = a <= b && a <= c && a <= d
      ? a 
      : b <= a && b <= c && b <= d
        ? b 
        : c <= a && c <= b && c <= d
          ? c 
          : d;
    return ans;
  };
  function<int(int,int,int,int)> dfs = [&](int depth,int a,int b,int c){
    if(depth == N){
      if(min3(a,b,c)> 0)
        return abs(A - a) + abs(B - b) + abs(C - c) - 30;
      else
        return INF;
    }
    int ans1 = dfs(depth+1,a,b,c);
    int ans2 = dfs(depth+1,a + l[depth],b,c) + 10;
    int ans3 = dfs(depth+1,a,b + l[depth],c) + 10;
    int ans4 = dfs(depth+1,a,b,c + l[depth]) + 10;
    return min4(ans1,ans2,ans3,ans4);
  };
  cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 2120
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,s;
    cin>>n>>k>>s;

    REP(i,k){
        cout<<s<<((i==n-1)?'\n':' ');
    }
    REPP(i,k,n){
        cout<<(s+(s<100000 ? 1:-1))<<((i==n-1)?'\n':' ');
    }
        
}


Measured memory_bytes: 1280
fn main() {
    let _ = read::<usize>();
    let a = read_vec::<u64>();

    let min = a.into_iter().map(|x| solve(x)).min().unwrap();

    println!("{}", min);
}

fn solve(x: u64) -> usize {
    let mut cnt = 0;
    let mut x = x;
    loop {
        if x % 2 == 0 {
            cnt += 1;
            x /= 2;
        } else {
            break;
        }
    }
    cnt
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
flag = 0

for i in range(N):
  for m in range(3):
    for n in range(3):
      if A[m][n] == b[i]:
        A[m][n] = 1
        
for m in range(3):
  if A[m][0] == A[m][1] and A[m][1] == A[m][2] and A[m][0] == A[m][2]:
    flag = 1
    
for n in range(3):
  if A[0][n] == A[1][n] and A[1][n] == A[2][n] and A[0][n] == A[2][n]:
    flag = 1
    
if A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[0][0] == A[2][2]:
  flag = 1
  
if A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[0][2] == A[2][0]:
  flag = 1
  
if flag == 1:
  print("Yes")
else:
  print("No")

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

using namespace std;

int main(){
    long a,b,c;
    cin>>a>>b>>c;
    if(a==1){
        cout<<"YES";
        return 0;
    }
    for(int i = a*10; i <= a*100; i+=a){
        if(i%b==c){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,N=1<<10;
	while(cin>>n,n){
		string s;
		cin>>s;
		s="u"+s;
		queue<pii>que;
		int used[1<<10][10]={0};
		int a=0;
		bool h=false;
		rep(i,n){
			if(s[i+1]=='u'){
				a=0;
				continue;
			}
			int to=s[i+1]-'0';
			que.push(pii(a,to));
			used[a][to]=true;
			if(a&1<<to)h=true;
			a|=1<<to;
		}
		while(!que.empty()){
			pii p=que.front();
			que.pop();
			rep(i,N)rep(j,10){
				if(!used[i][j])continue;
				if(i&p.first)continue;
				//cout<<i<<" "<<j<<" "<<p.first<<" "<<p.second<<endl;
				if(i&1<<p.second&&p.first&1<<j)h=true;
				else if(i&1<<p.second){
					int A=i|p.first,B=j;
					if(!used[A][B]){
						used[A][B]=true;
						que.push({A,B});
					}
				}else if(p.first&1<<j){
					int A=i|p.first,B=p.second;
					if(!used[A][B]){
						used[A][B]=true;
						que.push({A,B});
					}
				}
			}
		}
		
		if(!h)cout<<"SAFE"<<endl;
		else cout<<"UNSAFE"<<endl;
	}
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

struct s{
  int a;
  int b;
  double c;
};

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  REP(i,n){
    if(a[i] % 2 == 0){
      if(a[i] % 3 != 0 && a[i] % 5 != 0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
int p[50];
int main(void){
    cin >> N;
    rep(i,N) cin >> p[i];
    int c = 0;
    rep(i,N){
        if(i+1!=p[i]) c++;
    }
    if(c==0 or c==2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX_N 114514

typedef struct process {
    char name[20];
    int time;
} P;

P queue[MAX_N];
int head, tail;

void initialize() {
    head = 0;
    tail = 0;
}

void enqueue(P x) {
    queue[tail] = x;
    tail = (tail+1) % MAX_N;
}

P dequeue() {
    P x = queue[head];
    head = (head+1) % MAX_N;
    return x;
}

int main(void) {
    int i, n, q;
    scanf("%d %d\n", &n, &q);

    for (i = 0; i < n; i++) {
        P que;
        scanf("%s %d", que.name, &que.time);
        enqueue(que);
    }

    int elapsed = 0;
    while (head != tail) {
        P proc = dequeue();
        if (proc.time <= q) {
            elapsed += proc.time;
            printf("%s %d\n", proc.name, elapsed);
        } else {
            elapsed += q;
            proc.time -= q;
            enqueue(proc);
        }
    }

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    n = n % 10;
    if(n==3) {
        cout << "bon" << endl;
        return 0;
    } else if(n==0 || n==1 || n==6||n==8) {
        cout << "pon" << endl;
        return 0;
    } else {
        cout << "hon" << endl;
        return 0;
    }
    return 0;
}

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

int main()
{
	ll H,W;
	cin >> H >> W;
	if (min(H,W) == 1) cout << "1" << endl;
	else cout << (H*W+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
T,A = map(int,input().split())
H = input().split()
differ = [0]*N
for i in range(N):
 if A < 0:
  differ[i] = abs((T - int(H[i])*0.006) - A)
 else:
  differ[i] = abs(A - (T - int(H[i])*0.006))
differ = np.array(differ)
print(differ.argmin()+1)

Measured memory_bytes: 14532
#include <stdio.h>
#include <stdint.h>

int main()
{
  int N, K;
  scanf("%d%d", &N, &K);
  
  int64_t sum[N+1], min, max, ans=0, i;
  sum[0] = 0;
  for(i=1; i<=N; i++){
    sum[i] = i;
    sum[i] += sum[i-1];
  }
  
  for(i=K; i<=N+1; i++){
    min = sum[i-1];
    if(i==N+1)
      max = sum[N];
    else
      max = sum[N] - sum[N-i];
    ans += max - min + 1;
  }
  
  printf("%ld", ans % 1000000007);
  
  return 0;
}

Measured memory_bytes: 3284
# -*-coding:utf-8

#import fileinput
import math

def main():
    while True:
        a, b = map(int, input().split())

        if (a == 0 and b == 0):
            break
        else:
            for i in range(a):
                if (i == 0 or i == (a-1)):
                    for j in range(b):
                        print('#', end='')
                    print('')
                else:
                    for j in range(b):
                        if (j == 0 or j == (b-1)):
                            print('#', end='')
                        else:
                            print('.', end='')
                    print('')

            print('')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9084
n, y = list(map(int, input().split()))
nasi = True
for d in range(0,n+1):
    if nasi == False:
        break
    for e in range(0,(n+1)-d):
        if nasi == False:
            break
        f = n - d - e
        if ((10000 * d) + (5000 * e) + (1000 * f) == y):
            nasi = False
            print(d,e,f)
            break
if nasi == True:
    print('-1 -1 -1')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

vector<int> con[101];

#define INF ((int)1e9)

int bfs(int const S, int const T) {
  queue<pair<int, int> > q;
  int cost[101]; fill(cost, cost+100, INF);
  cost[S] = 0;
  q.push(make_pair(0, S));
  while(!q.empty()) {
    int now = q.front().second;
    int c = q.front().first; q.pop();
    int const size = con[now].size();
    for(int i=0; i<size; i++) {
      if(cost[con[now][i]]<INF) continue;
      cost[con[now][i]] = c + 1;
      //cout <<   "cost: " <<   cost[con[now][i]] << endl;
      q.push(make_pair(c + 1, con[now][i]));
    }
  }
  
  return cost[T];
}

int main() {
  
  int n; cin >> n;
  for(int I = 0; I < n; I++) {
    int r, k;
    cin >> r >> k; r--;
    for(int i=0; i<k; i++) {
      int t; cin >> t; t --;
      con[r].push_back(t);
    }
    // cout << "con["<<r<<"].size() " << con[r].size() << endl;
  }
  
  int m; cin >> m;
  for(int i=0; i<m; i++) {
    int a, b, ttl; cin >> a >> b >> ttl; a--; b--;
    int ans;
    if((ans = bfs(a, b)+1) <= ttl) {
      cout << ans << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
  
  return 0;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  string s[h];
  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  for(int i=0;i<h;i++){
    cout << "#" << s[i] << "#" << endl;
  }
  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
s = raw_input().rstrip().split(" ")
W = int(s[0])
H = int(s[1])
x = int(s[2])
y = int(s[3])
r = int(s[4])
if (x-r)>=0 and (x+r)<=W and (y-r)>=0 and (y+r)<=H:print "Yes"
else:print "No"

Measured memory_bytes: 6464
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// For prime mod.
	// Do not use if MOD is not prime number !!
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

typedef vector<mint> vm;
int n;
vector<vi> g;
vector<vm> dp;

void rec(int node, int par) {
    dp[node][0] = 1;
    dp[node][1] = 1;
    for(auto i: g[node]) {
        if(i == par) continue;
        rec(i, node);
        dp[node][0] *= dp[i][0] + dp[i][1];
        dp[node][1] *= dp[i][0];
    }
}

int main() {
//	cout << fixed << setprecision(15);
    cin >> n;
    g = vector<vi>(n);
    rep(i, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dp = vector<vm>(n, vm(2));
    rec(0, -1);
    mint ans = dp[0][0] + dp[0][1];
    cout << ans.x << endl;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF 1e8
using namespace std;
bool is_digit(char x){
    for(int i=48; i<=57; i++){
        if(x == i) return true;
    }
    return false;
}
int main(){
    int n;
    cin >> n;
    rep(k,n){
        string s,t;
        cin >> s >> t;
        for(int i=s.size()-1; i>=0; i--){
            //cout << t << endl;
            if(s[i] == 'J') rotate(t.rbegin(),t.rbegin()+1,t.rend());
            
            if(s[i] == 'C') rotate(t.begin(),t.begin()+1,t.end());
            if(s[i] == 'E') {
                rep(j,t.size()/2){
                    swap(t[j],t[t.size()-t.size()/2+j]);
                }
            }
            if(s[i] == 'A') reverse(t.begin(),t.end());
            if(s[i] == 'P') {
                rep(j,t.size()){
                    if(is_digit(t[j])) {
                        if(t[j] == 48) t[j] = 57;
                        else t[j]--;
                    }
                }
            }
            if(s[i] == 'M') {
                rep(j,t.size()){
                    if(is_digit(t[j])) {
                        if(t[j] == 57) t[j] = 48;
                        else t[j]++;
                    }
                }
            }
        }
        cout << t << endl;
    }
    return 0;
}


Measured memory_bytes: 2988
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int[] W = new int[N];
		for(int i = 0; i < N; i++)
			W[i] = GetInt();
		
		int[] csum = new int[N+1];
		for(int i = 1; i <= N; i++)
			csum[i] += csum[i-1] + W[i-1];

		int ans = int.MaxValue;
		for(int i = 1; i < N; i++)
		{
			int S1 = csum[i];
			int S2 = csum[N] - csum[i];
			ans = Math.Min(ans, Math.Abs(S1 - S2));
		}
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

template< typename T >
struct WeightedUnionFind {
  vector< int > data;
  vector< T > ws;

  WeightedUnionFind() {}

  WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {}

  int find(int k) {
    if(data[k] < 0) return k;
    auto par = find(data[k]);
    ws[k] += ws[data[k]];
    return data[k] = par;
  }

  T weight(int t) {
    find(t);
    return ws[t];
  }

  bool unite(int x, int y, T w) {
    w += weight(x);
    w -= weight(y);
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] > data[y]) {
      swap(x, y);
      w *= -1;
    }
    data[x] += data[y];
    data[y] = x;
    ws[y] = w;
    return true;
  }

  T diff(int x, int y) {
    return weight(y) - weight(x);
  }
};


int main() {
  int N, M;
  cin >> N >> M;
  WeightedUnionFind< int > tree(N);
  while(M--) {
    int A, B, C, D;
    cin >> A >> B >> C;
    if(A == 0) {
      cin >> D;
      tree.unite(B, C, D);
    } else {
      if(tree.find(B) == tree.find(C)) {
        cout << tree.diff(B, C) << endl;
      } else {
        cout << "?" << endl;
      }
    }
  }
}




Measured memory_bytes: 3632
s = gets.chomp.chars
q = gets.to_i
qs = q.times.map{gets.chomp.split}

reverse = false
qs.each do |i,f,c|
  if i == "1"
    reverse = !reverse
  end
  if i == "2"
    if (reverse && f == "2") || (!reverse && f == "1")
      s.unshift(c)
    else
      s.push(c)
    end
  end
end

if reverse
  s.reverse!
end

puts s.join

Measured memory_bytes: 68988
#include <stdio.h>
#include <string.h>

int main()
{
	char S[4], array[][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	int i, ans;

	scanf("%s", S);
	
	for (i = 0; i < 7; i++)
		if(!strcmp(S, array[i]))
			break;
	ans = i ? 7 - i: 7;
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
using System;
namespace ConsoleApplication4.Properties
{
    public class Class1
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            int a = n / 100;
            int b = n % 100;
            if (a!=0&&a<=12)
            {
                
                if (b!=0&&b<=12)
                {
                    Console.WriteLine("AMBIGUOUS");
                }
                else
                {
                    Console.WriteLine("MMYY");
                }
                
            }
            else
            {
                if (b==0)
                {
                    Console.WriteLine("NA");
                }
                else if (b<=12)
                {
                    Console.WriteLine("YYMM"); 
                }
                else
                {
                    Console.WriteLine("NA");
                }
                
            }
            
            

        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void){
int a,b,c,d;

    scanf("%d %d %d",&a,&b,&c);

    d=a;
    a=b;
    b=d;
    d=a;
    a=c;
    c=d;

    printf("%d %d %d\n",a,b,c);

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int r;
	cin >> r;
	cout << 3 * r*r << endl;
	

}

Measured memory_bytes: 256
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

lo r,c,d,w=1,p=1;
string s;



int main() {
	cin >> s;
	r = s.length();
	if (s[0] == 'A') { c = 1; }
	for (int i = 2;i <= r - 2;i++) {
		if (s[i] == 'C') { 
			if (d == 1) { w = 0; }
			else { d = 1; }
		}

	}
	for (int i = 1;i <= r - 1;i++) {
		if (s[i] != 'C'&('a' > s[i] | 'z' < s[i])) { p = 0; }
	}
	if (c&d&w&p) { cout << "AC"; }
	else { cout << "WA"; }
	
	
	
	//system("pause");
	return 0;

}


Measured memory_bytes: 256
def main():
    S = input()
    for index, s in enumerate(S):
        if index % 2 == 0:
            if s == 'L':
                print('No')
                exit()
        else:
            if s == 'R':
                print('No')
                exit()
    if index == len(S) - 1:
        print('Yes')



if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;



class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int size(){
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};



int main(){
    int n, m;   cin >> n >> m;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    Graph g(n);
    for(int i = 0; i < m; i++){
        int a, b;   cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    int res = 0;
    for(int i = 0; i < n; i++){
        bool ok = true;
        for(auto e: g[i]){
            if(h[i] <= h[e.vertice]){
                ok = false;
                break;
            }
        }
        if(ok){
            res++;
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 11124
#include<cstdio>
#include<cstring>

typedef long long int lli;

char map[50][100];
lli have[50][100];

int main(void) {
    while(1) {
        int n;
        scanf("%d",&n);
        if(!n) break;

        memset(map, 0, sizeof(map));
        memset(have, 0, sizeof(map));

        for(int i=0; i<n; i++) {
            int f;
            scanf("%d",&f);
            for(int j=0; j<f; j++) {
                int a;
                scanf("%d",&a);
                map[a][i] = 1;
            }
            have[0][i] = 1ULL<<i;
        }

        for(int d=1; d<=30; d++) {
            lli sum = 0ULL;
            for(int i=0; i<n; i++)
                if(map[d][i])
                    sum |= have[d-1][i];
            for(int i=0; i<n; i++) {
                if(map[d][i])
                    have[d][i] = sum;
                else
                    have[d][i] = have[d-1][i];
            }

        }

        lli full=(1ULL<<n)-1;
        int res=-1;

        for(int d=1; !(res+1) && d<=30; d++) {
            for(int i=0; !(res+1) && i<n; i++)
                if(have[d][i] == full)
                    res = d;
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <iomanip>
#include <limits>
#include <numeric>
#include <type_traits>

typedef long long ll;
typedef long double ld;

using namespace std;
using Graph = vector<vector<ll>>;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

const ll inf = 1e18+7;
const ll mod = 1e9+7;

ll fac(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll N,b=0,sum=0;
    cin >> N;
    for(ll i=1;i<=N;i++){
        sum += i;
        if(sum>=N){
            b=i;
            break;
        }
    }

    for(ll i=1;i<b+1;i++){
        if(sum-N!=i){
        cout << i << endl;
        }
    }
    return 0;
}

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

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

	std::vector<int> us(m);
	std::vector<int> vs(m);
	std::vector<int> ws(m);
	for (int i = 0; i < m; i++) {
		std::cin >> us[i] >> vs[i] >> ws[i];
		us[i]--;
		vs[i]--;
	}

	constexpr long long INF = 1e18;
	std::vector<long long> d(n, -INF);

	d[0] = 0;
	for (int i = 0; i < 5000; i++) {
		for (int j = 0; j < m; j++) {
			d[vs[j]] = std::max(d[vs[j]], d[us[j]] + ws[j]);
		}
	}
	long long ans1 = d[n - 1];
	for (int i = 0; i < 5000; i++) {
		for (int j = 0; j < m; j++) {
			d[vs[j]] = std::max(d[vs[j]], d[us[j]] + ws[j]);
		}
	}
	long long ans2 = d[n - 1];
	if (ans1 != ans2) {
		std::cout << "inf" << std::endl;
	} else {
		std::cout << ans1 << std::endl;
	}
}

Measured memory_bytes: 256
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline
    H, W = (int(i) for i in input().split())
    c = [[s for s in input()] for i in range(H)]
    dist = [[-1]*W for i in range(H)]

    def bfs(c, sy, sx, H, W):
        que = deque()

        dist[sy][sx] = 0
        que.append((sy, sx))
        d = ((1, 0), (0, 1), (-1, 0), (0, -1))
        flag = False  # 黒色マスにいるとき，True
        bla = 0
        whi = 0
        while que:
            uh, uw = que.popleft()
            if c[uh][uw] == "#":
                flag = True
                bla += 1
            else:
                flag = False
                whi += 1
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if dist[next_h][next_w] != -1:
                    continue
                if flag and c[next_h][next_w] == '#':
                    continue
                if not flag and c[next_h][next_w] == ".":
                    continue
                dist[next_h][next_w] = dist[uh][uw] + 1
                que.append((next_h, next_w))
        return bla * whi

    ans = 0
    for h in range(H):
        for w in range(W):
            if dist[h][w] != -1:
                continue
            if c[h][w] == "#":
                ans += bfs(c, h, w, H, W)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int ans1 = 10 * A + B + C;
	int ans2 = A + 10 * B + C;
	int ans3 = A + B + 10 * C;

	cout << max({ ans1,ans2,ans3 }) << endl;
	
}

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

int main(void){
    
    int a, tei, j, max = 0;
    scanf("%d", &a);
    
    for (tei = 2; tei*tei<=a; tei++) {
        for (j = 2; (int)pow(tei, j)<=a; j++) {
            max = (int)pow(tei, j) > max ? (int)pow(tei, j) : max;
        }
    }
    
    if (a == 1 || a == 2 || a == 3) {
        max = 1;
    }
    
    printf("%d\n", max);
    
    return 0;
}

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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  vector<int> pre;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()), pre(V) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          pre.at(w.to) = v;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
  vector<int> route(int from, int to) {
    vector<int> res;
    while (true) {
      res.push_back(to);
      if (to == from) break;
      to = pre.at(to);
    }
    reverse(res.begin(), res.end());
    return res;
  }
};

int cnt;
void dfs(int pre, int v, int ng, vector<vector<int>> &G) {
  cnt++;
  for (auto next : G.at(v)) {
    if (next == pre) continue;
    if (next == ng) continue;
    dfs(v, next, ng, G);
  }
}

int main() {
  int N;
  cin >> N;
  Dijkstra<int> D(N);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    D.add(--a, --b, 1);
    D.add(b, a, 1);
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  D.solve(0);
  auto res = D.route(0, N - 1);
  int tmp = res.size();
  int f = res.at(tmp - tmp / 2 - 1);
  int s = res.at(tmp - tmp / 2);
  dfs(-1, 0, s, G);
  int F = cnt;
  cnt = 0;
  dfs(-1, N - 1, f, G);
  int S = cnt;
  cout << ((F > S) ? "Fennec" : "Snuke") << "\n";
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int two = 0, four = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a % 4 == 0) four++;
    else if (a % 2 == 0) two++;
  }
  if ((n & 1 && 2 * four >= n - 1) || 2 * four + two >= n) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
lld xyz1 (lld n, lld a){
	if (n  ==  0)
		return 1;
	if (n  ==  1)
		return a;
	if (n%2==  0)
		return ((((xyz1(n/2,a) % MOD) * (xyz1(n/2,a) % MOD)) % MOD) * (1 % MOD)) % MOD;
	else
		return ((((xyz1(n/2,a) % MOD) * (xyz1(n/2,a) % MOD)) % MOD) * (a % MOD)) % MOD;
}
lld getc (lld n, lld a){
	if (a   >  n)
		return 0;
	lld x,y,r = 1;
	for(lld i = 1; i<=a; i++){
		x = n-i+1;
		y = i;
		r*= x%MOD;
		r = r%MOD;
		r*= xyz1(MOD - 2 , y);
		r = r%MOD;
	}
	return r;
}
int main (){
    FastIO
    lld n, a;
    lld b, i;
    cin >> n;
    cin >> a;
    cin >> b;
    lld x;
    x  = xyz1(n, 2);
    x %= MOD;
    x -= getc(n, a);
    x %= MOD;
    x -= getc(n, b);
    x %= MOD;
    x -=   1;
    x %= MOD;
    if (x<0){
    	cout<<MOD+x<<"\n";
    }
    else{
    	cout << x << "\n";
    }
    return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int H,W,N;
int dy[]={0,1},dx[]={1,0};
int pat[32][32];

int solve(vector<string> b){
    for(int i=H-1;i>=0;i--){
      rep(j,W){
	if(b[i][j]!='.') continue;
	int h=i;
	while(h>=0 && b[h][j]=='.') h--;
	if(h>=0){ b[i][j] = b[h][j]; b[h][j]='.';}
      }
    }
    //  rep(i,H) cout << b[i] << endl; cout << endl;
  int f=1;
  while(f){
    memset(pat, 0,sizeof(pat));
    f=0;
    rep(i,H) rep(j,W) rep(d,2){
      if(b[i][j]=='.') break;
      int y=i,x=j;
      int cnt=1;
      char color=b[y][x];
      while(1){
	y+=dy[d],x+=dx[d];
	if(y<0||y>=H||x<0||x>=W||b[y][x]!=color) break;
	cnt++;
      }
      if(cnt>=N){
	f=1;
	y=i,x=j;
	pat[y][x]=1;
	while(1){
	  y+=dy[d],x+=dx[d];
	  if(y<0||y>=H||x<0||x>=W||b[y][x]!=color) break;
	  pat[y][x] = 1;
	}
      }
    }
    rep(i,H) rep(j,W) if(pat[i][j]) b[i][j]='.';
    for(int i=H-1;i>=0;i--){
      rep(j,W){
	if(b[i][j]!='.') continue;
	int h=i;
	while(h>=0 && b[h][j]=='.') h--;
	if(h>=0){ b[i][j] = b[h][j]; b[h][j]='.';}
      }
    }
    //    rep(i,H) cout << b[i] << endl; cout << endl;
  }

  rep(i,H) rep(j,W) if(b[i][j]!='.') return 0;
  return 1;
}

int main(){
  cin >> H >> W >> N;
  vector<string>b(32);
  rep(i,H) cin >> b[i];

  rep(i,H) rep(j,W){
    int y=i+dy[0],x=j+dx[0];
    if(y<0||y>=H||x<0||x>=W||b[i][j]==b[y][x]) continue;
    swap(b[i][j], b[y][x]);
    if(solve(b)){
      cout << "YES\n";
      return 0;
    }
    swap(b[i][j], b[y][x]);
  }
  cout << "NO\n";
  return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll count = 0;
  for (int i = 1; i < int(s.size()); i++) {
    if(s[i-1] != s[i]) count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int func(int a)
{
	int c;
	c = a*a*a;
	return c;
} /*自作関数のプロトタイプ宣言*/
int main()
{
	int n, b;
	scanf("%d", &n);
	b = func(n);
	printf("%d\n", b);
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX



int n,m,vo,p,a,ok=3000000000,ng=0,ans;
vector<int> v;

signed main() {
    cin >> n >> m >> vo >> p;
    rep(i,n) cin >> a, v.pb(a);
    sort(rall(v));
    while(abs(ok-ng) > 1) {
        auto hoge = v;
        int mid = (ok+ng)/2;
        int sum = m*vo;
        vector<pair<int,int>> V;
        rep(i,n) {
            int huga = min(sum, min(m,max(0LL,mid-v[i])));
            sum -= huga;
            hoge[i] += huga;
            V.pb(mp(m-huga,i));
        }
        if (sum) {
            rep(i,p-1) {
                int huga = min(sum, V[i].fi);
                sum -= huga;
                hoge[V[i].se] += huga;
            }
        }
        sort(rall(hoge));
        if (hoge[p-1] <= mid && !sum) ok = mid;
        else ng = mid;
    }
    rep(i,n) if (ok <= v[i]+m) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 7480
#include <stdio.h>
#include <math.h>
int main(void){
  int n,m=1,l=0,i,j;
  int x[2001],y[2001];
  double r,tmp=0.0,a;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&x[i],&y[i]);
	m=m*i;
    l=l+i;
  }
  for(i=1;i<n;i++){
    for(j=i+1;j<=n;j++){
	  r=sqrt(pow(x[j]-x[i],2.0)+pow(y[j]-y[i],2.0));
	  tmp=tmp+r;
	}
  }
  a=tmp*(n-1)/(l-n);
  printf("%lf",a);
  return 0;
}

Measured memory_bytes: 128