akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int x, a; cin >> x >> a;
	if (x < a)
		cout << 0 << endl;
	else
		cout << 10 << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main(void){
    int a, b;
    cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = (a * 1.0) / (b * 1.0);
    cout << setprecision(5);
    cout << d << " " << r << " " << fixed << f << endl;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h> 
	using namespace std; 
	#define loop(i,a,b) for(ll i=a;i<b;i++)
	#define scan(a,n) for (ll i = 0; i < n; ++i) cin >> a[i]
	typedef long long int ll;

	int main() 
	{ 
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
		// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
		// #endif 

			ll n;
			cin>>n;
			ll a[n],c=0;
			scan(a,n);
			for(ll i=0;i<n-1;i++)
			{
				if(a[i+1]<a[i])
				{
					c+=a[i]-a[i+1];
					a[i+1]=a[i];
				}
			}
			cout<<c;
			return 0;
	}


Measured memory_bytes: 5212
N = int(input())
p = list(map(int,input().split()))
flg = 0
ans = 0
for i in range(N):
    if p[i] == i + 1 and flg == 1:
        flg = 0
    elif p[i] == i + 1 and flg == 0:
        ans += 1
        flg = 1
    else:
        flg = 0
print(ans)

Measured memory_bytes: 14008
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StronglyConnectedComponents
{
    class StronglyConnectedComponents
    {
        readonly int n;

        Dictionary<int, List<int>> G, Rev_G;
        List<int> st;
        bool[] visited;
        int[] cmp;

        public StronglyConnectedComponents(int n)
        {
            this.n = n;

            G = new Dictionary<int, List<int>>();
            Rev_G = new Dictionary<int, List<int>>();
            for (int i = 0; i < n; i++)
            {
                G.Add(i, new List<int>());
                Rev_G.Add(i, new List<int>());
            }
        }

        public void AddEdge(int from, int to)
        {
            G[from].Add(to);
            Rev_G[to].Add(from);
        }

        public void MakeSet()
        {
            st = new List<int>();
            cmp = new int[n];
            visited = new bool[n];

            for (int i = 0; i < n; i++)
            {
                if (!visited[i]) DFS(i);
            }

            visited = new bool[n];

            int cnt = 0;

            for (int i = st.Count - 1; i >= 0; i--)
            {
                int v = st[i];

                if (!visited[v]) Rev_DFS(v, cnt++);
            }
        }

        public bool IsSame(int x, int y)
        {
            return cmp[x] == cmp[y];
        }

        private void DFS(int v)
        {
            visited[v] = true;

            foreach (var next in G[v])
            {
                if (!visited[next]) DFS(next);
            }
            st.Add(v);
        }

        private void Rev_DFS(int v, int cnt)
        {
            visited[v] = true;
            cmp[v] = cnt;

            foreach (var next in Rev_G[v])
            {
                if (!visited[next]) Rev_DFS(next, cnt);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            StronglyConnectedComponents SCC = new StronglyConnectedComponents(V);

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                SCC.AddEdge(s, t);
            }

            SCC.MakeSet();

            StringBuilder sb = new StringBuilder();
            int Q = int.Parse(Console.ReadLine());

            for (int i = 0; i < Q; i++)
            {
                input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int v = int.Parse(input[1]);

                sb.AppendLine(SCC.IsSame(u, v) ? "1" : "0");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 15148
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10**18
mod = 10**9+7

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
xsub = 0
dicx = {}
xy.sort(reverse=True)
for i in range(n-1):
    for j in range(i+1,n):
        prex,prey = xy[i]
        x, y = xy[j]
        tmpx = x - prex
        tmpy = y - prey
        if (tmpx, tmpy) in dicx:
            dicx[(tmpx, tmpy)] += 1
        else:
            dicx[(tmpx, tmpy)] = 1
for _,num in dicx.items():
    xsub = max(num, xsub)
print(n-xsub)






Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, ll> il;
const int MAX = 1e3+3;
const int mod = 1e9+7;
int N, M, pd[MAX][MAX];
char m[MAX][MAX];

int solve() {
	pd[1][0] = 1;
	REP(i, 1, N) REP(j, 1, M) {
		if(m[i][j] == '#') pd[i][j] = 0;
		else pd[i][j] = (pd[i-1][j] + pd[i][j-1]) % mod;
	}
	return pd[N][M];
}

int main(int argc, char *argv[]) {
	scanf("%d%d", &N, &M);
	REP(i, 1, N) REP(j, 1, M)
		scanf(" %c", &m[i][j]);
	printf("%d\n", solve());
	return 0;
}


Measured memory_bytes: 5120
def main():
    num = int(input())
    data = [list(input()) for i in range(2)]

    kari = []
    pre = ''

    for i in range(num):
        now_data = data[0][i]
        if pre == '':
            pre = now_data
        elif now_data == pre:
            kari.append(1)
            pre = ''
        else:
            kari.append(0)
            pre = now_data
    if pre != '':
        kari.append(0)

    if kari[0]:
        ans = 6
    else:
        ans= 3
    mod = 10 ** 9 + 7
    pre_kari = kari[0]
    for i in range(1, len(kari)):
        now_kari = kari[i]
        if pre_kari and now_kari:
            ans = (ans * 3) % mod
        elif pre_kari and not now_kari:
            pass
        elif not pre_kari and not now_kari:
            ans = (ans * 2) % mod
        else:
            ans = (ans * 2) % mod
        pre_kari = now_kari


    print(ans % mod)





if __name__ == '__main__':
    main()




Measured memory_bytes: 38256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    cnt = collections.Counter(S)
    if list(cnt.values()) == [2, 2]:
        print(('Yes'))
    else:
        print(('No'))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10004
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(10 ** 5 + 1)]
d = {}

for key in a:
    if key in d:
        d[key] += 1
    else:
        d[key] = 1

ans = 0
for i in range(10 ** 5 + 1):
    if i in d:
        b[i] = d[i]

for i in range(1, 10 ** 5):
    ans = max(ans, b[i-1] + b[i] + b[i+1])
print(ans)


Measured memory_bytes: 14948
n=int(input())

ans=n
for i in range(n+1):
    count=0
    t=i
    while(t):
        count+=t%6
        t=int(t/6)
    t=n-i
    while(t):
        count+=t%9
        t=int(t/9)
    ans=min(ans,count)
print(ans)

Measured memory_bytes: 41580
S = str(input())
bw_list = [s for s in S]

sum = 0
count = 0
for j in range(len(S)):
    if bw_list[j] == 'B':
        continue
    elif bw_list[j] == 'W':
            count += 1
            sum += (j+1) - count
print(sum)

Measured memory_bytes: 5096
#include <iostream>
#include <queue>
using namespace std;
static const int INF = (1 << 21);

int main() {
  int n;
  cin >> n;
  int a[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) a[i][j] = 0;
  }

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      v--;
      a[u][v] = 1;
    }
  }

  queue<int> q;
  int d[n];
  for (int i = 0; i < n; i++) d[i] = INF;
  q.push(0);
  d[0] = 0;
  int u;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = 0; i < n; i++) {
      if (a[u][i] == 0) continue;
      if (d[i] != INF) continue;
      d[i] = d[u] + 1;
      q.push(i);
    }
  }

  for (int i = 0; i < n; i++)
    cout << i + 1 << " " << ((d[i] == INF) ? (-1) : d[i]) << endl;
}



Measured memory_bytes: 3148
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
ans=0
cnt=[0]
for i in range(1,9):
    for _ in range(i+1):
        cnt.append(i)
lis=factorization(n)


for a,b in lis:
    ans+=cnt[b]
if n==1:
    print(0)
else:print(ans)


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

int main() {
  int n, p, s = 0, mp = 0;
  cin >> n;
  REP(i, n) {
    cin >> p;
    s += p;
    mp = max(p, mp);
  }

  cout << s - mp / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
slist = input().strip()
e, w = 0, 0
for s in slist:
  if s == 'E':
    e += 1
  else:
    w += 1

le, lw, re, rw = 0, 0, e, w
minr = n + 1
for s in slist:
  if s == 'E':
    re -= 1
    minr = minr if minr <= re + lw else re + lw
    le += 1
  else:
    rw -= 1
    minr = minr if minr <= re + lw else re + lw
    lw += 1

print(minr)

Measured memory_bytes: 3784
def inpl(): return list(map(int, input().split()))

N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

for i in range(N, 0, -1):
    D[i] = (sum(D[2*i::i])%2)^A[i]
print(sum(D))
print(*[i for i in range(N+1) if D[i]])

Measured memory_bytes: 75612
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll h, w;
  cin >> h >> w;
  
  if (h != 1 && w != 1){
    if (w % 2 == 0)
      cout << ((w / 2) * h) << endl;
    else if (h % 2 == 0)
      cout << (h / 2) * w << endl;
    else 
      cout << (w / 2) * (h / 2) + ((w + 1) / 2) * ((h + 1) / 2) << endl;

    return 0;
  }
  else 
    cout << 1 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <map>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define INF 2000000000
#define llong long long
using namespace std;
int main(){
  int n;
  char str[10],com[13];
  map<string,bool> T;
  scanf("%d",&n);
  REP(i,n){
    scanf("%s %s",com,str);
    if(com[0]=='i') T[string(str)]=true;
    else {
      if(T[string(str)]) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 47492
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define eps 0.000000001
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
static const double pi = 3.141592653589793;
double f(double a,double b,double the){
  if(the>pi/2.0-eps){
    return 0;
  }
  double ret;
  if(a*tan(the)<=b){
    ret = a*a*b-a*a*a*tan(the)/2.0;
  }else{
    ret = b*b/tan(the)*a/2.0;
  }
  return ret;
}
signed main(){
  ll a,b,x,tmp,v;
  cin >> a >> b >> x;
  double s=pi/2,t=0,h;
  for(int i=0;i<1000;i++){
    h = (s+t)/2;
    if(f(a,b,h)<x) s = h;
    else t = h;
  }
  printf("%.8lf\n",(s)/pi*180);
}


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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var a = cin.Read();
            var b = cin.Read();
            var c = cin.Read();
            if (a[a.Length-1] == b[0] && b[b.Length-1] == c[0])
                WriteLine("YES");
            else
                WriteLine("NO");
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }
}


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

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

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

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

void run(){
    int N,W;
    cin>>N>>W;
    vi v(N),w(N);
    rep(i,N)cin>>v[i]>>w[i];
    vp a,b;
    int n=N/2;
    rep(i,1<<n){
        int sw=0,sv=0;
        rep(j,n){
            if((i>>j)&1)sw+=w[j],sv+=v[j];
        }
        a.pb({sw,sv});
    }
    int m=N-n;
    rep(i,1<<m){
        int sw=0,sv=0;
        rep(j,m){
            if((i>>j)&1)sw+=w[n+j],sv+=v[n+j];
        }
        b.pb({sw,sv});
    }
    SORT(a);
    SORT(b);
    Rep(i,1,1<<n)a[i].se=max(a[i].se,a[i-1].se);
    Rep(i,1,1<<m)b[i].se=max(b[i].se,b[i-1].se);
    int ans=0;
    rep(i,1<<n){
        auto p=upper_bound(all(b),mp(W-a[i].fi,inf));
        if(p==b.begin())continue;
        p--;
        ans=max(ans,a[i].se+p->se);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 43828
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define ll long long int
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))
int main(void){
	int n;
	scanf("%d",&n);
	ll a[n+1];
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	ll r=0;
	int c=1;
	for(int i=n;i>0;i--){
		if(c==1){
			r += a[i];
		}else{
			r -= a[i];
		}
		c*=-1;
	}
	ll x = r/2;
	for(int i=1;i<=n;i++){
		printf("%lld ",x*2);
		x = a[i]-x;
	}
	return 0;
}

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

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

	int N;
	cin >> N;

	map<int, int> cnt;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}

	int one = 0, two = 0;
	for(auto v : cnt) {
		int c = v.second;
		if(c % 2 == 0) two++;
		else one++;
	}

	if(two % 2 == 0) {
		cout << cnt.size() << endl;
	}
	else {
		cout << cnt.size() - 1 << endl;
	}
}

Measured memory_bytes: 4992
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)1e5 + 228;

using namespace std;

int n, m, cnt[N];
bool can[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	scanf("%d%d", &n, &m);
	can[1] = true;
	fill(cnt + 1, cnt + n + 1, 1);
	forn(i, m)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		cnt[x]--;
		cnt[y]++;
		if (can[x])
			can[y] = true;
		if (cnt[x] == 0)
			can[x] = false;		
	}
	int ans = 0;
	forn(i, n)	
		ans += can[i];
	cout << ans << endl;
	   
	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n,m;cin>>n>>m;
    vvint a(n,vint(m));
    rep(i,n)rep(j,m)cin>>a[i][j];
    int res=0;
    rep(i,n-1){
        range(j,i+1,n){
            int dist=0;
            rep(k,m){
                dist+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            for(int k=1; k*k<=dist; k++){
                if(k*k==dist) res++;
            }
        }
    }
    cout<<res<<endl;
}

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

class Program
{
    static void Main()
    {
        var N = Int64.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x));
        var nibaiA = A.Select(x => x * 2).ToArray();
        var goukei = A.Sum();

        var ans = new long[N];

        //A1を出す
        var aida = 0L;
        for (int i = 1; i < N; i += 2) aida += nibaiA[i];
        ans[0] = goukei - aida;

        for (int i=1;i<N;++i)
        {
            ans[i] = nibaiA[i - 1] - ans[i - 1];
        }
        for (int i=0;i<N;++i)
        {
            Console.Write(ans[i]);
            if(i!=N-1)Console.Write(" ");
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 30044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 1e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int a[N], b[N];
int h, n;
int main()
{
    cin>>n>>h;
    int mxa = -1;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i]>>b[i];
        mxa = max(mxa, a[i]);
    }
    ll ans = 0;
    sort(b, b+n, greater<int>());
    for (int i = 0; i < n && h > 0 ; i++)
    {
        if(b[i] >= mxa)
        {
            h -= b[i];
            ans++;
        }
        else
            break;
    }
    if(h > 0)
        ans += (ll)(h + mxa - 1) / mxa ; 
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int A[3];
	A[0] = a;
	A[1] = b;
	A[2] = c;
	sort(A, A + 3, greater<int>());
	for (int i = 0; i < k; i++) {
		A[0] *= 2;
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		ans += A[i];
	}
	cout << ans << endl;






	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Process terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    'outer: loop {
        let n = sc.read();
        let hp: u64 = sc.read();
        let mut cut = vec![0; 0];
        let mut thr = vec![0; 0];
        for _i in 0..n {
            cut.push(sc.read());
            thr.push(sc.read());
        }
        let best_cut = cut.iter().max().unwrap();
        thr.sort();
        thr.reverse();
        let mut sum = 0;
        let mut ans = (hp + best_cut - 1) / best_cut;
        for i in 0..n {
            sum += thr[i];
            let cand = if sum >= hp {
                (i + 1) as u64
            } else {
                (i as u64 + 1) + (hp - sum + best_cut - 1) / best_cut
            };
            if ans > cand {
                ans = cand;
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 12596
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1],b[n];
	int long long c=0;
	for(int i=0;i<n+1;i++){
		cin>>a[i];
		c+=a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	int d=a[n];
	for(int i=0;i<n;i++){
		if(b[i]>a[i]){
			b[i]-=a[i];
			a[i]=0;
			a[i+1]-=b[i];
			if(a[i+1]<0){
				a[i+1]=0;
			}
		}
		else{
			a[i]-=b[i];
		}
		c-=a[i];
	}
	c-=a[n];
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1024
/*
    Flowers, wake up like the sea!
*/
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x7fffffff
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
typedef vector<int> VI;
typedef map<int,int> MII;
const int N = 55, MOD = 7+1e9;
int a[N];
int dp[N][N][2*N];
int main()
{
#ifdef YUUKILP
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    for(int i = 1;i <= n;i ++)
        for(int j = i-1;j <= n;j ++) 
            for(int l = 0;l <= k;l ++) dp[i][j][l] = -2e9;
    dp[1][n][0] = 0;
    int ans = 0;
    for(int i = 1;i <= n;i ++)
    {
        for(int j = n;j >= i;j --)
        {
            for(int l = 0;l < k;l ++)
            {
                int cnt = i - 1 + n - j;
                if(l < cnt || l > 2 * cnt) continue;
                // cout << i << " " << j << " " << l << " " << dp[i][j][l] << endl;
                // left
                if(l+1 <= k)
                {
                    dp[i+1][j][l+1] = max(dp[i+1][j][l+1], dp[i][j][l] + a[i]);
                    ans = max(ans, dp[i+1][j][l+1]);
                    dp[i][j-1][l+1] = max(dp[i][j-1][l+1], dp[i][j][l] + a[j]);
                    ans = max(ans, dp[i][j-1][l+1]);
                }
                if(l+2 <= k)
                {
                    dp[i+1][j][l+2] = max(dp[i+1][j][l+2], dp[i][j][l]);
                    ans = max(ans, dp[i+1][j][l+2]);
                    dp[i][j-1][l+2] = max(dp[i][j-1][l+2], dp[i][j][l]);
                    ans = max(ans, dp[i][j-1][l+2]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>


const int maxn = 4e5 + 10, INF = 0x3f3f3f3f;
const ll MOD = 1000000007LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int a[maxn];

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    int n; cin>>n;
    for(int i = 1; i <= n; i++) {
        int x; cin>>x;
        a[x] = i;
    }
    int res = 1;
    int t = 1;
    for (int i = 2; i <= n; i++) {
        if (a[i] > a[i - 1]) {
            t++;
        } else {
            res = max(res, t);
            t = 1;
        }
    }
    res = max(res, t);
    cout<<n - res<<endl;



    return 0;
}


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

int main() { 
    int n;
    cin >> n;
    int a;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        if(a%2 == 0) {
            if(a%3 == 0 || a%5 == 0) {
                continue;
            } else {
                cout << "DENIED" << '\n';
                return 0;
            }
        }
    }
    cout << "APPROVED" << '\n';

    return 0;
}


Measured memory_bytes: 256
def main(argv)
  n = gets.chomp.to_i
  a = [0] * n
  b = [0] * n
  n.times{ |i| (a[i], b[i]) = gets.chomp.split(' ').map(&:to_i) }

  c = [0] * n
  n.times do |i|
    if a[i] % b[i] > 0 then
      c[i] = b[i] - (a[i] % b[i])
    end
  end

  (n - 1).times do |i|
    j = (n - 2) - i

    unless c[j] >= c[j + 1] then
      d = (a[j] + c[j + 1]).divmod(b[j])
      d[0] += 1 if d[1] > 0

      c[j] = d[0] * b[j] - a[j]
    end
  end

  cc = c.dup
  (n - 1).times do |i|
    j = (n - 2) - i
    cc[j] -= c[j + 1]
  end
  puts cc.reduce(:+).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[100010][2];

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (ll i = 0; i <= N - 1; i++) {
        dp[i][0] = dp[i][1] = -L_INF;
    }
    dp[0][0] = 0;

    for (ll i = 0; i < N - 1; i++) {
        if (dp[i][0] != -L_INF) {
            chmax(dp[i + 1][0], dp[i][0] + A[i]);
            chmax(dp[i + 1][1], dp[i][0] - A[i]);
        }
        if (dp[i][1] != -L_INF) {
            chmax(dp[i + 1][0], dp[i][1] - A[i]);
            chmax(dp[i + 1][1], dp[i][1] + A[i]);
        }
    }

    ll ans = -L_INF;
    chmax(ans, dp[N - 1][0] + A[N - 1]);
    chmax(ans, dp[N - 1][1] - A[N - 1]);
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 5572
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 1005, M = 200005;

int n, m, sc, cc, non, wh[N], col[N];
bool vis[N], ans[M], shu[N], can[N];
pii e[M];

vector<int> adj[N], rev[N], out[N], st;

void tdfs (int I) {
	if(vis[I]) return;
	vis[I] = true;
	for(auto &T : adj[I]) if(T != non) tdfs(T);
	st.push_back(I);
}

void rdfs (int I) {
	if(vis[I]) return;
	wh[I] = sc;
	vis[I] = true;
	if(I != non) for(auto &T : rev[I]) rdfs(T);
}

void toposort (int I) {
	non = I; sc = 0;
	for(int i=1;i<=n;i++) {
		if(!vis[i]) tdfs(i);
	}
	fill(vis+1, vis+1+n, 0);
	while(!st.empty()) {
		int T = st.back(); st.pop_back();
		if(!vis[T]) {rdfs(T); sc++;}
	}
	fill(vis+1, vis+1+n, 0);
}

void cdfs (int I) {
	col[I] = cc;
	vis[I] = true;
	if(shu[I] && I != st[cc]) {
		can[I] = true;
		if(wh[I] == wh[st[cc]]) can[st[cc]] = true;
	}
	for(auto &T : adj[I]) {
		if(T == non) continue;
		if(vis[T]) {
			if(col[I] == col[T]) continue;
			if(wh[T] == wh[st[col[T]]]) can[st[col[T]]] = true;
		}
		else cdfs(T);
	}
}

void solve (int I) {
	toposort(I);
	for(auto &T : adj[I]) shu[T] = true;
	for(auto &T : adj[I]) {
		if(vis[T]) continue;
		st.push_back(T);
		cdfs(T); cc++;
	}
	for(auto &T : out[I]) {
		ans[T] = can[e[T].Y];
	}
	cc = 0; st.clear();
	fill(vis+1, vis+1+n, 0);
	fill(shu+1, shu+1+n, 0);
	fill(can+1, can+1+n, 0);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		e[i] = {A, B};
		out[A].push_back(i);
		adj[A].push_back(B);
		rev[B].push_back(A);
	}
	for(int i=1;i<=n;i++) {
		if(!out[i].empty()) solve(i);
	}
	toposort(0);
	for(int i=1;i<=m;i++) {
		puts(ans[i] ^ (wh[e[i].X] == wh[e[i].Y]) ? "diff" : "same");
	}
}


Measured memory_bytes: 8192
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	ds := make([]int, n)
	for i := 0; i < n; i++ {
		ds[i] = eGetInt(scanner)
	}
	sum := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum += ds[i] * ds[j]
		}
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct UnionFind
{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> sz;
    UnionFind(ll n) : par(n), rank(n), sz(n)
    {
        for(ll i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    ll root(ll x)
    {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    void unite(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y])
        {
            par[x] = y;
            sz[y] += sz[x];
        }
        else
        {
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    ll size(ll x)
    {
        x = root(x);
        return sz[x];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    for(int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    int ans = 0;
    for(int i = 0; i < m; i++)
    {
        UnionFind tree(n);
        for(int j = 0; j < m; j++)
        {
            if(i == j) continue;
            tree.unite(a[j], b[j]);
        }
        if(!tree.same(a[i], b[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
void main() {
    dchar[] n = readln.chomp.to!(dchar[]);
    auto g = n.group.assocArray;
    writeln(g.values.any!"a >= 3" ? "Yes" : "No");

}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int A,B ;
  cin >> A >> B ;
  if(A%3==0||B%3==0||(A+B)%3==0)
  cout<<"Possible"<<endl;
  else{
    cout<<"Impossible"<<endl;
  }
  
}

   
  
   
 


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


ll R;
ll D;
ll X2000;

int main(){


    cin >> R >> D >> X2000;
    
    ll X = X2000;
    for(int i = 1; i <= 10; i++){
        X = X * R - D;
        cout << X << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
import math 
def prime(n):
    d = {}
    if n%2==0:
        d[2]=0
    while n % 2 == 0: 
        d[2]+=1
        n = n / 2
    for i in range(3,int(math.sqrt(n))+1,2):
        if n%i==0:
            d[i]=0
        while n % i== 0: 
            d[i]+=1
            n = n / i 
    if n > 2:
        d[n]=1
    return d
def maxsum(di):
    ans = 0
    for i in di.items():
        c = 1
        x = 0
        y = i[1]
        while y-c>=0:
            #print(y, c, x)
            y-=c
            c+=1
            x+=1
        ans+=x
    return ans
di = prime(int(input()))
#print(di)
print(maxsum(di))


Measured memory_bytes: 9092
import java.util.*;

class Main {
    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        
        int [] result = new int [51];

        for (int a = 0; a < 10; a++) {
            for (int b = 0; b < 10; b++) {
                for (int c = 0; c < 10; c++) {
                    for (int d = 0; d < 10; d++) {
                        result[a+b+c+d] += 1;
                    }
                }
            }
        }
            
        while (true) {
            int n;
            try {
                n = sc.nextInt();
            } catch (NoSuchElementException e) {
                break;
            }

            System.out.println(result[n]);
        }

    }
}

Measured memory_bytes: 11000
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        //箱A,B,Cに入る整数
        int boxA = scn.nextInt();
        int boxB = scn.nextInt();
        int boxC = scn.nextInt();
        int boxCopy = boxA;
        boxA = boxB;
        boxB = boxCopy;
        boxCopy = boxA;
        boxA = boxC;
        boxC = boxCopy;
        System.out.println(boxA +" " + boxB + " " + boxC);
    }
}

Measured memory_bytes: 21716
n,m = [int(i) for i in input().split()]
a = {int(input()) for i in range(m)}
dp = {}
for step in range(1,n+1):
    if step in a:
        dp[step] = 0
        continue
    if step == 1:
        if step in a:
            dp[1] = 0
        else:
            dp[1] = 1
        continue
    if step == 2:
        if step in a:
            dp[2] = dp[1]
        else:
            dp[2] = dp[1] + 1
        continue
    dp[step] = dp[step-1] + dp[step-2]
print(int(dp[n]%1000000007))

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

int main(){
	int n, x[100], y[100];
	
	cin >> n;
	for(int i=0; i < n; ++i)
		cin >> x[i];
	for(int i=0; i < n; ++i)
		cin >> y[i]; 
		
	for(int p=1; p <= 3; ++p){
		double d=0;
		for(int i=0; i < n; ++i)
			d += pow( fabs(x[i]-y[i]), p);
		
		printf("%f\n", pow(d, 1.0/p));
	}		
	
	double max=0;	
	for(int i=0; i < n; ++i)
		if(max < fabs(x[i]-y[i])) 
		max = fabs(x[i]-y[i]);
	
	printf("%f\n", max);	
	
	return 0;
}



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

using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvpl = vector<vpl>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back
#define eb emplace_back

#define all(X) begin(X),end(X)
#define sz(X) (X).size()

#define DBG 0
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

ll M;
const ll border = 1e9 + 7;

vl below;
vvl adj;
vvl tree;

ll first_dfs(ll cur, ll parent) {
	ll foo = 1;

	for(auto it : adj[cur]) {
		if(it != parent) {
			foo *= first_dfs(it, cur) + 1;
			foo %= M;
			tree[cur].pb(it);
		}
	}

	below[cur] = foo;
	return foo;
}

vl res;
void second_dfs(ll cur, ll parent, ll value) {
	TR(cur);
	TR(parent);
	TR(value);
	res[cur] = value * below[cur];
	res[cur] %= M;

	if(sz(tree[cur]) == 0){
		return;
	}

	vl prefix(sz(tree[cur]));
	vl suffix(sz(tree[cur]));

	prefix[0] = 1;

	FOR(i,1,sz(tree[cur])) {
		prefix[i] = prefix[i-1] * (below[tree[cur][i-1]] + 1);
		prefix[i] %= M;
	}

	suffix[sz(tree[cur]) - 1] = 1;

	FORD(i,0,sz(tree[cur]) - 1) {
		suffix[i] = suffix[i+1] * (below[tree[cur][i+1]] + 1);
		suffix[i] %= M;
	}

	FOR(i,0,sz(tree[cur])) {
		second_dfs(tree[cur][i], cur, (((value * prefix[i]) % M) * suffix[i] + 1) % M );
	}
}

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

	ll N;
	cin >> N >> M;

	below.assign(N, 0);
	res.assign(N, 0);
	adj.assign(N,vl());
	tree.assign(N,vl());

	FOR(i,0,N-1) {
		ll x, y;
		cin >> x >> y;

		x--;
		y--;

		adj[x].eb(y);
		adj[y].eb(x);
	}

	first_dfs(0, -1);

#if DBG
	TR("TREE");
	FOR(i,0,N){
		cerr << i << ": ";
		FOR(j,0,sz(tree[i])){
			cerr << tree[i][j] << " ";
		}
		cerr << endl;
	}
	TR("ADJ");
	FOR(i,0,N){
		cerr << i << ": ";
		FOR(j,0,sz(adj[i])){
			cerr << adj[i][j] << " ";
		}
		cerr << endl;
	}
#endif

	second_dfs(0, -1, 1);

	FOR(i,0,N) {
		cout << res[i] % M << '\n';
	}
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  string A, B, C;
  cin >> A;
  cin >> B;
  cin >> C;

  int ret = 0;
  rep(i,N){
    set<char> st;
    st.insert(A[i]);
    st.insert(B[i]);
    st.insert(C[i]);

    ret += st.size() - 1;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        int sum1=a+b;
        int sum2=b+c;
        int sum3=a+c;
        int maxx=min(sum1,sum2);
        maxx=min(maxx,sum3);
        printf("%d\n",maxx);
        return 0;
}


Measured memory_bytes: 256
V,E = list(map(int,input().split()))

#訪問済の頂点を保持
visit=[]
no_visit=list(range(V))

#各頂点の入次数
enter=[0]*V

#隣接リスト
ad_list=[[] for _ in range(V)]

for e in range(E):
    start,end=list(map(int,input().split()))
    ad_list[start].append(end)
    enter[end]+=1
    
enter , ad_list

while True:
    if len(visit)==V:
        break
        
    for n_v_idx,n_v in enumerate(no_visit):
        e=enter[n_v]
        if e == 0:
            v=no_visit.pop(n_v_idx)
            visit.append(v)
            for a in ad_list[n_v]:
                enter[a]=enter[a]-1
for v in visit:
    print(v)


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

int main(){
  string s,t,u;
  long long cnt=0;
  getline(cin,s);
  if(s.size()%2!=0)cout<<"No";
  else{
    for(int i=0;i<s.size();i+=2){
      t=s[i];
      u=s[i+1];
      if(t!="h"||u!="i"){
          cout<<"No";
          break;
      }
      else cnt++;
    }
    if(cnt==s.size()/2)cout<<"Yes";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
ll x[8];
ll y[8];
ll v[8];
ll r[8];
ll cnt=1;
ll jc(ll n)
{
    ll ans=1;
    for(ll i=1; i<=n; i++)
        ans*=i;
    return ans;
}
double jl(ll i,ll j)
{
    return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
int main()
{
    ll n;
    double s=0;
    cin>>n;
    for(ll i=0; i<n; i++)
        cin>>x[i]>>y[i];
    for(ll i=0; i<n; i++)
        r[i]=i;
    do
    {
        for(ll i=0; i<n-1; i++)
            s+=jl(r[i],r[i+1]);
    }
    while(next_permutation(r,r+n));
    printf("%.10lf",s/(jc(n)));

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;



int main(){

    int n;
    cin >> n;

    vector<int> h;

    rep(i,n){
        int tmp;
        cin >> tmp;

        h.pback(tmp);
    }

    vector<int> leftmax;
    vector<int> rightmin;

    leftmax.pback(h[0]);
    rightmin.pback(h[n - 1]);

    rep(i, n - 1){
        leftmax.pback(max(leftmax[i], h[i + 1]));
        rightmin.pback(min(rightmin[i], h[n - 2 - i]));
    }

    bool ans = true;

    rep(i,n){
        
        if(leftmax[i] - rightmin[n - 1 - i] >= 2){
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;

}

Measured memory_bytes: 1912