akhauriyash/Code-Regression huggingface dataset:
/********
*	???????????? I
*********/	
/*********??¢?????´?????????
*	(1)??°????????\???
*	(2)?¨???????????????????
*********/

#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;


int main(void)
{
//	double pi=3.14159265358979;
	int dice[6]={0}; 		//?????????????????¢?????°???????????????
	int temp;	
	char c[100]={0};		//?????????????????¢?????????????????????????????????????????????
	
	for(int i=0; i< 6; i++){//6??¢??????????????????????????????
		scanf("%d", &dice[i]);
	}
	
	scanf("%s", &c);
	for(int i = 0; c[i]; i++){
		if(c[i]=='S'){
			temp    = dice[4];
			dice[4] = dice[5];
			dice[5] = dice[1];
			dice[1] = dice[0];
			dice[0] = temp;
		} else if(c[i]=='N' ){
			temp     = dice[1];
			dice[1] = dice[5];
			dice[5] = dice[4];
			dice[4] = dice[0];
			dice[0] = temp;
		} else if (c[i]=='W'){
			temp     = dice[2];
			dice[2] = dice[5];
			dice[5] = dice[3];
			dice[3] = dice[0];
			dice[0] = temp ;
		}else if(c[i]=='E'){
			temp = dice[3];
			dice[3] = dice[5];
			dice[5] = dice[2];
			dice[2] = dice[0];
			dice[0] = temp;
		}
	}
	printf("%d\n",dice[0]);
	return 0;
}

Measured memory_bytes: 1188
N = int(input())
A = list(map(int,input().split()))
count = 0

for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if A[i] != A[minj]:
        count += 1
        A[i], A[minj] = A[minj], A[i]

print(*A)
print(count)


Measured memory_bytes: 5608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

ll memo[100010];
ll pos[100010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T=1, n;
    mem1(memo);
    while (T--){
        ll x, m, sum=0;
        cin >> n >> x >> m;
        ll i = 0;
        mem1(pos);
        for (i; i < n; ++i) {
            if (pos[x] != -1) break;
            sum += x;
            memo[i] = sum;
            pos[x] = i;
            x = x*x%m;
        }
        ll left = n-i;
        sum += (sum - (pos[x] == 0 ? 0: memo[pos[x]-1]))*(left/(i-pos[x]));

        left %= (i-pos[x]);
        for (i=0; i < left; ++i) {
            sum += x;
            memo[x] = sum;
            x = x*x%m;
        }
        cout << sum << "\n";
    }
}

Measured memory_bytes: 5204
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 3632
#47
data=list(input().split())
if (int(data[0])>int(data[1]) and int(data[0])>int(data[2])):
    if int(data[0])==int(data[1])+int(data[2]):
        print('Yes')
    else:
        print('No')
elif (int(data[1])>int(data[0]) and int(data[1])>int(data[2])):
    if int(data[1])==int(data[0])+int(data[2]):
        print('Yes')
    else:
        print('No')
elif (int(data[2])>int(data[1]) and int(data[2])>int(data[0])):
    if int(data[2])==int(data[1])+int(data[0]):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9208
n, m = map(int, input().split())
l = [1] * (n + 1)
l[0] = 0 
h = list(map(int, input().strip().split()))
h.insert(0, 0)
 
for i in range(m):
  a, b = map(int, input().split())
  if h[a] == h[b] :
    l[a] = l[b] = 0
  elif h[a] < h[b]:
    l[a] = 0
  else :
    l[b] = 0
  
 
print(sum(l))

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);

int h, w, n;
int x, y;
string s, t;

string ans;

int main(void) {
  // Here your code !
  scanf("%d %d %d", &h, &w, &n);
  scanf("%d %d", &x, &y);
  cin >> s;
  cin >> t;

  ans = "YES";

  int h1 = 1, h2 = h;
  int w1 = 1, w2 = w;

  for (int i = n - 1; i >= 0; --i) {
    if (t[i] == 'D') {
      h1 = max(1, h1 - 1);
    }
    else if (t[i] == 'U') {
      h2 = min(h, h2 + 1);
    }
    else if (t[i] == 'R') {
      w1 = max(1, w1 - 1);
    }
    else { // t[i] == 'L'
      w2 = min(w, w2 + 1);
    }

    if (s[i] == 'D') {
      h2 -= 1;
    }
    else if (s[i] == 'U') {
      h1 += 1;
    }
    else if (s[i] == 'R') {
      w2 -= 1;
    }
    else { // s[i] == 'L'
      w1 += 1;
    }

    if (h1 > h2 || w1 > w2) {
      printf("NO\n");
      return 0;
    }

    // printf("%d %d : %d %d\n", h1, h2, w1, w2);
  }

  if (h1 <= x && x <= h2 && w1 <= y && y <= w2) {
    printf("YES\n");
  }
  else {
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 900
import sys
#import bisect
#from collections import deque
import math

def input():
    return sys.stdin.readline().rstrip('\n')


X,Y = list(map(int, input().split()))

if (2*X-Y) % 3:
    print(0)
    sys.exit()

if (2*Y-X) % 3:
    print(0)
    sys.exit()

M = max((2*X-Y)//3, (2*Y-X)//3)
N = min((2*X-Y)//3, (2*Y-X)//3)

if M<0 or N<0:
    print(0)
    sys.exit()
    
mod = pow(10,9) + 7

#from scipy.special import comb
#print(comb(M+N,N) % (pow(10,9) + 7))
#print(comb(M+N,N, exact=True)% (pow(10,9) + 7))  causes "RE" at atcoder
#from math import factorial
#print((factorial(M+N)//factorial(M)//factorial(N)))

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def ohmycomb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

print(ohmycomb(M+N, N, mod))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL n,m;
	cin>>n>>m;
	vector<LL> a(n);
	vector<pll> b(m);
	priority_queue<LL> pq;
	FOR(i,0,n){
		cin>>a[i];
		pq.push(a[i]);
	}
	FOR(i,0,m){
		LL aa,aaa;
		cin>>aa>>aaa;
		b[i]=MP(aaa,min(aa,n));
	}
	sort(b.begin(),b.end());
	LL cnt=0;
	FORD(i,m,0){
		int tmp=(int)(b[i].ND);
		cnt+=tmp+0LL;
		FOR(j,0,tmp){
			pq.push(b[i].ST);
		}
		if(cnt>=n)break;
	}
	LL ans=0,idx=m-1;
	FOR(i,0,n){
		LL aa=pq.top();
		pq.pop();
		ans+=aa;
		//cerr<<aa<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 059_arc_b / Link: https://abc043.contest.atcoder.jp/tasks/arc059_b?lang=en  ----- */
/* ------問題------

文字列 t について、t の長さが 2 以上であり、かつ t の中の文字のうち過半数が同じ文字であるとき、t をアンバランスであると呼ぶことにします。例えば、voodoo や melee はアンバランスであり、noon や a はアンバランスではありません。
小文字のアルファベットからなる文字列 s が与えられます。s にアンバランスな (連続する) 部分文字列が存在するか判定してください。存在する場合は、s の中でそのような部分文字列が存在する位置を一つ示してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s;
	cin >> s;

	FOR(i, 0, SZ(s) - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	FOR(i, 0, SZ(s) - 2) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！


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

  int a = N % 10;
  if(a == 3){
    cout << "bon" << endl;
  }
  else if(a == 0 || a == 1 || a == 6 || a == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

struct unionfind {
  vector<int> A;

  unionfind(int n) : A(n, -1) {}

  int find(int x) {
    if (A[x] < 0) return x;
    return A[x] = find(A[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (A[x] > A[y]) swap(x, y);
    A[x] += A[y];
    A[y] = x;
  }

  int size(int x) {
    return -A[find(x)];
  }
};


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, H, W; cin >> N >> H >> W;
  unionfind uf(H + W);
  vector<tuple<int, int, int>> es;
  rep(i, N) {
    int r, c, a; cin >> r >> c >> a; r--; c--;
    es.emplace_back(a, r, c + H);
  }
  sort(es.rbegin(), es.rend());
  vector<int> state(H + W);
  ll ans = 0;
  for (auto e : es) {
    int c, u, v;
    tie(c, u, v) = e;
    if (uf.find(u) != uf.find(v) && (state[uf.find(u)] == 0 || state[uf.find(v)] == 0)) {
      int x = state[uf.find(u)] || state[uf.find(v)];
      ans += c;
      uf.unite(u, v);
      state[uf.find(u)] = x;
    } else if (state[uf.find(u)] == 0) {
      ans += c;
      state[uf.find(u)] = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int r = in.nextInt();
            out.println(3 * r * r);
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n;
  while(cin>>n) {
    vector<tuple<string,int,int>> v;
    REP(i,n) {
      string s;
      int p;
      cin >> s >> p;
      v.push_back(tpl(s,-p,i));
    }
    sort(ALL(v));
    REP(i,n) {
      cout << get<2>(v[i])+1 << endl;
    }
  }
}


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

int main() {
  int x,a,b,xa,xb;
  cin >> x >> a >> b;
  if(x>=a) xa = x - a;
  else xa = a - x;
  
  if(x>=b) xb = x - b;
  else xb = b - x;
  
  if(xa<xb) cout << 'A';
  else cout << 'B';
  
  return 0;
}

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

const int N=2e5+10;

char ch[N];

int main() {
	scanf("%s",ch+1);
	int l=strlen(ch+1);
	int Ans=1,opt=1;
	int i;
	for(i=2;i<=l;) 
		if(!opt) Ans++,i++,opt=1;
		else if(ch[i]!=ch[i-1]) Ans++,i++;else Ans++,i+=2,opt=0;
	if(i>l+1) Ans--;
	cout<<Ans<<endl;
}
		
			
		
	

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

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  for (int i = 0; i < x; i++) cin >> a[i];
  for (int i = 0; i < y; i++) cin >> b[i];
  for (int i = 0; i < z; i++) cin >> c[i];

  vector<ll> v;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      v.push_back(a[i] + b[j]);
    }
  }
  sort(begin(v), end(v), greater<ll>());

  vector<ll> ans;
  for (int i = 0; i < min(x * y, k); i++) {
    for (int j = 0; j < z; j++) {
      ans.push_back(v[i] + c[j]);
    }
  }
  sort(begin(ans), end(ans), greater<ll>());

  for (int i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 43112
#pragma GCC optimize("O3", "unroll-loops")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ext/random>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
using namespace std;
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

class RollingHash {
 public:
  RollingHash(const std::string& s) : s_(s) { Initialize(); }
  std::pair<ull, ull> GetHash(int left, int right);

 private:
  const std::string s_;
  static ull base0_;
  static ull base1_;
  static constexpr ull mod0_ = 2020202077;
  static constexpr ull mod1_ = 2020202111;
  std::vector<ull> hash0_;
  std::vector<ull> hash1_;
  static std::vector<ull> power0_;
  static std::vector<ull> power1_;
  void Initialize();
  static __gnu_cxx::sfmt19937_64 sfmt_;
};

inline void RollingHash::Initialize() {
  size_t n = s_.size();
  hash0_.assign(n + 1, 0);
  hash1_.assign(n + 1, 0);
  for (size_t i = 0; i < n; ++i) {
    hash0_[i + 1] = (hash0_[i] * base0_ + s_[i]) % mod0_;
    hash1_[i + 1] = (hash1_[i] * base1_ + s_[i]) % mod1_;
  }
  while (power0_.size() <= n) {
    power0_.emplace_back(power0_.back() * base0_ % mod0_);
    power1_.emplace_back(power1_.back() * base1_ % mod1_);
  }
}

inline std::pair<ull, ull> RollingHash::GetHash(int left, int right) {
  ull ret0 =
      hash0_[right] + mod0_ - hash0_[left] * power0_[right - left] % mod0_;
  if (ret0 >= mod0_) ret0 -= mod0_;
  ull ret1 =
      hash1_[right] + mod1_ - hash1_[left] * power1_[right - left] % mod1_;
  if (ret1 >= mod1_) ret1 -= mod1_;
 
  return {ret0, ret1};
}

__gnu_cxx::sfmt19937_64 RollingHash::sfmt_(chrono::steady_clock::now().time_since_epoch().count());
ull RollingHash::base0_ = uniform_int_distribution<ull>(2, RollingHash::mod0_)(RollingHash::sfmt_);
ull RollingHash::base1_ = uniform_int_distribution<ull>(2, RollingHash::mod1_)(RollingHash::sfmt_);
std::vector<ull> RollingHash::power0_{1};
std::vector<ull> RollingHash::power1_{1};


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

  int n; cin >> n;
  string s; cin >> s;

  RollingHash rh(s);

  auto ok = [&](int x) -> bool{
    for (int i = 0; i + 2 * x <= n; ++i) {
      for (int j = i + x; j + x <= n; ++j) {
        if (rh.GetHash(i, i + x) == rh.GetHash(j, j + x)) {
          return true;
        }
      }
    }
    return false;
  };
 
  int low = 0, high = n / 2 + 1;
 
  while (high - low > 1) {
    int mid = (low + high) >> 1;
    if (ok(mid)) {
      low = mid;
    } else {
      high = mid;
    }
  }

  cout << low << '\n';

  return 0;
}


Measured memory_bytes: 512
#include <complex>
#include <cmath>
#include <iostream>
#include <cstdio>

using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

int main() {

  int counter = 0;
  while(true) {
    counter++;
    xy_t P[100];
    
    int n;

    cin >> n;

    if (n==0) break;
  
    for (int i = 0; i < n; i++) {
      double x, y;
      cin >> x >> y;
      P[i] = xy_t(x,y);
    }

    //center all coordinates based on first element
    for (int i = 1; i < n; i++) {
      P[i] -= P[0];
    }
  
    //calculate sum
    double sum = 0.0;
    for (int i = 1; i+1 < n ; i++) {
      xy_t  a = P[i] , b = P[i + 1];
      sum += cross_product(a, b) / 2.0;
    }
    
    printf("%d %.1f\n", counter, abs(sum));
  }
  
}

Measured memory_bytes: 1248
h, w = map(int,input().split())
c = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if i == j:continue
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

cost = 0
for i in range(h):
    for j in range(w):
        temp = a[i][j]
        if temp == -1:continue
        cost += c[temp][1]
print(cost)

Measured memory_bytes: 40668
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int N,D;
	scanf("%d %d",&D,&N);
	int times=1;
	while(D--)
		times*=100;
	int sum=times*N;
	if(N==100)
		sum+=times;
		
		
	printf("%d\n",sum);
	return 0;
 } 
 
 

Measured memory_bytes: 128
N, K = map(int, input().split())

if K == 0:
    print(N**2)
else:
    ans = 0
    for b in range(K+1, N+1):
        q = N // b
        r = N % b
        if r >= K:
            ans += (r-K+1)*(q+1) + (b-r-1)*q
        else:
            ans += (b-K)*q
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> surplus(k);
  for (int i = 1; i <= n; ++i) {
    surplus[i % k]++;
  }
  ll ans = 0;
  for (int i = 0; i < k; ++i) {
    int a = i;
    int b = (k - a) % k;
    int c = (k - a) % k;
    if((b + c) % k == 0) {
      ans += surplus[a] * surplus[b] * surplus[c];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            string[] array = str.Split(' ');
            for (int i = array.Length - 1; i > 0; i--) {
                Console.Write(array[i]);
                Console.Write(' ');
            }
            Console.Write(array[0]+"\n");

        }
    }
}


Measured memory_bytes: 15940
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200+5;
int n,m,f[2][MAXN][MAXN][MAXN],co;
char c[MAXN][MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>c[i][j];
	for(int i=m;i;i--)
		for(int u=1;u<=n;u++)
			for(int d=u;d<=n;d++)
				if(c[u][i]==c[d][i])
				{
					f[co][i][u][d]=i;
					if(c[u][i]==c[u][i+1])
						f[co][i][u][d]=max(i,f[co][i+1][u][d]);
				}
				else
					break;
	for(int ans=0;ans<=20;ans++)
	{
		if(f[co][1][1][n]==m)
		{
			cout<<ans;
			return 0;
		}
		memset(f[co^1],0,sizeof(f[co^1]));
		for(int i=1;i<=m;i++)
			for(int u=1;u<=n;u++)
				for(int d=u;d<=n;d++)
				{
					int g=f[co][i][u][d];
					if(g>0&&g<m)
						g=max(g,f[co][g+1][u][d]);
					if(u!=d)
					{
						int l=u,r=d-1,ret=l;
						while(l<=r)
						{
							int mid=(l+r)>>1;
							if(f[co][i][u][mid]>=f[co][i][mid+1][d])
								ret=mid,l=mid+1;
							else
								r=mid-1;
						}
						g
						=max(g,min(f[co][i][u][ret],f[co][i][ret+1][d]));
						ret++;
						if(ret<d)
							g=max(g,min(f[co][i][u][ret],f[co][i][ret+1][d]));
					}
					f[co^1][i][u][d]=g;
				}
		co^=1;
	}
	return 0;
}

Measured memory_bytes: 67584
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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 dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a,ans;

int main()
{
	ll n, x;
	ll s = 0;
	cin >> n;
	ans.push_back(0);
	for (ll i = 0; i < n; i++){
		ll tmp;
		cin >> tmp;
		a.push_back(tmp);
		ans.push_back(tmp);
	}
	ans.push_back(0);

	for (ll i = 0; i < n+1; i++) {
		s += abs(ans[i] - ans[i + 1]);
	}
	
	for (ll i = 1; i < n+1; i++) {
		ll tmp = s + abs(ans[i - 1] - ans[i + 1]) - (abs(ans[i - 1] - ans[i]) + abs(ans[i] - ans[i + 1]));
		cout << tmp << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3052
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

print(sum([abs(z) for z in [y - x for x, y in zip(x, y)]]))
print(sum([(y - x) ** 2 for x, y in zip(x, y)]) ** 0.5)
print(sum([abs(z) for z in [(y - x) ** 3 for x, y in zip(x, y)]]) ** (1/3))
print(max([abs(z) for z in [y - x for x, y in zip(x, y)]]))


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

using namespace std;

int n,a,b,i,j;
bool ok[100005];
char s[100005];

int main(){
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s);
	int pass = 0;
	int cnt = 0;
	for(i = 0; i < n; i++){
		if(s[i] == 'a'){
			if(pass < a + b){
				ok[i] = 1;
				pass++;
			}
		}
		else if(s[i] == 'b'){
			cnt++;
			if(pass < a + b && cnt <= b){
				ok[i] = 1;
				pass++;
			}
		}
	}
	
	for(i = 0; i < n; i++){
		if(ok[i])
		printf("Yes\n");
		else
		printf("No\n");
	}
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  int max_k = 1000000000;

  rep(i, max_k){
    if (abs(A - i) == abs(B - i)){
      cout << i << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3632
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define cs const int &
const int N=5005,MOD=1e9+7;

inline int Add(cs a,cs b){return a+b>=MOD? a+b-MOD:a+b;}
inline int Sub(cs a,cs b){return a-b<0? a-b+MOD:a-b;}
inline int Mul(cs a,cs b){return 1ll*a*b%MOD;}
inline int Pow(int a,int b){int r=1;while(b){if(b&1)r=Mul(r,a);a=Mul(a,a),b>>=1;}return r;}
inline int Ri(){
	register int r=0,c=getchar();
	while(c<'0' || '9'<c) c=getchar();
	while('0'<=c && c<='9') r=(r<<1)+(r<<3)+c-'0',c=getchar();
	return r;
}

struct GRAPH{
	int head[N],to[N<<1],nxt[N<<1],ncnt;
	void AddEdge(cs u,cs v){
		int p=++ncnt,q=++ncnt;
		to[p]=v,nxt[p]=head[u],head[u]=p;
		to[q]=u,nxt[q]=head[v],head[v]=q;
	}
	int operator [](cs u){return head[u];}
}Gr;

int n;
int g[N],f[N][N],siz[N],tmp[N];

void DP(int u,int fa){
	siz[u]=1;
	f[u][1]=1;
	for(int it=Gr[u];it;it=Gr.nxt[it]){
		int v=Gr.to[it];
		if(v==fa) continue;
		DP(v,u);
		for(int i=1;i<=siz[u];i++)
			for(int j=1;j<=siz[v];j++){
				tmp[i+j]=Add(tmp[i+j],Mul(f[u][i],f[v][j]));
				tmp[i]=Sub(tmp[i],Mul(f[u][i],Mul(f[v][j],g[j])));
			}
		siz[u]+=siz[v];
		for(int i=1;i<=siz[u];i++) f[u][i]=tmp[i],tmp[i]=0;
	}
}
int main(){
	g[2]=1;
	for(int i=3;i<N;i++) g[i]=Mul(g[i-2],(i-1));
	n=Ri();
	for(int i=1;i<n;i++) Gr.AddEdge(Ri(),Ri());
	DP(1,0);
	int ans=g[n];
	for(int i=1;i<n;i++)
		ans=Add(ans,Mul(g[i],f[1][i]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 56264
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=MI()
    u-=1
    v-=1
    tree[u].append([v,w])
    tree[v].append([u,w])
q=deque([[0,0]])
al=[-1 for i in range(n)]
al[0]=0
col=[0 for i in range(n)]
while q:
    a,b=q.popleft()
    #print(a,b)
    for x,y in tree[a]:
        if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col)
for i in range(n):
    print(str(col[i]))

    
    


Measured memory_bytes: 46956
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1E5;
const int MAXH = 1E4;
int n;
int h[MAXN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	forn(i, n) cin >> h[i];
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	forr(i, 2, n)
	{
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout << dp[n-1];

	
	return 0;
}

Measured memory_bytes: 1024
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

k=n0()
a,b=n1()
ans="NG"
for i in range(a,b+1):
    if i%k==0:
        ans="OK"
print(ans)

Measured memory_bytes: 9200
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 200005
#define INF 1000000009

int n, a, b, v[NMAX];

int main (){
    
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) {
        scanf("%d",&v[i]);
    }
    sort(v + 1, v + n + 1);
    for(int i = n; i > 1; i--) {
        if(v[i] == v[i - 1]) {
            if(!a)
                a = v[i];
            else if(!b) {
                b = v[i];
                break;
            }
            i--;
        }
    }
    
    printf("%lld\n", (long long)a * b);
    
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int A, B;

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

  int sum = 0;
  for (int i = 0; i < 2; i++) {
    if (A > B) {
      sum += A;
      A--;
    } else {
      sum += B;
      B--;
    }
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

string s,t;
vector<int> v[30];

signed main(){
    cin>>s>>t;
    for(int i=0;i<s.size();++i)v[s[i]-'a'].push_back(i);
    int front=-1;
    int k=0;
    int cnt=0;
    while(k<t.size()){
        int c=t[k]-'a';
        if(v[c].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        int idx=lower_bound(v[c].begin(),v[c].end(),front+1)-v[c].begin();
        if(idx==v[c].size()){
            cnt++;
            front=-1;
        }
        else {
            k++;
            front=v[c][idx];
        }
    }
    cout<<cnt*s.size()+front+1<<endl;
}

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

using namespace std;
vector<int> a[60];
int dfn[60];
int low[60];
int sp[60];
int vis[60];
int cnt=1;
int dig=0;
void tarjan(int w,int u){
    vis[u]=1;
    low[u]=dfn[u]=(cnt++);
    for(int i=0;i<a[u].size();i++){
        int v = a[u][i];
        if(v==w) continue;
        if(vis[v]!=1) tarjan(u,v);
        if(vis[v]==1) low[u]=min(low[u],low[v]);
    }
    if(low[u]==dfn[u]){
        dig++;
    }
}
void init(){
    memset(dfn,0,sizeof dfn);
    memset(low,0,sizeof low);
    memset(vis,0,sizeof vis);
    memset(sp,0,sizeof sp);
}
int main()
{
    int n,m;
    cin>>n>>m;
    init();
    for(int i=0;i<m;i++){
        int k1,k2;
        cin>>k1>>k2;
        a[k1].push_back(k2);
        a[k2].push_back(k1);
    }
    tarjan(1,1);
    cout<<dig-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

template <class T>
bool contain(const string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    int sum = 0;
    rep(i, t){ 
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    int sum1 = sum - a[t - 1];
    int sum2 = a[t - 1];
    int ans = abs(sum1-sum2);
    rep(i, t)
    {
        sum1 -= a[i];
        sum2 += a[i];
        ans = min(ans, abs(sum1 - sum2));
    }

    cout << max(0,ans-1) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

llint PascalT[70][70] = {};

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var S = ReadText();

            var hasPair = new bool[N];
            for (int i = 0; i < N; i++)
            {
                if (hasPair[i]) continue;

                var from = S[i];
                var isL = from == '(';
                for (int j = i + 1; j < N; j++)
                {
                    if (hasPair[j]) continue;

                    var to = S[j];
                    var isR = to == ')';
                    if (isL && isR)
                    {
                        hasPair[i] = true;
                        hasPair[j] = true;
                        break;
                    }
                }
            }
            var noPairLCount = 0;
            var noPairRCount = 0;
            for (int i = 0; i < N; i++)
            {
                if (!hasPair[i])
                {
                    if (S[i] == '(')
                    {
                        noPairLCount++;
                    }
                    else
                    {
                        noPairRCount++;
                    }
                }
            }

            return new string('(', noPairRCount) + S + new string(')', noPairLCount);
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27428
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

void dfs(ll now, ll max_upto, vector<ll>& dp, vector<ll>& ans, vector<vector<ll>>& tree, vector<ll>& As, vector<bool>& visited) {
    visited[now] = true;
    auto it = partition_point(dp.begin(), dp.end(), [now, &As](ll x){ return x < As[now]; });
    ll end_now = distance(dp.begin(), it);
    ll bak = dp[end_now];
    dp[end_now] = min(bak, As[now]);
    max_upto = max(max_upto, end_now);
    ans[now] = max_upto;
    for (ll to : tree[now]) {
        if (visited[to]) {
            continue;
        }
        dfs(to, max_upto, dp, ans, tree, As, visited);
    }
    dp[end_now] = bak;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> As(N);
    rep(i,0,N) {
        cin >> As[i];
    }
    vector<vector<ll>> tree(N);
    rep(i,0,N-1) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    vector<ll> dp(N+1, numeric_limits<ll>::max());
    dp[0] = numeric_limits<ll>::min();
    vector<ll> ans(N);
    vector<bool> visited(N);
    dfs(0, 0, dp, ans, tree, As, visited);
    rep(i,0,N) {
        cout << ans[i] << endl;
    }
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    ll n;
    ll ans;
    cin >> n;
    
    ans = mod_pow(10, n, MOD);
    ans -= 2*mod_pow(9, n, MOD);
    ans %= MOD;
    ans += mod_pow(8, n, MOD);
    ans %= MOD;
    
    if(ans<0) cout << ans+MOD;
    else cout << ans;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
ll MOD=1e9+7;

ll power(ll a,ll x){
    ll res=1;
  while(x>0){
    if(x&1) res=res*a%13;
    a=a*a%13;
    x>>=1;
  }
    return res;
}

int main(){
    string s;cin>>s;
    int n=(int)s.size();
    vector<vector<ll> > dp(n+1,vector<ll>(13,0));
    dp[n][0]=1;
    for(int i=n;i>0;i--){
        for(int j=0;j<13;j++){
            if(s[i-1]=='?'){
                for(int d=0;d<10;d++){
                    dp[i-1][(d*power(10,n-i)+j)%13]+=dp[i][j];
                    dp[i-1][(d*power(10,n-i)+j)%13]%=MOD;
                }
            }else{
                int d=(int)(s[i-1]-'0');
                dp[i-1][(d*power(10,n-i)+j)%13]+=dp[i][j];
                dp[i-1][(d*power(10,n-i)+j)%13]%=MOD;
            }
        }
    }
    cout<<dp[0][5]<<endl;
    return 0;
}

Measured memory_bytes: 16616
def calc(n, v):
    m1 = {}
    m2 = {}
    for i in range(0, n, 2):
        m1[v[i]] = 1 + (m1[v[i]] if v[i] in m1 else 0)
    for i in range(1, n, 2):
        m2[v[i]] = 1 + (m2[v[i]] if v[i] in m2 else 0)
    m1a = [(k, m1[k]) for k in m1]
    m1a.sort(key=lambda p: -p[1])
    m2a = [(k, m2[k]) for k in m2]
    m2a.sort(key=lambda p: -p[1])
    if (len(m1a) == 1):
        if (len(m2a) == 1):
            return m1a[0][1] if m1a[0][0] == m2a[0][0] else 0
        else:
            if (m1a[0][0] == m2a[0][0]):
                return n // 2 - m2a[1][1]
            else:
                return n // 2 - m2a[0][1]
    else:
        if(len(m2a) == 1):
            if (m1a[0][0] == m2a[0][0]):
                return n // 2 - m1a[1][1]
            return n // 2 - m1a[0][1]
        else:
            a = m1a[0][1] + (m2a[1][1] if m1a[0][0] ==
                             m2a[0][0] else m2a[0][1])
            b = m2a[0][1] + (m1a[1][1] if m1a[0][0] ==
                             m2a[0][0] else m1a[0][1])
            return n - a if a > b else n - b


n = int(input())
v = [int(s) for s in input().split()]
print(calc(n, v))

Measured memory_bytes: 20648