akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using Int=long long;

int count(int i, int j,int H,int W,const std::vector<std::string> &S) {

	int res = 0;
	for (int k = std::max(0, i - 1); k <= std::min(H - 1, i + 1); k++) {
		for (int l = std::max(0, j - 1); l <= std::min(W - 1, j + 1); l++) {
			if (S[k][l] == '#')res++;
		}
	}
	return res;
}


int main() {

	int H, W;
	std::cin >> H >> W;

	std::vector <std::string> S(H);
	for (int i = 0; i < H; i++) std::cin >> S[i];

	std::vector<std::string> ans(H);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++)ans[i] += '0';
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') ans[i][j] += count(i, j,H,W, S);
			else ans[i][j] = '#';
		}
	}

	for(int i=0;i<H;i++)std::cout << ans[i] << std::endl;


}




Measured memory_bytes: 256
x = list(map(int, input().split()))
imos = [0]*(max(x) + 2)
imos[x[0]] += 1
imos[x[1]+1] -= 1
imos[x[2]] += 1
imos[x[3]+1] -= 1
for i in range(len(imos)-1):
    imos[i+1] += imos[i]
print(max(imos.count(2) - 1, 0))

Measured memory_bytes: 3064
w, h, n = map(int, input().split())
xl, xr, yd, yu = 0, w, 0, h
for _ in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    xl = max(x, xl)
  elif a == 2:
    xr = min(x, xr)
  elif a == 3:
    yd = max(y, yd)
  else:
    yu = min(y, yu)
if xl >= xr or yd >= yu:
  print(0)
else:
  print((xr-xl) * (yu-yd))

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

using namespace std;

void solve()
{
	vector<double> mountain;
	double height;
	while(cin >> height)
	{
		mountain.push_back(height);
	}
	sort(mountain.begin(), mountain.end());
	cout << mountain[mountain.size() - 1] - mountain[0] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define vp vector<pair <$$,$$> >
#define vctr vector<$$>
#define in(a) scanf("%lld",&a)
#define out(a) printf("%lld ",a)
#define loop(i,m,p) for ($$ i = m; i < p; i++)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;


int main()
{
    $$ n,k;
    in(n);
    in(k);
    $$ a[n];
    loop(i,0,n) in(a[i]);
    $$ cn=0;
    loop(i,0,n){
    	if (a[i]>=k)
    	{
    		/* code */cn++;
    	}
    }
    cout<<cn<<endl;



return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

ll dp[210000];
int col[210000];
vector<int> mp[210000];

int main()
{
  int N; cin >> N;
  REP(i, N) cin >> col[i];
  REP(i, N) mp[col[i]].PB(i);
  dp[0] = 1;
  REP(i, N) {
    (dp[i + 1] += dp[i]) %= MOD;

    int c = col[i];
    int idx = upper_bound(ALL(mp[c]), i) - mp[c].begin();
    if (idx < mp[c].size()) {
      int j = mp[c][idx];
      if (j - i > 1) (dp[j + 1] += dp[i + 1]) %= MOD;
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 13824
S = raw_input()

lenS = len(S)
intS = int(S)
binS = "0b" + S

start0 = ""
start1 = ""
flag = True

for _ in xrange(lenS):
    if flag:
        start0 += "0"
        start1 += "1"
        flag = False
    else :
        start0 += "1"
        start1 += "0"
        flag = True

bin0 = "0b" + start0
bin1 = "0b" + start1



bin0dif = str(bin(int(bin0, 2) ^ int(binS, 2))).count("1")
bin1dif = str(bin(int(bin1, 2) ^ int(binS, 2))).count("1")

if bin0dif > bin1dif:
    print bin1dif
else:
    print bin0dif



Measured memory_bytes: 3460
def f(n):
  d=[]
  for i in range(1,int(n**0.5)+1):
    if n%i<1:
      d+=i,
      if i!=n//i:d+=n//i,
  return d[1:]
n=int(input())
a=f(n-1)
for i in f(n):
  m=n
  while m%i<1:m//=i
  if m%i<2:a+=i,
print(len(set(a)))

Measured memory_bytes: 39536
h,w = map(int,input().split())
ans = 10**9
ans = min(ans,(h//3+min(1,h%3))*w-(h//3)*w)
ans = min(ans,(w//3+min(1,w%3))*h-(w//3)*h)
for i in range(1,h//2+1):
    s1 = i*w
    s2 = (h-i)*(w//2)
    s3 = (h-i)*(w//2+w%2)
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))
for i in range(1,w//2+1):
    s1 = i*h
    s2 = (w-i)*(h//2)
    s3 = (w-i)*(h//2+h%2)
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))
print(ans)

Measured memory_bytes: 3064
function main(input) {

  var input = input.split(' ');

  var answer = 'Yay!';
  if(input[0] >= 9 || input[1] >= 9) {
  	answer = ':(';
  }

  console.log(answer);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=305;
int n,m;
ll two[M];
vvi a;

int main(){
	two[0]++;
	for(int i=1;i<M;i++) two[i]=two[i-1]*2%mod;
	cin>>n>>m;
	a=vvi(n,vi(m));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>a[i][j];
	int I=0;
	for(int i=0;i<m;i++){
		for(int j=I;j<n;j++) if(a[j][i]){
			swap(a[I],a[j]);
			break;
		}
		if(I==n||!a[I][i]) continue;
		for(int j=0;j<n;j++) if(j!=I&&a[j][i]){
			for(int k=0;k<m;k++) a[j][k]^=a[I][k];
		}
		I++;
	}
	cout<<(two[m]-two[m-I]+mod)*two[n-1]%mod<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> t(N+1);
	vector<Int> x(N+1);
	vector<Int> y(N+1);

	for (Int i = 1; i < N+1; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	Int flag = 0;
	Int temp_t = 0;
	Int temp_dis = 0;
	for (Int i = 0; i < N; i++) {
		temp_t = t[i + 1] - t[i];
		temp_dis = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (temp_t < temp_dis) {
			flag = 1;
			break;
		}
		else if ((temp_t % 2) != (temp_dis % 2)) {
			flag = 1;
			break;
		}
	}

	cout << (flag ? "No" : "Yes") << endl;
}

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

//https://atcoder.jp/contests/dp/tasks

int main(){
    int n;
    cin >> n;
    vector<vector<int>> dp;
    dp.assign(n+1,vector<int>(3,0));

    for(int i =1;i<=n;i++){
        int a,b,c;
        cin >> a >> b >> c;

        dp[i][0] = max(dp[i-1][1]+b,dp[i-1][2]+c);
        dp[i][1] = max(dp[i-1][0]+a,dp[i-1][2]+c);
        dp[i][2] = max(dp[i-1][1]+b,dp[i-1][0]+a);
    }
    cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << endl;
}

Measured memory_bytes: 8736
#include<bits/stdc++.h>
using namespace std;
template<typename T> inline T& Min(T &x,const T &y) {return x>y?(x=y):x;}
const int maxn=3e5+10;
int n,sum[maxn];
char s[maxn];
inline int query(int l,int r) {
	if (l>r) return 0;
	return sum[r]-sum[l-1];
}
int main() {
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<=n;++i) sum[i]=sum[i-1]+(s[i]=='E');
	int ans=INT_MAX;
	for (int i=1;i<=n;++i) {
		int lef=i-1-query(1,i-1);
		int rig=query(i+1,n);
		Min(ans,lef+rig);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
 
int main(){
    ll a[3][3];
    rep(i, 3)rep(j, 3)cin >> a[i][j];

    int bingo[3][3] = {};
    
    ll n;
    cin >> n;
    rep(i, n){
        ll b;
        cin >> b;
        rep(j, 3)rep(k, 3)if(b == a[j][k]){
            bingo[j][k] = 1;
        }
    }

    rep(i, 3){
        if(bingo[i][0]*bingo[i][1]*bingo[i][2]){
            cout << "Yes";
            return 0;
        }
        if(bingo[0][i]*bingo[1][i]*bingo[2][i]){
            cout << "Yes";
            return 0;
        }
    }

    if(bingo[0][0]*bingo[1][1]*bingo[2][2]){
        cout << "Yes";
        return 0;
    }
    if(bingo[0][2]*bingo[1][1]*bingo[2][0]){
        cout << "Yes";
        return 0;
    }

    cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

ll f(ll &a, ll &b, ll x) {
  double d = (double)x / b;
  return floor(a * d) - a * floor(d);
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (n < b) {
    cout << f(a, b, n) << endl;
    return 0;
  }
  cout << f(a, b, b - 1) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#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 (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, ans = INF;
	vector<int> a(5000), b;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	for (int i = 0; i <= a[0]; ++i) {
		for (int j = 0; j <= a[n - 1]; ++j) {
			int cnt = i + j;
			b = a;
			b[0] -= i;
			b[n - 1] -= j;
			for (int k = 0; k < n; ++k) {
				if (b[k] < 0)
					continue;
				b[k + 1] -= b[k];
				cnt += b[k] * 2;
			}
			ans = min(ans, cnt);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>
int main()
{
    int i,A[100],N,count1=0,count2=0;

    scanf("%d",&N);
    for(i=0; i<N; i++)
        scanf("%d",&A[i]);

    for(i=0; i<N; i++)
        if(A[i]%2==0)
        {
            count1++;
            if(A[i]%3==0 || A[i]%5==0)
                count2++;
        }
    if(count1==count2)
        printf("APPROVED");
    else
        printf("DENIED");
    return 0;
}


Measured memory_bytes: 128
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   abc125_c.cpp                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: nkinoshi <nkinoshi@student.42tokyo.jp      +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/07/31 23:44:44 by nkinoshi          #+#    #+#             */
/*   Updated: 2020/07/31 23:52:49 by nkinoshi         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

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

	vector<int> A(n);
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	
	vector<int> L(n+1);
	vector<int> R(n+1);
	for (int i = 0; i < n; ++i)
		L[i+1] = gcd(L[i], A[i]);
	for (int i = n-1; i >= 0; --i)
		R[i] = gcd(R[i+1], A[i]);
	
	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = max(ans, gcd(L[i], R[i+1]));

	// for (int i = 0; i < n; ++i)
	// 	cout << L[i] << ", ";
	// cout << endl;
	// for (int i = 0; i < n; ++i)
	// 	cout << R[i] << ", ";
	// cout << endl;

	cout << ans << endl;
}



Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define ref(i,n) for(int i=1;i<=n;i++)
using namespace std;
#define INF 111111111111
#define mod 998244353
typedef long long ll;
typedef pair<int,int> P;
int n,m;
int v[1000000],w[1000000];
int dp[512][100001];
int dfs(int i,int k){
    if(i<=511) return dp[i][k];
    else if(w[i]<=k) return max(dfs(i/2,k),dfs(i/2,k-w[i])+v[i]);
    else return dfs(i/2,k);
}
int main()
{

        cin>>n;
        ref(i,n){
            scanf("%d %d",&v[i],&w[i]);
        }

        ref(i,511)ref(j,100000){
            if(j<w[i]) dp[i][j]=dp[i/2][j];
            else dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i]]+v[i]);
        }
        int q;
        cin>>q;
        ref(i,q) {
            int p,l;
            scanf("%d %d",&p,&l);
            printf("%d\n",dfs(p,l));
        }


    return 0;
        }




Measured memory_bytes: 205392
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

int main(void){
  char a;
  cin>>a;
  cout<<(char)((a - 'a' + 1)%26 +'a')<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define N 8

using namespace std;

void BombsChain(vector<string>&, int, int);
void CheckBombs(vector<string>&, int, int);

int main(){
  int i, j, n, x, y;
  string s;
  vector<string> data;

  cin >> n;

  for(i=0; i<n; ++i){
    for(j=0; j<N; ++j){
      cin >> s;
      data.push_back(s);
    }

    cin >> x >> y;
    BombsChain(data, y-1, x-1);

    cout << "Data " << i+1 << ":" << endl;
    for(j=0; j<data.size(); ++j)
      cout << data[j] << endl;

    data.clear();
  }

  return 0;
}

void BombsChain(vector<string>& data, int i, int j){
  data[i][j] = '0';

  CheckBombs(data, i-3, j);
  CheckBombs(data, i-2, j);
  CheckBombs(data, i-1, j);

  CheckBombs(data, i+3, j);
  CheckBombs(data, i+2, j);
  CheckBombs(data, i+1, j);

  CheckBombs(data, i, j-3);
  CheckBombs(data, i, j-2);
  CheckBombs(data, i, j-1);

  CheckBombs(data, i, j+3);
  CheckBombs(data, i, j+2);
  CheckBombs(data, i, j+1);
}

void CheckBombs(vector<string>& data, int i, int j){
  if(i > -1 && i < N && j > -1 && j < N && data[i][j] == '1')
    BombsChain(data, i, j);
}

Measured memory_bytes: 0
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
  int n;
  cin >>n;
  int m=n;
  int ans=0;
  while(n>=10){
    
    
    ans=ans+n%10;
    n=n/10;
    
  }
  ans=ans+n;
  if(m%ans==0){
    cout <<"Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	
	int i, sum = 0, digit;
	for (i = 1, digit = 0; i <= N; i++) {
		if (i % 10 != 0) digit++;
		else if (i % 100 != 0) digit -= 8;
		else if (i % 1000 != 0) digit -= 17;
		else if (i % 10000 != 0) digit -= 26;
		else digit -= 35;
		
		if (digit >= A && digit <= B) sum += i;
	}
	
	printf("%d\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>

#define black '#'
#define yes "Yes"
#define no "No"

using namespace std;

bool solver(int height,int width,vector<string> campus){
    bool result;
    result = true;
    // 上→右→下→左
    vector<int> hd={1,0,-1,0};
    vector<int> wd={0,1,0,-1};
    for(int j=0;j<height;j++){
        for(int k=0;k<width;k++){
            char nowPosValue;
            nowPosValue = campus.at(j).at(k);
            if(nowPosValue == black){
                int nextblack;
                nextblack = 0;
                for(int m=0;m<4;m++){
                    int checkPosH,checkPosW;
                    checkPosH = j+hd.at(m);
                    checkPosW = k+wd.at(m);
                    if(checkPosH<0 || checkPosW<0 || height<=checkPosH || width<=checkPosW){
                        continue;
                    }
                    char checkPosValue;
                    checkPosValue = campus.at(checkPosH).at(checkPosW);
                    if(checkPosValue == black){
                        nextblack = nextblack + 1;
                    }
                }
                if(nextblack == 0){
                    result = false;
                }
            }
        }
    }
    return result;
}

int main(void){
    bool answer;
    int H,W;
    cin >> H >> W;
    vector<string> S;
    S.clear();
    for(int j=0;j<H;j++){
        string s1;
        cin >> s1;
        S.push_back(s1);
    }
    answer = solver(H,W,S);
    if(answer){
        cout << yes << endl;
    }
    else{
        cout << no << endl;
    }
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

char grid[12][1024];
int ps[12][1024];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; i++) scanf("%s", grid[i]);

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			ps[i][j] = ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1];
			if (grid[i-1][j-1] == '1') ps[i][j]++;
		}
	}

	int ans = 1000000;
	for (int mask = 0; mask < (1 << (h-1)); mask++) {
		vii itv;
		int prv = 1;
		for (int i = 1; i < h; i++) {
			if (mask & (1<<(i-1))) {
				itv.emplace_back(prv, i);
				prv = i + 1;
			}
		}
		itv.emplace_back(prv, h);

		prv = 1;
		int c = 0;
		for (int i = 1; i <= w; i++) {
			int block = 0;
			for (auto p : itv) {
				int r1 = p.first, r2 = p.second;
				int c1 = prv, c2 = i;
				int cur = ps[r2][c2] + ps[r1-1][c1-1] - ps[r1-1][c2] - ps[r2][c1-1];
				block = max(block, cur);
			}
			if (block <= k) continue;
			if (i == prv) {
				c = 1000000;
				break;
			}
			c++;
			prv = i;
		}
		ans = min(ans, c + __builtin_popcount(mask));
	}
	printf("%d\n", ans);
}


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


bool is_integer( double x ){
  return floor(x) == x;
}

int main() {
  int N, D;
  cin >> N >> D;
  int X[N][D];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  
  int cnt = 0;
  float ans;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans = 0;
      for (int d = 0; d < D; d++) {
        ans += pow(abs(X[i][d] - X[j][d]), 2);
      }
      ans = sqrt(ans);

      if (is_integer(ans)) cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
		String b = sc.next();
	  if (a < 3200 && 2800 <= a){
	    System.out.println("red");
	  } else if (a < 5000 && 3200 <= a){
	    System.out.println(b);
	  }
	}
}


Measured memory_bytes: 21716
#if 0
2019.08.18

搞两排排列 a[i] = i 的排列，上下如果相差恰好为 k 则连 A 边，反之 B 边，连成一个完全二分图。
那么答案就是求在该二分图上选 B 边的最大匹配的方案数。
但是 B 边很多难以统计，如果能够转换为统计具有特殊性质的 A 边，问题就可能简化。
考虑容斥，设 g[i] 表示二分图上选最大匹配，其中至少 i 条 A 边的方案数。
那么只要能求出恰好 i 条 A 匹配的方案数，剩下的可以随便选，方案为 (n - i)! 。
A 边构成的子图是由若干条链组成的，把链拉出来排成一排，DP 统计。
设 f[i][j] 表示前 i 条边选 j 条匹配的方案数即可转移。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 2020, mod = 924844033;

bool real[maxn << 1];
int f[maxn << 1][maxn];
lolong fac[maxn];

int main() {
	int n = input(), k = input();

	int p = 0;
	for(int i = 1; i <= k; i ++)
		for(int t = 0; t < 2; t ++)
			for(int j = i; j <= n; j += k)
				real[++ p] = j > i;

	/* for(int i = 1; i <= n * 2; i ++) */
	/* 	debug(" %d", real[i]); */
	/* debug("\n"); */

	f[0][0] = 1;
	for(int i = 1; i <= p; i ++) {
		for(int j = 0; j <= n; j ++)
			f[i][j] = f[i - 1][j];
		if(real[i])
			for(int j = 1; j <= n; j ++)
				(f[i][j] += f[i - 2][j - 1]) %= mod;
	}

	/* for(int i = 0; i <= n; i ++) */
	/* 	debug(" %d", f[n << 1][i]); */
	/* debug("\n"); */

	fac[0] = 1;
	for(int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;

	lolong ans = 0;
	for(int i = 0; i <= n; i ++)
		ans += fac[n - i] * f[n << 1][i] % mod * ((i & 1) ? -1 : 1);
	((ans %= mod) += mod) %= mod;

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


Measured memory_bytes: 31744
A,B,C = map(int,input().split())
K = int(input())
cnt = 0
for i in range(K):
    if B > A:
        break
    B *= 2
    cnt += 1
for j in range(K-cnt):
    C *= 2
if A < B and C > B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	double L;
	cin >> L;

	cout << setprecision(10);
	cout << (L/3)*(L/3)*(L/3) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int32_t x;
  std::cin >> x;

  if (x <= 599) {
    std::cout << 8 << std::endl;
  } else if (x <= 799) {
    std::cout << 7 << std::endl;
  } else if (x <= 999) {
    std::cout << 6 << std::endl;
  } else if (x <= 1199) {
    std::cout << 5 << std::endl;
  } else if (x <= 1399) {
    std::cout << 4 << std::endl;
  } else if (x <= 1599) {
    std::cout << 3 << std::endl;
  } else if (x <= 1799) {
    std::cout << 2 << std::endl;
  } else {
    std::cout << 1 << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3192
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys

def _i(): return int(sys.stdin.readline().strip())


def main():
    x = _i()
    cur = 100
    cnt = 0
    while True:
        cur = int(cur*1.01)
        cnt += 1
        if x <= cur:
            return cnt

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 63352
#include <bits/stdc++.h>  
using namespace std;
const int nax=3005;
const long long MOD=(long long)(1e9+7);
int dp[nax][nax];

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    dp[1][1]=1;
    for(int i=2;i<=n;i++)
    { 
    vector<int> prefix_sums(n,0);
    
        for(int now =1;now<i;now++)
        prefix_sums[now]=(prefix_sums[now-1]+dp[i-1][now])%MOD;
        for (int now=1;now<=i;now++)
        {
           
           
            int L,R;
                if(s[i-2]=='>')
                {
                 L=now;R=i-1;
                }
                else
                {
                    L=1;R=now-1;
                }
                if(L<=R)
                dp[i][now]=(dp[i][now]+prefix_sums[R]-prefix_sums[L-1]+MOD)%MOD; 
        }
    }
    
    int ans=0;
 for(int i=0;i<=n;i++)
    ans=(ans+dp[n][i])%MOD;
    cout<<ans;
    return 0;
}






Measured memory_bytes: 34176
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n;
int a[maxn],b[maxn];
long long kq;

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n+1;i++) scanf("%d",&a[i]);
  for(int i=1;i<=n;i++) scanf("%d",&b[i]);
  kq=0;
  for(int i=1;i<=n;i++){
    int z=min(a[i],b[i]);
    kq=kq+z;a[i]=a[i]-z;b[i]=b[i]-z;
    z=min(a[i+1],b[i]);
    kq=kq+z;a[i+1]=a[i+1]-z;b[i]=b[i]-z;
  }
  cout<<kq<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long  i,n,a,b=1,c=1000000000000000000;
bool f=true,z=true;
int main(){
  for(cin>>n;i<n;++i){
    cin>>a;
    if(a==0)z=false;
    if(a>c)f=false;
    if(f&&z){
      b*=a;
      c=ceil(c/a);
    }
  }
  if(!z)cout<<0;
  else if(f)cout<<b;
  else cout<<-1;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};

vector<P> v[5555];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[5555];
int o[1400][1155][3];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[111111];
double j[111];

stack<int> s;
queue<P> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
string r;
//char r[333][333];


bool as(P a,P b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y>b.y;
}


int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
        scanf("%d %d",&u[t].x,&u[t].y);
    for(int t=1;t<=a;t++)
    {

        double x=0;
        for(int w=1,i=0;w<=a;w++)
            if(t!=w)
        {
            double r,q;
        r=atan2(u[w].y-u[t].y,u[w].x-u[t].x);
        if(r<0) r+=2*M_PI;
        i++;
        j[i]=r;
        }
        sort(j+1,j+1+a-1);
        for(int t=1;t<a-1;t++)
            x=max(x,j[t+1]-j[t]);
        x=max(x,j[1]-j[a-1]+2*M_PI);
        if(x<M_PI) puts("0");
        else printf("%lf\n",(x-M_PI)/(2*M_PI));
        //printf("%lf\n",(y-x)/(M_PI));
    }
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
#define INF (1LL << 60)
using namespace std;
int n, u[2], mode, tar; long long d, x[30], y[30], ret, seg[33554432], val[14348907]; pair<long long, long long> t[2][14348907];
inline void rec(int pos, long long a, long long b) {
	if (pos == tar) {
		if(b <= 0) t[mode][u[mode]++] = make_pair(a, b);
		return;
	}
	rec(pos + 1, a + x[pos], b + y[pos]);
	rec(pos + 1, a - x[pos], b - y[pos]);
	rec(pos + 1, a, b);
}
inline long long query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return seg[k];
	long long lch = query(a, b, k << 1, l, (l + r) >> 1);
	long long rch = query(a, b, (k << 1) + 1, (l + r) >> 1, r);
	return min(lch, rch);
}
int main() {
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &y[i]);
	mode = 0; tar = n / 2; rec(0, 0, 0);
	mode = 1; tar = n; rec(n / 2, 0, 0);
	sort(t[1], t[1] + u[1]);
	for (int i = 0; i < u[1]; i++) val[i] = t[1][i].first;
	for (int i = 0; i < u[1]; i++) seg[i + 16777216] = t[1][i].second;
	for (int i = u[1]; i < 16777216; i++) seg[i + 16777216] = INF;
	for (int i = 16777215; i >= 1; i--) seg[i] = min(seg[2 * i], seg[2 * i + 1]);
	for (int i = 0; i < u[0]; i++) {
		int pl = lower_bound(val, val + u[1], -t[0][i].first - d) - val;
		int pr = upper_bound(val, val + u[1], -t[0][i].first + d) - val;
		long long res = query(pl, pr, 1, 0, 16777216);
		ret = max(ret, -t[0][i].second - res);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 545576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}
vector<int> prime;

signed main(){
  LOOP(i,1,1000000){
    if(Is_Prime(i))prime.PB(i);
  }
  int n;
  while(cin>>n){
    int ans=0;
    REP(i,prime.size()){
      if(prime[i]<=n)ans++;
      else break;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <assert.h>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;
// static const ll 1000000007;

// typedef long long ll;
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

void Main(){
    ll K;
    string S;
    sll(K);
    cin >> S;
    ll N = S.size();

    combination comb = combination(N+K);
    mint comb_n = comb(N+K, N);
    mint ans = 0;
    rep(i, K+1){
        mint now = mint(26).pow(K-i) * mint(25).pow(i) * comb(i+(N-1), N-1);
        ans += now;
    }

    cout << ans <<endl;


}

int main(){
    Main();
}

Measured memory_bytes: 35252
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
deque<int>dp;
int n,m;
int a[200005];
int sum=0;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;i++)cin>>a[i],sum+=a[i];
	sum-=a[1];sum-=a[2];
	for(int i=0;i<=sum;i++)dp.push_back(i);
	for(int i=3;i<n;i++){
		vector<int>add_front;
		for(int j=1;j<=a[i];j++)add_front.push_back(dp[j]);
		for(auto x:add_front){
			dp.push_front(x);
		}
	}
	cin>>m;
	while(m--){
		int x;cin>>x;
		if(x>=sum){
			cout<<x-sum+a[1]-a[2]<<endl;
		}else{
			cout<<dp[x]+a[1]-a[2]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 13180
import math

A, B, H, M = map(int, input().split())
long_ = [0, 0]
short_ = [0, 0]

#その時刻の角度を求める
rad_a = 90 - ( 360 * H/12 + 30 * M/60)
rad_b = 90 - ( 360 * M/60)

#print(rad_a, rad_b)

#極座標⇒直行座標に変換
long_[0] = A * math.cos(math.radians(rad_a))
long_[1] = A * math.sin(math.radians(rad_a))
short_[0] = B * math.cos(math.radians(rad_b))
short_[1] = B * math.sin(math.radians(rad_b))

#print(long_)
#print(short_)

ans = math.sqrt((long_[0]-short_[0])**2 + (long_[1]-short_[1])**2)
print(ans)


Measured memory_bytes: 79924
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
ans = [None]*N
for i in range(K):
    if T[i] == 'r':
        ans[i] = 'p'
    elif T[i] == 's':
        ans[i] = 'r'
    else:
        ans[i] = 's'
for i in range(K, N):
    if T[i] == 'r':
        if ans[i-K] == 'p':
            ans[i] = 'd'
        else:
            ans[i] = 'p'
    elif T[i] == 's':
        if ans[i-K] == 'r':
            ans[i] = 'd'
        else:
            ans[i] = 'r'
    else:
        if ans[i-K] == 's':
            ans[i] = 'd'
        else:
            ans[i] = 's'
r = R * ans.count('r')
s = S * ans.count('s')
p = P * ans.count('p')
print(r+s+p)


Measured memory_bytes: 4084
import java.util.*;
 
class Main {

    public static void main(String[] args) {
      
      
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
      	int P = Integer.parseInt(sc.next());
		int hen = 0;
      
      	hen = P+(A*3);
        System.out.print(hen/2);
        
      

		
    }
}

Measured memory_bytes: 23892
n = int(input())
t=[]
x=[]
y=[]
for i in range(n):
  p,q,r = map(int,input().split())
  t.append(p)
  x.append(q)
  y.append(r)

if (t[0]-x[0]-y[0])%2==1 or t[0]-x[0]-y[0]<0:
  print("No")
  exit()
 
for i in range(n-1):
  k=t[i+1]-t[i]
  dx=abs(x[i+1]-x[i])
  dy=abs(y[i+1]-y[i])
  if (k-(dx+dy))%2==1 or k-(dx+dy)<0:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 11724
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
    void BubbleUp(std::size_t Index)
    {
        assert(FArray.size() > Index);
        if(Index == 1) return;
        int Parent = Index / 2;
        if(FArray[Index] <= FArray[Parent]){
            return;
        }
        std::swap(FArray[Index], FArray[Parent]);
        BubbleUp(Parent);
    }
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        FArray.push_back(Value);
        BubbleUp(FArray.size()-1);
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();

        std::size_t Size = FArray.size();
        std::size_t Index = 1;
        std::size_t Left, Right;
        while(Index < Size){
            Left = Index * 2;
            Right = Left + 1;
            if(Left >= Size) break;
            std::size_t Target = Right >= Size ? Left : FArray[Left] > FArray[Right] ? Left : Right;
            if(FArray[Target] <= FArray[Index]) break;
            std::swap(FArray[Index], FArray[Target]);
            Index = Target;
        }
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

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


int main(){
    int a,b;
    cin >> a>>b;
    if(a*b%2==1) cout << "Odd" <<endl;
    else cout << "Even" <<endl;

   }

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    i64 N;
    read(N);

    i64 ans = 1;
    reps(i, 2, N) {
        i64 a = i;
        reps(k, 1, 10) {
            a *= i;
            if (a <= N) chmax(ans, a);
            else break;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using namespace std;

int main(){
  int n,x;
  map<int,int>m;
  for(;cin>>x;m[x]++);
  vector<pair<int,int> >v;
  for(map<int,int>::iterator it=m.begin();it!=m.end();it++)v.push_back(make_pair((*it).second,(*it).first));
  sort(v.begin(),v.end(),greater<pair<int,int> >());
  vector<int>w;
  for(n=v[0].first,x=0;v[x].first==n;x++)w.push_back(v[x].second);
  sort(w.begin(),w.end());
  for(n=0;n<w.size();n++)cout<<w[n]<<endl;
}

Measured memory_bytes: 0
n = int(input())
al = []
for i in range(n):
    al.append(int(input()))

al.sort()
al.append(10**9+1)
cnt = 1
ans = 0
for j in range(n):
    if al[j] == al[j+1]:
        cnt += 1
    elif cnt%2 == 0:
        cnt = 1
    elif cnt%2 == 1:
        cnt = 1
        ans += 1
print(ans)

Measured memory_bytes: 13288
def dist(p1,p2):
    x1, y1 = p1
    x2, y2 = p2
    return ((x2-x1)**2+(y2-y1)**2)**.5

def combi(m,n):
    a=1
    b=1
    for i in range(n):
        a*=m-i
        b*=(i+1)
    return a//b

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

edge=[]
for i in range(n):
    for j in range(i+1,n):
        edge.append(dist(a[i],a[j]))

c = combi(n,2)
ans = sum(edge)*(combi(c-1,n-2))/(combi(c,n-1))
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(NULL); 

  	int n;
  	string s, t;
  	cin >> n >> s >> t;
  	string res = "";
  	int p = 0, q = 0;
  	for(int i = 0; i < (2*n); i++) {
  		if(i & 1) {
  			res += t[q];
  			q++;
  		}
  		else {
  			res += s[p];
  			p++;
  		}
  	}
  	cout << res << '\n';

  	return 0;
}

Measured memory_bytes: 256
import Control.Monad                                                                                                                                  
import Data.List                                                                                                                                      
                                                                                                                                                      
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  [n,m] <- map read . words <$> getLine                                                                                                               
  abn <- replicateM n $ (\[x,y] -> (x,y)) . map read . words <$> getLine :: IO [(Int,Int)]                                                            
  print . fst . foldl' (sum' m) (0,0) . sort $ abn                                                                                                    
                                                                                                                                                      
sum' :: Integral a => a -> (a,a) -> (a,a) -> (a,a)                                                                                                    
sum' m' (p,q) (x,y)                                                                                                                                   
  | q >= m' = (p,q)                                                                                                                                   
  | (q + y) <= m' = (p + x * y, q + y)                                                                                                                
  | otherwise = (p + x * (m' - q), m') 

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

int main()
{
    string str, target;
    cin >> str >> target;
    
    str += str;
    string::size_type index = str.find(target);
    cout << (index == string::npos ? "No" : "Yes") << endl;
    
    return 0;
}

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

typedef long long ll;

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

    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0;i<n;i++) cin >> s[i] >> t[i];
    string x; cin >> x;
    int ans = 0;
    bool ok = false;
    for(int i=0;i<n;i++){
        if(ok) ans += t[i];
        if(s[i]==x) ok = true;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int ans[100][100];

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			ans[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		int num2;
		cin >> num2;
		for (int j = 0; j < num2; j++) {
			int num1;
			cin >> num1;
			ans[num - 1][num1 - 1] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j > 0) cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
//const int mod = 1e9 + 7;
const int mod = 998244353;
const double eps = 1e-9;

/*{
  }*/

int modpow(int a, int b)
{
  if(b == 0) return 1; 
  return modpow(a*a%mod, b/2)*(b%2?a:1)%mod;
}

signed main(){
  int n;
  cin >> n;

  vi d(n);
  vi cnt(n+1);
  int maxd = 0;
  rep(i, 0, n){
    cin >> d[i];
    cnt[d[i]]++;
    chmax(maxd, d[i]);
    if(i and d[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 1;
  int tmp = 1;
  rep(i, 1, n+1){
    (ans *= modpow(cnt[i-1], cnt[i])) %= mod;
  }

  cout << ans << endl;

  return 0;
}



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

int main(void) {
  int W, H, N, a, x, y,ans = 0, xs = 0, xg, ys = 0, yg;

  cin>>W>>H>>N;
  xg = W; yg = H;
  for(int i = 0; i < N; ++i) {
    cin >> x >> y >> a;
    if(a == 1) {
      if(x - xs < 0) continue;
      if(x > xg) x = xg;
      ans+=(x - xs)*(yg - ys);
      xs = x;
    } else if(a == 2) {
      if(xg - x < 0) continue;
      if(x < xs) x = xs;
      ans+=(xg - x)*(yg - ys);
      xg = x;
    } else if(a == 3) {
      if(y - ys < 0) continue;
      if(y > yg) y = yg;
      ans+=(xg - xs) * (y - ys);
      ys = y;
    } else if(a == 4) {
      if(yg - y < 0) continue;
      if(y < ys) y = ys;
      ans+=(xg - xs)*(yg - y);
      yg = y;
    }
  }

  cout << W*H - ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i ++) {
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" " + i);
            } else {
                while (x != 0) {
                    if (x % 10 == 3) {
                        System.out.print(" " + i);
                        break;
                    }
                    x = x / 10;
                }
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 29168