akhauriyash/Code-Regression huggingface dataset:
W,H,N=map(int,input().split())
xya=[list(map(int,input().split()))for _ in range(N)]

wl=0
wr=W
hd=0
hu=H
for x,y,a in xya:
    if a==1:
        wl=max(wl,x)
    elif a==2:
        wr=min(wr,x)
    elif a==3:
        hd=max(hd,y)
    else:
        hu=min(hu,y)

ans=max(wr-wl,0)*max(hu-hd,0)
print(ans)

Measured memory_bytes: 9188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.ReadStrArray(3);
            for(int i = 0; i < 3; i++)
            {
                Write(s[i].ToUpper().ToCharArray()[0]);
            }
            WriteLine("");
        }



        public long C(int X, int Y)
        {

            if (Y == 0 || Y == X)
            {
                return 1;
            }
            if (X < Y)
            {
                return 0;
            }
            var Pascal = new long[X + 1, X + 1];
            for (int i = 0; i <= X; i++)
            {
                Pascal[i, 0] = 1L;
                Pascal[i, i] = 1L;
            }
            for (int i = 2; i <= X; i++)
            {
                for (int j = 1; j < i; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[X, Y];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)
#define REP(i, r) for(int i =(int)0; i < (int)r; ++i)
 
using namespace std;
typedef long long ll;
const int Nmax = 3e3 + 11;
 
int n;
double p[Nmax], f[Nmax][Nmax], ans;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> p[i];
    }
    f[1][1] = p[1];
    f[1][0] = 1.0 - p[1];
    if (n == 1) {
        printf("%0.9f", p[1]);
        return 0;
    }
    FOR(i, 2, n) FOR(j, 0, i) {
        f[i][j] = f[i - 1][j] * (1.0 - p[i]);
        if (j > 0) f[i][j] += f[i - 1][j - 1] * p[i];
        if (i == n && j > n / 2) {
            ans += f[i][j];
        }
    }
    printf("%0.10f", ans);
}

Measured memory_bytes: 69248
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void D(){
	int n ;
	cin >> n ;
	int x , y ; 
	cin >> x >> y ; 
	x-- ; 
	y--;
	vi ans(n);
	rep(i,0,n){
		rep(j,0,i){
			int dis = min(i-j,abs(y-i)+1+abs(x-j));
			ans[dis]++;
		}
	}
	rep(i,1,n) cout << ans[i] << endl;
}




signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) D();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int Prime(int);
int main(){
  int total,i,number,count=0;
  scanf("%d",&total);
  for(i=0;i<total;++i){
    scanf("%d",&number);
    if(Prime(number)){
        ++count;
      }
  }
  printf("%d\n",count);
  return 0;
}
int Prime(int number){
  int i;
  if(number<2){
    return 0;
  }
  for(i=2;i*i<=number;++i){
    if(number%i==0){
      return 0;
    }
  }
  return 1;
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ans = new List<int>();
            for (var i = 10; i <= 55555; i++) {
                if (IsPrime(i) && i % 5 == 1) {
                    ans.Add(i);
                    if (ans.Count == n) break;
                }
            }
            
            Console.WriteLine(string.Join(" ", ans));
        }

        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);

    for(int i=0; i<m ; ++i){
        cin >> l[i] >> r[i];
    }

    int maxl = *max_element(l.begin(),l.end());
    int minr = *min_element(r.begin(),r.end());
    if(minr < maxl){
        cout << 0 << endl;
        return 0;
    }
    cout << minr - maxl + 1 << endl;
    return 0;

}

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

int a[201];
int main()
{
	ios::sync_with_stdio(false);
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	while(1){
		bool f=1;
		for(int i=1;i<=n;i++)
			if(a[i]%2==0) a[i]/=2;
			else{
				f=0;
				break;
			}
		if(f) ans++;
		else break;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

bool is_valid(int h,int w,int y,int x){
    return 0<=y&&y<h&&0<=x&&x<w;
}

void run(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    rep(i,h)cin>>a[i];
    int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
    vvi c(h,vi(w,-1));
    queue<pi> q;
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#'){
                q.push({i,j});
                c[i][j]=0;
            }
        }
    }
    int ans=0;
    while(!q.empty()){
        pi p=q.front();
        q.pop();
        int y=p.fi,x=p.se;
        rep(i,4){
            int ny=y+dy[i],nx=x+dx[i];
            if(is_valid(h,w,ny,nx)&&a[ny][nx]=='.'){
                c[ny][nx]=max(c[ny][nx],c[y][x]+1);
                ans=max(ans,c[ny][nx]);
                a[ny][nx]='#';
                q.push({ny,nx});
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 25524
use std::io;
use std::io::prelude::*;
fn main() {
    let stdin = io::stdin();
    let mut input = String::new();
    stdin.lock().read_line(&mut input).expect("read line!");
    let input: String = input;
    let n: u64 = (&input).trim().parse().unwrap();
    println!("{}", (n * (n - 1)) / 2);
}


Measured memory_bytes: 4352
import fractions

N,X = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
#d = [abs(X-i) for i in x if abs(X-i)!=0]
d = [abs(X-i) for i in x]

gcd = d[0]
i=1
while True:
    if i>=N:
        break
    gcd = fractions.gcd(gcd,d[i])
    i=i+1 

print(gcd)

Measured memory_bytes: 16276
// 2020/08/17 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

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

	// 往路

	int D = 0;					// 現時点の最大距離

	for(int i=0; i<N-1; i++){	// 左端から右端へ
		D = max(D, d[i]);			// 最大距離の更新

		if(D<10){					// 次に跳べないならば
			cout << "no" << endl;
			return 0;
		}

		D -= 10;					// 次に跳んだ
	}

	// 復路

	D = 0;

	for(int i=N-1; i>0; i--){	// 右端から左端へ
		D = max(D, d[i]);

		if(D<10){
			cout << "no" << endl;
			return 0;
		}

		D -= 10;
	}

	cout << "yes" << endl;
	return 0;
}



Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
  } 

Measured memory_bytes: 384
S = list(input())
F = ["A", "C", "G", "T"]
count = 0
max = 0
f = 0
for i in S:
    for j in F:
        if j == i:
            count += 1
    if max < count:

        max = count
    else:
        count = 0
        if max != 0:
            f = max
        max = 0
    
print(max if max > f else f)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int N;
int A[101010];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> A[j];
    }

    LL count = 0;

    count += A[0] - 1;

    int l = 2;

    for (int j = 1; j < N; ++j) {
        if (A[j] == l) {
            ++l;
        } else if (A[j] > l) {
            int inc = (A[j]-1) / l;
            count += inc;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc099/tasks/abc099_c

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N;

ll cc(ll cn, ll r)
{
  if (cn < 6)
    return r + cn;

  ll tcs = 0, tcn = 0, t = 1;
  while (t * 9 <= cn)
  {
    t *= 9;
    tcn++;
  }

  t = 1;
  while (t * 6 <= cn)
  {
    t *= 6;
    tcs++;
  }

  return min(cc(cn - powf(6, tcs), r + 1), cc(cn - powf(9, tcn), r + 1));
}

int main()
{
  cin >> N;

  cout << cc(N, 0) << '\n';

  return 0;
}


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

void solve(int n, vector<int>h, int k){
  vector<ll>dp(n, INF);
  dp[0] = 0;
  for (int i=0; i<n; i++){
    for(int j=i+1; j<=k+i; j++){
      if (j<n){
        dp[j] = min(
          dp[j],
          dp[i] + abs( h[j] - h[i] )
        );
      }
    }
  }
  cout << dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n); rep(i,n) cin>>h[i];
  solve(n,h,k);
}

Measured memory_bytes: 4832
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
int main(){
	int n;
	while(scanf("%d",&n),n){
		char ch[]="01235789";
		string ans = "";
		int cnt=0;
		while(n!=0){
			ans+=ch[n%8];
			n/=8;
		}
		reverse(ans.begin(),ans.end());
		cout << ans << endl;
	}
	return 0;
}

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


int main(){
  
  int N, i;
  cin >> N;
  vector<long long> A(N);
  map<long long, int> Counter;
  for (i = 0; i < N; i++) cin >> A.at(i);
  
  for (i = 0; i < N; i++){
    
    if (Counter[A.at(i)] == 1){
      cout << "NO" << endl;
      return 0;
    }
      
    Counter[A.at(i)]++;
  }
  
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 14336
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9,N=100010;
const db eps=1e-8;
inline void read(int &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void read(ll &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
int n,a[N];
int fa[N];
bool ans[N];
int head[N],to[N<<1],nxt[N<<1],lst=0;
inline void adde(int x,int y) {nxt[++lst]=head[x]; to[lst]=y; head[x]=lst;}
inline bool ok(int x,int p) {x=x%((int)pow(10,p+1)); return x/(int)pow(10,p)!=0;}
inline void dfs1(int u)
{
	for(int i=head[u];i;i=nxt[i])
		if(to[i]!=fa[u])
		{
			fa[to[i]]=u;
			dfs1(to[i]);
 	  	 	if(!ans[to[i]] && a[u]>a[to[i]]) ans[u]=1;
		}
}
void dfs2(int u)
{
	for(int i=head[u];i;i=nxt[i])
		if(to[i]!=fa[u])
		{
			if(!ans[u] && a[to[i]]>a[u]) ans[to[i]]=1;
			dfs2(to[i]);
		}
}
int main()
{
//	freopen("C.in","r",stdin);
//	freopen("C.out","w",stdout);
	read(n);int Sta=0;
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<n;i++)
	{
		int x,y; read(x); read(y);
		adde(x,y); adde(y,x);
	}
	dfs1(1); 
//	for(int i=1;i<=n;i++) printf("%d ",ans[i]); 
	dfs2(1);
	for(int i=1;i<=n;i++) if(ans[i]) printf("%d ",i);
	return 0;
}
/*5
5 4 1 2 3
1 2
1 3
2 4
2 5*/

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 100000;
ll const MOD = 1000000007;

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];
    }

    mint p(int n, int k) { return fact[n] * ifact[n - k]; }
};

int main() {
    ll N, M;
    cin >> N >> M;

    combination comb(M);
    mint ans = 0;

    rep(i, N + 1) {
        if (i % 2 == 0) {
            ans += comb(N, i) * comb.p(M, i) * comb.p(M - i, N - i) *
                   comb.p(M - i, N - i);
        } else {
            ans -= comb(N, i) * comb.p(M, i) * comb.p(M - i, N - i) *
                   comb.p(M - i, N - i);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11088
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
class Node {
public:
    Node(int x, int y, int times) :x(x), y(y), times(times) {}
    int x;
    int y;
    int times;
    bool operator <(const Node& n) const {
        return this->times > n.times;
    }
};
int m, n, startx, starty, endx, endy;
priority_queue<Node> pq;
char matrix[3005][3005];
int vis[3005][3005];
//int cnt[3005][3005];
int dx[4] = { 0,0,-1,1 };
int dy[4] = { -1,1,0,0 };
void bfs(Node start, Node end) {
    pq.push(start);
    while (!pq.empty()) {
        Node top = pq.top();
        if (top.x == end.x && top.y == end.y) {
            cout << top.times << endl;
            return;
        }
        for (int i = 0; i < 4; i++) {
            int newX = top.x + dx[i];
            int newY = top.y + dy[i];
            if (newX > 0 && newX <= m && newY>0 && newY <= n && matrix[newX][newY] == '.' && vis[newX][newY]>top.times) {
                vis[newX][newY] = top.times;
                pq.emplace(Node(newX, newY, top.times));
            }
        }
        for (int i = top.x - 2; i <= top.x + 2; i++)
            for (int j = top.y - 2; j <= top.y + 2; j++) {
                if (matrix[i][j] == '.' && vis[i][j]>top.times+1 && i > 0 && i <= m && j>0 && j <= n) {
                    vis[i][j] = top.times+1;
                    pq.emplace(Node(i, j, top.times + 1));
                }
            }
        pq.pop();
        //cout << pq.size() << endl;
    }
    cout << -1 << endl;
    return;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> m >> n;
    cin >> startx >> starty >> endx >> endy;
    Node start(startx, starty, 0), end(endx, endy, 0);
    memset(vis, 0x7f, sizeof(vis));
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= n; j++) {
            cin >> matrix[i][j];
        }
    vis[startx][starty] = 0;
    bfs(start, end);
    return 0;
}

Measured memory_bytes: 41408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N+1),B(N);

  for(int i=0;i<=N;i++) cin>>A[i];
  for(int i=0;i<N;i++) cin>>B[i];

  ll ans=0;
  for(int i=N-1;i>=0;i--){
    if(A[i+1]<=B[i]){
      B[i]-=A[i+1];
      ans+=A[i+1];
    }else{
      ans+=B[i];
      B[i]=0;
    }
    if(B[i]==0) continue;

    ans+=min(B[i],A[i]);
    A[i]-=min(B[i],A[i]);
  }

  cout<<ans<<endl;

  return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

string a, b;
int x;

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

	cin >> a >> b;

	string ab = a+b;

	stringstream X(ab);

	X >> x;

	int ans = sqrt(x);

	if(ans*ans == x){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;		
}


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

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;
}

const int N=101000;
int a[N],vis[N],st[N];
ll b[N],p[N],k;
int n,m,tp;

void init();void work();void print();
int main(){init();work();print();return 0;}

void work(){
	int x;
	for(rg int i=1;i<=m;++i)read(x),swap(a[x],a[x+1]);
	for(rg int i=1;i<=n;++i)if(!vis[i]){
		vis[st[0]=x=i]=tp=1;
		while(!vis[a[x]])
			vis[st[tp++]=x=a[x]]=1;
		int e=k%tp;
		for(rg int j=0;j<tp;++j)
			b[st[j]]=p[st[j+e<tp?j+e:j+e-tp]];
	}
}

void print(){
	ll sm(0ll);
	for(rg int i=1;i<=n;++i)
		printf("%lld\n",sm+=b[i]);
}

void init(){
	read(n);
	for(rg int i=1;i<=n;++i)read(p[i]),a[i]=i;
	for(rg int i=n;i;--i)p[i]-=p[i-1];
	read(m),read(k);
}

Measured memory_bytes: 3968
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())
w, h, x, y = map(int, input().split())
s = (w * h) / 2
if w%2 == 0 and w//2 == x and h%2 == 0 and h//2 == y:
    print(s, '1')
else:
    print(s, '0')

Measured memory_bytes: 5104
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


class UnionFindLabel(UnionFind):
    def __init__(self, labels):
        assert len(labels) == len(set(labels))

        self.n = len(labels)
        self.parents = [-1] * self.n
        self.d = {x: i for i, x in enumerate(labels)}
        self.d_inv = {i: x for i, x in enumerate(labels)}

    def find_label(self, x):
        return self.d_inv[super().find(self.d[x])]

    def union(self, x, y):
        super().union(self.d[x], self.d[y])

    def size(self, x):
        return super().size(self.d[x])

    def same(self, x, y):
        return super().same(self.d[x], self.d[y])

    def members(self, x):
        root = self.find(self.d[x])
        return [self.d_inv[i] for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [self.d_inv[i] for i, x in enumerate(self.parents) if x < 0]

def MAP(): return map(int, input().split())
def ZIP(n): return zip(*(MAP() for _ in range(n)))

N, M, K = list(map(int, input().split()))
ans = [-1] * N
uf = UnionFindLabel(range(1, N + 1))
for i in range(M):
    node1, node2 = list(map(int, input().split()))
    ans[node1 - 1] -= 1
    ans[node2 - 1] -= 1
    if not uf.same(node1, node2):
        uf.union(node1, node2)
for i in range(N):
    ans[i] += uf.size(i + 1)
for i in range(K):
    node1, node2 = list(map(int, input().split()))
    if uf.same(node1, node2):
        ans[node1 - 1] -= 1
        ans[node2 - 1] -= 1
print(*ans)


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

int power(int x, int y, int p)
{
    int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int32_t main(){
	int sx, sy, tx, ty;
	cin>>sx>>sy>>tx>>ty;
	for(int i=1; i<=ty-sy; i++) cout<<'U';
	for(int i=1; i<=tx-sx; i++) cout<<'R';
	for(int i=1; i<=ty-sy; i++) cout<<'D';
	for(int i=1; i<=tx-sx; i++) cout<<'L';

	cout<<'L';
	for(int i=1; i<=ty-sy; i++) cout<<'U';
	cout<<'U';
	cout<<'R';
	for(int i=1; i<=tx-sx; i++) cout<<'R';
	cout<<'D';
	cout<<'R';
	for(int i=1; i<=ty-sy; i++) cout<<'D';
	cout<<'D';
	for(int i=1; i<=tx-sx; i++) cout<<'L';
	cout<<'L';
	cout<<'U';
}

// UUURRRDDDLLLLUUUURRRRDRDDDDLLLLU
// UURRURRDDDLLDLLULUUURRURRDDDLLDL


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int m,n;
  
  scanf("%d %d",&n,&m);
  int a[n];
  int i;
  int sum = 0;
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  float th = (float)sum/(4.0*m);
  int cnt=0;
  for(i=0;i < n;i++){
    if(a[i] >= th){
      cnt++;
    }
  }
  if(cnt >= m){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}
  


Measured memory_bytes: 128
N = int(input())
AB = [tuple(map(int, input().split())) for i in range(N)]
A = [AB[i][0] for i in range(N)]
B = [AB[i][1] for i in range(N)]

A.sort()
B.sort()
if N % 2 == 1:
    id = (N+1)//2
    print(B[-id] - A[id-1] + 1)
else:
    id = N // 2
    ans = (B[-id-1]-A[id])*2 + 1
    ans += B[-id] - B[-id-1]

    ans += A[id] - A[id-1]

    print(ans)


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

int main() {
    int n, k;
    string s;

    cin >> n >> k >> s;

    vector<int> nums;
    int now = 1;
    int cnt = 0;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] - '0' != now) {
            nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        } else {
            cnt++;
        }
    }

    if (cnt > 0) {
        nums.push_back(cnt);
    }

    // 1の数 - 0の数 - 1の数 - 0の数 - 1の数 という配列を作りたい
    // 0で終わってたら最後に1のやつを加える

    if (nums.size() % 2 == 0) {
        nums.push_back(0);
    }

    // for (auto a : nums) {
    //     cout << a << " ";
    // }
    // cout << endl;

    // TLEするバージョン
    int ans = nums[0];
    for (int i = 0; i < nums.size(); i += 2) {
        int left = i;
        int right = min(left + k * 2, (int)nums.size() - 1);

        // cout << left << " " << right << endl;

        int a = 0;
        for (int j = left; j <= right; j++) {
            a += nums[j];
        }
        ans = max(ans, a);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int H,W,h,w;
   cin>>H>>W>>h>>w;
   cout<<(H-h)*(W-w)<<endl;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n;
  vector<string> v(n);
  for(int i=0; i < n; i++) cin >> v[i];
  cin >> m;
  vector<string> vv(m);
  for(int i=0; i < m; i++) cin >> vv[i];
  
  int ans = 0;
  for(int i=0; i < n; i++) {
    int count = 0;
    for(int j=0; j < n; j++) {
      if(v[i] == v[j]) count++;
    }
    for(int j=0; j < m; j++) {
      if(v[i] == vv[j]) count--;
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
k = int(input())

def gcf(a,b):
    if a % b == 0 :
        return b
    return gcf(b, a%b)

def gcf3(a,b,c):
    f_ab = gcf(a,b)
    return gcf(f_ab,c)

ans = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        for c in range(b,k+1):
            if a == b == c:
                ans += gcf3(a,b,c)
            elif a != b and b != c and a != c:
                ans += gcf3(a,b,c)*6
            else:
                ans += gcf3(a,b,c)*3
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  vector<int>x={A,B,C};
  sort(x.begin(),x.end());
  if(x[0]==5&&x[1]==5&&x[2]==7){
    cout<<"YES"<<endl;
  }
  else{cout<<"NO"<<endl;}
  return 0;
}

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

const int MAX = 100005;
vector<int> vt[MAX], topo;
int vis[MAX], dp[MAX];
int n;

void dfs(int v) {
	vis[v] = 1;
	for(auto g : vt[v]) {
		if(!vis[g]) dfs(g);
	}
	topo.push_back(v);
}

int main() {
	int m,i,u,v;
	cin>>n>>m;
	for(i=0;i<m;++i) {
		cin>>u>>v;

		vt[u].push_back(v);
	}

	for(i=1;i<=n;++i) {
		if(!vis[i]) dfs(i);
	}

    
	for(auto x : topo) {
		for(auto g : vt[x]) {
			dp[x] = max(dp[x], dp[g]+1);
		}
	}

	cout<<*max_element(dp+1,dp+1+n)<<endl;
	return 0;
}

Measured memory_bytes: 9080
#!/usr/bin/env python3
import sys
from collections import defaultdict, deque

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int, adj):
    visited = [False] * N
    pos = [None] * N

    for i, vis in enumerate(visited):
        if vis:
            continue
        pos[i] = 0
        visited[i] = True
        Q = deque([i], M)
        while len(Q) > 0:
            u = Q.popleft()
            for v, d in adj[u]:
                if pos[v] is None:
                    pos[v] = pos[u] + d
                elif pos[v] != pos[u] + d:
                    print(NO)
                    return

                if visited[v]:
                    continue
                Q.append(v)
                visited[v] = True
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    adj = [set() for _ in range(N)]
    for i in range(M):
        l = int(next(tokens)) - 1
        r = int(next(tokens)) - 1
        d = int(next(tokens))
        adj[l].add((r, d))
        adj[r].add((l, -d))
    solve(N, M, adj)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91680
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)] + [0]
mod = 10 ** 9 + 7

dp = [0] * (n + 1)
dp[0] = 1
b = a[0]
j = 1
for i in range(1, n + 1):
    if i == b:
        b = a[j]
        j += 1
    else:
        tmp = dp[i - 2] + dp[i - 1]
        if tmp >= mod:
            tmp -= mod
        dp[i] = tmp
print(int(dp[-1]))

Measured memory_bytes: 7824
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int n,a[100];
	int i,j;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=n-1;i>=0;i--){ 
		cout<<a[i];
		if(i>0) cout<<" ";
	}
	cout <<endl;
return 0;
}

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

[N, K, S] = [int(i) for i in input().split()]

A = []
k_number = K
for n in range(N):
    if k_number > 0:
        A.append(S)
        k_number -= 1
    else:
        if S == 1:
            A.append(S+1)
        else:
            A.append(S-1)

for a in A[:N-1]:
    print('{} '.format(a), end='')

print(A[N-1])

Measured memory_bytes: 8904
#include<stdio.h>
int main(void)
{
  int h,m,s,t,x;

  scanf("%d", &t);

  h = t/3600;
  x = t % 3600;
  m = x/60;
  s = x % 60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;


int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<pair<int,int>> a,c;
	for (size_t i = 0; i < n; i++) {
		int ss,tt;
		std::cin >> ss >> tt;
		a.push_back(make_pair(ss,tt));
	}
	for (size_t i = 0; i < n; i++) {
		int ss,tt;
		std::cin >> ss >> tt;
		c.push_back(make_pair(ss,tt));
	}
	std::vector<bool> x(n,true);
	std::vector<bool> y(n,true);

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	int count = 0;
	for (size_t i = 0; i < c.size(); i++) {
		int maxy = -1;
		int pota;
		for (size_t j = 0; j < a.size(); j++) {
			if (c[i].first > a[j].first && c[i].second > a[j].second && x[i] && y[j]) {
				if (maxy < a[j].second) {
					maxy = a[j].second;
					pota = j;
				}
			}
		}
		if (maxy != -1) {
			x[i] = false;
			y[pota] = false;
			count++;
		}
	}

	std::cout << count << '\n';

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)


int main(void) {
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;

	int ans = 1e9;
	for (int i = 0; i <= 2 * max(x, y); ++i) {
		int cntx = max(x - i / 2 + (i % 2 ? 1 : 0), 0);
		int cnty = max(y - i / 2 + (i % 2 ? 1 : 0), 0);
		// printf("%d %d %d\n", i, cntx, cnty);
		ans = min(ans, a * cntx + b * cnty + c * i);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define int long long

using namespace std;

int cou(int a, int m);
int ggd(int number1, int number2);
int lcm(int number1, int number2);

signed main() {
	int a1, a2, a3, m1, m2, m3;
	int x, y, z;
	int count;
	int countx, county, countz;
	while (cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3, a1 || a2 || a3 || m1 || m2 || m3) {
		x = 1;
		y = 1;
		z = 1;
		count = 0;

		countx = cou(a1, m1);
		county = cou(a2, m2);
		countz = cou(a3, m3);

		cout << lcm(lcm(countx, county), countz) << endl;
	}
	return 0;
}

int cou(int a, int m) {
	int x = 1;
	int count = 0;
	do {
		count++;
		x = (a * x) % m;
	} while (x != 1);
	return count;
}

int ggd(int number1, int number2) {
	int m = number1;
	int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}

	while (n != 0) {
		int temp = m % n;
		m = n;
		n = temp;
	}

	return m;
}

int lcm(int number1, int number2) {
	return number1 * number2 / ggd(number1, number2);
}

Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

// グラフを隣接行列で管理する
bool G[10][10];

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a][b] = G[b][a] = true;
    }

    // 順列
    vector<int> ord(N);
    for (int i = 0; i < N; ++i) ord[i] = i;

    // 順列を全部試すa
    int res = 0;
    do {
        if (ord[0] != 0) break;

        bool ok = true;
        for (int i = 0; i + 1 < N; ++i) {
            int from = ord[i];
            int to = ord[i+1];
            if (!G[from][to]) ok = false;
        }
        if (ok) ++res;
    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << endl;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 100000;
const int K = 100000;
int n, k;
int w[N], t[K];

bool check(int limit) {
  int i, j;
  
  for (i=0; i<n; i++)
    if (limit < w[i]) return false;

  memset(t, 0, sizeof(t));
  i = j = 0;
  while (i<n && j<k) {
    if (t[j] + w[i] < limit) 
      t[j] += w[i++];
    else if (t[j] + w[i] == limit)
      t[j++] += w[i++];
    else
      j++;
  }

  if (i<n && j==k)
    return false;
  else
    return true;
}

int main() {
  int i;
  scanf("%d%d ", &n, &k);
  for (i=0; i<n; i++)
    scanf("%d ", w+i);

  int l = 0, u = 0;
  for (i=0; i<n; i++) u += w[i];
  while (u-l > 1) {
    int m = (l+u)/2;
    if (check(m))
      u = m;
    else
      l = m;
  }
  printf("%d\n", u);
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) cin >> b[i];
    ll diff[n];
    rep(i, n) diff[i] = a[i] - b[i];
    sort(diff, diff + n);
    int ans = 0;
    ll sum = 0;

    rep(i, n) {
        if (diff[i] < 0) {
            sum += diff[i];
            ans++;
        } else
            break;
    }
    int i = n;
    while (sum < 0) {
        i--;
        if (diff[i] > 0) {
            sum += diff[i];
            ans++;
        } else {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
long int a[200];
int n,i,temp=0,count=0;

scanf("%d",&n);

for(i=0;i<n;i++)
scanf("%ld",&a[i]);

do
{
	for(i=0,temp=0;i<n;i++)
	{
		if((a[i]%2)==0)
		{
		a[i]=a[i]/2;
		temp++;

		}
	}

if(temp==n)
{
count++;
}
}while(temp==n);

printf("%d",count);



}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

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

    int ans = 0;
    for(int i = 1; i < N; i++){
        int cnt = 0;

        for(char c = 'a'; c <= 'z'; c++){
            bool left = false, right = false;

            rep(j, i){
                if(S[j] == c) left = true;
            }
            for(int j = i; j < N; j++){
                if(S[j] == c) right = true;
            }

            if(left && right) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout<< ans << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int l,r;
    cin >> l >> r;
    if(r - l >= 2019)
    {
        cout << "0";
    }
    else
    {
        int min;
        int ans = 2019;
        for(long long int i = l;i <= r;i++)
        {
            min = 2019;
            for(long long int j = i + 1;j <= r;j++)
            {
                if((i * j) % 2019 < min)
                {
                    min = (i * j) % 2019;
                    if(min == 0)
                    {
                        cout << min;
                        return 0;
                    }
                }
            }
            if(min < ans)
            {
                ans = min;
            }
        }
        cout << ans;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    map<char, int> counts;
    string word;
    cin >> word;
    repeat (i, word.size()) {
        counts[word[i]] += 1;
    }
    map<char, int>::iterator itr = counts.begin();

    int totalCount = 0;

    for (; itr != counts.end(); ++itr) {
        if (itr->second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        } else {
            totalCount += itr->second;
        }
    }
    if (totalCount % 2 == 0) {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    String rev ="";
    int half=s.length()/2;
    int count=0;
    for(int k=s.length()-1;k>=half;k--) {
        rev+=s.charAt(k);
    }
    for(int i=0;i<half;i++) {
        if(s.charAt(i)!=rev.charAt(i)) {
            count++;
        }
    }
    System.out.println(count);
}
}


Measured memory_bytes: 23124
import math

a, b, h, m = map(int, input().split())


def choshin_angle(m):
    return 6 * m

def tanshin_angle(h, m):
    return 0.5 * (60 * h + m)

theta = abs(tanshin_angle(h, m) - choshin_angle(m))

if (theta >= 180.):
    theta = 360 - theta

theta = math.radians(theta)

x2 = a**2 + b**2 - 2 * a * b * math.cos(theta)

x = math.sqrt(x2)

print(x)



Measured memory_bytes: 9508
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
	int x;
	cin >> x;
	int ans=1;
	for(int i=2;i<=sqrt(x);i++){
		int tmp=i;
		while(tmp*i <= x)tmp*=i;
		if(ans < tmp)ans=tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int m, n, ans;
int dp[2][1 << 19][2], fill, all = 1;
char c;
int main(){
  scanf("%d%d", &m, &n);
  fill = (1 << (n - 1)) - 1;
  dp[1][0][0] = 1;
  for(int i = 0;i < m * n;i++){
    scanf(" %c", &c);
    if(c == '?'){
      all *= 3;
      all %= 100000;
    }
    memset(dp[i % 2], 0, sizeof(dp[i % 2]));
    for(int j = 0;j <= fill;j++){
      int next = (j << 1) & fill;
      if(c == 'J' || c == '?'){
	dp[i % 2][next][1] += dp[(i + 1) % 2][j][0] + dp[(i + 1) % 2][j][1];
      }
      if(c == 'O' || c == '?'){
	dp[i % 2][next][0] += dp[(i + 1) % 2][j][0];
	dp[i % 2][next + 1][0] += dp[(i + 1) % 2][j][1];
      }
      if(c == 'I' || c == '?'){
	if(j >> (n - 2) == 0 || i % n == n - 1){
	  dp[i % 2][next][0] += dp[(i + 1) % 2][j][0] + dp[(i + 1) % 2][j][1];
	}
      }
      dp[i % 2][next][0] %= 100000;
      dp[i % 2][next][1] %= 100000;
      dp[i % 2][next + 1][0] %= 100000;
      dp[i % 2][next + 1][1] %= 100000;
    }
  }
  for(int i = 0;i <= fill;i++){
    ans += dp[(m * n - 1) % 2][i][0] + dp[(m * n - 1) % 2][i][1];
    ans %= 100000;
  }
  printf("%d\n", (100000 + all - ans) % 100000);
  return 0;  
}

Measured memory_bytes: 9224