akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int n;
  ci(n);
  co(n * n * n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, a[N], b[N], c[N], dp[3][N];

void solve()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i] >> b[i] >> c[i];
    dp[0][1]=a[1], dp[1][1]=b[1], dp[2][1]=c[1];

    for (int i=2; i<=n; i++) {
        dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + a[i];
        dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + b[i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + c[i];
    }
    nout(max_3(dp[0][n],dp[1][n],dp[2][n]));

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5948
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	vector<long long> a(n), b(n);

	long long sum=0, asum=0, bsum=0, count=0;

	rep(i, n) cin>>a[i];
	rep(i, n) cin>>b[i];

	rep(i, n){
		if(a[i]-b[i]>0){
			bsum+=a[i]-b[i];
		}else if(a[i]-b[i]<0){
			asum+=(b[i]-a[i])/2+(b[i]-a[i])%2;
		}
		sum+=b[i]-a[i];
	}
	//cout<<asum<<" "<<bsum<<" "<<count<<endl;
	cout<<yn(sum>=asum&&sum>=bsum)<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{


    int a, b, c, k;
    
    cin >> a >> b >> c >> k;
    
    if(a > k)
    {
        cout << k;
    }
    else if(a + b > k)
    {
        cout << a;
    }
    else
    {
        cout << a - (k - a - b);
    }
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while True:
    for a in A:
        if a % 2 != 0:
            flag = False
    if flag:
        A = list(map(lambda x: x//2, A))
        count += 1
    else:
        break
print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int N,A;
  cin >> N >> A;
  N%=500;
  if(N<=A)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])throws Exception
  {
    Scanner Sc=new Scanner(System.in);
    long a=Sc.nextLong();
    long b=Sc.nextLong();
    long c=findXOR(b);
    long d=findXOR(a-1);
    long e=c^d;
    System.out.println(e);
  }
  static long findXOR(long n)
  {
    if(n%4==0)
      return n;
    else if(n%4==1)
      return 1;
    else if(n%4==2)
      return n+1;
    return 0;
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
	while(1){
	int n ; cin >> n ; if(n==-1) break;
	double x,y,lenA,lenB;	double ca,sa;
	double* Sn=new double[n+1]; double* Cn=new double[n+1] ;
	for(int i=2;i<=n;i++){
	lenA=sqrt((double)i); lenB=sqrt((double)i-1);
	Sn[i]=1/lenA ; Cn[i]=lenB/lenA ;
	};
	ca=1/sqrt((double)2) ; sa=1/sqrt((double)2);
	for(int i=3;i<=n;i++){
	double temp=Cn[i]*ca-Sn[i]*sa;
	sa=Sn[i]*ca+Cn[i]*sa;
	ca=temp;
	};
	if(n==1) x=1,y=0;
	else if(n==2) x=1,y=1;
	else x=sqrt((double)n)*ca, y=sqrt((double)n)*sa ;
	cout << fixed << setprecision(2);
	cout << x << '\n' << y << '\n' ;
	};
}

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

#define        read         freopen("in.txt", "r", stdin);
#define        ll           long long

using namespace std;

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

	ll n, m, c, cc[100005], num, ans=0, total=0;
	vector <ll> v[100005];

	cin >> n >> m >> c;

	for(int i = 0; i < m; i++) cin >> cc[i];

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> num;
			v[i].push_back(num);
		}
	}

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			total += (v[i][j]*cc[j]);
		}

		total += c;

		if(total>0) ans++;

		total = 0;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<regex>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
string S;

bool dfs(string n)
{
	n=regex_replace(n,regex("dream"),"1");
	n=regex_replace(n,regex("erase"),"2");
	n=regex_replace(n,regex("1er"),"");
	n=regex_replace(n,regex("2r"),"");
	n=regex_replace(n,regex("1"),"");
	n=regex_replace(n,regex("2"),"");
	return n.length()==0;
}

int main()
{
	cin>>S;
	if(dfs(S))puts("YES");
	else puts("NO");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 5005;
const long long mod = 1000000007ll;

int n, p[N], fa[N], sz[N];
bool tag[N];
long long inv[N], f[N], g[N], fac[N];

int findroot (int u) {
	return fa[u] == u ? u : fa[u] = findroot(fa[u]);
}
void merge (int u, int v) {
	u = findroot(u), v = findroot(v);
	if (u != v) fa[u] = v, sz[v] += sz[u];
}

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
	for (int i = 1; i <= n; i++) fa[i] = i, sz[i] = 1;
	for (int i = 1; i <= n; i++) {
		if (p[i] > 0) merge(i, p[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (fa[i] == i) tag[i] = false;
	}
	for (int i = 1; i <= n; i++) {
		if (p[i] < 0) tag[findroot(i)] = true;
	}

	long long exp = 0ll, ans;

	inv[1] = 1ll;
	for (int i = 2; i <= n; i++) inv[i] = (mod / i) * (mod - inv[mod % i]) % mod;
	fac[0] = 1ll;
	for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
	for (int i = 0; i <= n; i++) f[i] = 0ll;
	f[0] = 1ll;
	
	for (int i = 1; i <= n; i++) {
		if (fa[i] == i) {
			if (tag[i]) {
				for (int j = 0; j <= n; j++) g[j] = f[j];
				for (int j = 1; j <= n; j++) g[j] = (g[j] + f[j - 1] * inv[n - 1] % mod * sz[i]) % mod;
				for (int j = 0; j <= n; j++) f[j] = g[j];
				exp = (exp + inv[n - 1] * (sz[i] - 1)) % mod;
			}
			else exp = (exp + 1ll) % mod;
		}
	}
	for (int i = 2; i <= n; i++) exp = (exp + fac[i - 1] * f[i]) % mod;

	ans = (mod + n - exp) % mod;
	for (int i = 1; i <= n; i++) {
		if (p[i] < 0) ans = ans * (n - 1) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4064
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;
 
/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;
 
/*** define ***/
#define sz(x)           ((int)x.size())
#define tin(x)          scanf("%d",&x)
#define all(x)          x.begin(),x.end()
#define Set(b,a)        memset(b,a,sizeof b)
#define print1(x)       printf("Case %d:",x++)
#define tin2(x,y)       scanf("%d%d",&x,&y)
#define tin3(x,y,z)     scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)   for(int i=i0 ; i<in ; i++)
#define rep(i,n)        for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)       for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)  for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)     for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
      
int main()  
{  
#ifdef Online_Judge
    freopen("a.in","r",stdin);
#endif
    int k=1,n;
    while(cin>>n && n)
        printf("Case %d: %d\n",k++,n);
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> su(m,0);

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int ak;
            cin >> ak;
            su[ak-1]++;
        }
    }

    int ans = 0;

    for (int i = 0; i < m; i++) {
        if (su[i] == n)ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N,H;
    cin >> N >> H;
    vector<pair<int,int>> d;
    for(int i = 0; i < N; i++){
        int a,b;
        cin >> a >> b;
        d.emplace_back(make_pair(a,1));
        d.emplace_back(make_pair(b,0));
    }
    sort(d.begin(),d.end(),greater<>());
    int index = 0;
    int count = 0;
    while(H > 0){
        int damage = d[index].first;
        int check = d[index].second;
        if(check == 0){
            H -= damage;
            count++;
            index++;
        }
        else break; 
    }
    if(H > 0) count += (H-1) / d[index].first + 1;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N  = sc.nextInt();
		sc.close();
		long[][] A = new long[N+1][N+1];


		for(int i = 2 ; i <= N ; i++){
			int p = i;
			for(int j = 2 ; j <= i ; j++){
				while(p%j == 0){
					p = p/j;
					A[i][j]++;
				}
			}
		}

/*
		for(int i = 1 ; i <= N ; i++){
			for(int j = 1 ; j <= N ; j++){
				System.out.print(A[i][j] + " ");
			}
			System.out.println("");
		}
*/
		long ans = 1;
		long inf = 1000000007;
		for(int i = 1 ; i <= N ; i++){
			long pp = 0;
			for(int j = 1 ; j <= N ; j++){
				pp+=A[j][i];
			}
			//System.out.println(pp);
			ans =(ans * (pp+1))%inf;
		}

		long ans2 = ans%inf;
		System.out.println(ans2);
	}
}


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

string s, now;
int cnt = 0;

int main() {
  cin >> s;
  now = 'A';
  now += s;
  for(int i = 1; i < now.size(); ++i) {
    if(now[i] == now[i - 1]) cnt += 26;
    cnt += (now[i] - now[i - 1] + 26) % 26;
  }
  cout << cnt / 26 << endl;
  return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

bool isPrime[100010];
void set_prime()
{
	for (int i = 1; i <= 100000; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = false; isPrime[1] = false;
	for (int i = 2; i * i <= 100000; i++) {
		int j = 2;
		while (i * j <= 100000) {
			isPrime[i * j] = false;
			j++;
		}
	}
}
int main()
{
	int N; cin >> N;
	int j = 1;
	set_prime();
	for (int i = 0; i < N; i++) {
		while (j <= 55555) {
			if (isPrime[j] && j % 5 == 1) {
				cout << j << " ";
				break;
			}
			j++;
		}
		j++;
	}
}


Measured memory_bytes: 384
#include <stdio.h> 
 #include <string.h> 
 
 
 int main(){ 
     int m, h; 
     char cards[256], temp[256], result[256]; 
     int i, j=0, len; 
 
 
     while(1){ 
         scanf("%s", cards); 
         len=strlen(cards); 
        if(strcmp(cards, "-")==0&&len==1)break; 
         scanf("%d", &m); 
         for(;m>0;m--){ 
             scanf("%d", &h); 
            strcpy(temp, cards); 
             for(i=0;i<h;i++){ 
                 cards[len-h+i]=temp[i]; 
             } 
             for(i=0;i<len-h;i++){ 
                 cards[i]=temp[i+h]; 
             } 
         } 
         for(i=0;i<len;i++){ 
             result[j++]=cards[i]; 
         } 
         result[j++]='\n'; 
     } 
     result[j]='\0'; 
     printf("%s", result); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2064
n,m,r=map(int,input().split())
r_list=list(map(int,input().split()))
dp=[]
INF=10**9
for i in range(n):
    sub_list=[INF]*n
    dp.append(sub_list)
for i in range(n):
    dp[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    dp[a-1][b-1]=c
    dp[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
R=[i for i in range(r)]
import itertools
Rp=itertools.permutations(R,r)
ans=INF
count=0
for i in Rp:
    temp=0
    for j in range(r-1):
        temp+=dp[r_list[i[j]]-1][r_list[i[j+1]]-1]
    ans=min(ans,temp)
print(ans)



Measured memory_bytes: 48856
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;

string S;
int cnt[2020];
int dp[200001];
int main(){
	cin>>S;
	reverse(S.begin(),S.end());
	cnt[0]=1;
	int ans=0;
	int a=S[0]-'0';
	cnt[a]++;
	dp[0]=a;
	int now=10;
	REP(i,S.size()){
		if(i==0)continue;
		int a=S[i]-'0';
		int aa=a*now+dp[i-1];
		aa%=2019;
		dp[i]=aa;
		//cout<<aa<<endl;
		ans+=cnt[aa];
		cnt[aa]++;
		now*=10;
		now%=2019;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4500
def f(n):
    ans = 0
    if ((n%2)== 0) & ((n%4)==0):
        ans = n
    elif ((n%2)==0) & ((n%4)!=0):
        ans = 1+n
    elif ((n%2)!=0) & ((n%4)==1):
        ans = 1
    elif ((n%2)!=0) & ((n%4)==3):
        ans = 0
    return ans



A,B = map(int,input().split())
final_ans = 0

if A<0:
    print('a')
    print(f(B))
else:
    final_ans = f(A-1) ^ f(B)
    print(final_ans)


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
char buf[20000];sz;
inline int rd()
{
	int ret=buf[sz++]-'0';
	if(buf[sz]>='0')
	{
		ret=ret*10+buf[sz++]-'0';
		if(buf[sz]>='0')
		{
			ret=ret*10+buf[sz++]-'0';
			if(buf[sz]>='0')
			{
				ret=ret*10+buf[sz++]-'0';
				if(buf[sz]>='0')
				{
					ret=ret*10+buf[sz++]-'0';
				}
			}
		}
	}
	sz++;
	return ret;
}
int d[3001],d2[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=1;i<=N;i++)
	{
		d[S]=i;
		int A=rd();
		for(int j=0;j<=S-A;j++)d2[j]=d[j+A];
		for(int j=0;j<=S-A;j++)
		{
			d[j]+=d2[j];
			d[j]-=mod*(d[j]>=mod);
		}
		ans+=d[0];
		ans-=mod*(ans>=mod);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long x;
  cin >> x;
  string ss = "";
  if (x<=26){
  	ss = (x-1)+'a';
  }
  else{
  	while (x>=1){
  		char ch = (x-1)%26+'a';
  		if (ch==0){
  			 ch='z';
  		}
  		if (x%26==0) x--;
  		x /= 26;
  		ss = ch + ss;
  	}
  }
  cout << ss << endl;
}

Measured memory_bytes: 3612
#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<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,m,q;
vi a;

int main(){
	cin>>m>>n>>q;
	a=vi(q);
	for(int i=0;i<q;i++){
		cin>>a[i];
		a[i]--;
	}
	reverse(a.begin(),a.end());
	vi b(n,-1),c(n+1),b_(n);
	int id=0,M=0,B=1;
	c[0]=m;
	for(int i=0;i<q;i++) if(b[a[i]]==-1){
		b[a[i]]=id;
		b_[id++]=a[i];
	}
	for(int i=0;i<n;i++) if(b[i]==-1){
		b[i]=id;
		b_[id++]=i;
	}
	for(int i=0;i<q;i++){
		int I=b[a[i]];
		if(M<I) B=0;
		if(c[I]){
			c[I]--;
			c[I+1]++;
			M=max(M,I+1);
		}
	}
	int s=c[n]+c[n-1];
	for(int i=n-2;i>=0&&b_[i]<b_[i+1];i--) s+=c[i];
	cout<<(s==m&&B?"Yes":"No")<<endl;
}

Measured memory_bytes: 1920
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	if(n%10==n/100) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
a = input()
b = a.split()

if b[0]=="5" and b[1]=="5" and b[2]=="7":
  print("YES")
elif b[0]=="5" and b[1]=="7" and b[2]=="5":
  print("YES")
elif b[0]=="7" and b[1]=="5" and b[2]=="5":
  print("YES")
else:
  print("NO")

Measured memory_bytes: 8956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


using namespace std;
class B {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    long long int n, max_v, max_n, res, tmp;
    long long int sum = 0;
    res = 0;
//    multiset<int> s;
    in >> n;
//    vector<int> a(n);
    map<long long int, long long int> m;
    auto mit = m.begin();
    for(int i = 0; i < n; ++i){
      in >> tmp;
      sum += tmp;
      mit = m.find(tmp);
      if(mit != m.end()){
        m[tmp]++;
      }else{
        m.insert({tmp, 1});
      }
    }
    long long int lower_sum = sum;
    auto mit2 = m.rbegin();
    long long int last = mit2->first;
    res += mit2->second;
    lower_sum -= mit2->first * mit2->second;
    ++mit2;
    while(2 * lower_sum >= last && mit2 != m.rend()){
      res += mit2->second;
      lower_sum -= mit2->first * mit2->second;
      last = mit2->first;
      ++mit2;
    }
    out << res << endl;

	}
};


int main() {
	B solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  long a,b; cin >> a >> b;
  long ans = gcd(a,b);
  for(int i = 2; i < n; i++){
    long c; cin >> c;
    ans = gcd(ans,c);
  }
  cout << ans;
}

Measured memory_bytes: 3648
#include <cstdio>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}P;
P Q[LEN+1];
int head,tail,n;
void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN){
    tail=0;
  }
  else tail++;
}
P dequeue(){
  P x;
  x=Q[head];
  if(head+1==LEN)head=0;
  else head++;
  return x;
}
int main(){
  P u;
  int i,n,q,time=0;
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
  scanf("%s", u.name);
  scanf("%d", &u.t);
  enqueue(u);
  }  
  while(head!=tail){
    u=dequeue();
    if(u.t>q){
      u.t=u.t-q;
      enqueue(u);
      time+=q;
    }
    else{
      printf("%s %d\n",u.name, u.t+time);
      time+=u.t;
    }
  }
  return 0;
}

Measured memory_bytes: 12860
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	int ans = 0;
	rep(i, N) {
		int h;
		cin >> h;
		if (h >= K)ans++;
	}
	cout << ans;
	
}



Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	static char flag[] = new char[]{'m', 'c', 'x', 'i'};
	static int num[] = new int[]{1000, 100, 10, 1};
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		
		int n = Integer.valueOf(reader.readLine());
		for(int i = 0; i < n; i++){
			System.out.println((app.change(app.sum(reader.readLine()))));
		}
		reader.close();
	}
	public int sum(String str){
		String s[] = str.split(" ");
		int res = 0, hoge = 1;
		char c;
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < s[i].length(); j++){
				c = s[i].charAt(j);
				if('2' <= c && c <= '9'){
					hoge = c - '0';
					continue;
				}else{
					res += hoge * set(c);
				}
				hoge = 1;
			}
		}
		return res;
	}
	public String change(int n){
		String res = "";
		int hoge = 0;
		for(int i = 0; i < 4; i++){
			while(n >= num[i]){
				n -= num[i];
				hoge++;
			}
			if(hoge == 1){
				res += flag[i];
			}else if(hoge != 0){
				res += String.valueOf(hoge) + flag[i];
			}
			hoge = 0;
		}
		return res;
	}
	public int set(char c){
		switch(c){
		case 'm' : return 1000;
		case 'c' : return 100;
		case 'x' : return 10;
		case 'i' : return 1;
		}
		return 0;
	}
}

Measured memory_bytes: 29844
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  chmin(a, b);
  chmin(c, d);
  print(a + c);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;

int rest[501];

int main(void){
	scanf("%d%d",&n,&m);
	int res=0;
	for(int i=0;i<n;i++){
		printf("lst %d\n",i);
		fflush(stdout);
		scanf("%d",&rest[i]);
		if(rest[i]==0)continue;
		res+=rest[i]*(rest[i]-1);
		for(int j=0;j<rest[i];j++){
			int a;
			scanf("%d",&a);
		}
	}
	printf("ans %d\n",res);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(n);
    ll ans=0,d;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            d=(n/i)-1;
            if(d!=0&&n/d==n%d){
                ans+=d;
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 3788
#include <cstdio>
#include <algorithm>
using namespace std;
int read () {
	int k=0;
	char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') {k=k*10+c-'0';c=getchar();}
	return k;
}
int main () {
	int x,y,z,i=0,s=0;
	x=read();y=read();z=read();
	for (;s+z<=x;s=s+z+y,i++);
	printf ("%d",i-1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 200001
#define M 21
vector<int> ex[N], ey[N];
void init(int n, vector<int>* e) {
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d%d", &u, &v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
}
int fx[N], fy[N][M], dx[N], dy[N];
void dfsy(int u) {
    for (auto v : ey[u]) {
        if (v == fy[u][0]) continue;
        fy[v][0] = u, dy[v] = dy[u] + 1;
        for (int i = 1; i < M; i++) fy[v][i] = fy[fy[v][i - 1]][i - 1];
        dfsy(v);
    }
}
int lca(int u, int v) {
    if (dy[u] < dy[v]) swap(u, v);
    for (int i = M - 1; ~i; i--)
        if (dy[fy[u][i]] >= dy[v]) u = fy[u][i];
    if (u == v) return u;
    for (int i = M - 1; ~i; i--)
        if (fy[u][i] != fy[v][i]) u = fy[u][i], v = fy[v][i];
    return fy[u][0];
}
int ans;
void dfsx(int u) {
    if (dx[u] >= dy[u]) return;
    if (~ans) ans = max(ans, dy[u] << 1);
    for (auto v : ex[u]) {
        if (v == fx[u]) continue;
        fx[v] = u, dx[v] = dx[u] + 1;
        if (dy[v] + dy[u] - 2 * dy[lca(u, v)] > 2) ans = -1;
        dfsx(v);
    }
}
int main() {
    int n, addx, addy;
    scanf("%d%d%d", &n, &addx, &addy);
    init(n, ex);
    init(n, ey);
    dfsy(addy);
    dfsx(addx);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 49532
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n, h, w;cin>>n>>h>>w;
	int ans=0;
	for(int i=0;i<n;i++){
		int a, b;cin>>a>>b;
		ans+=(a>=h&&b>=w);
	}
	cout << ans << endl;
}

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

using namespace std;

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

    vector<int> v(N);
    vector<int> P(N), Q(N);
    int count = 0;
    int a, b;

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

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

    for(int i = 1; i <= N; i++) {
        v[i-1] = i;
    }

    do {
        count++;
        if(P == v) {
            a = count;
        }
        if(Q == v) {
            b = count;
        }
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;    
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


struct Coord {
    Int x;
    Int y;
};

double CalcDist(Coord first, Coord second) {
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId) {
    Int size = (Int)coordId.size();
    double ret = 0;
    for (Int i = 0; i < size - 1; ++i) {
        ret += CalcDist(coords[coordId[i]], coords[coordId[i + 1]]);
    }
    return ret;
}
Int Factorial(Int n) {
    if (n == 1) {
        return 1;
    } else {
        return n * Factorial(n - 1);
    }
}


// ここの処理が問題によって変わる
void Func(vector<Coord>& coords, vector<Int>& v) {
    Int n = (Int)v.size();
    double sum = 0;
    do {
        sum += CalcDistSum(coords, v);
    } while (std::next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
    return;
}

template <typename RetType, typename LoopFunc>
RetType PermutationLoop(Int n, LoopFunc loopFunc);

int main(void) {
    // 入出力処理
    Int n;
    cin >> n;
    vector<Coord> coords(n);
    for (Int i = 0; i < n; ++i) {
        cin >> coords[i].x >> coords[i].y;
    }

    // permutationループの処理(キャプチャリストは問題によって変わる)
    // PermutationLoop<Func関数の戻り値型>[キャプチャリスト](引数)->戻り値の型
    PermutationLoop<void>(n, [&coords]
            (vector<Int>& v) -> auto {
            return Func(coords, v); 
            }
            );
    return 0;
}

template <typename RetType, typename LoopFunc>
RetType PermutationLoop(Int n, LoopFunc loopFunc) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }
    return loopFunc(v);
}



Measured memory_bytes: 3816
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    i = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
    
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i)
            break


    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int N,M,X,Y;
		scanf("%d %d %d %d",&N,&M,&X,&Y);
	int a;
	for(int i=0;i<N;i++){
		scanf("%d",&a);
		if(X<a)
			X=a;
	}
	for(int i=0;i<M;i++){
		scanf("%d",&a);
		if(Y>a)
			Y=a;
	}
	if(X<Y)
		puts("No War");
	else
			puts("War");
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def divisors(n):
    lower = []
    upper = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)

    lower.extend(reversed(upper))
    return lower


def main():
    N = int(readline())

    ans = 0
    for n in range(1, N + 1, 2):
        d = divisors(n)
        if len(d) == 8:
            ans += 1

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> r(n+1,0);
    for(int i = 0; i < m; i++){
        int a,b;
        cin>>a>>b;
        r[a]++;
        r[b]++;
    }
    for(int i = 1; i < n+1; i++)
        cout<<r[i]<<endl;
}

Measured memory_bytes: 256
X = input().split()

stack = []
for x in X:
    if x == "+":
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif x == "-":
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif x == "*":
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(x))
print(stack[0])



Measured memory_bytes: 5600
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
P = LI()
ans = 0
for i in range(1, n-1):
    if P[i-1]<P[i]<P[i+1] or P[i-1]>P[i]>P[i+1]:
        ans += 1
print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
#define N 100
#define WHITE 0
#define BLACK 2
#define INF 10000001
#define NIL -1

int A[N][N],color[N],t,min,d[N],pi[N];

void prim(int G,int r){
  int i,j,u=0;
  
  for(i=0;i<G;i++){
    d[i]=INF;
    pi[i]=NIL;
  }
  d[r]=0;
  while(1){
    min = INF;
    for(i=0;i<G;i++){
      if(color[i]!=BLACK && d[i]<min){
	min =d[i];
	u=i;
      }
    }
    
    if(min == INF) break;
    
    color[u]=BLACK;
    
    for(i=0;i<G;i++){
      if(color[i] != BLACK && A[u][i]<d[i] && A[u][i]!=-1){
	pi[i]=u;
	d[i] = A[u][i]; 
      }
      
    }
  }
  for(i=0;i<G;i++){
    if(pi[i]!=NIL){
      t+=A[i][pi[i]];
    }
  }
  
  
  
}

int main(){

  int x,i,j;

  scanf("%d",&x);

  for(i=0;i<x;i++){
    for(j=0;j<x;j++){
      scanf("%d",&A[i][j]);
      color[i]   =WHITE;
    }
  }
  prim(x,0);

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

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

vi g[114514];
int dist[114514];
void dfs(int v,int p,int d){
	dist[v]=max(dist[v],d);
	for(auto c:g[v])if(c!=p)
		dfs(c,v,d+1);
}

int main(){
	int n=read();
	REP(i,n-1){
		int u=read()-1,v=read()-1;
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(0,-1,0);
	int x=max_element(dist,dist+n)-dist;
	fill(dist,dist+n,0);
	dfs(x,-1,0);
	int y=max_element(dist,dist+n)-dist;
	dfs(y,-1,0);
	REP(i,n)
		printf("%d\n",(n-1)*2-dist[i]);
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] A = new char[H+2][W+2];
		for(int i = 1; i <= H; i++) {
			String S = sc.next();
			for(int j = 1; j <= W; j++)
				A[i][j] = S.charAt(j-1);
		}
		int ans = 0;
		Queue<Integer> q = new ArrayDeque<>();
		int[][] used = new int[H+2][W+2];
		for(int j = 0; j <= W+1; j++) {
			used[0][j] = 1;
			used[H+1][j] = 1;
		}for(int i = 0; i <= H+1; i++) {
			used[i][0] = 1;
			used[i][W+1] = 1;
		}
		for(int i = 1; i <= H; i++)
			for(int j = 1; j <= W; j++)
				if(A[i][j] == '#') {
					q.offer(i*(W+2)+j);
					used[i][j] = 1;
				}
		while(q.size() > 0) {
			int x = q.poll();
			int i = x / (W+2), j = x % (W+2);
			if(used[i-1][j] == 0) {
				used[i-1][j] = used[i][j]+1;
				q.offer((i-1)*(W+2)+j);
			}
			if(used[i+1][j] == 0) {
				used[i+1][j] = used[i][j]+1;
				q.offer((i+1)*(W+2)+j);
			}
			if(used[i][j-1] == 0) {
				used[i][j-1] = used[i][j]+1;
				q.offer(i*(W+2)+j-1);
			}
			if(used[i][j+1] == 0) {
				used[i][j+1] = used[i][j]+1;
				q.offer(i*(W+2)+j+1);
			}	
			ans = used[i][j] - 1;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 66916
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e3+10;
int N,L[maxn],c1[maxn],c2[maxn];
int t=0,raw[maxn];
ll ans=0;
inline long long read()
{
	long long s=0,f=1; char ch;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+ch-'0';
	return s*f;
}
bool check(int a,int b,int c)
{
	if(L[a]+L[b]>L[c]&&L[b]<L[a]+L[c]&&L[c]<L[a]+L[b]) return 1;
	return 0;
}
int main()
{
	N=read();
	for(int i=1;i<=N;++i) L[i]=read();
	sort(L+1,L+N+1); 
	for(int i=1;i<=N;++i)
	{
		for(int j=i+1;j<=N;++j)
		{
			for(int k=j+1;k<=N;++k)
			{
				if(check(i,j,k)) ++ans;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
 * @file C-Unification.cpp
 * @author murnana
 * @brief C - Unification
 *        https://atcoder.jp/contests/abc120/tasks/abc120_c
 * 
 * @copyright Copyright (c) 2019
 * 
 */

#include <iostream>
#include <string>
#include <math.h>
using namespace std;

/**
 * @brief Entry point
 * 
 * @return int 
 */
int main()
{
    // 長さN与えられない説…
    string S;
    cin >> S;

    // ぷよぷよみたく、隣り合っている色を消すが
    // 消すための最大数は決まっていて、どんなにきれいに消せたとしても
    // N / 2 以上にはならない

    // 0と1が並んでいるときなら消せる、つまり
    // 0と1の数がどちらが一番小さいかによっても決まる

    // なので、0の数と1の数を調べる
    size_t red = 0;
    size_t blue = 0;
    auto length = S.length();
    for (size_t i = 0; i < length; ++i)
    {
        if (S[i] == '0')
        {
            ++red;
        }
        else
        {
            ++blue;
        }
    }

    // 小さい方を答えにする
    cout << (min(red, blue) * 2) << endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
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;
}

template<typename T>
T ceil(T x, T y){
    return (x + (y - 1)) / y;
}

int X, A;
int main(void){
    cin >> X >> A;
    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#ifdef __GNUC__
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#endif

#ifdef MSC_VER
#pragma comment(linker, "/STACK:400000000")
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#endif

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())
#define vc vector

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

int D,N,T[222],A[222],B[222],C[222];
int dp[222][111];

int f(int cur,int pre){
	int& res=dp[cur][pre];
	if(res!=-1)return res;
	if(cur==D)return res=0;
	res=0;
	rep(i,N)if(A[i]<=T[cur] && T[cur]<=B[i]){
		res=max(res,cur==0 ? f(cur+1,C[i]) : abs(pre-C[i])+f(cur+1,C[i]));
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin>>D>>N;
	rep(i,D)cin>>T[i];
	rep(i,N)cin>>A[i]>>B[i]>>C[i];
	memset(dp,-1,sizeof(dp));
	cout<<f(0,0)<<endl;
}

Measured memory_bytes: 1312
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

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

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int H, W;
	int ans = 0;
	vector<string> c;
	vector<pair<int,int>> in;
	
	
	in.resize(4);
	in[0] = make_pair(INF,INF);
	in[1] = make_pair(INF,0);
	in[2] = make_pair(0,INF);
	in[3] = make_pair(0,0);
	
	cin>>H>>W;
	
	c.resize(H);
	
	for(int i  = 0; i < H; i++){
		cin>>c[i];
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(c[i][j] != 'B') continue;
			if(abs(in[0].first) + in[0].second > i + j){
				in[0] = make_pair(i,j);
			}
			if(abs(in[1].first) + abs(in[1].second-W+1) > abs(i) + abs(j-W+1)){
				in[1] = make_pair(i,j);
			}
			
			if(abs(in[2].first -H+1) + abs(in[2].second) > abs(i-H+1) + abs(j)){
				in[2] = make_pair(i,j);
			}
			
			if(abs(in[3].first -H+1) + abs(in[3].second-W+1) > abs(i -H+1) + abs(j-W+1)){
				in[3] = make_pair(i,j);
			}
		}
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = i+1; j < 4; j++){
			ans = max(ans, abs(in[i].first-in[j].first) + abs(in[i].second-in[j].second));
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  double ans = 0;
  for (int i = 0; i < N; ++i) ans += 1.0 / A[i];
  cout << 1.0 / ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int n,x;
	cin >> n >> x;
	vector <int> v(n);
	rep(i,n) cin >> v[i];
	sort(v.begin(), v.end());
	int ans=0;
	rep(i,n){
		if(i==n-1){
			if(x==v[i]){
				ans++;
			}else{
				break;
			}
		}else if(x>=v[i]){
			x-=v[i];
			ans++;
		}else{
			cout << ans << endl;
			return 0;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256