akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		int X=nextInt();
		int T=nextInt();
		if(N%X==0)
			System.out.println(N/X*T);
		else
			System.out.println((N/X+1)*T);
	}
	public static long lmod(long i, long j) {
	     return (i%j)<0?(i%j)+0+(j<0?-j:j):(i%j+0);
	 }
	static boolean isOK(int index,int key,int[]a){
		if (a[index]>=key) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32448
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


// DAGなので、トポロジカルソート後の入次数0の頂点から右に進んで、dp[i]:= 頂点iが終点としたときにの最長の長さ　とおけば、
// chmax(dp[nv],dp[v]+1) とすればいい。　(nvは頂点vから刺さる先の頂点)
// これを考えてみると、vからスタートすると、vは0、nvは１になって・・・・・・と更新が続いていく。
// 結局、入次数0 の頂点からスタートして、進むごとに辺を消去していくので入次数0の頂点を次々と始点としてループしていけば、いずれすべてのルートを通りつくす。
// このとき、一度通った流れはdpに記録されているので、その経路を別から通った時には大きくなるほうにchangeしていく。
// 例としては、 0→1→2→3→4 5→6   h[]は入り次数
//             ↓→→→→→↑ ↓→→→↑
// とあったら、０から始まって、dp[1] = 1 , dp[3] = 1, h[1] = 0 →　dp[2] = 2 h[2] = 0 → chmax(dp[3],dp[2]+1) で dp[3] = 1, dp[2]+1 = 3　なので dp[3] = 3に更新
//                          dp[4] = dp[3]+1 = 4 , dp[6] = dp[4]+1 = 5, chmax(dp[6],dp[5]+1) だけど、dp[5]+1 = 1 なので、dp[6] = 5 が採用。
// よって、dpは [1] = 1
//             [2] = 2
//             [3] = 3
//             [4] = 4
//             [5] = 1
//             [6] = 5
// となる。
// なので、repなり、max_elementなりすれば ans = 5 となる。
// つまり、上の矢印のDAGを作ったあとは、chmaxの回数は結局辺の数になっている。
// よって、トポロジカルソートはO(V+E)なので、全体での計算量は O(V+E+E)になっているような気がする。

// トポロジカルソートをしないと、
//             ↓←←←←←←←←←↑
// 例としては、 0→1→2→3→4 5→6   
//             ↓→→→→→↑ ↓→→→↑

// みたいに、後ろに戻っちゃうやつがでてきたら困るから？こうなると、DPを頭からやっていって答えが一意になる保証がなくなる。
// 仮に上の例だと、トポロジカルソートすると、
//             ↑→→→→→→→→→→→↓
//             5→0→1→2→3→4→6
//               ↓→→→→→↑
// みたいになって確かに、DPしていける感じになる。


int main(){
    int N,M;cin >> N >> M;
    vector<vector<int>> G(N,vector<int>());           // ここをvector<int> G(N+1) にしたら alloc関連のバグが出た。これって、あらかじめ二次元配列ですって宣言しておくと回避できたってこと？
    vector<int> h(N);

    //グラフ化と入次数
    rep(i,M){
        int a,b;cin >> a >> b;
        a--; b--;   //0-index化
        G[a].push_back(b);
        h[b]++;
    }

    //入0のスタック
    queue<int> zero;

    //zero作成
    rep(i,N)if(h[i] == 0)zero.push(i);

    // BFS
    vector<int> dp(N);
    while(zero.size()){
        int v = zero.front();zero.pop();
        for(auto nv : G[v]){
            h[nv]--; // 辺を破壊する
            if(h[nv] == 0){
                zero.push(nv);  //  入次数0になったのでスタックにつっこむ
                chmax(dp[nv],dp[v]+1);  // この時、トポロジカルソートは頂点nvの周りでは完了していると考えられるので、同時並行でDPテーブルを作っちゃう。 ※1
            }
        }
    }

    int res = 0;
    rep(i,N)chmax(res,dp[i]);
    cout << res << endl;

}

// push_back() した時の alloc バグの原因がここにきて2か月ぶりくらいにやっと解明された感ある。

Measured memory_bytes: 6528
#include<stdio.h>
int min(int a,int b)
{
	if(a<b)return a;
	else return b;
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int i;
	int x,ans=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		ans+=min(x,k-x);
	}
	ans*=2;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

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

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const long double PI = 3.14159265358979323846;







// ****************************************CODE***************************************//
//





const ll MAX = 4005;

ll Com[MAX][MAX];

void COMcalc(){
        Com[0][0] = 1;
        for(int i = 0; i <= MAX-5; i++){
                for(int j = 0; j <= i; j++){
                        Com[i+1][j] = (Com[i+1][j] + Com[i][j]) % MOD;
                        Com[i+1][j+1] = (Com[i+1][j+1] + Com[i][j]) % MOD;
                }
        }
}

ll comb(int n, int k){
        return Com[n][k];
}
ll f2(int n, int k){
        return comb(n+k-1,k-1);
}
ll f(int n, int k){
        if(n < k) return 0;
        if(n == 0 && k == 0) return 1;
        if(k < 1) return 0;
        return f2(n-k,k);
}


int main(){
        COMcalc();
        ll n, k;
        cin >> n >> k;
        for(int i = 1; i <= k; i++){
                ll blue = f(k,i);
                //ll red = f2(n-k-(i-1),i+1);
                ll red = 0;
                {
                        red += f(n-k,i-1);
                        red %= MOD;
                        red += f(n-k,i);
                        red %= MOD;
                        red += f(n-k,i);
                        red %= MOD;
                        red += f(n-k,i+1);
                        red %= MOD;
                }
                ll ans = blue * red % MOD;
                cout << ans << endl;
        }
        return 0;
}










Measured memory_bytes: 123648
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(0, N - 1):
    p = P[i]
    if (i + 1) == p:
        ans += 1
        P[i] = P[i + 1]
        P[i + 1] = p

if N == P[N - 1]:
    ans += 1

print(ans)


Measured memory_bytes: 52908
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ll N;
    cin >> N;
    vector<string> s(N);
    for (ll i = 0; i < N; ++i) {
        cin >> s[i];
    }
    ll ret = 0;
    for (ll i = 0; i < N; ++i) {
        for (ll j = 0; j < s[i].size() - 1; ++j) {
            if (s[i].substr(j, 2) == "AB")
                ret++;
        }
    }
    ll startB = 0;
    ll endA = 0;
    ll BtoA = 0;
    for (ll i = 0; i < N; ++i) {
        if (s[i][0] == 'B')
            startB++;
        if (s[i][s[i].size() - 1] == 'A')
            endA++;
        if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A')
            BtoA++;
    }
    ll add = min(startB, endA);
    if (add != 0) {
        if (startB == BtoA && endA == BtoA)
            add--;
    }
    ret += add;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::synMwith_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
//ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

int dirx[] = {0,1,-1,0};
int diry[] = {1,0,0,-1};

const int N = 1e6+5;

int n, m;
char s[500][500];

int f(int x,int y){
    return 400*x+y;
}

int M[N];
int fa[N],cnt[N];

int Find(int x){
    return x == fa[x]?x:fa[x] = Find(fa[x]);
}

void Join(int x,int y){
    int tx = Find(x);
    int ty = Find(y);
    if(tx != ty){
        fa[tx] = ty;
        M[ty] += M[tx];
        cnt[ty] += cnt[tx];
    }
}

void init()
{
    for(int i=0;i<N;i++)
        fa[i] = i, cnt[i] = 1;
}
ll ans;
void solve()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            for(int k=0;k<4;k++)
            {
                int x = i+dirx[k];
                int y = j+diry[k];
                if(x>0&&x<=n&&y>0&&y<=m && s[i][j]!=s[x][y])
                    Join(f(x,y),f(i,j));
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int t = Find(f(i,j));
            if(cnt[t]>1){
                ans += 1ll*M[t]*(cnt[t]-M[t]);
                cnt[t] = 0;
            }
        }
    }
    cout<<ans<<nl;
}

int main()
{
    init();
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(s[i][j]=='#')
                M[f(i,j)] = 1;
    solve();
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 2147483647
#define MININF -INF
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> value;
int N;

void add(int i,int x){
    i += N-1;
    value[i] += x;
    while (i > 0){
        i = (i - 1)/2;
        value[i] = value[i*2+1]+value[i*2+2];
    }
}
int Sum(int l0,int r0,int p,int l,int r){
    if (r <= l0 || r0 <= l) return 0;
    if (l0 <= l && r <= r0) return value[p];
    else {
        int c1 = Sum(l0,r0,2*p + 1,l,(l+r)/2);
        int c2 = Sum(l0,r0,2*p + 2,(l+r)/2,r);
        return c1+c2;
    }
}
int main(void){
    int n,q;
    cin >> n >> q;
    N = 1;
    while(N < n) N*=2;
    value.resize(2*N -1);
    REP(j,q){
        int c;
        cin >> c;
        if (!c){
            int i,x;
            cin >> i >> x;
            add(i-1,x);
        }
        else{
            int a,b;
            cin >> a >> b;
            PRINT(Sum(a-1,b,0,0,N));
        }
    }
}



Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg char ch=getchar();
	reg int ans=0;
	while(ch<'0'||'9'<ch)ch=getchar();
	while('0'<=ch&&ch<='9')ans=10*ans+ch-'0',ch=getchar();
	return ans;
}

const int MAXN=1e5+5;
const int MAXM=2e5+5;

int n,m;
int a[MAXN],b[MAXN];
vector<int> V;
int c[MAXN],diff[MAXN];
int cnt,head[MAXN],to[MAXM<<1],w[MAXM<<1],Next[MAXM<<1];

inline void Add_Edge(reg int u,reg int v,reg int len){
	Next[++cnt]=head[u];
	to[cnt]=v;
	w[cnt]=len;
	head[u]=cnt;
	return;
}

bool vis[MAXN];
int tot,ans[MAXM];

inline int dfs(reg int u,reg int father,reg int x){
	vis[u]=true;
	reg int t=0;
	for(reg int i=head[u];i;i=Next[i]){
		reg int v=to[i];
		if(!vis[v])
			t^=dfs(v,u,i);
	}
	if(u==father)
		return t;
	if(diff[u]^t){
		ans[++tot]=w[x];
		return 1;
	}
	return 0;
}

int main(void){
	n=read(),m=read();
	for(reg int i=1;i<=n;++i){
		a[i]=read(),b[i]=read();
		V.push_back(a[i]);
	}
	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());
	for(reg int i=1;i<=n;++i){
		a[i]=lower_bound(V.begin(),V.end(),a[i])-V.begin()+1;
		c[a[i]]=b[i];
	}
	for(reg int i=1;i<=n;++i)
		diff[i]=c[i-1]^c[i];
	for(reg int i=1;i<=m;++i){
		static int L,R;
		L=read(),R=read();
		L=lower_bound(V.begin(),V.end(),L)-V.begin()+1;
		R=upper_bound(V.begin(),V.end(),R)-V.begin();
		if(L<=R){
			Add_Edge(L,R+1,i);
			Add_Edge(R+1,L,i);
		}
	}
	dfs(n+1,n+1,0);
	for(reg int i=1;i<=n;++i){
		if(vis[i])
			continue;
		if(dfs(i,i,0)!=diff[i]){
			puts("-1");
			exit(0);
		}
	}
	printf("%d\n",tot);
	sort(ans+1,ans+tot+1);
	for(reg int i=1;i<=tot;++i)
		printf("%d%c",ans[i],i==tot?'\n':' ');
	return 0;
}

Measured memory_bytes: 15444
#include<iostream>
using namespace std;
int main(void){
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  double px[4], py[4];
  while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
    bool f = false;
    for(int i = 0;i < 4; i++)
      if(xa1 <= xb2 && xb1 <= xa2 && ya1 <= yb2 && yb1 <= ya2) f = true;
    cout << (f? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 1216
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int d[] = new int[N];
        int ans = 0;
        for(int i=0;i<N;i++){
            d[i]=sc.nextInt();
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<i;j++){
                ans+=d[i]*d[j];
            }
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 24788
S = list(input())
N = len(S)
ans = float('inf')
# 10101....
cnt = 0
T = ["0"]*N
for i in range(N):
    if i%2==0: T[i] = "1"
# print(T)
for si,ti in zip(S, T):
    if si != ti:
        cnt += 1
ans = min(cnt, ans)

# 01010....
cnt = 0
T = ["0"]*N
for i in range(N):
    if i%2==1: T[i] = "1"
# print(T)
for si,ti in zip(S, T):
    if si != ti:
        cnt += 1
ans = min(cnt, ans)
print(ans)


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,sum=0;
	cin>>n;
	ll a[n];
	forn(i,n)cin>>a[i];
	forni(i,n){
		if(a[i-1]>a[i]){
			sum+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<sum<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	cout << (ll)(pow(n,3));
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

using namespace std;

int a[2019], b[2019];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < 2019; ++i) a[i] = b[i] = 0;
    long long ans = 0LL;
    for (char g: s)
    {
        int x = g - '0';
        ++b[x];
        for (int i = 0; i < 2019; ++i)
            b[(i * 10 + x) % 2019] += a[i];

        ans += 1LL * b[0];
        for (int i = 0; i < 2019; ++i)
            a[i] = b[i], b[i] = 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3720
import sys
from itertools import accumulate

input = sys.stdin.readline


def solve(H, W, D, A, Q, LR):
    position = [None] * (H * W + 1)
    for h in range(H):
        for w in range(W):
            position[A[h][w]] = (h, w)

    mp = [0] * (H * W + 1)

    for i in range(1, H * W + 1 - D):
        h, w = position[i]
        y, x = position[i + D]
        mp[i + D] = abs(x - w) + abs(y - h)

    for d in range(1, D + 1):
        mp[d::D] = list(accumulate(mp[d::D]))

    ans = [str(mp[r] - mp[l]) for l, r in LR]
    ans = "\n".join(ans)
    return ans


def main():
    H, W, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    Q = int(input())
    LR = [list(map(int, input().split())) for _ in range(Q)]

    ans = solve(H, W, D, A, Q, LR)
    print(ans)


if __name__ == "__main__":
    main()


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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())
#define mp            make_pair
#define pb            push_back


typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N == 0){
    cout << "0" << endl;
    return 0;
  }
  string ans;
  while(N != 0){
    if(N & 1){
      ans = "1" + ans;
      N--;
    }else{
      ans = "0" + ans;
    }
    N /= -2;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
   ll n,m,i,a,b,c,d;
   scanf("%lld %lld",&n,&m);
   if(n==1 || m==1)
   {
       printf("1\n");
       return 0;
   }
   i=n*m;
   a=n/2;
   if(n%2)
    a++;
   b=m/2;
   if(m%2)
    b++;
   c=n/2;
   d=m/2;
   i=a*b+c*d;
   printf("%lld\n",i);
}


Measured memory_bytes: 256
#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 mod=1000000007;
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() {
  int64_t N;
  cin>>N;
  auto p=prime_factorize(N);
  int cnt=0;
  for(auto c:p){
    int a=c.first;int b=c.second;
    int r=1;
    while(b-r>=0){
      cnt++;
      b-=r;
      r++;
    }
  }
  cout<<cnt<<endl;
  return 0;  
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void mH(int i){
  int l, r, maximum;
  l=2*i;
  r=2*i+1;

  if(l<=H && A[l]>A[i])maximum=l;
  else maximum=i;
  if(r<=H &&A[r]>A[maximum])maximum=r;

  if(maximum!=i){
    swap(A[i], A[maximum]);
    mH(maximum);
  }
}

int main(){
  cin>>H;
  for(int i=1;i<=H;i++) cin>>A[i];
  for(int i=H/2;i>=1;i--) mH(i);
  for(int i=1;i<=H;i++){
    cout<<" "<<A[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5016
use proconio::{
    input, 
    fastout,
    marker::Chars,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut cc: Chars,
    }

    let mut w_index = 0;
    let mut r_index = n;

    let mut count = 0;

    while w_index < r_index {
        let mut has_w = false;
        for i in w_index..n {
            if cc[i] == 'W' {
                w_index = i;
                has_w = true;
                break;
            }
        }
        let mut has_r = false;
        for i in (0..r_index).rev() {
            if cc[i] == 'R' {
                r_index = i + 1;
                has_r = true;
                break;
            }
        }
        if has_r && has_w && w_index < r_index {
            count += 1;
            w_index += 1;
            r_index -= 1;
        } else {
            break;
        }
    }

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


Measured memory_bytes: 3116
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>n>>s;
  k=0;
  for(int i=0;i<n;i++){
    if(s[i]=='1') k++;
  }
  vector<int> ans(n+10);
  bool can=false;
  if(k-1==0) can=true;
  lol sum1=0,sum2=0;
  for(int i=0;i<n;i++){
    sum1*=2;
    sum2*=2;
    sum1+=s[i]-'0';
    sum2+=s[i]-'0';
    sum1%=k+1;
    if(!can) sum2%=k-1;
  }
  lol tmp1=1,tmp2=1;
  for(int i=n-1;i>=0;i--){
    lol a;
    lol p=1;
    if(s[i]=='1'){
      a=sum2;
      a-=tmp2;
      if(can){
        ans[i]=0;
        continue;
      }
      while(a<0) a+=k-1;
    }else{
      a=sum1;
      a+=tmp1;
      a%=k+1;
    }
    tmp1*=2;
    tmp2*=2;
    tmp1%=k+1;
    if(!can) tmp2%=k-1;
    while(a!=0){
      lol t=__builtin_popcount(a);
      a%=t;
      p++;
    }


    ans[i]=p;
  }
  for(int i=0;i<n;i++) cout <<ans[i]<<'\n';
  return (0);
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main() {
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> pairs(N);
  for (int i(0);i<N;i++){
    int a,b;
    cin>>a>>b;
    pairs[i]={a,b};
  }
  sort(pairs.begin(),pairs.end());
  priority_queue<int> q;
  int itr(0);
  int ans;
  for (int i(M);i>=1;i--){
    while (pairs[itr].first <= M-i+1){
      if (itr==N) break;
      q.push(pairs[itr].second);
      itr++;
    }
    if (!q.empty()){
      ans+=q.top(); 
    //  cout << "aaa" << endl;
      q.pop();
     // cout << "bbb" << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1660
N = int(input())
A = list(map(int,input().split()))

ans = 0
f = True
while(f):
  for i in range(N):
    if A[i]%2 == 0:
      A[i] //= 2
    else:
      f = False
      break
  if f:
    ans += 1
print(ans)

Measured memory_bytes: 38512
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=2e5+5;
int n,a[maxn],b[maxn],c[maxn],d[maxn],dp[222];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=0;i<=28;i++){
		for(int j=1;j<=n;j++)
			c[j] = a[j]%(1<<(i+1)),
			d[j] = b[j]%(1<<(i+1));
		sort(d+1,d+n+1);
		for(int j=1;j<=n;j++){
			int x=(1<<i)-c[j], y=(1<<(i+1))-c[j];
			int t1 = lower_bound(d+1,d+n+1,x) - d;
			int t2 = lower_bound(d+1,d+n+1,y) - d;
			if(d[t2] >= y)-- t2;
			if(t2 > n)-- t2;
			if(t1<=t2 && (t2-t1+1)%2==1)dp[i]^=1;
			
			x=(1<<i)*3-c[j], y=(1<<(i+2))-c[j];
			t1 = lower_bound(d+1,d+n+1,x)-d;
			t2 = lower_bound(d+1,d+n+1,y)-d;
			if(d[t2] >= y)-- t2;
			if(t2 > n)-- t2;
			if(t1<=t2 && (t2-t1+1)%2==1)dp[i]^=1;
		}
	}
	int ans=0;
	for(int i=0;i<=28;i++)if(dp[i])ans |= (1<<i);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
//1秒間で処理できる for 文ループの回数は、10^8=100,000,000回程度
int main(){
    //A
    
    int N;
    cin>>N;
    if(N/100==7||N/10%10==7||N%10==7){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    
   //B
   /*
   int n;cin>>n;
   ll c=0;
   rep(i,1,n+1) {
       if(i%3!=0&&i%5!=0) c+=i;
   }
   cout<<c<<endl;
   */
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int city[4]={};
    int a[6];
    for(int i=0; i<6; i++){
        cin >> a[i];
        a[i]--;
        city[a[i]]++;
    }
    
    int one=0;
    int two=0;
    for(int i=0; i<4; i++){
        if(city[i]==1){
            one++;
        }else if(city[i]==2){
            two++;
        }
    }
    
    if(one==2 && two==2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
#define int long long
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
signed main() {
	int a; cin >> a;
	int b; cin >> b;
	for (int c = 1; c < a; c++) {
		int d; cin >> d;
		b = lcm(b, d);
	}
	cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    string S;
    cin>>S;
    set<char> s;
    for(auto i:S)
    s.insert(i);
    if(s.size()==1)
    cout<<"No";
    else
    {
        cout<<"Yes";
    }
    
    return 0;
}

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

int main(){
    ll a,b;
    cin >> a >> b;
    if((a+b)%2==1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

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

char s[100010];

int main () {
    cin >> s;
    int len = strlen (s);
    if (s[0] == s[len - 1]) {
        if (len % 2 == 0) {
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    } else {
        if (len % 2 == 0) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    }
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll K, ans[50];

int main(){
  cin >> K;
  for (ll i = 0; i < 50; i++){
    ans[i] = (K / 50) + i;
  }

  for (int i = 0; i < K % 50; i++){
    ans[49 - i]++;
  }

  cout << 50 << endl;
  cout << ans[0];
  for (int i = 1; i < 50; i++) cout << " " << ans[i];
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
// https://gcc.gnu.org/onlinedocs/gcc-4.6.2/libstdc++/api/a01040_source.html
using namespace std;
#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define pb push_back // 配列の最後にappendする
#define mp make_pair 
#define ALL(x) (x).begin(),(x).end()   // accumulateする場合、最初から最後までということか？
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

ll A,B,C,D,E,F,K,G,H,L,M,N,P,Q,R,W,X,Y,Z;
string S,T, U;
vector<ll> V;
int ans_s, ans_t;

// #define LOCAL
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

int main(){
//    pair <int,int> foo;
//    vector<int> vec{ 1, 2, 3 };

//    ll ans = 1;
  // int x =10;
  // int y =5;
  // swap(x,y);
  // cout << min(x,y)<< '\n';
  // cout << max(x,y)<< '\n';

  // cin >> N >> K;
  // REP(i,N){
  //   cin >> X;
  //   V.pb(X);
  // }

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    ans_s = A;
    ans_t = B;

    int UPos = S.find(U);
    if (UPos != std::string::npos) {
      ans_s = A -1;
    }
    UPos = T.find(U);
    if (UPos != std::string::npos) {
      ans_t = B -1;
    }

 cout << ans_s << " " << ans_t;


  // auto result = find(ALL(S), 10);
  
  // if (result != S.end()) {
  //   ans_s = A -1;
  // }

  //   cout << s << endl;
  //   s = s + t; //連結
  //   s == t; //比較
  //   s.length(); //長さ
  //   cout << s[0] << '\n';    //i番目の文字を参照
  //   cout << s.substr(0, 5)<< '\n'; //i番目以降k文字を抽出して得られる文字列
  //   cout << s.find("abc")<< '\n';  //sの中に文字列tがあればその先頭のアドレスを返す．なければs.nopsを返却
  //   cout << s.replace(0, 3, "zxc")<< '\n'; //i番目以降k文字を文字列tで置換する．tを空文字列にすれば削除の動作
  //   cout << s.insert(5, "ins")<< '\n'; //i番目の文字の前に文字列tを挿入

  //   vector<int> a{1,2,3,4,5};
  //   cout << a.size()<< '\n'; //aの大きさ
  //   cout << a[3]<< '\n'; //i番目の要素にアクセス
  //   cout << a.front()<< '\n';  //先頭を参照
  //   cout << a.back()<< '\n';   //末尾を参照
  //   a.push_back(10);  //末尾に要素を追加
  //   // cout << a << '\n';
  //   a.pop_back();   //末尾の要素を削除
  //   // cout << a << '\n';

  //   FOR(i,0,10){
  //       //   vec.push_back(i);
  //       a.pb(i);
  //   }
  //   // reverse(a, a.end());
  //   sort(ALL(a));
  //   cout << binary_search(a.begin(), a.end(), 20)<< '\n'; //trueかfalseを返す
  //   vector<int>::iterator lit = lower_bound(a.begin(), a.end(), 5);   //x以上の値が初めて現れる位置のイテレータを返す
  //   vector<int>::iterator uit = upper_bound(a.begin(), a.end(), x);   //xより大きい値が初めて現れる位置のイテレータを返す 
	// if(lit != a.end() && lit != uit)
	// 	cout << uit - lit << '\n';	// この場合, ult - lit は vc 中の x の個数になる    
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
c=[[]  for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    c[a-1].append(b-1)
    c[b-1].append(a-1)
for d in c:
    if 0 in d and n-1  in d:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 38320
def solve():
    s = [int(x) for x in input()]

    def dfs(i, x, a):
        if i == 4:
            if x == 7:
                return a + "=7"
            else:
                return False
        res1 = dfs(i + 1, x + s[i], a + "+" + str(s[i]))
        res2 = dfs(i + 1, x - s[i], a + "-" + str(s[i]))
        return res1 or res2

    res = dfs(1, s[0], str(s[0]))
    print(res)


solve()

Measured memory_bytes: 9204
#include<cstdio>
#include<set>

using namespace std;


int main(void)
{
	int s;

	while(scanf("%d", &s)==1)
	{
		set<int> a;
		int ans=1;

		for(;;ans++)
		{
			if(a.find(s)!=a.end()) break;
			a.insert(s);
			if(s&1) s=3*s+1;
			else s=s/2;
		}
		printf("%d\n", ans);
	}

	return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll H, W;
ll dy[] = {1, 0 ,-1, 0};
ll dx[] = {0, 1, 0, -1};
ll id[410][410];
ll num[2][999999];
string field[410];
int main() {
    cin>>H>>W;
    REP(i,0,H){
        cin>>field[i];
    }
    ll max_id=0;
    REP(i,0,H){
        REP(j,0,W){
            id[i][j]=888888;
        }
    }
    bool ok=false;
    while(!ok){
        ok=true;
        REP(i,0,H){
            REP(j,0,W){
                if(id[i][j]==888888){
                    max_id++;
                    id[i][j]=max_id;
                    //num[field[i][j]=='#'][max_id]=1;
                }
                REP(k,0,4){
                    ll y = i+dy[k];
                    ll x = j+dx[k];
                    if(CK(y,0,H) && CK(x,0,W)){
                        if(field[y][x] != field[i][j]){
                            if(id[y][x] > id[i][j]){
                                id[y][x] = id[i][j];
                                ok=false;
                                //num[field[y][x]=='#'][id[y][x]]++;
                            }else if(id[y][x] < id[i][j]){
                                //num[field[i][j]=='#'][id[i][j]]--;
                                //if(id[i][j]==max_id) max_id--;
                                id[i][j] = id[y][x];
                                ok=false;
                                //num[field[i][j]=='#'][id[i][j]]++;
                            }

                        }


                    }
                }
            }
        }
    }

    REP(i,0,H){
        REP(j,0,W){
            num[field[i][j]=='#'][id[i][j]]++;
        }
    }
    ll ans = 0;
    REP(i,0, 888888){
        ans+=num[0][i]*num[1][i];
    }
//    REP(i,0,H){
//        REP(j,0,W){
//            cout<<id[i][j]<<" ";
//        }
//        cout << endl;
//    }
    p(ans);
    return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<string> blue(N);
  
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> red(M);
  
  for (int j = 0; j < M; j++) {
    cin >> red.at(j);
  }
  
  int a, b = 0;
  
  for (int k = 0; k < N; k++) {
    a = 0;
    for (int l = k; l < N; l++) {
      if (blue.at(k) == blue.at(l)) {
        a++;
      }
    }
    
    for (int m = 0; m < M; m++) {
      if (blue.at(k) == red.at(m)) {
        a--;
      }
    }
    
    if (b < a) {
      b = a;
    }
  }
  cout << b << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
   long long x,y; cin >> x >> y;
   if(x*y<0) cout << abs(abs(x)-abs(y))+1 << endl;
   else if(x*y==0){
       if(x<y) cout << y-x << endl;
       else cout << x-y+1 << endl;
   }else{
       if(x<y) cout << y-x <<endl;
       else cout << x-y+2 << endl;
   }
}


Measured memory_bytes: 256
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
// #define base 100001
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld:\n", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const int N = 300010;
ll n, mem[1000005][2][2],cnt;
ll dp(ll pos, bool f1, bool f2) {
	if (pos >= n) {
		if (f1 && f2) return 1;
		else return 0;
	}
	ll &ret = mem[pos][f1][f2];
	if (~ret) return ret;
	ret=0;
	for (int i = 0; i <= 9; i++) {
		if (i == 0) ret = (ret + dp(pos + 1, 1, f2)) % MOD;
		else if (i == 9) ret = (ret + dp(pos + 1, f1, 1)) % MOD;
		else ret = (ret + dp(pos + 1, f1, f2)) % MOD;
	}
	return ret;
}
int solve() {
	cin >> n;
	memn(mem);
	printf("%lld\n", dp(0, 0, 0));
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return solve();
}

Measured memory_bytes: 128652
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 100005
int a,b,c;
int main(){scanf("%d%d%d",&a,&b,&c);if(a==b&&b==c)puts("Yes");else puts("No");}

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

int main() {
    int n;
    cin >> n;
    
    vector<int> w(n), acc(n+1);
    for (auto& e : w) cin >> e;
    for (int i = 0; i < n; i++) acc[i+1] = acc[i] + w[i];

    int ans = 1e9;
    for (int i = 1; i < n; i++) {
        ans = min(ans, abs(acc[n] - acc[i] - acc[i]));
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a[200000],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=n-1;i>=0;i-=2)printf("%d ",a[i]);
  for(i=n%2;i<n;i+=2)printf("%d ",a[i]);
}


Measured memory_bytes: 2816
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



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

    ll n,a,b;
    cin>>n>>a>>b;
    if(a >= n){
        cout << 1 << endl;
        return 0;
    }
    ll sum = a-b;
    if(sum <= 0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = (n-a) / sum;
    n -= ans*sum;
    ans *= 2;
    while(n > 0){
        n -= a;
        ans++;
        if(n <= 0)break;
        n += b;
        ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;

const int MAXN = 300005;
ll N, M, T, X, cnt, D[MAXN], E[MAXN], res[MAXN];
char _C[MAXN], C[MAXN];
pair<ll,int> A[MAXN], B[MAXN];

ll dist(ll l, ll r){
  if(l <= r) return r - l;
  return r + M - l;
}

int main(){
  cin >> N >> M >> T;
  for(int i = 0; i < N; i++){
		int x;
    cin >> X >>  x;
		X++;
		if (x == 2) {
			_C[i] = 'L';
			} else {
				_C[i] = 'R';
				}
    A[i] = make_pair(X - 1, i);
    if(_C[i] == 'L'){
      cnt -= 1;
    } else {
      cnt += 1;
    }
  }
  sort(A, A + N);
  copy(A, A + N, B);
  for(int i = 0; i < N; i++){
    C[i] = _C[A[i].second];
  }
  ll shift = T / M * cnt, offset = 0;
  shift = (shift % N + N) % N;
  T %= M;
  for(int i = 0; i < N; i++){
    B[(i + shift) % N].second = A[i].second;
    if(C[i] == 'L'){
      D[i] = (B[i].first - T + M) % M;
    } else {
      D[i] = (B[i].first + T) % M;
    }
    if(C[i] != C[0]){
      if(C[0] == 'L'){
        if(dist(B[i].first, B[0].first) < 2 * T){
          offset -= 1;
        }
        if(M + dist(B[i].first, B[0].first) < 2 * T){
          offset -= 1;
        }
      } else {
        if(dist(B[0].first, B[i].first) < 2 * T){
          offset += 1;
        }
        if(M + dist(B[0].first, B[i].first) < 2 * T){
          offset += 1;
        }
      }
    }
  }
  offset = (offset % N + N) % N;
  copy(D, D + N, E);
  sort(D, D + N);
  ll *pos;
  if(C[0] == 'L'){
    pos = upper_bound(D, D + N, E[0]) - 1;
  } else {
    pos = lower_bound(D, D + N, E[0]);
  }
  rotate(D, pos, D + N);
  for(int i = 0; i < N; i++){
    res[B[(i + offset) % N].second] = D[i];
  }
  for(int i = 0; i < N; i++){
    cout << res[i]  << "\n";
  }
  cout << '\n';
	return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N;
string s,t;

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

    int ans=0;
    rep(i,N){
        for(int j=i;j<N;j++){
            if(s[j]!=t[j-i]) goto a;
        }
        ans=N-i;
        break;
        a:;
    }

    ans=2*N-ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

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

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q, C;
signed main() {
	cin >> N >> C;
	int ans = 0;
	vector< pii > A(N), B;
	rep(i, N) cin >> A[i].first >> A[i].second;
	B = A;
	reverse(B.begin(), B.end());
	rep(i, N) B[i].first = C - B[i].first;
	vector< int > acA(N + 1, 0), acB(N + 1, 0), acA2(N + 1, 0), acB2(N + 1, 0);
	rep(i, N) {
		acA[i + 1] = acA[i] + A[i].second - (A[i].first - (i == 0 ? 0 : A[i - 1].first));
		acB[i + 1] = acB[i] + B[i].second - (B[i].first - (i == 0 ? 0 : B[i - 1].first));
		acA2[i + 1] = acA2[i] + A[i].second - (A[i].first - (i == 0 ? 0 : A[i - 1].first)) * 2;
		acB2[i + 1] = acB2[i] + B[i].second - (B[i].first - (i == 0 ? 0 : B[i - 1].first)) * 2;
	}
	vector< int > acAmax(N + 1, 0), acBmax(N + 1, 0), acA2max(N + 1, 0), acB2max(N + 1, 0);
	rep(i, N) {
		acAmax[i + 1] = max(acAmax[i], acA[i + 1]);
		acBmax[i + 1] = max(acBmax[i], acB[i + 1]);
		acA2max[i + 1] = max(acA2max[i], acA2[i + 1]);
		acB2max[i + 1] = max(acB2max[i], acB2[i + 1]);
	}
	rep(i, N + 1) {
		chmax(ans, acAmax[i] + acB2max[N - i]);
		chmax(ans, acBmax[i] + acA2max[N - i]);
	}
	//cout << acAmax << acBmax;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9600