akhauriyash/Code-Regression huggingface dataset:
(* 横一列のn個の整数の入力を、配列に格納する *)
let i_inp_array : 'a array -> int -> unit = fun a n ->
  let rec loop i =
    if i = n then ()
    else
      (a.(i) <- (Scanf.scanf " %d" (fun x -> x));
       loop (i + 1))
  in loop 0

let floop init_v init_i condition acc body =
  let rec loop i v =
    if condition i then loop (acc i) (body i v)
    else v
  in
  loop init_i init_v
   
(* ocamlc str.cma main.ml でコンパイルできる *)
let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let a = Array.make n 0 in
  let () = i_inp_array a n in
  let b = Array.make n 0 in
  let sum = floop 0 0 (fun i -> i < n) (fun i -> i + 1) (fun i v -> v + a.(i)) in
  for i = 0 to (n - 1) do
    if i = 0 then b.(i) <- a.(i)
    else
      b.(i) <- b.(i - 1) + a.(i)
  done;
  let l = floop [] 0 (fun i -> i < n - 1) (fun i -> i + 1) (fun i v -> (abs (b.(i) - (sum - b.(i)))) :: v) in
  let ans = List.fold_right min l 2020202020000 in
  print_int ans;
  print_newline ()


Measured memory_bytes: 15364
#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string.h>


typedef long long int ll;
using namespace std;

int main(void)
{
	double f;
	int d,a,b,r;

	cin >> a >> b;

	d = a / b;
	r = a%b;
	f = (double)a / b;

	cout << d << ' ' << r<<' ';
	printf("%lf\n", f);
	return 0;
}


Measured memory_bytes: 3224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=2e6+1; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX],sinv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  sinv[0]=0,sinv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
    sinv[i]=(sinv[i-1]+inv[i]%mod)%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

ll dp[500010];

int main(){
  cominit();
  ll n,m; cin >> n >> m;
  dp[0]=1;
  dp[1]=m-n;
  dp[2]=(1+(m-n)*2+(m-n)*(m-n-1))%mod;
  for(ll i=3;i<=n;i++){
    dp[i]=((m-n+i-1)*dp[i-1]+(i-1)*dp[i-2])%mod;
  }
  ll ans=dp[n]*fac[m]%mod*finv[m-n]%mod;
  cout << ans << endl;
}

Measured memory_bytes: 69848
import java.util.*;
import java.awt.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int X = sc.nextInt();
    int ans = Math.abs(sc.nextInt() - X);

    for (int i = 1; i < n; i++) {
      int diff = Math.abs(sc.nextInt() - X);
      ans = gcd(ans, diff);
    }

    System.out.println(ans);
  }

  public static int gcd(int m, int n) {
      if(m < n) return gcd(n, m);
      if(n == 0) return m;

      return gcd(n, m % n);
  }
}


Measured memory_bytes: 47792
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int flag=0;
		while(sc.hasNext())
		{
			int st = sc.nextInt();
			int fi = sc.nextInt();
			if(st==0 && fi==0)
				return;
			if(flag!=0)
				System.out.println();
		
			boolean judge = true;
			for(int i = st; i<=fi; i++)
			{
				if(i%4==0 && i%100!=0)
				{
					System.out.println(i);
					judge = false;
					continue;
				}
				else if(i%400==0)
				{
				System.out.println(i);
				judge = false;
				}
			}
			if(judge)
				System.out.println("NA");
			flag=1;
		}	
	}
}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, q;
vector<int>e[300000];
int a[300000];
bool b[300000];
signed main() {
	cin >> n >> q;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for (int i = 0; i < q; i++) {
		int u, v;
		cin >> u >> v;
		a[u] += v;
	}
	queue<int>que;
	que.push(1);
	while (!que.empty()) {
		int t = que.front(); que.pop();
		b[t] = 1;
		for (auto v : e[t]) {
			if (!b[v]) {
				a[v] += a[t];
				que.push(v);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << (i == n ? "\n" : " ");
	}
}

Measured memory_bytes: 21104
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		char S[][] = new char[H][W];
		for(int i=0; i<H; i++) {
			S[i] = sc.next().toCharArray();
		}

		int L[][] = new int[H][W];
		int R[][] = new int[H][W];
		int U[][] = new int[H][W];
		int D[][] = new int[H][W];

		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				char c = S[i][j];
				if(c=='#') {
					L[i][j]=0;
					U[i][j]=0;
				}else {
					if(j-1>=0) {
						L[i][j] = L[i][j-1]+1;
					}else {
						L[i][j] = 1;
					}

					if(i-1>=0) {
						U[i][j] = U[i-1][j]+1;
					}else {
						U[i][j] = 1;
					}
				}
			}
		}
		for(int i=H-1; i>=0; i--) {
			for(int j=W-1; j>=0; j--) {
				char c = S[i][j];
				if(c=='#') {
					R[i][j]=0;
					D[i][j]=0;
				}else {
					if(j+1<W) {
						R[i][j] = R[i][j+1]+1;
					}else {
						R[i][j] = 1;
					}
					if(i+1<H) {
						D[i][j] = D[i+1][j]+1;
					}else {
						D[i][j] = 1;
					}
				}
			}
		}
		int ans = 0;
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				ans = Math.max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 113560
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

ll int N,M;
ll int L[100004],R[100004];
ll int A[100004];
int main(void){
    scanf("%lld %lld",&N,&M);
    ll int ans=0;
    rep(i,M){
        scanf("%lld %lld",&L[i],&R[i]);
        A[L[i]-1]++;A[R[i]]--;
    }
    rep(i,N){
        if(i>0)A[i]+=A[i-1];
        if(A[i]>=M)ans++;
    }
    printf("%lld",ans);
}


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

using namespace std;
typedef long long int ll;

#define p(V) for(int iiv=0;iiv<V.size();iiv++) cout<<V[iiv]<<" ";
#define mp make_pair
#define pb push_back
#define graph vector<vector<int> >
#define pf first
#define ps second
#define pq priority_queue
const int N = 2e5;
const int l = 18;
const double pi = acos(-1);
struct d{
    int a , b , c;
    d(){
        a=b=c=0;
    }
};
int dp[N][1<<3];
int n;
vector<d> day;
int main(){   
    cin >> n;
    day.resize(n);
    for(int i=0;i<n;i++) cin>>day[i].a>>day[i].b>>day[i].c;
    dp[n-1][1<<0] = day[n-1].a;
    dp[n-1][1<<1] = day[n-1].b;
    dp[n-1][1<<2] = day[n-1].c;
    for(int i=n-2;i>=0;i--){
        dp[i][1<<0] = day[i].a + max(dp[i+1][1<<1],dp[i+1][1<<2]);
        dp[i][1<<1] = day[i].b + max(dp[i+1][1<<0],dp[i+1][1<<2]);
        dp[i][1<<2] = day[i].c + max(dp[i+1][1<<0],dp[i+1][1<<1]);
    }
    cout<<max(dp[0][1<<0],max(dp[0][1<<1],dp[0][1<<2]));
    return 0;
}


Measured memory_bytes: 5504
from collections import defaultdict

n,k = map(int, input().split())
dic = defaultdict(int)
prev = []
if n%k==0:
    print(0)
    exit()

    


while True:
    if n > k:
        m = n//k
        ab=n-m*k
    else:
        ab = abs(n-k)
    if dic[ab] == 0:
        prev.append(ab)
        dic[ab] = 1
        n = ab
    else:
        prev.sort()
        break

print(prev[0])



Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

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


Measured memory_bytes: 256
while 1:
    n = int(input())
    if n==0: break
    if n==1: print(1, 1); continue
    a = [0]
    b = [0]
    for i in range(n-1):
        m, d = map(int,input().split())
        if d == 0:
            a.append(a[m]-1)
            b.append(b[m])
        elif d == 1:
            a.append(a[m])
            b.append(b[m]-1)
        elif d == 2:
            a.append(a[m]+1)
            b.append(b[m])
        else:
            a.append(a[m])
            b.append(b[m]+1)
    print(max(a)-min(a)+1, max(b)-min(b)+1)



Measured memory_bytes: 5612
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;

int main()
{
	char s;
	cin >> s;

	if (isupper(s))
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "a" << endl;
	}

	return 0;
}

Measured memory_bytes: 3032
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<stack>
#include<vector>
//#include<conio.h>
#include<string>
#include<map>
#include<cstdlib>
#include<queue>
#include<math.h>
#include<time.h>
#include<set>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
using namespace std;
inline int read(){
	int ans=0,flag=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
	if(ch=='-') flag=-1,ch=getchar();
	while(ch>='0'&&ch<='9'){
		ans=(ans<<1)+(ans<<3)+(ch^'0');
		ch=getchar();
	}
	return ans*flag;
}
int a,b,c,x,ans;
int main(){
	a=read(),b=read(),c=read(),x=read();
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*500+j*100+k*50==x) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int x, y, i, ans;

  while(scanf("%d %d", &x, &y) != EOF){
    i = 0;
    ans = x + y;
    while(ans > 0){
      ans /= 10;
      i++;
    }    
    
    printf("%d\n", i);
  }
    
  return(0);
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;

int a[(int)1e5];
int rui[(int)1e5+1];

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

	int n,m;
	cin >> n >> m;

	int tmp;
	for(int i=0;i<n;i++){
		cin >> tmp;
		a[i] = tmp % m;
	}

	for(int i=1;i<=n;i++){
		rui[i] = (rui[i-1]+a[i-1]) % m;
	}

	sort(rui,rui+n+1);
//	cout << "\n";
//	for(int i=0;i<n+1;i++){
//		cout << rui[i] << "\n";
//	}
//	cout << "\n";

	long long ans = 0;
	for(int i=0;i<n+1;){
		auto up = upper_bound(rui+i,rui+n+1,rui[i]);
		for(int j=up-(rui+i)-1;j>0;j--){
			ans += j;
		}
		i = up-rui;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i,m,n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main()
{
  string s;
  cin >> s;
  int ans = 700;
  REP(i,3) {
    if(s[i] == 'o') {
      ans += 100;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sf scanf
#define pf printf
#define REP(i,n) for (int (i) = 0;(i) < (n);++(i))
#define FORN(i,a,b) for (int i = (a);i <=(b); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define SORT(list) sort(ALL((list)));
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SIZE(x) ((int)(x).size())
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
 
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
    IOS
    ll n,a,b;
    cin>>n>>a>>b;
    ll rem = n%(a+b);
    ll ans = a * (n/(a+b)) + min(rem,a);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int k;
    cin >> k;

    while (a >= b) b *= 2, k--;
    while (b >= c) c *= 2, k--;

    cout << (k >= 0 ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
int N ;
cin >> N;
int M = N -1;
vector<int> A(M);
for(int i = 0; i < M; i++)cin >> A.at(i);
int a_joushi[200100] = {0};
for(int i = 0; i < M; i++){
  a_joushi[A.at(i)]++;
}
for(int i = 1; i < N+1; i++){
  cout << a_joushi[i] <<endl;
}
}

Measured memory_bytes: 4836
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c; cin >> a >> b >> c;
    cout << c / a * b << '\n';
    return 0;
}


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

	typedef long long ll;
using namespace std;

#include <complex>
namespace FFT{
	// blog.myungwoo.kr/54
	typedef complex<double> base;
 
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
 
	const double C_PI = acos(-1);
 
	void fft(vector <base> &a, bool invert){
		int n = sz(a);
		for(int i=0,j=0;i<n;++i) {
			if(i>j) swap(a[i],a[j]);
			for(int k=n>>1;(j^=k)<k;k>>=1);
		}
		for (int len=2;len<=n;len<<=1){
			double ang = 2*C_PI/len*(invert?-1:1);
			base wlen(cos(ang), sin(ang));
			for (int i=0;i<n;i+=len){
				base w(1);
				for (int j=0;j<len/2;j++){
					if((j & 127) == 127)w = base(cos(ang * j), sin(ang * j));	//오차가 클 경우 이 빈도를 늘린다. cos, sin 함수는 시간 부담이 있으니 주의
					base u = a[i+j], v = a[i+j+len/2]*w;
					a[i+j] = u+v;
					a[i+j+len/2] = u-v;
					w *= wlen;
				}
			}
		}
		if (invert){
			for (int i=0;i<n;i++) a[i] /= n;
		}
	}
 
	void multiply_big(const vector<int> &a,const vector<int> &b, vector <ll> &res){
		// 단순히 오차가 심해 구하지 못하는 경우
		// 결과값은 long long 범위 안
		int n = 1;
		while (n < max(sz(a),sz(b))) n <<= 1; n <<= 1;
		vector <base> A(n), B(n);
		int L_BLOCK = 10;
		for(int i=0;i<n;i++) A[i] = (i < sz(a) ? base(a[i] & ((1<<L_BLOCK)-1), a[i] >> L_BLOCK) : base(0));
		for(int i=0;i<n;i++) B[i] = (i < sz(b) ? base(b[i] & ((1<<L_BLOCK)-1), b[i] >> L_BLOCK) : base(0));
		fft(A, false); fft(B, false);
		vector <base> f1(n), f2(n), f3(n), f4(n);
		for(int i=0;i<n;i++) {
			int j=(n-i)&(n-1);
			f2[i]=(A[i]+conj(A[j]))*base(0.5,0);
			f1[i]=(A[i]-conj(A[j]))*base(0,-0.5);
			f4[i]=(B[i]+conj(B[j]))*base(0.5,0);
			f3[i]=(B[i]-conj(B[j]))*base(0,-0.5);
		}
		for(int i=0;i<n;i++) {
			A[i]=f1[i]*f3[i]+f1[i]*f4[i]*base(0,1);
			B[i]=f2[i]*f4[i]*base(0,1)+f2[i]*f3[i];
		}
		fft(A, true); fft(B, true);
		res.resize(n);
		for(int i=0;i<n;i++) {
			ll g1=(ll)round(A[i].real());
			ll g2=(ll)round(A[i].imag());
			ll g3=(ll)round(B[i].real());
			ll g4=(ll)round(B[i].imag());
			res[i] = (g4 + ((g2+g3)<<(L_BLOCK)) + (g1<<(L_BLOCK<<1)));
		}
	}
}
int Z[201000], n, U[201000];
int main(){
    int i, j, Mod = 200003, G=0;
    for(i=2;;i++){
        int t=1;
        for(j=1;;j++){
            t=1ll*t*i%Mod;
            if(t==1)break;
        }
        if(j==Mod-1){
            G=i;
            break;
        }
    }
    long long t=1;
    for(i=1;i<=Mod-1;i++){
        t=t*G%Mod;
        Z[t] = i;
        U[i]=t;
    }
    U[0]=1;
    Z[1]=0;
    scanf("%d",&n);
    vector<int>P(200003);
    vector<ll>res;
    long long r=0;
    for(i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        if(a==0)continue;
        P[Z[a]]++;
        r-=1ll*a*a%Mod;
    }
    FFT::multiply_big(P,P,res);
    for(i=0;i<res.size();i++){
        r += 1ll*res[i]*U[i%(Mod-1)];
    }
    r/=2;
    printf("%lld\n",r);
}

Measured memory_bytes: 59380
from collections import deque
import sys


def bfs(s, trail):
    q = deque()
    q.append((s, 0))
    trail[s] = 0
    while q:
        p, step = q.popleft()
        for np in edge[p]:
            nstep = step + 1
            if trail[np] > nstep:
                q.append((np, nstep))
                trail[np] = nstep


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)


INF = 10 ** 9
path0 = [INF] * N
pathN = [INF] * N

bfs(0, path0)
bfs(N - 1, pathN)

fennec = 0
snuke = 0
for i in range(N):
    if path0[i] <= pathN[i]:
        fennec += 1
    else:
        snuke += 1

ans = 'Fennec' if fennec > snuke else 'Snuke'
print(ans)


Measured memory_bytes: 69680
#include <iostream>
using namespace std;
    string convertToTitle(long long int n) {
        string out="";
        while(n){
            n--;
            out = char((n%26)+'a') + out;
            n/=26;
        }
        return out;
    }

int main() {
	long long int str;
	cin>>str;
	cout<<convertToTitle(str);
	return 0;
}


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

int main(){
  long long N;cin>>N;
  long long S=(N*(N+1))/2;
  long long F=(N/3)*(N/3+1)*3/2;
  long long B=(N/5)*(N/5+1)*5/2;
  long long FB=(N/15)*(N/15+1)*15/2;
  cout << S-F-B+FB <<endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> cnts(10001, 0);
  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j < 101; ++j) {
      for (int k = 1; k < 101; ++k) {
        int a = i * i + j * j + k * k;
        a += (i * j) + (j * k) + (i * k);
        if (a >= cnts.size()) {
          continue;
        }

        cnts[a]++;
      }
    }
  }

  for (int i = 1; i <= n; ++i) {
    cout << cnts[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(void){
  int n, m, b, i, j, x;
  int a[100], ans[100] = {0};
  scanf("%d", &n);
  scanf("%d", &m);
  //printf("%d\n%d\n", n, m);
  for(i = 0; i < m; i++){
    scanf("%d", &a[i]);
    //printf("%d ", a[i]);
  }
  //printf("\n");
  for(i = 0; i < m; i++){
    x = 0;
    for(j = 0; j < n; j++){
      scanf("%d", &b);
      //printf("%d ", b);
      if(b == a[i]){ ans[j]++; }
      else{ x++; }
    }
    //printf("\n");
    ans[a[i]-1] += x;
  }

  for(i = 0; i < n; i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 100;
ll a[maxn];
int main(){
	ll k;
	cin >> k;
	if (k < 10) cout << k << endl, exit(0);
	ll x = 10, cnt = 10;
	a[1] = 0; a[2] = 1;
	int len = 2;
	while (cnt < k){
		int h = 0;
		for (int i = 1; i <= len; i++){
			if (a[i] != 9){
				h = 1;
				break;
			}
		}
		if (h == 0){
			len++;
			a[len] = 1;
			for (int i = 1; i < len; i++) a[i] = 0;
			cnt++; continue;
		}


		a[1]++;
		if (a[1]>9){
			a[1] = 9;
			h = 0;
			for (int i = 1; i < len; i++){
				if ((a[i] - a[i + 1]) < 1&&a[i]<9){
					h = 1;
					a[i]++;
					for (int j = i - 1; j >= 1; j--){
						if (a[j + 1])		a[j] = a[j + 1] - 1;
						else		a[j] = 0;
					}
					break;
				}
			}
			if (h) cnt++;
			else{
				if (a[len] == 9){
					len++;
					a[len] = 1;
					for (int i = 1; i < len; i++) a[i] = 0;
				}
				else{
					a[len]++;
					for (int i = len - 1; i >= 1; i--){
						if (a[i + 1]) a[i] = a[i + 1] - 1;
						else a[i] = 0;
					}
				}
				cnt++;
			}
			continue;
		}
		int flag = 0;
		for (int i = 1; i < len; i++){
			if (abs(a[i] - a[i + 1])>1){
				flag = 1;
				break;
			}
		}
		if (!flag) cnt++;
		else{
			int g = 0;
			for (int i = 1; i < len; i++){
				if ((a[i] - a[i + 1]) < 1){
					g = 1;
					a[i]++;
					for (int j = i - 1; j >= 1; j--){
						if (a[j + 1])		a[j] = a[j + 1] - 1;
						else		a[j] = 0;
					}
					break;
				}
			}
			if (g) cnt++;
			else{
				if (a[len] == 9){
					len++;
					a[len] = 1;
					for (int i = 1; i < len; i++) a[i] = 0;
				}
				else{
					a[len]++;
					for (int i = len - 1; i >= 1; i--){
						if (a[i + 1]) a[i] = a[i + 1] - 1;
						else a[i] = 0;
					}
				}
				cnt++;
			}
		}

// 		for (int i = len; i >= 1; i--)
// 			cout << a[i];
// 		cout << endl;
	}
	for (int i = len; i >= 1; i--)
		cout << a[i];
	cout << endl;
	return 0;
}

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

int main(void) {
  string s;
  cin >> s;

  // すべてのWについて、それより左にあるBの数を数えて
  // 全部足した数が、求める値。
  long long n = 0;
  long long r = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      n++;
    } else {
      r += n;
    }
  }

  cout << r << endl;
  return 0;
}

Measured memory_bytes: 640
W,H,N = gets.split.map(&:to_i)
x,y,a = N.times.map { gets.split.map(&:to_i) }.transpose

# 初期状態の長方形
A = H.times.map { '0' * W }

N.times do |i|
  case a[i]
  when 1
    H.times do |n|
      (0...x[i]).each { |j| A[n][j] = '1' }
    end
  when 2
    H.times do |n|
      ((x[i])..(W-1)).each { |j| A[n][j] = '1' }
    end
  when 3
    (y[i]).times { |j| A[j] = '1' * W }
  when 4
    ((y[i])..H).each { |j| A[j] = '1' * W }
  end
end

# 0の数を足し合わせる
p H.times.map { |i| A[i].count('0') }.inject(:+)

Measured memory_bytes: 1916
from collections import defaultdict

N = int(input())

cnt = defaultdict(int)
for i in range(1, N + 1):
    i = str(i)
    l = i[0]
    r = i[-1]
    cnt[(l, r)] += 1
    cnt[(r, l)] += 0

ans = 0
for (l, r), c in cnt.items():
    ans += cnt[(r, l)] * c

print(ans)


Measured memory_bytes: 9420
N = gets.to_i
z = readlines(chomp:true).map{|line| line.split.map(&:to_i)}
ary = []
num = (1..N).to_a    #必ずこれを作ってからpermutation
per = num.permutation(N).to_a     #これで各順列を全て配列perに格納した
dis = 0
for i in 0.. per.size-1
  new = per[i]
  for k in 0..N-2
    x = z[(new[k]-1)][0]-z[(new[k+1]-1)][0]
    y = z[(new[k]-1)][1]-z[(new[k+1]-1)][1]
    dis += Math.sqrt(x**2+y**2)
  end
end
puts dis.to_f/per.size

Measured memory_bytes: 21592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
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){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    string s;
    cin >> s;
    pf(s.substr(0,3));
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=0,a=0,K=0,b=0,c=0,ans=0;
    string str;
    int mid;
    vector<int> retu(3);
    cin>>retu[0]>>retu[1]>>retu[2];
    cin>>K;

    sort(retu.begin(),retu.end());

    for(int i=0;i<K;i++){
        retu[2]*=2;
    }

    ans=retu[0]+retu[1]+retu[2];

    cout<<ans<<endl;

}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int res = 0, count = 0;
    for (char c : s) {
        switch (c) {
        case 'I':
            count++;
            break;
        case 'D':
            count--;
            break;
        }
        res = max(res, count);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class BinaryIndexTree:
    def __init__(self, n):
        self.size = n
        self._container = [0] * (n + 1)
        self.depth = n.bit_length()

    def sum(self, i):
        if i == 0:
            return 0
        s = 0
        while i > 0:
            s += self._container[i]
            i -= i & (-i)
        return s

    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self._container[i] += x
            i += i & (-i)

    def lower_bound(self, x):
        if x == 0:
            return 0

        s = 0
        idx = 0
        for i in range(self.depth, -1, -1):
            k = idx + (1 << i)
            if k <= self.size and s + self._container[k] < x:
                s += self._container[k]
                idx += 1 << i
        return idx + 1

    def __repr__(self):
        return str(self._container)


def main():
    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    bit = BinaryIndexTree(2000)

    p = 0
    q = 0
    for x in a[::-1]:
        p += bit.sum(x - 1)
        bit.add(x, 1)

    for i in range(2, 2001):
        q += (bit.sum(i) - bit.sum(i - 1)) * bit.sum(i - 1)

    ans = p * k + q * (k - 1) * k // 2
    print(ans % MOD)


if __name__ == '__main__':
    main()


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

int main(){
  int n; cin >>n;
  long R=0, G=0, B=0;
  vector<char> s(n+1);
  for(int i=1; i<=n; i++){
    cin >>s[i];
    if(s[i]=='G') G++;
    if(s[i]=='R') R++;
    if(s[i]=='B') B++;
  }
  
  long ans=0;
  ans=R*G*B;
  //cout <<ans <<endl;
  long NG=0;
  for (int i=1; i<=n; i++){
    for (int j=1; i+j+j<=n; j++){
      if((s[i]^s[i+j]^s[i+j+j])==('R'^'G'^'B')) NG++;
    }
  }
  cout <<ans-NG <<endl;
}

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

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int N;
vector<vector<int> > tree;
vector<int> X;
vector<int> A;
const int inf = 1<<28;

void rec(int v){
    if(tree[v].size()==0){
        A[v] = 0;
        return;
    }

    vector<vector<int> > dp(tree[v].size()+1, vector<int>(X[v]+1, inf));
    dp[0][0] = 0;
    REP(i, tree[v].size()){
        int u = tree[v][i];
        rec(u);
        REP(j, X[v]+1){
            if(j+X[u]<=X[v]){
                // cerr << i << " " << endl;
                dp[i+1][j+X[u]] = min(dp[i+1][j+X[u]], dp[i][j]+A[u]);
            }
            if(j+A[u]<=X[v]){
                dp[i+1][j+A[u]] = min(dp[i+1][j+A[u]], dp[i][j]+X[u]);
            }
        }
    }
    // REP(i, X[v]+1)cerr << dp[tree[v].size()][i] << " ";
    //cerr << endl;
    A[v] = *min_element(ALL(dp[tree[v].size()]));
    // cerr << v << " " << A[v] << " ,X: " << X[v] << endl;
}

int main(){
    cin >> N;
    tree.assign(N, vector<int>());
    X.resize(N);
    A.assign(N, inf);
    REP(i, N-1){
        int p;
        cin >> p;
        tree[p-1].push_back(i+1);
    }
    REP(i, N)cin >> X[i];
    rec(0);
    cout << ((*max_element(ALL(A))) == inf ? "IMPOSSIBLE" : "POSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 13296
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> Q;

int main() {
	int n, m;
	while (cin >> m >> n) {
		if (n == 0 && m == 0) {
			break;
		}
		vector< vector<char> > c(n, vector<char>(m));
		vector< vector<int> > d(n, vector<int>(m, 1000));
		int si, sj;
		si = sj = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> c[i][j];
				if (c[i][j] == '&') {
					si = i;
					sj = j;
					c[si][sj] = '.';
				}
			}
		}
		d[si][sj] = 0;
		queue<Q> q;
		int di[] = {1, 0, -1, 0};
		int dj[] = {0, 1, 0, -1};
		q.push(Q(P(si, sj), 0));
		while (!q.empty()) {
			Q qq = q.front();
			q.pop();
			P pp = qq.first;
			for (int i = 0; i < 4; i++) {
				if (pp.first+di[i] >= 0 && pp.first+di[i] < n && pp.second+dj[i] >= 0 && pp.second+dj[i] < m) {
					int aa = qq.second;
					if (c[pp.first][pp.second] == '.' && c[pp.first+di[i]][pp.second+dj[i]] == '#') {
						aa++;
					}
					if (d[pp.first+di[i]][pp.second+dj[i]] > aa) {
						d[pp.first+di[i]][pp.second+dj[i]] = aa;
						q.push(Q(P(pp.first+di[i], pp.second+dj[i]), aa));
					}
				}
			}
		}
/*
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cout << d[i][j];
			}
			cout << endl;
		}
		*/
		int MIN = 1000;
		for (int i = 0; i < n; i++) {
			MIN = min(MIN, min(d[i][0], d[i][m-1]));
		}
		for (int i = 0; i < m; i++) {
			MIN = min(MIN, min(d[0][i], d[n-1][i]));
		}
		cout << MIN << endl;
	}
	return 0;
}

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

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

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

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

/*{
}*/

signed main(){
  string s;
  cin >> s;
  int n = s.size();

  vvi dp(n+1, vi(2)); 
  dp[0][0] = 1;
  rep(i, 0, n) rep(j, 0, 2){
    if(s[i] == '1'){
      dp[i+1][0] = dp[i][0]*2%mod;
      dp[i+1][1] = (dp[i][1]*3 + dp[i][0])%mod;
    }else{
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1]*3%mod;
    }
  }

  cout << (dp[n][0] + dp[n][1])%mod << endl;

  return 0;
}


Measured memory_bytes: 5760
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();	
		int[] arr = r.ria();
		int sum = 0;
		
		for(int i = 1; i<=arr[0]; i++) {
			int n = getDigitSum(i);
			if(n>=arr[1] && n<=arr[2])
				sum+=i;
		}
		
		print(sum);
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 27988
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int A, B, C, D;

	A = a * x + b * y; //それぞれをそれぞれの個数買う場合

	B = c * x * 2; //a円x枚のピザの方が少ない、かつ同じ数になるまでcを買った方が安い時
	if( y > x ){ //同じ数の時に足さなくていいから条件分岐が必要？？
		B += b * (y - x);
	}

	C = c * y * 2;
	if( x > y ){
		 C += a * (x - y);
	}

	D = max(x,y) * c * 2; // 全部cを買った方が安い時

	cout << min( min(A,B) , min(C,D) ) <<endl;




	return 0;
}

//mokoさんさんのコードを参照したの

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c;
    d=max(a,max(b,c));
    d=d-a+d-b+d-c;
    if(d&1) d+=3;
    cout<<d/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
  int n;
  while(cin>>n){
    for(int i=0; i<n; ++i)
    cin>>a[i];
    vector <int> v;
    int tmp=1;
    for(int i=1; i<n; ++i){
      if(a[i]!=a[i-1]){
        v.push_back(tmp);
        tmp=1;
      }
      else{
        ++tmp;
      }
    }
    v.push_back(tmp);
    int ans=0;
    for(int i=0; i<v.size(); ++i){
      ans+=v[i]/2;
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;

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

    int sum = 0;
    int temp = Y;

    int a, b, c;

    a = temp / 10000;
    temp = temp % 10000;

    b = temp / 5000;
    temp = temp % 5000;

    c = temp / 1000;
    temp = temp % 1000;

    for(int i = 0;  i <= a; i++) {
        for(int j = 0;  j <= b + i * 2; j++) {
            if(a - i + b + i * 2 - j + c + j * 5 == N){
                cout << a - i << " " << b + i * 2 - j << " " << c + j * 5 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

vector<vector<pair<int, int> > > Edges;
vector<int> ans;
vector<bool> seen;
int max_col=0;

void dfs(int cur, int in) {
    seen[cur] = true;
    
    int col=1;
    if(col==in) col++;
    for(int i=0; i<Edges[cur].size(); i++) {
        if(seen[Edges[cur][i].first]) continue;
        if(max_col<col) {
            max_col = col;
        }
        ans[Edges[cur][i].second] = col;
        dfs(Edges[cur][i].first, col);
        
        col++;
        if(col==in) col++;
    }
}

int main() {
    int N;
    cin >> N;
    Edges.resize(N+1);
    ans.assign(N-1, 0);
    seen.assign(N+1, false);
    for(int n=0; n<N-1; n++) {
        int a, b;
        cin >> a >> b;
        Edges[a].push_back(make_pair(b, n));
        Edges[b].push_back(make_pair(a, n));
    }
    
    dfs(1, 0);

    cout << max_col << endl;
    for(int n=0; n<N-1; n++) {
        cout << ans[n] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 6912
N = int(input())
L = list(map(int, input().split()))

count = 0
for i in range(N):
    for j in range(i + 1, N):
        if L[i] == L[j]:
            continue
        for k in range(j + 1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                count += 1

print(count)


Measured memory_bytes: 9132
#define mst(a,b) memset((a),(b),sizeof(a))  
#define rush() int T;scanf("%d",&T);while(T--)  
#define f(i,a,b) for(register int i=a;i<=b;i++)
#include<stdio.h>  
   
int a[105][105],b[10050];  
   
int main ()  
{  
    int h,w;  
    
    while(scanf("%d %d",&h,&w)!=EOF)  
    {  
        int i,j,t,k=0;  
        scanf("%d",&t);  
        for(i=0;i<t;i++)  
            scanf("%d",&b[i]);  
        for(i=0;i<h;i++)  
        {  
            if(i%2==0)  
                for(j=0;j<w;j++)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
            if(i%2==1)  
                for(j=w-1;j>=0;j--)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
        }  
        for(i=0;i<h;i++)  
        {  
            for(j=0;j<w-1;j++)  
                printf("%d ",a[i][j]);  
            printf("%d\n",a[i][w-1]);  
        }  
    }  
}  

Measured memory_bytes: 256
S=input()
T=input()
sc={}
tc={}
for i in S:
    sc[i]=sc.get(i,0)+1
for i in T:
    tc[i]=tc.get(i,0)+1
x=list(sc.values())
x.sort()
y=list(tc.values())
y.sort()
if x==y:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

ll f(int n){
    if(n==1)return 1;
    else return n*f(n-1);
}

double kyori(P p1, P p2){
    double rel = pow(p1.first - p2.first,2)+pow(p1.second - p2.second,2);
    return pow(rel,0.5);
}

int main(){
    int n;
    cin >> n;
    vector<P> d(n);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        d[i] = P(x,y);
    }
    vector<int> l(n);
    rep(i,n)l[i] = i+1;
    double ans=0;
    int tot = f(n);
    do{
        double s=0;
        rep(i,n-1){
            s+=kyori(d[l[i]-1], d[l[i+1]-1]);
        }
        ans += s; 
        // cout << s/n << endl;
    }while(next_permutation(l.begin(),l.end()));
    ans = (double)ans/tot;
    printf("%8f",ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 30005

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;


ll dp[65][3];

int main() {

	ll n;
	cin >> n;

	dp[60][0] = 1;

	for (int bit = 59; bit >= 0; bit--)
	{
		if ((n >> bit) & 1)
		{
			//ビットが立っている
			dp[bit][0] = dp[bit + 1][0];
			dp[bit][1] = dp[bit + 1][0] + dp[bit + 1][1];
			dp[bit][2] = 2 * dp[bit + 1][1] + 3 * dp[bit + 1][2];
		}
		else
		{
			dp[bit][0] = dp[bit + 1][0] + dp[bit + 1][1];
			dp[bit][1] = dp[bit + 1][1];
			dp[bit][2] = dp[bit + 1][1] + 3 * dp[bit + 1][2];
		}
		dp[bit][0] %= MOD;
		dp[bit][1] %= MOD;
		dp[bit][2] %= MOD;
	}

	ll ans = (dp[0][0] + dp[0][1] + dp[0][2]) % MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, x, m;
  cin >> n >> x >> m;
  vector<bool> used(m);
  ll ans = 0;
  while (!used[x]) {
    used[x] = true;
    ans += x;
    x = x*x%m;
    n--;
    if (!n) {
      cout << ans << endl;
      return 0;
    }
  }
  ll cnt = 1, sum = x, st = x;
  x = x*x%m;
  while (x != st) {
    sum += x;
    cnt++;
    x = x*x%m;
  }
  if (!x) {
    cout << ans << endl;
    return 0;
  }
  ans += n/cnt*sum;
  ll rem = n%cnt;
  rep(i, rem) {
    ans += x;
    x = x*x%m;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n,x,i;
    cin >> n >> x;
    vector<int> l(n);
    for(i = 0;i < n;++i){
        cin >> l.at(i);
    }
    vector<int> d(n+1);
    d.at(0) = 0;
    for(i = 1;i <= n;++i){
        d.at(i) = d.at(i-1)+l.at(i-1);
    }
    int num = 0;
    for(i = 0;i <= n;++i){
        if(d.at(i) <= x){
            ++num;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll n,m;
const int maxn=1e5+5;
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	cin>>n>>m;
	rep(i,n)
	{
		cin>>a[i];
		a[i]/=2;
	}	
	if(n==1)
	{
		ll f=m/a[0];
		if(f%2) cout<<(f/2)+1;
		else cout<<(f/2);
		cout<<'\n';
		return 0;
	}
	ll lc=a[0];
	repA(i,1,n-1)
	{
		lc=(a[i]*lc)/(gcd(a[i],lc));
	}
	int flag=1;
	rep(i,n)
	{
		ll val=lc/a[i];
		if(val%2==0)
		{
			flag=0;
			break;
		}
	}
	if(flag==0)
	{
		cout<<0<<'\n';
	}
	else
	{
		ll f=m/lc;
		if(f%2) cout<<(f/2)+1;
		else cout<<(f/2);
		cout<<'\n';
	}
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 4432
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();

    let mut ans = "No";
    for i in 0..(n / 7) + 1 {
        if (n - (7 * i)) % 4 == 0 {
            ans = "Yes";
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352