akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N;

	cin >> N;

	int C[N], V[N], A[N];
	long ans = 0;

	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		int tmp = V[i] - C[i];
		if(tmp > 0) ans += V[i] - C[i];
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  int m;
  while (1)
  {
    cin >> n >> m;
    if (n == 0)
      break;
    vi a(n);
    REP(i, n)
    {
      cin >> a[i];
    }
    int cnt;
    int ans = 0;
    REP(i, n)
    {

      REP(j, n)
      {
        if (i == j)
        {
          continue;
        }
        cnt = a[i] + a[j];
        if (cnt > m)
        {
          continue;
        }
        ans = max(ans, cnt);
      }
    }
    if (ans == 0)
    {
      cout << "NONE" << endl;
    }
    else
    {
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3100
//ΔAGC007E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 133333;
int n,f[N],g[N],l[N],r[N];
LL m;
vector<pair<LL,LL> > v[N],t,w;
void dfs(int u){
	if(!l[u]){
		v[u].push_back(make_pair(g[u],g[u]));
		return;
	}
	int x=l[u],y=r[u],sx,sy,i,j;
	LL o;
	dfs(x);
	dfs(y);
	sx=v[x].size();
	sy=v[y].size();
	for(i=0,j=sy-1;i<sx&&j>=0;){
		while(j>=0&&v[x][i].first+v[y][j].first>m){
			j--;
		}
		while(i+1<sx&&v[x][i+1].first+v[y][j].first<=m){
			i++;
		}
		if(i<sx&&j>=0){
			t.push_back(make_pair(v[x][i].second+g[u],v[y][j].second+g[u]));
			i++;
			j--;
		}
	}
	sx=t.size();
	for(i=0,j=sx-1;i<sx||j>=0;){
		if(j<0||(i<sx&&t[i].second<t[j].first))
			w.push_back(make_pair(t[i].second,t[i].first)),i++;
		else
			w.push_back(t[j]),j--;
	}
	t.clear();
	sx=w.size();
	o=1e13;
	for(i=0;i<sx;i=i+1)
		if(w[i].second<o)
			v[u].push_back(w[i]),o=w[i].second;
	w.clear();
}
int main()
{
	int i;
	LL le,ri;
	scanf("%d",&n);
	for(i=2;i<=n;i=i+1){
		scanf("%d%d",f+i,g+i);
		if(!l[f[i]])
			l[f[i]]=i;
		else
			r[f[i]]=i;
	}
	le=0,ri=1e12;
	while(le<ri){
		m=le+ri>>1;
		dfs(1);
		if(v[1].size())
			ri=m;
		else
			le=m+1;
		for(i=1;i<=n;i=i+1)
			v[i].clear();
	}
	cout<<le;
	return 0;
}

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

int T[501][501];

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

  int N,M;
  cin >> N >> M;

  vector<int> SUMS(N+1);
  SUMS[0] = 0;
  rep(i, N) {
    int a; cin >> a;
    SUMS[i + 1] = (SUMS[i] + a) % M;
  }

  map<int, int> m;
  ll ans = 0;
  rep(i, N + 1) {
    ans += m[SUMS[i]];
    m[SUMS[i]]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X, Y;
  cin >> X >> Y;
  bool flag = false;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      if (i + j == X && 2 * i + 4 * j == Y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

public class Program{
  public static int med3(int x, int y, int z){
    if(x<y){
      if(y<z) return y; else if(z<x) return x; else return z;
    }else{
      if(z<y) return y; else if(x<z) return x; else return z;
    }
  }
  public static void sort(ref int[] a, int l, int r){
    if(l<r){
      int i=l, j=r;
      int y = i+(j-i)/2;
      if(y%2==0) y--;
      int t1, t2, p=med3(a[i], a[y], a[j]);
      while(true){
        while(a[i]<p) i+=2;
        while(p<a[j]) j-=2;
        if(i>=j) break;
        t1 = a[i-1]; t2 = a[i];
        a[i-1] = a[j-1]; a[i] = a[j];
        a[j-1] = t1; a[j] = t2;
        i+=2; j-=2;
      }
      sort(ref a, l, i-2);
      sort(ref a, j+2, r);
    }
  }
  public static void Main(){
    var nm = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    var a = new int[2*nm[1]];
    for(var i=0; i<nm[1]; i++){
      var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
      a[2*i] = ab[0];
      a[2*i+1] = ab[1];
    }
    sort(ref a, 1, 2*nm[1]-1);
    //for(var i=0; i<nm[1]; i++)Console.WriteLine("[{0} {1}]", a[2*i], a[2*i+1]);
    var c=0;
    var b=0;
    for(var i=0; i<nm[1]; i++){
      if(b<a[2*i]){ b=a[2*i+1]-1; c++; }
    }
    Console.WriteLine(c.ToString());
  }
}


Measured memory_bytes: 17312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int inf = 1e9;
const int mod = 1e9+7;
char mat[maxn][maxn];
ll dp[maxn][maxn];
void dodaj(ll &a, ll b){
    a+=b;
    if(a>=mod)a-=mod;
    if(a<=-mod)a+=mod;
}
int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)cin >> mat[i][j];
    }
    if(mat[0][0] == '#')return cout << 0, 0;
    for(int i=0;i<n;i++){
        if(mat[0][i] == '#')break;
        dp[0][i] = 1;
    }
    for(int i=0;i<n;i++){
        if(mat[i][0] == '#')break;
        dp[i][0]=1;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(mat[i][j] == '#')continue;
            if(mat[i-1][j] == '.')dodaj(dp[i][j],dp[i-1][j]);
            if(mat[i][j-1] == '.')dodaj(dp[i][j],dp[i][j-1]);
        }
    }
    if(mat[n-1][m-1] == '.')cout << dp[n-1][m-1] << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 9088
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int[] d = new int[a];
		int[] e = new int[a];
		for(int i = 0; i < a; i++){
			d[i] = sc.nextInt();
          e[i] = sc.nextInt();
		} 
		
		double b = 0;
		for(int i = 0;i < a;i++){
			for(int j = 0;j < a;j++){
				b += Math.pow(((d[i] - d[j]) * (d[i] - d[j]) + (e[i] - e[j]) * (e[i] - e[j])),0.5);
				//System.out.println(i);
              	//System.out.println(j);
              	// System.out.println(e[i]);
              	// System.out.println(e[j]);
              	//System.out.println(Math.pow(((d[i] - d[j]) * (d[i] - d[j]) + (e[i] - e[j]) * (e[i] - e[j])),0.5));
              	
            }
		}
		b = b / (a);
		System.out.println(b);
		
		
	}
}

Measured memory_bytes: 36048
#include<iostream>
#include<math.h>
#include <cstdio>
#define pi 3.14159265

using namespace std;

int main()
{
	double dis,ang;
	double nx,ny;
	double nang=pi/2.0,hang=90;
	nx=ny=0;
	while(scanf("%lf,%lf",&dis,&ang),dis){
		ny+=dis*sin(nang);
		nx+=dis*cos(nang);
		nang=(hang-ang)*pi/180;
		hang-=ang;
	}

	cout<<(int)nx<<endl<<(int)ny<<endl;
	return 0;
}

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

int main(){
  string w;
  int cnt[26]={};
  int flag[26];
  int i=0;
  cin>>w;

  for(i=0;i<w.size();i++){
    cnt[w[i]-'a']++;
  }

  for(i=0;i<26;i++){
    //cout<<cnt[i];
    if(cnt[i]%2==0){
      flag[i]=0;
    }else{
      flag[i] =-1;
    }
  }

  int sum =accumulate(flag,flag+25,0);

  if(sum>=0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
vector<ll> G[110000];
bool used[110000]={};
vector<ll> a(110000);
void dfs(ll v,vector<ll> &val){
  if(used[v]) return;
  used[v]=true;
  val.push_back(a[v]);
  for(auto nv:G[v]){
    dfs(nv,val);
  }
}
signed main(){
  init_io();
  ll n,m,need,ans=0;
  cin >> n >> m;
  vector<ll> x(m),y(m),tmp,lest;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
    G[x[i]].push_back(y[i]);
    G[y[i]].push_back(x[i]);
  }
  if(m==n-1){
    cout <<"0\n";
    return 0;
  }
  need = 2*(n-m-1);
  for(int i=0;i<n;i++){
    if(!used[i]){
      dfs(i,tmp);
      sort(tmp.begin(),tmp.end());
      ans += tmp[0];
      need--;
      for(int j=1;j<tmp.size();j++){
        lest.push_back(tmp[j]);
      }
      tmp.clear();
    }
  }
  if(need<0){
    cout <<"Impossible\n";
    return 0;
  }
  sort(lest.begin(),lest.end());
  ll lcnt = lest.size();
  for(int i=0;i<need;i++){
    if(i==lcnt){
      cout <<"Impossible\n";
      return 0;
    }
    ans += lest[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 11384
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    x ^= x >> 32
    x ^= x >> 64
    x ^= x >> 128
    x ^= x >> 256
    x ^= x >> 512
    x ^= x >> 1024
    x ^= x >> 2048
    x ^= x >> 4096
    x ^= x >> 8192
    x ^= x >> 16384
    x ^= x >> 32768
    x ^= x >> 65536
    x ^= x >> 131072
    x ^= x >> 262144
    x ^= x >> 524288
    return x & 1

N = int(input()) - 1
s = 1
while N:
    l = N & -N
    s *= 1 + (1 << l)
    N ^= l

A = input()
if "2" in A:
    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
    print(popcount_parity(a & s))
else:
    a = int(A.replace("1", "0").replace("3", "1"), 2)
    print(popcount_parity(a & s) * 2)

Measured memory_bytes: 87536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, z, w;
const int MAXN = 2005;
int dp[2][MAXN][MAXN];
int mx[2][MAXN][MAXN], mn[2][MAXN][MAXN];
vector<int> a;
const int INF = 1234567890;

int main() {
    scanf("%d%d%d", &n, &z, &w);
    a.push_back(z);
    a.push_back(w);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a.push_back(x);
    }
    n += 2;

    dp[0][n - 2][n - 1] = dp[1][n - 2][n - 1] = abs(a[n - 2] - a[n - 1]);
    mx[0][n - 2][n - 1] = dp[0][n - 2][n - 1];
    mn[0][n - 2][n - 1] = dp[0][n - 2][n - 1];
    mx[1][n - 2][n - 1] = dp[1][n - 2][n - 1];
    mn[1][n - 2][n - 1] = dp[1][n - 2][n - 1];
    for (int i = n - 3; i >= 0; i--) {
        for (int p = 0; p < 2; p++) {
            for (int j = i + 1; j < n; j++) {
                if (p == 0) {
                    dp[p][i][j] = -INF;
                } else {
                    dp[p][i][j] = INF;
                }
                if (j == n - 1) {
                    dp[p][i][j] = abs(a[i] - a[j]);
                } else {
                    if (p == 0) {
                        dp[p][i][j] = mx[1 - p][j][j + 1];
//                    for (int k = j + 1; k < n; k++) {
//                        dp[p][i][j] = max(dp[p][i][j], dp[1 - p][j][k]);
//                    }
                    } else {
                        dp[p][i][j] = mn[1 - p][j][j + 1];
//                    for (int k = j + 1; k < n; k++) {
//                        dp[p][i][j] = min(dp[p][i][j], dp[1 - p][j][k]);
//                    }
                    }
                }
            }

            mx[p][i][n - 1] = dp[p][i][n - 1];
            mn[p][i][n - 1] = dp[p][i][n - 1];
            for (int j = n - 2; j >= 0; j--) {
                mx[p][i][j] = max(mx[p][i][j + 1], dp[p][i][j]);
                mn[p][i][j] = min(mn[p][i][j + 1], dp[p][i][j]);
            }
        }
    }

    cout << dp[0][0][1] << endl;

    return 0;
}

Measured memory_bytes: 94464
use std::io;


fn main() {
    let (n, k) = {
        let i = read::<i64>();
        (i[0], i[1])
    };

    println!("{}", k * (k - 1).pow((n - 1) as u32));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int gcd(int p, int q) {
	if (p < q) swap(p, q);
	if (p % q == 0) return q;
	else return gcd(p / q, p % q);
}
int keta(long p, int q) {
	if (p / 10 == 0) return q + 1;
	else return keta(p / 10, q + 1);
}
long long kaijo(int p, int q) {
	if (p == 1) return q;
	else return kaijo(p - 1, p * q);
}
long long Combination(int p, int q, int r, long long tmp) {
	if (q == 0) return tmp;
	else {
		tmp = tmp * p / r;
		tmp %= 1000000007;
		return Combination(p - 1, q - 1, r + 1, tmp);
	}
}
long long ruijo(long long p, long long q) {
	long long ans = 1;
	rep(i, q) {
		ans *= p;
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	//テンプレート
	using pll = pair<long long, long long>;

	long long a, b, c, d, A, B, C, D, ans;
	cin >> a >> b >> c >> d;
	A = max(a, b) * max(c, d);
	B = max(a, b) * min(c, d);
	C = min(a, b) * max(c, d);
	D = min(a, b) * min(c, d);
	ans = max(max(A, B), max(C, D));
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

typedef long long LL;

int main() {
    LL takahashi_cookie, aoki_cookie,k;

    cin >> takahashi_cookie >> aoki_cookie >> k;
    if(k >= takahashi_cookie) {
        aoki_cookie -= k - takahashi_cookie;
        if(aoki_cookie < 0) {
            aoki_cookie = 0;
        }
        takahashi_cookie = 0;
    } else {
        takahashi_cookie -= k;
    }

    cout << takahashi_cookie << " " << aoki_cookie << endl;

    return 0;
}

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

using namespace std;

#define MAX_N 100
#define MAX_C 100001
#define INF (1<<29)
typedef pair<int, int> pii;

int m[MAX_N];
pii dp[2][MAX_C];

void set_m(vector<int> &p)
{
    for (int i = 0; i < (int)p.size(); i++) {    
        m[i] = ((p[i] - 1) / 1000 + 1) * 1000;
    }
}

void update(pii &a, pii &b)
{
    if (a.first < b.first) {
        a = b;
    } else if (a.first == b.first) {
        if (a.second > b.second) {
            a = b;
        }
    }
}

int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> p(N);
        for (int i = 0; i < N; i++) {
            cin >> p[i];
        }
        
        set_m(p);
        
        memset(dp, -1, sizeof(dp));
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < MAX_C; j++) {
                dp[i][j] = pii(-1, INF);
            }
        }
        
        dp[0][0] = pii(0, 0);
        for (int i = 0; i < N; i++) {
            int curr = (i & 1), next = !(i & 1);
            for (int j = 0; j < MAX_C; j++) {
                if (dp[curr][j].first == -1) continue;
                
                update(dp[next][j], dp[curr][j]);
                
                {
                    int pay = m[i];
                    int change = pay - p[i];                    

                    int _500 = (change / 500);
                    int nc = j + change - _500 * 500;                    
                    
                    pii ncost = pii(dp[curr][j].first + _500,
                                    dp[curr][j].second + p[i]);                    
                    
                    update(dp[next][nc], ncost);
                }
                
                {
                    int pp = p[i] % 1000;
                    if (pp > 500 || pp == 0) {
                        if (abs(pp - 500) <= j) {
                            int pay = m[i] + abs(pp - 500);
                            int change = pay - p[i];
                            int _500 = (change / 500);
                            int nc = j - abs(pp - 500) + change - _500 * 500;
                            
                            pii ncost = pii(dp[curr][j].first + _500,
                                            dp[curr][j].second + p[i]);                    
                    
                            update(dp[next][nc], ncost);
                        }
                    } 
                }
            }
            
            for (int j = 0; j < MAX_C; j++) {
                dp[curr][j] = pii(-1, INF);
            }
        }
        
        pii res = pii(-1, INF);
        for (int i = 0; i < MAX_C; i++) {
            update(res, dp[N&1][i]);            
        }
        cout << res.first << " " << res.second << endl;
    }
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
 using namespace std;
const long long int mod=1e9+7;
typedef long long ll;

ll dfs(int K,const vector<vector<int>>&graph, int now,int from) {
int cancol;
 if (from==-1) {
cancol=K-1; 
}
else { cancol=K-2;
}
if (K<graph[now].size()) {
return 0; }
else {
ll case_num=1;
 for (auto e : graph[now]) {
if(e==from)continue;
case_num*=cancol; cancol--; case_num%=mod;
}
for (auto e : graph[now]) {
if(e==from)continue;
case_num *=dfs(K,graph,e,now);
case_num %= mod; 
}
return case_num; 
}
}
int main() {
int n,k;
cin>>n>>k;
vector<vector<int>>graph(n); 
for(int i=0;i<n-1;++i){
int a,b;
cin>>a>>b;
a--;b--;
graph[a].push_back(b);
graph[b].push_back(a); 
}
ll ans=k*dfs(k,graph,0,-1); 
ans%=mod;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 11520
#include<stdio.h>
#define MAX_V  1000000
int prime[MAX_V+1];
int a[MAX_V];
int data[30];
int n,count=0,k=0;

int main(void)
{
  int i, k, v;
  for(i = 2; i <= MAX_V; i++)
    prime[i] = 1;

  for(i = 2; i*i <= MAX_V; i++)
    if(prime[i])
      for(k = 2 * i; k <= MAX_V; k += i)
        prime[k] = 0;

  while(scanf("%d",&n)!=EOF)
    for(i=n;i>=2;i--)
      if(prime[i]==1 && prime[i-2] == 1){
          printf("%d %d\n",i-2,i);  break;
        }
}

Measured memory_bytes: 5660
data = [[[0 for r in range(10)] for f in range(3)] for b in  range(4)]
n = int(input())
for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Measured memory_bytes: 7724
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n;
    cout<<n+n*n+n*n*n<<"\n";
    return 0;
}



Measured memory_bytes: 3644
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
vector <int> v;
int a;
int n,m;
int main()
{
  cin>>n;
  v.pb(0);
  for(int i=1;i<=n;i++)
  {
    cin>>a;
    v.pb(a);
  }
  v.pb(0);
  int last=0;
  for(int i=1;i<=n+1;i++)
  {
    m+=max(v[i]-last,last-v[i]);
    last=v[i];
  }
  for(int i=1;i<=n;i++)
  {
    if(v[i-1]>=v[i] && v[i]>=v[i+1]
     ||v[i-1]<=v[i] && v[i]<=v[i+1])
      cout<<m<<endl;
    else if(v[i-1]>v[i] && v[i]<v[i+1])
      cout<<m-2*(min(v[i-1],v[i+1])-v[i])<<endl;
    else if(v[i-1]<v[i] && v[i]>v[i+1])
      cout<<m-2*(v[i]-max(v[i-1],v[i+1]))<<endl;
  }
  return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=1e9+7;
const int maxx=1e7;
int a[maxx];
int main()
{
    int n;
    scanf("%d",&n);
    int c=0;
    for(int i=2;i<=n;i++)
         {
             int l=i;
             for(int j=2;j<=l;j++)
             {
                while(l%j==0)
                {
                    a[j]++;
                    l/=j;
                }
             }

        }
        long long sum=1;
        for(int i=2;i<=n;i++)
        {
            if(a[i])
            {
                sum*=(1+a[i]);
                sum=sum%maxn;
            }
        }
        printf("%lld\n",sum%maxn);
        return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    double v[n];
    for(int a=0;a<n;a++){
        scanf("%lf",&v[a]);
    }
    for(int b=0;b<n-1;b++){
        for(int c=1;c<n-b;c++){
            if(v[b]>v[b+c]){double tmp;
            tmp=v[b];
            v[b]=v[b+c];
            v[b+c]=tmp;}
        }
    }
    for(int d=0;d<n-1;d++){
        double e;
        e=(v[d]+v[d+1])/2;
        v[d+1]=e;
    }
    printf("%f\n",v[n-1]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define gap " "
#define pi 2 * acos (0.0)

int main()
{
    
    int n;
    cin>> n;
    char c[n];
    cin >> c[0];
    int s=1;
    for (int i=1;i<n;i++){
        cin>> c[i];
        if (c[i]!=c[i-1]) s++;
    }
    cout << s <<endl;
}


Measured memory_bytes: 3696
// 2020-08-24 22:56:49
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
const int mod = 1000000007;
struct mint {
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % mod) {
    if (val < 0) val += mod;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = mod, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += mod;
    u %= mod;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += mod;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % mod;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % mod;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

void answer() {
  int n, m;
  cin >> n >> m;
  vector<ll> x(n), y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];
  mint X = 0;
  rep(i, n-1) {
    ll l = i + 1, r = n - i - 1;
    X += mint(1) * l * r * (x[i+1] - x[i]);
  }
  mint Y = 0;
  rep(i, m-1) {
    ll l = i + 1, r = m - i - 1;
    Y += mint(1) * l * r * (y[i+1] - y[i]);
  }
  cout << X * Y << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main()
{
	int x;
	cin>>x;
	int i = 3;
	while (i <= x)
	{
		int k = i;
		if (i % 3 == 0)
			cout <<" "<<i;
		else
		{
			while (k != 0)
			{
				if (k % 10 == 3)
				{
					cout <<" "<<i;
					break;
				}
				k = k/10;
			}
		}
		i ++;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n, k;
	cin >> n >> k;
	set<int> st;
	for(int i = 1; i <= n; ++i) st.insert(i);

	while(k--){
		int d;
		cin >> d;
		while(d--){
			int x;
			cin >> x;
			st.erase(x);
		}
	}

	cout << st.size() << endl;
	
	return 0;
}

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

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    ll d = abs(a-b);

    if((v-w)*t >= d) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 3596
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [usize;n],
    }
    a.sort();
    a.push(0);
    let mut b: Vec<(usize,usize)> = Vec::new();
    let mut cnt = 0;
    for i in 0..n {
        let tmp = a[i];
        cnt += 1;
        if a[i+1]==tmp {
            continue;
        } else {
            debug!(cnt);
            if cnt>=2 {
                b.push((tmp, cnt));
            }
            cnt = 0;
        }
    }
    debug!(b);
    if b.len()==0 {
        println!("0");
    } else if b.len()==1 {
        if b[0].1<4 {
            println!("0");
        } else {
            println!("{}", b[0].0*b[0].0);
        }
    } else {
        if b[b.len()-1].1<4 {
            println!("{}", b[b.len()-1].0*b[b.len()-2].0);
        } else {
            println!("{}", b[b.len()-1].0*b[b.len()-1].0);
        }
    }

}


Measured memory_bytes: 4728
from heapq import *
from numpy import array
INF = 10**15

def djikstra(G,s,d):
    #d = [0]*V
    que = []
    d[s] = 0
    visited = [False] * V
    heappush(que,(0,s))
    while(len(que)!=0):
        c,v = heappop(que)
        if visited[v]:
            continue
        visited[v] = True
        for i in range(len(G[v])):
            e = G[v][i]
            if visited[e[0]]:
                continue
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heappush(que,(d[e[0]],e[0]))


n,m,s,t = map(int,input().split())
V = n
Ga = [[] for i in range(n)]
Gb = [[] for i in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    Ga[u-1].append((v-1,a))
    Ga[v-1].append((u-1,a))
    Gb[u-1].append((v-1,b))
    Gb[v-1].append((u-1,b))

S = [INF]*V
T = [INF]*V
djikstra(Ga,s-1,S)
djikstra(Gb,t-1,T)

M = INF-(array(S)+array(T))
ans = [0]*n
ans[n-1] = M[n-1]
for i in range(n-2,-1,-1):
    ans[i] = max(ans[i+1],M[i])

for i in range(n):
    print(ans[i])


Measured memory_bytes: 95856
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = input()

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string S, T;
  cin >> S >> T;
  i64 ans = 1e9;
  for (i64 i = 0; i < S.size() - T.size() + 1; i++)
  {
    i64 tmp = 0;
    for (i64 j = 0; j < T.size(); j++)
      if (S[i + j] != T[j])
        tmp++;
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;

string t;
string s;
vector<int> id;

int go(int i,int j) {
	int res = 0;
	int n = s.length();
	string o = s.substr(i,j-i+1);
	// cout << o << endl;
	for(int a=i,b=j;;) {
		if(a>=0 && b<n && s[a]==s[b]) {
			if(a!=b) o = s[a] + o + s[b];
			a--;
			b++;
		} else if(a>=0 && s[a]=='x') {
			o = s[a] + o + s[a];
			res++;
			a--;
		} else if(b<n && s[b]=='x') {
			o = s[b] + o + s[b];
			res++;
			b++;
		} else {
			o = s[a] + o + s[b];
			a--;
			b++;
		}
		// cout << o << endl;
		if(a<0 && b>=n) break;
	}
	// cout << s << " " << o << " " << i << " " << j << " " << res << endl;
	return res;
}

 
int main() {
	int res = 0;
	cin >> s;
	for(int i = 0; i < s.length(); i++) if(s[i]!='x') {
		t += s[i];
		id.push_back(i);
	}
	if(t.length()==0) {
		cout << 0 << endl;
		return 0;
	}
	bool f = true;
	for(int i = 0; i < t.length(); i++) if(t[i] != t[t.length()-1-i]) f = false;
	if(!f) {
		res = -1;
	} else {
		int i = id[t.length()/2-1];
		int k = id[t.length()/2];
		int cnt = 1;
		for(int j = 0; j+1 < t.length(); j++) {
			if(t[j]!=t[j+1]) cnt = 2;
		}
		if(t.length()%2==0) {
			res = go(i,k);
		} else {
			res = go(k,k);
		}
	}
	cout << res << endl;
	return 0;
}




Measured memory_bytes: 1272
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int N;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println(N % 2 == 0 ? N : N * 2);
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

#define int long long

int n, x, y;
int ans[3000];

signed main(){
	cin >> n >> x >> y;
	x--;
	y--;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			int val;
			val = abs(i - j);
			val = min(val, abs(i - x) + abs(j - y) + 1);
			val = min(val, abs(i - y) + abs(j - x) + 1);
			ans[val]++;
		}
	}
	for(int i = 1; i < n; i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a = int(readline())
    ans = a + a**2 + a**3
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include <iostream>

using namespace std;

int main (){
  int a,b;
  cin >> a >> b;
  
  double x = (double)(a+b)/2;
  
  int y =(int)((10*x))%10;
  
  if(y>=5){
    cout << ((a+b)/2)+1 <<endl;
  }else{
    cout << (a+b)/2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  scanf("%d\n",&n);
  int d[n-1];
  for(int a=0;a<n;a++){
    scanf("%d\n",&d[a]);
  }
  int x = n;
  for(int b=1;b<n;b++){
    for(int c=0;c<b;c++){
      if(d[b] == d[c]){
        x--;
        c = b;
      }
    }
  }
  printf("%d\n",x);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  long long L = 1, LL = 2;
  for (int i = 1; i < N; i++) {
    long long tmp;
    tmp = L;
    L += LL;
    LL = tmp;
  }
  cout << L << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define nmax 200005
#define pii pair<int,int>
using namespace std;
int n, ans, a[nmax], br[nmax];
int main() {
    cin>>n;
    for (int i=1;i<=n;++i){
        cin>>a[i];
    }
    int curr = 1;
    for (int i=1;i<=n;++i){
        if (a[i] == curr){
            ++curr;
        } else {
            br[i] = 1;
        }
    }
    int destr = 0;
    for (int i=1;i<=n;++i){
        if (br[i]){
            ++destr;
        }
    }
    if (destr == n){
        ans = -1;
    } else {
        ans = destr;
    }
    cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1920
def main():
  N, M = map(int, input().split())
  anss = []
  for _ in range(N):
    anss.append(set(list(map(int, input().split()))[1:]))

  # print(ans)
  result = set([i for i in range(31)])
  for ans in anss:
    result = result & ans

  print(len(result))
  

main()

Measured memory_bytes: 3060
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main (m shops)
  (loop for shop in (sort shops (lambda (a b) (< (car a) (car b))))
        until (zerop m)
       sum 
           (progn
             (let ((buy (min m (cdr shop))))
               (decf m buy)
               (* buy (car shop))))))

(let* ((n (read))
       (m (read))
       (shops (collect-times n (cons (read) (read)))))
  (princ (main m shops)))


Measured memory_bytes: 64572
n  =int(input())
ls = []
for  i in range(n):
    x,y  =map(int,input().split())
    ls.append((x,y))
import itertools
ans = 0
cnt = 0
a = [i for i in range(n)]
for aa in itertools.permutations(a):
    cnt +=1
    idx = aa[0]
    xp,yp =  ls[idx]
    for idx in aa:
        x,y =  ls[idx]
        ans += ((x-xp)**2 + (y-yp)**2)**0.5
        xp ,yp = x,y
print(ans/cnt)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

vector<ll> a;

template<typename T>
map<T, long long> factorize(T x) {
  map<T, long long> res;
  for (ll i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      res[i] = 1;
      res[x / i] = 1;
    }
  }
  return res;
}

int main() {
  ll n,p; cin >> n >> p;
  ll res = 1;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  if (p <= n) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> mp = factorize(p);
  for (auto itr : mp) {
    ll test = itr.first;
    ll tar = itr.first;
    ll cpy = p / tar, cnt = 1;
    
    if (p / tar < tar) {
      break;
    }

    if (tar == 1) continue;

    while(true) {
      if (cpy % tar == 0 and cpy > 0) cnt++;
      else {
        break;
      }
      test *= tar;
      cpy /= tar;
    }

    // cout << cnt << endl;

    if (cpy != 0) {
      test *= cpy;
    }

    // cout << test << endl;

    if (cnt >= n and test == p) {
      res = tar;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int N;
bitset<200002> vis[2];
vi G[2][200002];
map<ii, vi> mp;

struct UFDS {
	int p[200002], rank[200002] = { 0 };
	int find_set(int i) { return (p[i] == i) ? i : (p[i] = find_set(p[i])); }
	bool same_set(int i, int j) { return find_set(i) == find_set(j); }
	void union_set(int i, int j) {
		if (same_set(i, j)) return;
		int x = find_set(i), y = find_set(j);
		rank[x] > rank[y] ? p[y] = x : p[x] = y;
		if (rank[x] == rank[y]) rank[y]++;
 	}
} U[2];

void dfs(int i, int u) {
	vis[i][u] = 1;
	for (auto v : G[i][u]) {
		if (!vis[i][v]) {
			U[i].union_set(u, v);
			dfs(i, v);
		}
	}
}

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

	int K[2]; cin >> N >> K[0] >> K[1];
	for (int i = 0; i < 2; ++i) {
		while (K[i]--) {
			int u, v; cin >> u >> v;
			G[i][u].push_back(v), G[i][v].push_back(u);
		}
	}
	for (int u = 1; u <= N; u++) U[0].p[u] = U[1].p[u] = u;
	for (int i = 0; i < 2; ++i) {
		for (int u = 1; u <= N; ++u) {
			if (!vis[i][u]) dfs(i, u);
		}
	}
	for (int u = 1; u <= N; ++u)
		mp[ii(U[0].find_set(u), U[1].find_set(u))].push_back(u);
	for (int u = 1; u <= N; ++u)
		cout << mp[ii(U[0].find_set(u), U[1].find_set(u))].size() << ' ';
}

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

int main() {
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  for(int i = 0; i < t; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans;
  if(a.at(0) <= (k + 1) / 2) ans = 0;
  else if(k % 2) ans = (a.at(0) - (k+1) / 2) * 2;
  else ans = 1 + (a.at(0) - k / 2 - 1) * 2;
  
  cout << ans << endl;  
}

Measured memory_bytes: 3616
import java.util.*

fun main(args: Array<String>) {
    abc141d()
}

fun abc141d() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toLong() }
        .toLongArray()

    val queue = PriorityQueue<Long>(n, Comparator { o1: Long, o2: Long -> if (o1 > o2) -1 else 1 })
    aList.forEach { queue.add(it) }

    repeat(m) {
        val max = queue.poll()
        val halved = max / 2

        queue.add(halved)
    }

    println(queue.sum())
}


Measured memory_bytes: 71728
#include <stdio.h>
#include <math.h>
int main(){
    double q,x;
     
    while(scanf("%lf",&q) !=EOF){
    	if(q==-1)	break;
    	x = q/2;
    	while(fabs(pow(x,3)-q) >= 0.00001 * q){
    		x = x-(pow(x,3)-q)/(3.0 * pow(x,2));
    	}
    	printf("%lf\n",x);
    }
    return 0;
}



Measured memory_bytes: 2020
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
string S;
signed main(){
    cin >> N >> S;
    int ans = 0;
    rep(i, N-2){
        if(S.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);    
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char> (w)), tmp(h, vector<char> (w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int si = 0; si < (1 << h); si++) {
        for (int sj = 0; sj < (1 << w); sj++) {
            tmp = c;
            for (int i = 0; i < h; i++) {
                if (si & (1 << i)) {
                    for (int j = 0; j < w; j++) {
                        tmp[i][j] = '0';
                    }
                }
            }        
            for (int j = 0; j < w; j++) {
                if (sj & (1 << j)) {
                    for (int i = 0; i < h; i++) {
                       tmp[i][j] = '0';
                    }
                }
            }           
            int cnt = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    cnt += (tmp[i][j] == '#');
                }
            }
            ans += (cnt == k);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3644