akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
template <typename T> bool chmin(T &x, const T &y) {if (x > y) {x = y; return true;} return false;}
template <typename T> bool chmax(T &x, const T &y) {if (x < y) {x = y; return true;} return false;}

struct RollingHash {
    static constexpr int base1 = 1007, base2 = 2009;
    static constexpr int mod1 = 1000000007, mod2 = 1000000009;
    vector<ll> hash1, hash2, pow1, pow2;
    RollingHash (const string &S) {
        int length = SZ(S);
        hash1.assign(length + 1, 0);
        hash2.assign(length + 1, 0);
        pow1.assign(length + 1, 1);
        pow2.assign(length + 1, 1);
        rep(i, length) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    pair<ll, ll> get(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return pair<ll, ll>{res1, res2};
    }
};

int main() {
    string T, P;
    cin >> T >> P;
    
    RollingHash RHT(T), RHP(P);
    rep(i, SZ(T) - SZ(P) + 1) {
        if (RHT.get(i, i + SZ(P)) == RHP.get(0, SZ(P))) cout << i << "\n";
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)2e5 + 10;
ll low[N];
ll high[N];

struct Sweep{
  ll mod;
  ll pos;
  int sign;
  bool operator< (const Sweep &R){
    if(mod == R.mod){
      if(pos == R.pos) return sign < R.sign;
      return pos < R.pos;
    }
    return mod < R.mod;
  }
};

int main(){
  fastIO;
  ll x, d;
  int n;
  cin >> n >> x >> d;
  if(d == 0){
    if(x == 0) cout << 1 << "\n";
    else cout << n + 1;
    return 0;
  }
  if(d < 0) d = -d, x = -x;
  low[0] = high[0] = 0;
  for(int i = 1; i <= n; i ++ ){
    low[i] = (low[i - 1] + (i-1));
    high[i] = (high[i - 1] + (n-i));
  }
  ll p;
  ll li, ri;
  vector<Sweep> iv;
  for(int k = 0 ; k <= n; k ++ ){
    p = (k * 1ll * x) % d;
    if(p < 0) p += d;
    li = low[k];
    ri = high[k];
    li += (k*1ll*x)/d;
    ri += (k*1ll*x)/d;
    iv.push_back({p, li, +1});
    iv.push_back({p, ri + 1, -1});
  }
  sort(iv.begin(), iv.end());
  int sm = 0;
  ll ans = 0;
  for(int i = 0 ; i < iv.size(); i ++ ){
    sm += iv[i].sign;
    if(sm > 0){
      ans += iv[i + 1].pos - iv[i].pos;
    }
  }
  cout << ans << "\n";
  return 0; 
}


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

#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    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
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

int k;

void input() {
  scanf("%d", &k);
}

void solve() {
  int e = 0;
  int o = 0;
  for (int i = 1; i <= k; i++) {
    if (i % 2 == 0)
      e++;
    else
      o++;
  }
  printf("%d\n", e * o);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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();
        
        if (a < b && b < c) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26400
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  int n;
  string s,t;
  cin >> n >> s >> t;
  for(int i=0; i<n; i++){
    cout << s[i] << t[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  string s;
  cin >> s;
  if (s.at(0) == '7') cout << "Yes" << endl;
  else if (s.at(1) == '7') cout << "Yes" << endl;
  else if (s.at(2) == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n, m;
  LL diff;
  vector<vector<pair<int, LL>>> g;
  vector<LL> val;
  vector<LL> visit;
  vector<LL> mini;
  set<pair<int, int>> used;
  int oddloop;
  Solver(LL n) : n(n), g(n), val(n), visit(n, -1), mini(2, LINF), oddloop(0){};
  void no() {
    cout << 0 << endl;
    exit(0);
  }
  void dfs(int v, int p) {
    mini[visit[v]] = min(mini[visit[v]], val[v]);
    for (int i = 0; i < g[v].size(); ++i) {
      auto x = g[v][i];
      if (used.count(make_pair(v, x.first))) continue;
      if (x.first != p) {
        if (visit[x.first] >= 0) {
          if (visit[x.first] == visit[v]) {
            used.insert({x.first, v});
            oddloop++;
            if ((val[x.first] + val[v]) % 2 != x.second % 2) {
              cout << 1 << endl;
              exit(0);
            } else if (val[x.first] + val[v] != x.second) {
              diff = (-val[x.first] - val[v] + x.second) / 2;
              auto tmp = val[v] + diff;
              fill(visit.begin(), visit.end(), -1);
              val[v] = tmp;
              visit[v] = 0;
              mini[0] = mini[1] = LINF;
              used = set<pair<int, int>>();
              dfs2(v, -1);
              if (min(mini[0], mini[1]) <= 0)
                cout << 0 << endl;
              else
                cout << 1 << endl;
              exit(0);
            }
          } else {
            if (val[x.first] + val[v] != x.second) {
              no();
            }
          }
        } else {
          visit[x.first] = !visit[v];
          val[x.first] = x.second - val[v];
          dfs(x.first, v);
        }
      }
    }
  }
  void dfs2(int v, int p) {
    mini[visit[v]] = min(mini[visit[v]], val[v]);
    for (int i = 0; i < g[v].size(); ++i) {
      auto x = g[v][i];
      if (used.count(make_pair(v, x.first))) continue;
      if (x.first != p) {
        if (visit[x.first] >= 0) {
          if (val[x.first] + val[v] != x.second) {
            no();
          }
        } else {
          visit[x.first] = !visit[v];
          val[x.first] = x.second - val[v];
          dfs2(x.first, v);
        }
      }
    }
  }
  void solve() {
    cin >> m;
    for (int i = 0; i < m; ++i) {
      int u, v, s;
      cin >> u >> v >> s;
      --u;
      --v;
      g[u].push_back({v, s});
      g[v].push_back({u, s});
    }
    val[0] = 1;
    visit[0] = 0;
    dfs(0, -1);
    if (oddloop >= 1) {
      if (min(mini[0], mini[1]) <= 0)
        cout << 0 << endl;
      else
        cout << 1 << endl;
    } else {
      cout << max<LL>(0, mini[0] + mini[1] - 1) << endl;
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

typedef long long ll;

int main() {
  ll n;
  cin >> n;

  bool flag = true;
  ll prod = 1, a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a > 1000000000000000000 / prod) {
      flag = false;
    } else {
      prod *= a;
    }

    if (a == 0) {
      flag = true;
      break;
    }
  }

  cout << ((flag) ? prod : -1) << endl;
}

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

int main()
{
    long long int n;
    cin>>n;
    if(n%2==1)
        cout<<0;
    else
    {
        long long int ans=0,j=n/10,k=n/100;
        while(n!=0)
        {
            ans+=n/10;
            n=n/10;
        }
        while(j!=0)
        {
            ans+=j/5;
            j=j/5;
        }
        while(k!=0)
        {
            ans-=k;
            k/=10;
        }
        cout<<ans;
    }
    
}

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


Measured memory_bytes: 128
import java.util.*;
public class Main 
{
	static int days[] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		while(n-- != 0)
		{
			int y = stdIn.nextInt();
			int m = stdIn.nextInt();
			int d = stdIn.nextInt();
			int sum = 0;
			for(int i = y + 1; i < 1000; ++i)
			{
				if(i % 3 == 0)
				{
					sum += 200;
				}
				else
				{
					sum += 195;
				}
			}
			if(y % 3 == 0)
			{
				for(int i = m; i < 10; ++i)
				{
					sum += 20;
				}
				sum += 20 - d;
			}
			else
			{
				for(int i = m; i < 10; ++i)
				{
					sum += days[i];
				}
				if(m % 2 == 0)
				{
					sum += 19 - d;
				}
				else
				{
					sum += 20 - d;
				}
			}
			System.out.println(sum + 1);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int max = 0;
		int before = 0;
		int cnt = 0;
		for (int i=0;i<N;i++) {
			int H = Integer.parseInt(sc.next());
			if (before>=H) {
				cnt++;
			} else {
				cnt=0;
			}
			before = H;
			max = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 47048
n,l=input().split()
n=int(n)
s=f=0
l=int(l)

for i in range(n):
    a=l+i
    if(a==0):
        f=1
    else:
        s+=a
if(f==0):
    if(l<0):
        s-=(l+n-1)
    else:
        s-=l
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define fgx cerr<<"-------------"<<endl
#define N 2333
#define T 2*n+5
#define add(a,b,c,d) adde(a,b,c,d),adde(b,a,0,-(d))
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
void dbg(){cerr<<endl;}
template<typename A,typename... B>void dbg(A x,B... y){cerr<<x<<" ";dbg(y...);}
#define debug(...) cerr<<#__VA_ARGS__<<"=",dbg(__VA_ARGS__)
int head[N],tot=1,vis[N],n,pre[N]; ll dis[N];
struct Edge{int u,v,w,f,next;ll c;}edge[N*100];
inline void adde(int x,int y,int w,int c){edge[++tot]=Edge{x,y,w,0,head[x],c};head[x]=tot;}
inline int spfa()
{	for(rint i=0;i<=T;i++) dis[i]=-1e18; queue<int> q; q.push(0); dis[0]=0; pre[T]=-1;
	while(!q.empty())
	{	int x=q.front(); vis[x]=0; q.pop();
		for(rint i=head[x];i;i=edge[i].next)
		if(dis[to]<dis[x]+edge[i].c&&edge[i].f<edge[i].w)
		{	dis[to]=dis[x]+edge[i].c; pre[to]=i;
			if(!vis[to])q.push(to),vis[to]=1;
		}
	}
	return pre[T]!=-1;
}
inline ll mcmf(int f=0,ll c=0)
{	while(spfa())
	{	int mn=1e9; for(rint i=pre[T];i;i=pre[edge[i].u]) mn=min(mn,edge[i].w-edge[i].f);
		f+=mn; c+=dis[T]*mn; for(rint i=pre[T];i;i=pre[edge[i].u]) edge[i].f+=mn,edge[i^1].f-=mn;
	}
	return c;
}
int main()
{	int x,y,k; cin>>n;
	for(rint i=1;i<=n;i++)
	{	scanf("%d%d%d",&x,&y,&k),add(0,i,k,0);
		add(i,2*n+1,k,x+y),add(i,2*n+2,k,x-y),add(i,2*n+3,k,y-x),add(i,2*n+4,k,-x-y);
	}
	for(rint i=1;i<=n;i++)
	{	scanf("%d%d%d",&x,&y,&k),add(n+i,T,k,0);
		add(2*n+1,n+i,k,-x-y),add(2*n+2,n+i,k,y-x),add(2*n+3,n+i,k,x-y),add(2*n+4,n+i,k,x+y);
	}
	cout<<mcmf();
	return 0;
}


Measured memory_bytes: 896
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({ a * c,a * d,b * c,b * d }) << endl;
	return 0;
	
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
	int seito[30]={0},i,no;

	for(i=0;i<28;i++){
		scanf("%d",&no);
		seito[no-1]=1;
	}
	for(i=0;i<30;i++){
		if(!seito[i]){
			printf("%d\n",i+1);
		}
	}
	return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

ull cnt = 0;
ull N;
void calc(ull div){
    if(N / div < 1) return;
    cnt += N / div;
    div *= 5;
    calc(div);
}
int main() {
    cin >> N;
    if(N % 2 == 1) puts("0");
    else{
        calc(10);
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    char C;
    cin>>C;
    cout<<char(int(C)+1);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>

using namespace std;
typedef long long ll; //64bit型

const int INF = 1050000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int N_MAX = 2010;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() //input->compute->output
{
    int i = 1;
    while (1)
    {
        int x;
        cin >> x;
        if (x == 0)
            break;
        printf("Case %d: %d\n", i, x);
        i++;
    }

    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int k, n;
	cin >> k >> n;

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

	int maxi = k - a.back() + a[0];
	for (int i = 1; i < n; i++) {
		maxi = max(maxi, a[i] - a[i-1]);
	}
	int ans = k - maxi;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(n):
  m = i
  for j in range(i, n):
    if l[j] < l[m]:
      m = j
  if m != i:
    l[i], l[m] = l[m], l[i]
    c += 1
print(*l)
print(c)


Measured memory_bytes: 5604
from itertools import combinations
import numpy as np
n,m,x=map(int, input().split())

S = []
for i in range(n):
    A=list(map(int, input().split()))
    S.append(A)

ans = 10**9
for i in range(1,n+1):
    for comb in combinations(S,i):
        #print(comb)
        tmp = np.array([0]*m)
        
        cost = 0
        for s in comb:
            tmp += np.array(s[1:])
            cost += s[0]
        #print(tmp)
        #print(cost)
        cnt = 0
        for t in tmp:
            if t >= x: cnt+=1
        #print(cnt,m)
        if cnt == m:
            ans = min(ans,cost)
if ans == 10**9:
    print(-1)
else:
    print(ans)
        
        

Measured memory_bytes: 27172
import java.util.Scanner;

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

        for (int i0 = 0; i0 <= n && 10000 * i0 <= y; i0++) {
            for (int i1 = 0; i0 + i1 <= n && 10000 * i0 + 5000 * i1 <= y; i1++) {
                for (int i2 = 0; 10000 * i0 + 5000 * i1 + 1000 * i2 <= y && i0 + i1 + i2 <= n; i2++) {
                    if (10000 * i0 + 5000 * i1 + 1000 * i2 == y && i0 + i1 + i2 == n) {
                        System.out.println(String.format("%d %d %d", i0, i1, i2));
                        return;
                    }
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23380
function main(arg) {
	arg = arg.split("\n")
	var N = Number(arg[0])
	var s = arg[1]
	var nr = s.split("R").length - 1
	var nb = s.split("B").length - 1
	if (nr > nb) {
		console.log("Yes")
	} else {
		console.log("No")
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(void){
string s;cin>>s;
char x[5];
strcpy(x,s.c_str());
sort(x,x+4);
cout<<((x[0]==x[1])&&(x[2]==x[3]&&x[0]!=x[3])?"Yes":"No")<<endl;
return 0;}


Measured memory_bytes: 3632
A, B, C = map(int, input().split())

AA, BB, CC = A, B, C
cnt = 0
while True:
    if (A % 2) | (B % 2) | (C % 2):
        print(cnt)
        exit(0)
    a, b, c = A // 2, B // 2, C // 2
    A, B, C = b + c, a + c, a + b
    cnt += 1
    if (A == B) & (B == C):
        print(-1)
        exit(0)
    if (A == AA) & (B == BB) & (C == CC):
        print(-1)
        exit(0)


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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

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

    if (n % 2 == 0) {
        cout << n << endl;
    } else {
        cout << (n * 2) << endl;
    }

    return 0;
}


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

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

const long long INF = 1LL << 60;

int main(){
  int n, r;
  cin >> n >> r;

  int ans = r + 100 * max(0, 10-n);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# Contest No.: ABC169
# Problem No.: D
# Solver:      JEMINI
# Date:        20200531

import sys
import heapq

def main():
    temp = [True] * (10 ** 6 + 10)
    temp[0] = False
    temp[1] = False
    for i in range(2, 10 ** 6 + 10):
        if temp[i]:
            cnt = 2 * i
            while cnt < 10 ** 6 + 10:
                temp[cnt] = False
                cnt += i
    prime = []
    for i in range(10 ** 6 + 10):
        if temp[i]:
            prime.append(i)
 
    n = int(input())
    ans = 0
    tempN = n
    for i in prime:
        if i > tempN:
            break
        if tempN % i:
            continue
        div = 0
        while tempN % i == 0:
            tempN = tempN // i
            div += 1
        tempAns = int((div * 2) ** 0.5)
        if tempAns * (tempAns + 1) // 2 > div:
            tempAns -= 1
        #print(tempAns)
        ans += tempAns
    if tempN > 1:
        ans += 1
    print(ans)
    return
 
if __name__ == "__main__":
    main()

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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main() {
  int a,b,d,g;cin>>a>>b;
  bool c=true,f=true,e=true;
  g=b;
  rep(i,a-1){
    cin>>d;
    g=gcd(g,d);
  }
   cout<<g;
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 100005
#define maxm 200005
int n,m,ia,pa,qa;
bool f,val[maxn],vis[maxn];
struct node { int v; node *nxt; } edge[maxm*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(int u)
{
	vis[u]=true;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(!vis[v]) { val[v]=val[u]^1; dfs(v); }
		else if(val[u]==val[v]) f=true;
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		if(!head[i]) ia++;
		else if(!vis[i])
		{
			f=false;
			dfs(i);
			if(f) pa++;
			else qa++;
		}
	}
	printf("%lld\n",1ll*ia*ia+2ll*ia*(n-ia)+1ll*pa*pa+2ll*qa*qa+2ll*pa*qa);
}


Measured memory_bytes: 9216
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,x,k;
  cin>>n>>m>>x;
  vector<int> a(n+1);
  for(int i=0;i<n+1;i++){
    a[i]=0;
  }
  for(int i=0;i<m;i++){
    cin>>k;
    a[k]++;
  }
  
  int ans1=0,ans2=0;
  for(int i=x+1;i<n+1;i++){
    if(a[i]==1) ans1++;
  }
  
  for(int i=x-1;i>=1;i--){
    if(a[i]==1) ans2++;
  }
   printf("%d",ans2>ans1?ans1:ans2);
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=3000,M=3000;
int n,m;
int a[N+1];
int dp[M+1];//dp' 
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++){
		if(m==a[i])(ans+=1ll*i*(n-i+1)%mod)%=mod;
		else if(m>a[i])(ans+=1ll*dp[m-a[i]]*(n-i+1)%mod)%=mod;//更新答案 
		for(int j=m;j>=a[i];j--)(dp[j]+=dp[j-a[i]]+(j==a[i]?i:0))%=mod;//转移 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	string a;
	cin>>n;
	cin>>a;
	cin>>k;
	for(int i=0;i<n;i++)
	{
		if(a[k-1]==a[i])
		{
			cout<<a[i];
		}
		if(a[k-1]!=a[i])
		{
			cout<<'*';
		}
	}
	return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	//p = p.split("\n");//2 or more
	const X=parseInt(p);
	//const t=p[1];
	//const N = parseInt(p[0]);//N
    //const A = parseInt(p[1].split(" ")[0]);//N M
	//const B = parseInt(p[1].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...

	//let w = new Array(s.length+1);
	//let ans = new Array(Math.max(s.length,t.length));
	//for(let i=0;i<=s.length;i++)w[i]=new Array(t.length+1).fill(-1);
	//let v = new Array(N);
	//let c=new Array(N);
    //let z=new Array(N);
    let t=100,i=0;
    while(++i){
        t*=1.01;
        t=Math.floor(t);
        if(X<=t)break;
    }
    console.log(i);
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29976
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]
 
N = int(input())
L = [None]*N
for i in range(N):
    *L[i], = map(int, input().split())
 
p = (0, 0, 0, 1, 1, 2, 2, 3)
ok = 1
for i in range(N):
    Li = L[i]
    for j in range(i+1, N):
        Lj = L[j]
        for k in range(24):
            if Li == Lj:
                ok = 0
            Lj[:] = (Lj[e] for e in D[p[k%8]])
print("Yes" if ok else "No")


Measured memory_bytes: 5608
fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (p, q, r) = reader.readLine()!!.split(" ").map { it.toInt() }

    var ans = Int.MAX_VALUE

    ans = Math.min(ans, p + q)
    ans = Math.min(ans, q + r)
    ans = Math.min(ans, p + r)

    println(ans)
}

Measured memory_bytes: 35648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,a[max_n],b[max_n];
struct Node{
    int x;
    bool operator < (Node p)const {
        return b[x]<b[p.x];
    }
};
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",a+i);
    for(int i=0;i<n;i++)scanf("%d",b+i);
    for(int i=0;i<n;i++){
        if(b[i]<a[i]){
            printf("-1\n");
            return 0;
        }
    }
    priority_queue<Node> que;
    for(int i=0;i<n;i++)if(b[i]>a[i])que.push({i});
    ll ans=0;
    while(!que.empty()){
        Node p=que.top();que.pop();
        int x=p.x;
        int k=b[(x+1)%n]+b[(x+n-1)%n];
        int delt=b[x]-a[x];
        if(delt<k){
            printf("-1\n");
            return 0;
        }
        ans+=delt/k;
        b[x]=a[x]+delt%k;
        if(b[x]!=a[x])que.push({x});
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2936
import string

def Getletterfromindex(num):

    num2alphadict = dict(zip(range(1, 27), string.ascii_lowercase))
    outval = ""
    numloops = (num-1) //26

    if numloops > 0:
        outval = outval + Getletterfromindex(numloops)

    remainder = num % 26
    if remainder > 0:
        outval = outval + num2alphadict[remainder]
    else:
        outval = outval + "z"
    return outval

num = int(input())

print(Getletterfromindex(num))

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	set<char> all;
	string s;
	cin >> s;
	for (auto u : s) all.insert(u);
	if (all.count('N') ^ all.count('S')) puts("No");
	else if (all.count('E') ^ all.count('W')) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [list(input()) for _ in range(n)]

def check(a):
    t = s[a:] + s[:a]
    t_t = list(map(list, zip(*t)))
    
    return t == t_t

ans = [check(a) for a in range(n)]
print(ans.count(True) * n)

Measured memory_bytes: 4760
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n;

main(){
	cin>>n;
	cout<<(n==25?"Christmas":n==24?"Christmas Eve":n==23?"Christmas Eve Eve":n==22?"Christmas Eve Eve Eve":0)<<endl;
}


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

const int N=205; 

using namespace std;

int n,cnt; 
int r[N]; 

int main(){
	cin>>n; 
	n<<=1; 
	for(int i=1; i<=n; ++i) cin>>r[i];
	sort(r+1,r+n+1);  
	for(int i=1; i<=n; i+=2) cnt+=r[i]; 
	cout<<cnt<<endl; 
	return 0; 
}

Measured memory_bytes: 256
w, h, n = map(int,input().split())
p = [list(map(int,input().split())) for i in range(n)]

l, r, b, t = 0, w, 0, h
for i in range(n):
    if p[i][2] == 1:
        l = max(l, p[i][0])
    if p[i][2] == 2:
        r = min(r, p[i][0])
    if p[i][2] == 3:
        b = max(b, p[i][1])
    if p[i][2] == 4:
        t = min(t, p[i][1])

W = r-l if r > l else 0
H = t-b if t > b else 0
print(W*H)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.size()%2 != 0)
    {
        cout << "No\n";
        return 0;
    }
    for(int i=0;i<n/2;i++)
    {
        if(s[i] != s[n/2+i])
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

using namespace std;

int main(void)
{
    string S, T;
    cin >> S >> T;

    if(S == T.substr(0, S.length())){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int B[] = new int[N];

		for (int i=0;i<N;i++) {
		B[i] = sc.nextInt();
		}

		int cnt=0;
		loop: while(true){
			for (int i=0;i<N;i++) {
				if(B[i]%2==1){
					break loop;
				}
			}
			for (int i=0;i<N;i++) {
				B[i]/=2;
			}
			cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/dsu> 
using namespace atcoder;

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

  int n, m; cin >> n >> m;
  dsu DSU(n);

  rep (i, m) {
    int x, y; cin >> x >> y;
    x--, y--;
    DSU.merge(x, y);
  }

  cout << DSU.groups().size()-1 << '\n';
  
  return 0;
}

Measured memory_bytes: 8872
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;

int main(){
	int n,h;
	cin >> n >> h;

	vector<int> b(n);
	int a = 0;
	for(int i = 0;i < n;i++){
		int aa;
		cin >> aa >> b[i];
		a = max(aa,a);
	}

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

	int cnt = 0;
	for(int i = 0;i < n;i++){
		if(a > b[i])break;
		else{
			h -= b[i];
			cnt++;
			if(h <= 0)break;
		}
	}

	if(h > 0)cnt += (h + a - 1) / a;
	cout << cnt << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[6010];
int dp[2010][2010];
using tiii = tuple<int, int, int>;
int ma_row[2020];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N * 3) cin >> A[i];

	rep(i, 1, N + 1) rep(j, 1, N + 1) dp[i][j] = -inf;
	dp[A[0]][A[1]] = dp[A[1]][A[0]] = 0;
	rep(i, 1, N + 1) ma_row[i] = -inf;
	ma_row[A[0]] = ma_row[A[1]] = 0;

	int additionalPoint = 0;
	int ma = 0;

	rep(i, 0, N - 1) {
		int idx = i * 3 + 2;

		vector<int> nxt;
		rep(j, 0, 3) nxt.push_back(A[idx + j]);
		sort(all(nxt));

		if (nxt[0] == nxt[1] && nxt[1] == nxt[2]) {
			additionalPoint++;
			continue;
		}

		vector<tiii> changeQueue;
		rep(_a, 0, 3) rep(_b, 0, 3) if(_a != _b) {
			int a = nxt[_a], b = nxt[_b], c = (nxt[0] + nxt[1] + nxt[2] - a - b);

			// dp[i][x][y] -> dp[i + 1][x][a]
			rep(x, 1, N + 1) {
				int opt = ma_row[x];
				if (b == c) chmax(opt, dp[x][b] + 1);
				changeQueue.push_back(tiii(x, a, opt));
			}

			// dp[i][any][any] -> dp[i + 1][a][b]
			int ma2 = ma;
			chmax(ma2, dp[c][c] + 1);
			changeQueue.push_back(tiii(a, b, ma2));
		}

		fore(t, changeQueue) {
			int x, y, val;
			tie(x, y, val) = t;

			chmax(dp[x][y], val);
			chmax(dp[y][x], val);
			chmax(ma_row[x], val);
			chmax(ma_row[y], val);
			chmax(ma, val);
		}
	}

	int ans = 0;
	rep(x, 1, N + 1) rep(y, 1, N + 1) chmax(ans, dp[x][y] + ((x == y && x == A[N * 3 - 1]) ? 1 : 0));
	ans += additionalPoint;
	cout << ans << endl;
}







Measured memory_bytes: 19524
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int main()
{
	FAST;
	string str;
	cin >> str;

	int minDiff = 100000;
	for(int i=0 ; i<str.size()-2 ; i++)
	{
		int ans = 0;
		ans += (str[i]-'0')*100;
		if(i+1 < str.size())
			ans += (str[i+1]-'0')*10;
		if(i+1 < str.size())
			ans += str[i+2]-'0';

		minDiff = min(minDiff , abs(753-ans));
	}
	cout << minDiff;
	return 0;
}

Measured memory_bytes: 256
import numpy as np


def get_prime_factorized(N):
    result    = []
    base, exp = 2, 0
    while base ** 2 <= N:
        while N % base == 0:
            N    = N // base
            exp += 1
        if exp > 0:
            result.append([base, exp])
        base, exp = base + 1, 0
    if N > 1:
        result.append([N, 1])
    return result

def re_func_divisior(prime_factorized):
    base, exp = prime_factorized.pop()
    P = re_func_divisior(prime_factorized) if prime_factorized else [[]]
    Q = [[base ** k] for k in range(exp + 1)]
    return [p + q for p in P for q in Q]

def get_list_divisor(N, reverse=True):
    try:
        prime_factorized = get_prime_factorized(N)
        res    = re_func_divisior(prime_factorized)
        result = []
        for k in res:
            for i, x in enumerate(k):
                if i == 0:
                    r = x
                else:
                    r *= x
            result.append(r)
        result = sorted(result, reverse=reverse)
    except:
        result = [N]
    return result


N, K = map(int, input().split())
A    = list(map(int, input().split()))

X = get_list_divisor(sum(A))

is_break = False

for x in X:
    POS = sorted([a % x for a in A if a % x != 0])
    NEG = [x - pos for pos in POS]
    POS_cumsum = np.cumsum(POS)
    NEG_cumsum = np.cumsum(NEG[::-1])[::-1]
    for sep in range(1, len(POS)):
        if POS_cumsum[sep-1] == NEG_cumsum[sep] and POS_cumsum[sep-1] <= K:
            is_break = True
            break
    if is_break:
        break

print(x)


Measured memory_bytes: 14416
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}

int main()
{
    int n;
    cin>>n;
    int x=n;
    long long sum=0;
    while(n>0){
        sum+=(n%10);
        n/=10;
    }

    if(x%sum==0)
            cout<<"Yes\n";
     else
            cout<<"No\n";
}


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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ret = b / x - a / x;
    if (a % x == 0)
        ret++;
    cout << ret << endl;
    return 0;
}

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

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines().skip(1);

  let x = lines.next().unwrap().unwrap()
    .split_whitespace()
    .map(|s| s.parse::<i64>().unwrap())
    .collect::<Vec<_>>();

  let y = lines.next().unwrap().unwrap()
    .split_whitespace()
    .map(|s| s.parse::<i64>().unwrap())
    .collect::<Vec<_>>();

  let p1 = x.iter().zip(y.iter())
    .fold(0, |acc, (&x, &y)| acc + (x - y).abs());

  let p2 = (x.iter().zip(y.iter())
    .fold(0, |acc, (&x, &y)| acc + (x - y).abs().pow(2)) as f64).sqrt();

  let p3 = (x.iter().zip(y.iter())
    .fold(0, |acc, (&x, &y)| acc + (x - y).abs().pow(3)) as f64).powf(1.0 / 3.0);

  let pinf = x.iter().zip(y.iter())
    .fold(0, |acc, (&x, &y)| std::cmp::max(acc, (x - y).abs()));

  println!("{}\n{}\n{}\n{}", p1, p2, p3, pinf);
}



Measured memory_bytes: 5160
#include<stdio.h>
int main(void){

int n, m, X, Y, z, f, x[100], y[100], i, j, t;

scanf("%d %d %d %d", &n, &m, &X, &Y);
for(i=0; i<n; i++){
 scanf("%d", &x[i]);
}
for(i=0; i<m; i++){
 scanf("%d", &y[i]);
}
for(i=0; i<n-1; i++){
 for(j=n-1; j>i; j--){
 if(x[j]<x[j-1]){
  t=x[j];
  x[j]=x[j-1];
  x[j-1]=t;
}
}
}
for(i=0; i<m-1; i++){
 for(j=m-1; j>i; j--){
 if(y[j]<y[j-1]){
  t=y[j];
  y[j]=y[j-1];
  y[j-1]=t;
}
}
}


for(z=X+1; z<=Y; z++){
 f=0;
 for(i=0; i<n; i++){
  if(x[i]>=z){
   f=1;
   break;
  }
 }
 if(f==0){
 for(i=0; i<m; i++){
  if(y[i]<z){
   f=1;
   break;
  }
  }
 }

 if(f==0)
  break;
}

if(f==0)
 printf("No War\n");
else
 printf("War\n");


return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

int main(){
	int p,x[4],c[4]={10,50,100,500},d=1,flag=0;
	while(1){
		cin>>p;
		if(p==0)break;
		else{
		       if(flag)cout<<endl;
		       flag=1;
		}
		d=0;
		rep(i,4)cin>>x[i];
		rep(i,4)d+=x[i]*c[i];
		d-=p;
		rrep(i,4)x[i]-=d/c[i],d%=c[i];
		rep(i,4)if(x[i]>0)cout<<c[i]<<" "<<x[i]<<endl;
	}
}
		

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

//#include<stdio.h>

int main()

{
	
	int a,b,x,c1,c2;
	
	scanf("%d %d %d",&x,&a,&b);
	
	c1=abs(x-a);
	
	c2=abs(x-b);
	
	
	if(c1<c2)
	
	printf("A");
	
	else
	
	printf("B");
	
	
	return 0;
}


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

int main() {
	int x,a,b;
	cin >> x >> a >> b;
	if(x-a>0){
		if(x-b>0){
			if(b>a){
				cout << "B" << endl;
			}
			else cout << "A" << endl;
		}
		else if(a+b-2*x>0){
			cout << "A" << endl;
		}
		else cout << "B" << endl;
	}
	else if(x-b>0){
		if(a+b-2*x>0){
			cout << "B" << endl;
		}
		else cout << "A" << endl;
	}
	else if(a<b){
		cout << "A" << endl;
	}
	else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;




public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n1  = sc.nextInt();
		int n2  = sc.nextInt();
		int n3  = sc.nextInt();
		
		
		
		if( n1 > n2 ) {
			int tmp = n1;
			n1 = n2;
			n2 = tmp;
		}
		if( n2 > n3 ) {
			int tmp = n2;
			n2 = n3;
			n3 = tmp;
		}
		if( n1 > n2 ) {
			int tmp = n1;
			n1 = n2;
			n2 = tmp;
		}
		
		System.out.println(n1 + " " + n2 + " " + n3);
		
		
	}

}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    
    long long x,no;
    cin>>x>>no;
    bool exist[210]={};
    rep(i,no){
        int p;
        cin>>p;
        exist[p]=true;
    }
    int n=0;
    while(1){
        if(x-n>=0 && !exist[x-n]){
            cout<<x-n<<endl;
            break;
        }
        else if(x+n<=110 && !exist[x+n]){
            cout<<x+n<<endl;
            break;
        }
        
        n++;
    }

    return 0;

}
/*


*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n,m;
    cin>>n>>m;
    int a[n];

    lli count=0;
    f1(i,m) {
        cin>>a[i];
        count+=a[i];
    }

    (count>n)?cout<<"-1"<<endl:cout<<n-count<<endl;
    
    return 0;
}

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

int main() {
  int n;
  int m;
  int s[100100];
  int c[100100];
  int nn[4];
  int nf[4]; 
  int tr = 1;

  cin >> n >> m;
  for ( int i=1 ; i <= n ; ++i ){
    nn[i] = 0;
    nf[i] = 0;
  }
  if ((m == 0) && (n==1)){   cout << 0 << endl; return 0;}
  if ((m == 0) && (n==2)){   cout << 10 << endl;  return 0;}
  if ((m == 0) && (n==3)){   cout << 100 << endl;  return 0;}
  for ( int i=1 ; i <= m ; ++i ) {
    cin >> s[i] >> c[i];
    // cout << i;
    // cout << s[i] << c[i];
    if (nf[s[i]] == 0 ){
      nf[s[i]] = 1;
      nn[s[i]] = c[i];
    }
    if (nn[s[i]] != c[i]){
      cout << -1 << endl; 
      return 0;     
    } 
    if (s[i] == 1 && c[i] == 0 && n >=2){
      cout << -1 << endl; 
      return 0;     
    }
  }
  if (tr == 0) {
    cout << -1 << endl;
  } else
  {
    for ( int i=1 ; i <= n ; ++i ){
      if (( i == 1 ) && ( n > 1 ) && ( nn[i] == 0)) {
        cout << 1;
      }else
      {
        cout << nn[i];
      }
    }
    cout << endl;
  }
}

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

using namespace std;
int dp[10][100001];

int main()
{
	int n, d, x;
	int p[11][11], diff[11][11][11];

	scanf("%d %d %d", &n, &d, &x);

	memset(diff, 0, sizeof(diff));

	for (int i = 0; i < d; i++){
		for (int j = 0; j < n; j++){
			scanf("%d", &p[i][j]);
		}
	}

	
	for (int i = 0; i < d - 1; i++){
		memset(dp, 0, sizeof(dp));
		dp[i][x] = x;
		for (int j = i + 1; j < d; j++){
			for (int k = 0; k < n; k++){
				for (int l = 0; l + p[i][k] <= x; l++){
					dp[j][l + p[i][k]] = max(dp[j][l + p[i][k]], dp[j][l] + p[j][k] - p[i][k]);
				}
			}
		}

		x = x + dp[i + 1][x];
	}

	printf("%d\n", x);

	return (0);
}

Measured memory_bytes: 5108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author Node2
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  

       
        String str = in.readLine();
        
        int a = Integer.parseInt(str);
        
        str = in.readLine();
        
        int b = Integer.parseInt(str);       
        str = in.readLine();
        
        int h = Integer.parseInt(str);

  
        int anser = (a+b)*h/2;
        
        System.out.println(anser);
    }
    

}



Measured memory_bytes: 7892