akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rreq(i,n) for(ll i = n;i >= 1;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MOD = 1000000007;
struct Dinic {
    struct edge {
        int to, cap, rever;
        edge(int to, int cap, int rever) :to(to), cap(cap), rever(rever) {}
    };
    vector< vector<edge> > graph;
    vector<int> level, iter;
    Dinic(int V) :graph(V), level(V), iter(V) {}
    void add_edge(int from, int to, int cap) {
        graph[from].emplace_back(to, cap, graph[to].size());
        graph[to].emplace_back(from, 0, graph[from].size() - 1);
    }
    void bfs(int s) {
        fill(ALL(level), -1);
        queue<int> que;
        level[s] = 0;
        que.push(0);
        while (que.size()) {
            int v = que.front(); que.pop();
            for (edge& e : graph[v]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int& i = iter[v]; i < graph[v].size(); i++) {
            edge& e = graph[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(e.cap, f));
                if (d > 0) {
                    e.cap -= d;
                    graph[e.to][e.rever].cap += d;
                    return d;
                }
            }
        }return 0;
    }
    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0) return flow;
            fill(ALL(iter), 0);
            int f; while ((f = dfs(s, t, 1e9)) > 0) flow += f;
        }
    }
};
int n, m;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main(void) {
    while (cin >> n >> m, n, m) {
        Dinic dn(n + m + 2);
        vector<int> a(n), b(m);
        rep(i, n) cin >> a[i],dn.add_edge(0,i+1,1);
        rep(i, m) cin >> b[i],dn.add_edge(i+n+1,n+m+1,1);
        rep(i, n) {
            rep(j, m) {
                if (gcd(a[i], b[j]) > 1) {
                    dn.add_edge(i + 1, j + n+1, 1);
                }
            }
        }cout << dn.max_flow(0, n + m+1) << endl;
     }
}


Measured memory_bytes: 7316
#include<stdio.h>
int linearSearch(int*,int,int);
int main(){
  int a,b,i,j,flag=0;
  int aa[10000];
  int bb[500];
  int count=0,judge=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&aa[i]);
  }
  scanf("%d",&b);
  for(j=0;j<b;j++){
    scanf("%d",&bb[j]);
    judge=linearSearch(aa,bb[j],a);
    if(judge!=0){
      count++;
      flag=1;
    }
  }
  if(flag==0){
    printf("0\n");
  }
  else{
    printf("%d\n",count);
  }
  return 0;
}

int linearSearch(int* A,int key,int n){
  int i;
  for(i=0;i<n;i++){
    if(A[i]==key){
      return 1;
    }
  }
  return 0;
}


Measured memory_bytes: 2108
N = int(input())
D, X = map(int, input().split())
A = []

for i in range(N):
    A.append(int(input()))

sum_list = []
for i in A:
    if (D % i) != 0:
        sum_list.append(int(D/i)+1)
    else:
        sum_list.append(int(D/i))

print(sum(sum_list)+X)


Measured memory_bytes: 3060
#include <stdio.h>

int main(){

int N,D,X;
int sum = 0;

scanf("%d",&N);
scanf("%d %d",&D,&X);


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


int A;
scanf("%d",&A);


for(int i = 0; i<D;i++){

int s = 1 + A*i;


if(s <= D){

 sum++;

}

}

}






int choco = sum + X;

printf("%d",choco);

}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int a,b,c; cin >> a >> b >> c;
    int mx = max(a, max(b,c));
    if(mx == a){
        cout << b*c/2 << endl;
    }
    else if(mx == b){
        cout << a*c/2 << endl;
    }
    else cout << a*b/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=10;
ll n,a[M][M];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		auto s=to_string(i);
		a[s[0]-'0'][s.back()-'0']++;
	}
	ll res=0;
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) res+=a[i][j]*a[j][i];
	cout<<res<<endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def F(a,b):
	a = len(str(a))
	b = len(str(b))
	return a if a > b else b

n = int(input())
results = []
for i in make_divisors(n):
	j = int(n/i)
	results.append(F(i,j))

print(min(results))

Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <string>

using namespace std;

map<string,string>m;

int main(){
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";

    string s;
    cin >> s;
    cout << m[s] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll gcd(ll a, ll b){
  if(a<b) swap(a,b);
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}

int main(){
  ll n; cin >> n;
  ll a[n];
  REP(i,n) cin >> a[i];
  ll b[n];
  b[0] = a[0];
  REP(i,n-1) b[i+1] = gcd(b[i],a[i+1]);
  ll c[n];
  c[n-1] = a[n-1];
  REP(i,n-1) c[n-2-i] = gcd(c[n-1-i],a[n-2-i]);
  ll ans = 1;
  REP(i,n){
    if(i==0){
      ans = max(ans,c[1]);
    }else if(i==n-1){
      ans = max(ans,b[n-2]);
    }else{
      ans = max(ans,gcd(b[i-1],c[i+1]));
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> b(n);
  rep(i,n) cin >> b[i];
  vector<ll> f(n,0);
  f[0]=a[0]; f[n-1]=b[n-1];
  ll ans=1;
  for(int i=1;i<n-1;i++){
    if(a[i-1]==a[i]&&b[i]==b[i+1]){
      ans*=min(a[i],b[i]);
      ans%=mod;
    }
    if(a[i-1]<a[i]){
      f[i]=a[i];
    }
    else if(b[i]>b[i+1]){
      f[i]=b[i];
    }
  }
  vector<ll> aa=f;
  vector<ll> bb=f;
  rep(i,n-1){
    chmax(aa[i+1],aa[i]);
  }
  for(int i=n-2;i>=0;i--){
    chmax(bb[i],bb[i+1]);
  }
  if(a==aa&&b==bb){
    cout << ans << endl;
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 4224
#include<iostream>

using namespace std;

int pre[300];
int now[300];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<300;i++){
		pre[i]=i+1;
	}
	int m;
	cin>>m;
	for(int j=0;j<m;j++){
		int x;
		cin>>x;
		if(x==0){
			for(int i=0;i<n;i++){
				now[2*i]=pre[i];
				now[2*i+1]=pre[i+n];
			}
		
		}
		else {
			int k=x;
			for(int i=0;i<2*n-k;i++){
				now[i]=pre[i+k];
			}
			for(int i=0;i<k;i++){
				now[i+2*n-k]=pre[i];
			}
		}
		for(int i=0;i<2*n;i++)pre[i]=now[i];
	}
	
	for(int i=0;i<2*n;i++)cout<<now[i]<<endl;
	
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin >> h >> w;
  vector<vector<int>> a(h,vector<int>(w));
  vector<vector<int>> b(h,vector<int>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> b[i][j];
    }
  }
  bool c[h][w][25600];
  c[0][0][a[0][0]-b[0][0]+12800]=true;
  c[0][0][b[0][0]-a[0][0]+12800]=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<25600;k++){
        int t=a[i][j]-b[i][j];
        if((i&&c[i-1][j][k])||(j&&c[i][j-1][k])){
          if(k+t<25600){
            c[i][j][k+t]=true;
          }
          if(k-t>=0){
            c[i][j][k-t]=true;
          }
        }
      }
    }
  }
  int ans=1e6;
  for(int i=0;i<25600;i++){
    if(c[h-1][w-1][i]){
      ans=min(ans,abs(i-12800));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 160128
s = gets.to_i
previous_a = s
as = [previous_a]
current_a = nil
i = 1
while as.count(current_a) < 2
    previous_a.even? ? current_a = previous_a / 2 : current_a = previous_a * 3 + 1
    previous_a = current_a
    as.push(current_a)
    i += 1
end
p i

Measured memory_bytes: 14272
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;

//const double eps = 1 * 10e-10;

int main()
{
	int l;
	cin >> l;
	double x = l / 3.0;
	cout <<fixed<<setprecision(15)<< x * x * x << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

grid = [['#' for _ in range(100)] for _ in range(50)] \
  + [['.' for _ in range(100)] for _ in range(50)]

for i in range(a-1):
  grid[(i // 50) * 2][(i % 50) * 2] = '.'

for i in range(b-1):
  grid[-((i // 50) * 2) - 1][(i % 50) * 2] = '#'

print(100, 100)
for g in grid:
  print(*g, sep='')


Measured memory_bytes: 4468
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int a, b;
    cin >> a >> b;
    if(a < b){
        for(int i=0; i<b; i++)
            cout << a;
    }else{
        for(int i=0; i<a; i++)
            cout << b;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

def calc(T, h):
    return T - h*0.006

ans = 0
for i, h in enumerate(H):
    tmp = calc(T, h)
    if abs(A-tmp) < abs(A - calc(T, H[ans])):
        ans = i
print(ans+1)

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N;
    cin >> N;
    ll A[N + 1], B[N];
    for(int i = 0; i < N + 1; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll a = min(A[i], B[i]);
        ans += a;
        B[i] -= a;
        a = min(A[i + 1], B[i]);
        ans += a;
        A[i + 1] -= a;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
N,_X,M=map(int,input().split())
X=_X

s=set()

while True:
    if X==0:
        print(sum(s))
        exit()
    if X in s:
        break
    else:
        s.add(X)
        X=X**2%M
    
loop=set()
while True:
    if X in loop:
        break
    else:
        loop.add(X)
        X=X**2%M

bef_loop=[]
X=_X
while True:
    if  X in loop:
        break
    else:
        bef_loop.append(X)
        X=X**2%M

if N<=len(bef_loop):
    print(sum(bef_loop[:N]))
else:
    ans=sum(bef_loop)
    R=N-len(bef_loop)

    ans+=R//len(loop)*sum(loop)
    r=R%len(loop)

    X=_X
    for _ in range(len(bef_loop)):
        X=X**2%M
    for _ in range(r):
        ans+=X
        X=X**2%M
    print(ans)



Measured memory_bytes: 76644
import java.util.Scanner;

public class Main {
		
		public static void main(String[] args){
			Scanner sc=new Scanner(System.in);
			
			String str=sc.next();
			
			switch(str){
			case "SUN": System.out.println(7);
                        break;
			case "MON": System.out.println(6);
            break;
			case "TUE": System.out.println(5);
            break;
			case "WED": System.out.println(4);
            break;
			case "THU": System.out.println(3);
            break;
			case "FRI": System.out.println(2);
            break;
			case "SAT": System.out.println(1);
            break;
			default:
	            System.out.println("EROOR");
			}
			
			
		}
		
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    rep(i, 10)rep(j, 10){
        if(i==0 || j==0) continue;
        if(i*j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val Fs = (1..N).map { Integer.parseInt(readInputLine().replace("\\s".toRegex(), ""), 2) }
    val Ps = Array(N, {readInputLine().split(" ").map { it.toInt() }})

    var ans = Int.MIN_VALUE
    
    for (i in 1 until (1 shl 10)) {
        var tmp = 0
        for (j in 0 until N) {
            tmp += Ps[j][cntBit(i and Fs[j])]
        }
        ans = Math.max(tmp, ans)
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun cntBit(i: Int): Int {
    var ret = 0
    var tmp = i
    while (tmp != 0) {
        ret += tmp and 1
        tmp = tmp shr 1
    }
    return ret
}


Measured memory_bytes: 36392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = 1e18;
  for (ll i = 0; i <= 2 * max(x, y); i += 2) {
    ll s = max(x - i / 2, 0LL);
    ll t = max(y - i / 2, 0LL);
    ans = min(ans, a * s + b * t + c * i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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 namespace std;

int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

mint dp[61][2][2][2];
int main(){
    ll l, r;
    cin >> l >> r;

    dp[60][0][0][0] = 1;

    for (int i = 59; i >= 0; i--) {
        int lb = l >> i&1;
        int rb = r >> i&1;
        rep(j, 2) rep(k, 2) rep(s, 2) {
            mint pre = dp[i+1][j][k][s];
            rep(x, 2) rep(y, 2) {
                if (x && !y) continue;
                int nj = j, nk = k, ns = s;
                if (!s && x != y) continue;
                if (x && y) ns = 1;
                if (!j && !x && lb) continue;
                if (x && !lb) nj = 1;
                if (!k && y && !rb) continue;
                if (!y && rb) nk = 1;
                dp[i][nj][nk][ns] += pre;
            }
        }
    }

    mint ans;
    rep(j, 2) rep(k, 2) rep(s,2) ans += dp[0][j][k][s];
    cout << ans.x << endl;


}

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

#define FOR(i,n) for(int i=0;i<n;i++)
int count[100001][2]={};
int main(){
	int n;
	cin>>n;
	FOR(i,n){
		int a;
		cin>>a;
		count[a][i%2]++;
	}
	int max[2][2][2]={};
	FOR(i,100001){
		FOR(j,2){
			if(max[0][j][0]<count[i][j]){
				max[1][j][0]=max[0][j][0];
				max[0][j][0]=count[i][j];
				max[1][j][1]=max[0][j][1];
				max[0][j][1]=i;
			}
			else if(max[1][j][0]<count[i][j]){
				max[1][j][0]=count[i][j];
				max[1][j][1]=i;
			}
		}
	}
	
	if(max[0][0][1]!=max[0][1][1]){cout<<(n-max[0][0][0]-max[0][1][0])<<endl;}
	else{int k=min(n-max[0][0][0]-max[1][1][0],n-max[1][0][0]-max[0][1][0]);cout<<k<<endl;}
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>


using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int ans = 0;
	long long int i = 2;
	long long int waru = i;

	while(n % waru == 0){
		ans ++;
		n /= waru;
		waru *= i;
	}
	waru /= i;
	while(n % i == 0){
		if(n % waru == 0) n /= waru;
		waru /= i;
	}
	for(long long int i = 3; i*i <= n; i+=2){
		long long int waru = i;
		while(n % waru == 0){
			ans ++;
			n /= waru;
			waru *= i;
		}
		while(n % i == 0){
			if(n % waru == 0) n /= waru;
			waru /= i;
		}
	}
	if(n != 1){
		ans ++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

double T, X;

int main(){
	cin >> T >> X;
	printf("%.10f\n", T / X);
}

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

n2 = [int(i) for i in input().split()]

r4 = 0
for i3 in range(n1):
    if i3 == 0:
        if n2[0] > n2[1]:
            continue


    elif i3 == n1 - 1:
        if n2[n1 - 1] > n2[n1 - 2]:
            continue
    
    else:
        if (n2[i3 - 1] > n2[i3] and n2[i3] > n2[i3 + 1]) or (n2[i3 + 1] > n2[i3] and n2[i3] > n2[i3 - 1]):
            r4 += 1
print(r4)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
// [gcd]
template<class T> T gcd(T a,T b)
{if (a < b) swap(a,b);return b ? gcd(b, a % b) : a;}
template<class T> T lcm(const T a, const T b)
{return (a * b / gcd(a, b));}
void Main(){
  string s;
  cin>>s;
  int n=s.length();
  int cn01=0;
  rep(i,n/2){
    if(s[2*i  ]=='0'){cn01++;}
    if(s[2*i+1]=='1'){cn01++;}
  }
  if(n%2==1) if(s[n-1]=='0'){cn01++;}
  cout<<min(cn01,n-cn01)<<endl;
} int main(int argc,char** argv)
{fastio; myio; Main();}


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

int main() {
  int n,m,l,r;
  cin >> n >> m;
  
  int maxl=0;
  int minr=10e5;
  
  for(int i=0; i<m; i++){
    cin >> l >> r;
    maxl=max(maxl,l);
    minr=min(minr,r);
    
  }
  
  int ans = minr-maxl+1;
  
  if(ans<0) cout << 0 << endl;
  else cout << ans << endl;
  
  return 0;
  
}

 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define mod 1000000007
int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= (m - i);
        ans %= mod;
    }
    ll p = 1;
    ll q = 0;
    for (int i = 0; i < n; i++) {
        int qq = q;
        q = (p+qq) * (n - i - 1);
        p *= (m - n);
        p += qq * (m - n + 1);
        p %= mod;
        q %= mod;
    }
    cout << ans*p%mod<< endl;
}

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

constexpr unsigned long MOD = 998244353;
constexpr unsigned long mx = 1000001;
constexpr unsigned long R = 4294967296, MODinv = 998244351, R2 = 932051910, mask = R - 1, R_bitsize = 32;

constexpr unsigned long montgomery_reduction(unsigned long a){
    return (a + (mask & a * MODinv) * MOD) >> R_bitsize;
}

template<unsigned long maxsize, unsigned long MOD, unsigned long primesize>
class divisor_convolution_coefficients{
    unsigned long sieve[maxsize];
public:
    unsigned long prime[primesize];
    unsigned long coef[maxsize];
    constexpr divisor_convolution_coefficients() : coef(), sieve(), prime(){
        coef[1] = 1;
        for(unsigned long i = 2; i < maxsize; ++i){
            coef[i] = i;
            sieve[i] = 1;
        }
        for(unsigned long i = 2, c = 0; i < maxsize; ++i)if(sieve[i]){
                prime[c++] = i;
                for(unsigned long j = i; j < maxsize; j += i){
                    sieve[j] = 0;
                    (coef[j] *= MOD + 1 - i) %= MOD;
                }
            }
    }
};

constexpr divisor_convolution_coefficients<mx, MOD, 78498> coef{divisor_convolution_coefficients<mx, MOD, 78498>()};

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    unsigned long ans{0};
    unsigned long max_size{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        max_size = max(i, max_size);
        ++hoge[i];
    }
    ++max_size;
    hoge.resize(max_size);

    for(const auto& i : coef.prime)for(unsigned long j = max_size / i; j; --j)hoge[j] += hoge[j * i] * i;
    for(auto& i : hoge)i %= MOD;

    ans = MOD - hoge[1];
    for(unsigned long i = 1; i < max_size; ++i)if(hoge[i])ans += hoge[i] * hoge[i] % MOD * coef.coef[i] % MOD;
    (ans += (ans & 1) * MOD) >>= 1;
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 8064
/*
    飲んだ魔剤で家が建つ。
    created at: 
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        if(k <= a) {
            System.out.println(k);
        } else if(k <= a + b) {
            System.out.println(a);
        } else {
            int m = k - a - b;
            System.out.println(a - m);
        }
    }
}

Measured memory_bytes: 35708
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

char s[1000001];
long long ans = 0;

struct node {
    bool last;
    int count[26];
    node* child[26];
};

node* create() {
    int i;
    node* n = new node();
    
    n->last = false;
    for (i = 0; i < 26; i++) n->count[i] = 0;
    for (i = 0; i < 26; i++) n->child[i] = NULL;
    
    return n;
}

int add(node* now, int x) {
    if (x == -1) {
        now->last = true;
        return 0;
    } else {
        int c = s[x] - 'a', p, i;
        
        if (now->child[c] == NULL) now->child[c] = create();
        
        p = add(now->child[c], x - 1) | (1 << c);
        
        for (i = 0; i < 26; i++) {
            if ((p >> i) & 1) now->count[i]++;
        }
        
        return p;
    }
}

void dfs(node* now) {
    int i, j;
    
    for (i = 0; i < 26; i++) {
        if (now->child[i] != NULL && now->child[i]->last) ans += now->count[i] - 1;
    }
    
    for (i = 0; i < 26; i++) {
        if (now->child[i] != NULL) dfs(now->child[i]);
    }
}

int main() {
    int n, i;
    node* top = create();
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int m;
        
        scanf("%s", s);
        
        m = strlen(s);
        
        add(top, m - 1);
    }
    
    dfs(top);
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 373824
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
void update(int& n, int m){
  n = max(n, m);
}

int main(){
  int C, N, M, X;
  while(cin>>C>>N>>M>>X && C){
    int c_s[101] = {}, e_s[101] = {};
    int c[101] = {}, e[101] = {};
    string tmp;
    REP(i, N) cin>>tmp>>c_s[i]>>e_s[i];
    REP(i, M){
      cin>>tmp>>c[i]>>e[i];
    }
    int dp[2][101][1001] = {}; // i use money
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    for(int i = 0; i < M; i++){
      for(int use = 0; use <= i; use++){
        for(int cost = 0; cost <= C; cost++){
          if(cost + c[i] <= C && dp[i % 2][use][cost] != -1) update(dp[(i + 1) % 2][use + 1][cost + c[i]], dp[i % 2][use][cost] + e[i]);
          update(dp[(i + 1) % 2][use][cost], dp[i % 2][use][cost]);
        }
      }
    }
    for(int use = 1; use <= M; use++){
      for(int cost = 1; cost <= C; cost++){
        update(dp[M%2][use][cost], dp[M%2][use][cost - 1]);
      }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
      for(int j = i + 1; j <= N; j++){
        int rest = C - (c_s[i] + c_s[j]);
        if(rest <= 0) continue;
        int effect_c = e_s[i] + e_s[j];
        int effect = 0;
        for(int use = X; use <= M; use++){
          update(effect, dp[M%2][use][rest]);
        }
        ans = max(ans, effect_c + effect);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2000
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 55555;

int vis[MaxN + 5],ans[MaxN + 5];

int main()
{
	int n,piu,sum;
	while(~scanf("%d",&n))
	{
		memset(vis,0,sizeof(0));
		piu = 0;
		for(int i = 2;i <= MaxN;i++)
		{
			if(vis[i] != 0) continue;
			for(int j = i;j <= MaxN;j += i) vis[j] = 1;
			vis[i] = 2;
			if(i % 5 == 1)  ans[++piu] = i;
		}
		printf("2");
		for(int i = 1;i < n;i++)
		{
			printf(" %d",ans[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main() {
    int a,b;
    while(1) {
        scanf ("%d",&a);
        scanf ("%d",&b);
        if (a == 0 && b == 0){
            break;
        }
        if (a <= b){
            printf ("%d %d\n", a, b);
        }
        else {
            printf ("%d %d\n", b, a);
        }
    }
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
long long ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}
 
signed main(){
	int n,m;
	cin>>n>>m;
	vector<int>x,y;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(a==1)x.push_back(b);
		else if(b==n)y.push_back(a);
	}
	sort(x);
	sort(y);
	int ne=0;
	for(int i=0;i<x.size();i++){
		for(int j=ne;j<y.size();j++){
			if(x[i]==y[j]){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}
			else if(x[i]<y[j]){
				ne=j;
				break;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int dp[110000];
    const int inf = 1e9;
    for (auto &v: dp) v = inf;
    dp[0] = 0;
    for (int i = 1; i < 110000; i++) {
        for (int j = 1; i - j >= 0; j *= 6) dp[i] = min(dp[i], dp[i-j] + 1);
        for (int j = 1; i - j >= 0; j *= 9) dp[i] = min(dp[i], dp[i-j] + 1);
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	int k;
	cin >> s >> k;

	set<string> se;

	rep(i, 26){

		rep(j, s.size()) {
			char c = 'a' + i;
			string ss = "";
			if (s[j] == c) {
				ss += c;
				se.insert(ss);
				if (j + 1 < s.size()) {
					ss += s[j + 1];
					se.insert(ss);
				}
				if (j + 2 < s.size()) {
					ss += s[j + 2];
					se.insert(ss);
				}
				if (j + 3 < s.size()) {
					ss += s[j + 3];
					se.insert(ss);
				}
				if (j + 4 < s.size()) {
					ss += s[j + 4];
					se.insert(ss);
				}
			}
		}
		if (se.size() >= 5)break;
	}

	auto itr = se.begin();
	rep(i, k - 1)itr++;
	cout << (*itr) << endl;

}

Measured memory_bytes: 256
function Main(input) {

  var input = input.split("\n");
  var arya = input[0].split(" ").map(val => parseInt(val, 10)).slice(0, 2);
  var x = arya[0];
  var a = arya[1];
  var result = 10;
  if(x < a){
    var result = 0;
  }

  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n;
	LLi ans=0;
	vector<int> v;

	cin>> n;
	v.resize(n);

	rep(i, n) cin >> v[i];

	sort(v.begin(), v.end(), greater<int>());

	rep(i, n/2) ans+=v[i];
	ans*=2;
	ans-=v[0];
	if(n%2==1) ans+=v[n/2];

	cout<< ans << endl;
 
	return 0;
}

Measured memory_bytes: 4032
import java.io.*;
class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(br.ready()) {
           String[] grades  = br.readLine().split(" ");
           int exam1 = Integer.valueOf(grades[0]);
           int exam2 = Integer.valueOf(grades[1]); 
           int examTotal = exam1 + exam2;
           int reExam    = Integer.valueOf(grades[2]);
           String clas  = null;
           if(exam1 == -1 && exam2 == -1 && reExam == -1 ) break;
           if(exam1 == -1 | exam2 == -1 ) {
              clas = "F";
           }
           else {
               clas  =  examTotal >= 80 ? "A" : 
               examTotal >= 65 & examTotal < 80 ? "B" :
               examTotal >= 50 & examTotal < 65 ? "C" :
               examTotal >= 30 & examTotal < 50 ? reExam >= 50 ? "C" : "D" :
               examTotal <  30 ? "F" : null;
           }
           System.out.println(clas);
        }
    }
}
     
           
        


Measured memory_bytes: 24440
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	inputA = parseInt(input[0]);
	inputB = parseInt(input[1]);
	
	var ret = inputA - 2*inputB;
	if (ret < 0) ret = 0;

	console.log(ret);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include<iostream>
#include <string>
#include <vector>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<char>  s(n);
    for(int i=0;i<n;i++){
        cin >> s.at(i);
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='Y'){
            count++;
        }
    }
    if(count==0) cout << "Three" << endl;
    else cout << "Four" << endl;
}

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

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

int main(){
	int K,ans=0;
  	cin>>K;
  	for(int a=1;a<=K;a++){
    	for(int b=1;b<=K;b++){
        	for(int c=1;c<=K;c++){
            	ans=ans+gcd(gcd(a,b),c);
            }
        }
    }
  	cout<<ans;
  	return 0;
}

Measured memory_bytes: 3640
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/

#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define fo(x,y) for(int x = 1 ; x <= y ; ++x)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;

typedef long long ll;
typedef unsigned int uint;
const int nmax = 200005;
const ll linf = LLONG_MAX;
const int mod = 1e9+7;
const int inf = INT_MAX;

ll h , n, a, sum;
int main(){
    cin >> h >> n;
    fo(i,n){
        cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes\n" : "No\n");

}


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

int check(int n)
{
    int res = 0;
    while (n % 2 == 0)
    {
        res++;
        n /= 2;
    }
    return res;
}


int main()
{
    int n, k, ans = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        ans += check(k);
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[1005];
ll dp[1005][10005];

int main() {
    ll H, N;
    cin >> H >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    REP(i, N + 1) {
        REP(j, H + 1) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    REP(i, N) {
        REP(j, H + 1) {
            dp[i + 1][j] = std::min(dp[i][j], dp[i + 1][j]);
            ll d = std::min(H, j + A[i].first);
            dp[i + 1][d] = std::min(dp[i + 1][d], dp[i + 1][j] + A[i].second);
        }
    }

    cout << dp[N][H] << endl;
    return 0;
}

Measured memory_bytes: 78464
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val allXor = aa.reduce { acc, i -> acc.xor(i) }
    val ans = mutableListOf<Int>()

    aa.forEach { a ->
        ans.add(a.xor(allXor))
    }

    println(ans.joinToString(separator = " "))
}

Measured memory_bytes: 73640
N=int(input())

def digitsum(x):
    res=0
    while x>0:
        res+=x%10
        x//=10
    return res

counter=90
for A in range(1,N):
    if digitsum(A)+digitsum(N-A)<counter:
        counter=digitsum(A)+digitsum(N-A)

print(counter)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

/*	verified	: 2020/09/26
	problem		: https://atcoder.jp/contests/abc177/tasks/abc177_d
	submission	: https://atcoder.jp/contests/abc177/submissions/17012779
*/
#include <iostream>
#include <vector>

struct union_find {
//private :
	const int N; // the number of nodes
	int M; // the number of trees
	std::vector<int> parent, sz;
public :
	union_find(const int& n) : N(n), M(n), parent(n, -1), sz(n, 1) {}
	const int& root(const int& i) {return (parent[i] == -1?i:root(parent[i]));}
	const int& size(const int& i) {return sz[root(i)];}
	bool is_united(const int& i, const int& j) {return (root(i) == root(j));}
	bool unite(int i, int j) {
		i = root(i); j = root(j);
		if (i == j) return false;
		if (sz[i] < sz[j]) std::swap(i, j);
		parent[j] = i;
		sz[i] += sz[j];
		M--;
		return true;
	}
};

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

 	int n, m;
	cin >> n >> m;
	union_find uf(n);
	while (m--) {
		int a, b;
		cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}
	cout << uf.M - 1 << endl;
}

Measured memory_bytes: 3976
// 2011/05/31 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int a, b;
		cin >> a;
		if(cin.eof())
			break;
		cin >> b;

		int m, n;
		if(a>=b){
			m = a;
			n = b;
		}
		else{
			m = b;
			n = a;
		}

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

		int gcd = n;
		int lcd = a/gcd*b;

		cout << gcd << ' ' << lcd << endl;
	}

	return 0;
}

Measured memory_bytes: 0
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int inverse(int x){
    return binpow(x, MOD - 2, MOD);
}
int ncr(int n, int k) 
{ 
    int ne = 1, de = 1; 
    if (k > n - k) k = n - k;
    for (int i = 0; i < k; ++i) { 
        de = (de * (i + 1)) % MOD;
        ne = (ne * (n - i)) % MOD;
    }
    return ne * inverse(de) % MOD;
} 
void solve()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = binpow(2, N, MOD) - 1 - ncr(N, A) - ncr(N, B);
    cout << (ans % MOD + MOD) % MOD << "\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1), B(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        B[i] = A[i] - i;
    }
    sort(B.begin()+1, B.end());
    int b = B[N/2+1];
    long long result = 0;
    for (int i = 1; i <= N; i++) {
        result += abs(A[i] - (b + i));
    }
    cout << result << endl;
    return 0;
}


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

using namespace std;

int dp[100000];

int main()
{
	int n, k; cin >> n >> k;
	vector<int> height(n);
	for (auto& el : height) cin >> el;

	for (auto i = 0; i < 100000; i++) dp[i] = numeric_limits<int>::max();
	dp[0] = 0;
	for (auto i = 1; i < n; i++)
		for (auto j = 1; j<=k && i-j >= 0; j++)
			dp[i] = min(dp[i], dp[i-j] + abs(height[i - j] - height[i]));

	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;
using namespace std;

int dis(int a, int b) {
        return abs(a-b);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 2);
    REP(i,n){
        cin >> a.at(i + 1);
    }
    a.at(0) = 0;
    a.at(n + 1) = 0;
    
    int sum = 0;
    for (int i = 0; i < n + 1; i++)
        sum += dis(a.at(i),a.at(i + 1));
    int res;
    for (int i = 0; i < n; i++) {
        res = sum;
        res += - dis(a.at(i),a.at(i + 1)) - dis(a.at(i + 1),a.at(i + 2)) + dis(a.at(i),a.at(i + 2));
        cout << res << endl;
    }
}



Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll a, b, c, d;

ll gcd(ll a, ll b) {
	return (b == 0 ? a : gcd(b, a % b));
}
int main() {
	cin >> a >> b >> c >> d;
	ll x = abs(c - a), y = abs(d - b);
	cout << x + y - gcd(x, y) << endl;
}

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

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

    int n; cin >> n;
    vector<int> a(n+2, 0);

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

    int cost = 0;
    for (int i = 0; i < n+1; ++i) {
        cost += abs(a[i] - a[i+1]);
    }

    int ans;
    for (int i = 1; i <= n; ++i) {
        ans = cost + abs(a[i-1] - a[i+1])
            - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]));
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664