akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

class dice{
public:
	int a[7];
	void moveS(){
		int temp = a[1];
		a[1] = a[5];
		a[5] = a[6];
		a[6] = a[2];
		a[2] = temp;
	}

	void moveW(){
		int temp = a[1];
		a[1] = a[3];
		a[3] = a[6];
		a[6] = a[4];
		a[4] = temp;
	}

	void moveN(){
		int temp = a[1];
		a[1] = a[2];
		a[2] = a[6];
		a[6] = a[5];
		a[5] = temp;
	}

	void moveE(){
		int temp = a[1];
		a[1] = a[4];
		a[4] = a[6];
		a[6] = a[3];
		a[3] = temp;
	}
};

int main(){
	dice x;
	int a1, b2, c3, d4, e5, f6;
	cin >> a1 >> b2 >> c3 >> d4 >> e5 >> f6;
	x.a[0] = 0;
	x.a[1] = a1;
	x.a[2] = b2;
	x.a[3] = c3;
	x.a[4] = d4;
	x.a[5] = e5;
	x.a[6] = f6;

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'S'){
			x.moveS();
		}
		else if (s[i] == 'W'){
			x.moveW();
		}
		else if (s[i] == 'N'){
			x.moveN();
		}
		else x.moveE();
	}

	cout << x.a[1] << endl;

	return 0;
}


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

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

  LL sum1 = 0, ans1 = 0;
  for (int i = 0; i < n; i ++) {
    sum1 += a[i];
    if (i % 2 == 0) {
      if (sum1 >= 0) {
        ans1 += sum1 + 1;
        sum1 = -1;
      }
    } else {
      if (sum1 <= 0) {
        ans1 += abs(sum1) + 1;
        sum1 = 1;
      }
    }
  }

  LL sum2 = 0, ans2 = 0;
  for (int i = 0; i < n; i ++) {
    sum2 += a[i];
    if (i % 2 == 0) {
      if (sum2 <= 0) {
        ans2 += abs(sum2) + 1;
        sum2 = 1;
      }
    } else {
      if (sum2 >= 0) {
        ans2 += sum2 + 1;
        sum2 = -1;
      }
    }
  }

  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}
 
vector<int>cnt;
vector<int>sum;
vector<int>g[200020];
void dfs(int now,int par,int add){
	add += cnt[now];
	sum[now] = add;
	for(auto e:g[now]){
		if(e == par)continue;
		dfs(e,now,add);
	}
}
 
signed main(){
	int N,Q;
	cin>>N>>Q;
	REP(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cnt.resize(N,0);
	sum.resize(N,0);
	REP(i,Q){
		int p,x;
		cin>>p>>x;
		cnt[p-1]+=x;
	}
	dfs(0,-1,0);
	int ans = 0;
	REP(i,N){
		if(i)cout<<" ";
		cout<<sum[i];
	}
	cout<<endl;
}

Measured memory_bytes: 25856
import java.util.*

fun main(args: Array<String>) {
    val xx = Stack<Int>()

    Scanner(System.`in`).use {
        val n = it.nextInt()
        val x = it.nextInt()
        for (i in 0 until n) {
            xx.push(Math.abs(it.nextInt() - x))
        }
    }

    while (1 < xx.size) {
        val xxx = (0 until 2).map {
            xx.pop()
        }

        val i = if (xxx[1] < xxx[0]) {
            1
        } else {
            0
        }
        xx.push(xxx[i])
        val r = xxx[(i + 1) % 2] % xxx[i]

        if (0 < r) {
            xx.push(r)
        }
    }

    println(xx.pop())
}


Measured memory_bytes: 53948
#include<bits/stdc++.h>
#define int long double
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]=(a[i]*(a[i]+1))/(2.0*a[i]);
    }
    int csum=0,msum=0;
    for(int i=0;i<k;i++)
        csum+=a[i];
    msum=csum;
    for(int i=k;i<n;i++){
        csum+=a[i];
        csum-=a[i-k];
        msum=max(msum,csum);
    }
    cout<<fixed<<setprecision(7)<<msum;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double r; cin >> r;
    printf("%.4lf\n", r*2*3.1415926);
    return 0;
}

Measured memory_bytes: 3788
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut a: Vec<i64> = sc.vec(n);
    a.sort();
    assert!(n >= 2);

    let mut max = a[n - 1];
    let mut min = a[0];

    let mut ans = vec![];
    if max < 0 {
        for i in 0..(n - 1) {
            ans.push((max, a[i]));
            max -= a[i];
        }
    } else if min > 0 {
        for i in 1..(n - 1) {
            ans.push((min, a[i]));
            min -= a[i];
        }
        ans.push((max, min));
        max -= min;
    } else {
        for i in 1..(n - 1) {
            if a[i] > 0 {
                ans.push((min, a[i]));
                min -= a[i];
            } else {
                ans.push((max, a[i]));
                max -= a[i];
            }
        }
        ans.push((max, min));
        max -= min;
    }

    println!("{}", max);
    for (a, b) in ans.into_iter() {
        println!("{} {}", a, b);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10108
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	cout<<(a+b-1)/b<<endl;
	return 0;
}

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

int main()
{
    string s;
    string rs;
    cin >> s;
    string::reverse_iterator rit = s.rbegin();
    while( rit != s.rend() ){
        rs += *rit;
        ++rit;
    }
    cout << rs << endl;
    return 0;
}

Measured memory_bytes: 1176
#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>

using namespace std;

int main(){

	int H, W;

	cin >> H >> W;

	int b[H][W];

	for(int h=0; h<H; h++){
		for(int w=0;w<W;w++){
			cin >> b[h][w];
		}
	}

	vector<tuple<int, int, int, int> > ans;

		for(int h=0; h<H; h++){
			if(h % 2 == 0){
				for(int w=0;w<W-1;w++){
					if(b[h][w] % 2 == 1){
						b[h][w]--;
						b[h][w+1]++;
						ans.emplace_back(h, w, h, w+1);
					}
				}
				if(H-1 > h && b[h][W-1] % 2 == 1){
					b[h][W-1]--;
					b[h+1][W-1]++;
					ans.emplace_back(h, W-1, h+1, W-1);
				}

			} else {
				for(int w=W-1;w>0;w--){
					if(b[h][w] % 2 == 1){
						b[h][w]--;
						b[h][w-1]++;
						ans.emplace_back(h, w, h, w-1);
					}
				}
				if(H-1 > h && b[h][0] % 2 == 1){
					b[h][0]--;
					b[h+1][0]++;
					ans.emplace_back(h, 0, h+1, 0);
				}
			}
		}

	cout << ans.size() << endl;

	for(auto& x : ans){
		int a, b, c ,d;
		tie(a, b, c, d) = x;
		cout << a+1 << " " << b+1 << " "  << c+1 << " "  << d+1 << endl;
	}

	return 0;
}


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

using namespace std;

int n,q;
vector<int> G[200010];
int val[200010];
int ans[200010];

void dfs(int u, int p, int cur) {
    ans[u] = cur + val[u];   
    for (int v: G[u]) {
        if(v == p) continue;
        dfs(v,u, ans[u]);
    }
}
int main() {
    
    scanf("%d %d", &n, &q);

    for (int i = 0; i < n - 1; ++i) {
        int x,y;
        scanf("%d %d", &x, &y);
        G[x].push_back(y);
        G[y].push_back(x);
    }

    while(q--) {
        int p,x;
        scanf("%d %d", &p, &x);
        val[p] += x;
    }

    dfs(1,1,0);

    for (int i = 1; i <= n; ++i)
        printf("%d ", ans[i]);

    puts("");
    return 0;
}


Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
int main () {
  int a, b, c;
  cin >> a >> b >> c;

  int res;
  res = a -b;
  int ans;
  ans = c -res;
  if( ans < 0) {
    ans = 0;
  }
  cout << ans << endl;
  
}


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

# 降順ソート
a.sort()
a.reverse()

tmp = int(len(a) / 2 + 0.5) - 1

Alice = 0
Bob = 0
for i in range(len(a)):
  if i % 2 == 0:
    Alice += a[i]
  else:
    Bob += a[i]

print(Alice - Bob)


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;

    if(2*x <= y && y<=4*x && y%2==0)YES;
    else NO;

}


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

int g[15][15];

int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,n) g[i][j] = -1;
  rep(i,n) {
    int a;
    cin >> a;
    rep(j,a) {
      int x, y;
      cin >> x >> y;
      x--;
      g[i][x] = y;
    }
  }
  int ans = 0;
  rep(i,1<<n) {
    bool ok = true;
    vector<int> d(n);
    rep(j,n) if((i>>j)&1) {
      d[j] = 1;
    }
    rep(j,n) {
      if(d[j]) {
        rep(k,n) {
          if(g[j][k] == -1) continue;
          if(d[k] != g[j][k]) ok = false;
        }
      }
    }
    if(ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
CSFlist = [list(map(int, input().split())) for _ in range(N-1)]
def calc_time(start):
    now = 0
    for i in range(start, N-1):
        C, S, F = CSFlist[i]
        if now < S:
            now = S
        if now % F != 0:
            now += F - now % F
        now += C
    return now
for _ in range(N-1):
    print(calc_time(_))
print(0)

Measured memory_bytes: 40304
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    ll n, a, b, h[112345] = {0};
    cin >> n >> a >> b;
    REP(i, n)
    cin >> h[i];

    ll l = 0, r = 1000000000;
    while (r - l > 0)
    {
        ll m = (r + l) / 2; // ceil((r + l) / 2.0);

        ll h_[112345] = {0};
        REP(i, n)
        {
            h_[i] = h[i] - b * m;
        }

        ll ans_ = 0;
        sort(h_, h_ + 112345);
        int i = 112344;
        while (h_[i] > 0)
        {
            ans_ +=(ll) ceil((float)h_[i] / (float)(a - b));

            //cout << ceil((float)h_[i] / (float)(a - b)) << endl;

            i--;
        }

        //cout << l << " " << r << " " << m << " " << ans_ << endl;

        if (ans_ > m)
        {
            l = m + 1;
        }
        else
        {
            r = m;
        }
    }

    cout << l << endl;

    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
int main()
{
	int a,b,c,i,j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		if(c%i==0)
		{
			j++;
		}
	}
	printf("%d\n",j);
	
return 0;}

Measured memory_bytes: 2752
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

p = n + 1
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if a[i] == p + 1:
        ans += c[p - 1]
    p = a[i]

print(ans)

Measured memory_bytes: 38384
from collections import Counter

H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

count = Counter()
for i in range(H):
    count.update(list(map(int, input().split())))
print(sum([c[i][1] * count[i] for i in range(10)]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define pii pair <int, int>
#define xx first
#define yy second
#define LL long long
using namespace std;

const int N = 100100;
int a[N], b[N];
priority_queue <pii, vector <pii>, greater <pii> > q;

int main ()
{
//    freopen ("in", "r", stdin);
    int n;
    cin >> n;
    int now = 1;
    LL res = 0;
    for (int i = 1; i <= n; i++) {
        scanf ("%d", &a[i]);
        if (a[i] == now) now++;
        else res += (a[i] - 1) / now;
        if (i == 1) now = 2;
//        cout << now << ' ' << (a[i] - 1) / now << endl;
    }
    cout << res << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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

void solve(int n,vector<int> Rlist,vector<int> Wlist){
    int redcount=Rlist.size();
    int Whitecount=Wlist.size();
    int count=0;  
    while(true){
        if(Rlist.empty()||Wlist.empty()){
            break;
        }else{
            int redlast=Rlist[Rlist.size()-1];
            int whitefarst=Wlist[0];
            if(redlast<whitefarst)break;
            count++;
            Rlist.erase(Rlist.end()-1);
            Wlist.erase(Wlist.begin());
        }
        
    }
    cout<<min({redcount,Whitecount,count})<<endl;
}

int main(){
    int n;
    cin >> n;
    vector<int> Rlist(0);
    vector<int> Wlist(0);
    bool isWhite=false;
    char tmp;
    rep(i,n){
        cin>>tmp;
        if(tmp=='R'){
            Rlist.push_back(i);
        }else{
            Wlist.push_back(i);
        }
    }
    solve(n,Rlist,Wlist);


    return 0;
}


Measured memory_bytes: 5060
#include<stdio.h>
#include<stdlib.h>

#define SENTINEL 1000000000

void mergeSort(int [], int, int);
void merge(int [], int, int, int);
int count=0;

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  int *L,*R;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}


main(){
  int A[500000];
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 5428
'use strict'
let n, m, visited, graph

const trace = arr => {
  let tmp = ''
  for (let i in arr) {
    for (let j in arr[i]) {
      tmp += arr[i][j] ? '@' : '-'
    }
    tmp += '\n'
  }
  console.log(tmp)
}

const dfs = i => {
  visited[i] = true
  for (let i2 = 0; i2 < n; i2++) {
    //訪問済みか、辺がなかったら探索スキップ
    if (visited[i2] || graph[i][i2] == false) continue //スキップ
    dfs(i2)
  }
}

function main(input) {
  // data
  input = input.split('\n').map(v => v.split(' ').map(v => ~~v))
  n = input[0][0]
  m = input[0][1]
  const edges = input.slice(1, -1)

  //連結グラフは隣接行列表現＝二次元配列
  graph = Array.apply(null, {
    length: n
  }).map(
    v =>
      (v = Array.apply(null, {
        length: n
      }).fill(false))
  )

  for (let i = 0; i < m; i++) {
    let a = edges[i][0] - 1
    let b = edges[i][1] - 1
    graph[a][b] = true
    graph[b][a] = true
  }
  visited = Array.apply(null, {
    length: n
  }).fill(false)

  let cnt = 0
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < n; j++) {
      if (graph[i][j]) {
        //辺を見つけたら

        //辺を取り除く
        graph[i][j] = false
        graph[j][i] = false

        //探索
        visited.fill(false) //初期化

        dfs(0) //全て訪問できるかチェック
        if (!visited.every(v=>v==true)) cnt++

        //元に戻す
        graph[i][j] = true
        graph[j][i] = true
      }
    }
  }

  //   count(graph)
  console.log(cnt / 2)
  // trace(graph)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3){
    int a;
    cin >> a;
    ans ^= a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) {
        for (int j = i; j < n; ++j) {
            string t = "";
            rep(k, n) {
                if (k >= i && k < j) {
                    continue;
                }
                t += s[k];
            }
            if (t == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define inf (ll)1000000000
#define mod 1000000007
#define MAX_N 50001
#define pb push_back
#define pll pair<ll,ll>
 
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n][k+1],cum[2][k+1];
	memset(dp,0,sizeof dp);
	for(int i=0;i<=a[0];i++)
	{
		dp[0][i]=1;
		if(i==0)
		{
			cum[0][i]=1;
		}else
		{
			cum[0][i]=cum[0][i-1]+1;
		}
	}
	for(int i=a[0]+1;i<=k;i++)
	{
		cum[0][i]=cum[0][i-1];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(j>=a[i]+1)
			{
				dp[i][j]=(dp[i][j]%mod+(mod+cum[(i-1)%2][j]%mod-cum[(i-1)%2][j-a[i]-1]%mod)%mod)%mod;
			}else
			{
				dp[i][j]=(dp[i][j]%mod+cum[(i-1)%2][j]%mod)%mod;
			}
			if(j==0)
			{
				cum[i%2][j]=dp[i][j];
			}else
			{
				cum[i%2][j]=(cum[i%2][j-1]%mod+dp[i][j]%mod)%mod;
			}
		}
	}
	cout<<dp[n-1][k];
}



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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	
	int max;
	for (int i = 1; ; i++) {
		if (i * i > n) {
			cout << max << endl;
			return 0;
		}
		max = i * i;
	}
}

Measured memory_bytes: 256
using System;

class Tester
{
    static void Main(string[] args)
    {
        string x = Console.ReadLine();
        int a, b,c;
        string[] result;

        const char Space = ' ';
        char[] delimiters = new char[] { Space };
        result = x.Split(delimiters);

        a = int.Parse(result[0]);
        b = int.Parse(result[1]);
        c = int.Parse(result[2]);

        if (a<b&&b<c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 8888
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  string S;
  cin>>S;
  vector<char> X(S.size());
  for(int i=0;i<S.size();i++){
      X[i]='x';
  }
  for(int j=0;j<S.size();j++){
  cout<<X[j];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
    cin>>a[i];
    int l=a[0]; int r=a[0];
    for(i=0;i<n;i++)
    {
        l=min(l,a[i]);
        r=max(r,a[i]);
    }
    int sum=1000000000;
    for(i=l;i<=r;i++)
    {
        int ans=0;
        for(int j=0;j<n;j++)
         ans+=(a[j]-i)*(a[j]-i);
      sum=min(sum,ans);
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3652
n=int(input())
li=list(map(int,input().split()))
li2=list(map(int,input().split()))

count=0

for i in range(len(li2)):
  temp=min(li2[i],li[i])
  count+=temp
  li[i]-=temp
  li2[i]-=temp
  
  temp=min(li2[i],li[i+1])
  count+=temp
  li[i+1]-=temp
  li2[i]-=temp
print(count)

Measured memory_bytes: 19156
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n+1];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < q; i++) {
            int t = T[i];
            if(LinearSearch(S,n,t)){
                ans++;
            }
        }

        System.out.println(ans);

    }

    static Boolean LinearSearch(int[] S, int n, int t){
        S[n] = t;
        int i = 0;
        while (S[i] != t){
            i++;
        }
        return i != n;
    }
}



Measured memory_bytes: 40508
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    vector<long long> abc(3);
    for (int i = 0; i < 3; i++)cin >> abc[i];

    long long sum = accumulate(abc.begin(), abc.end(), 0LL);
    bool b = true;
    for (int i = 0; i < 3; i++) if (abc[i] % 2) b = false;
    if(!b){
        cout << 0 <<endl;
        return 0;
    }

    long long cnt = 0;

    while (true) {
        vector<long long> to(3);
        bool good = true;
        for (int i = 0; i < 3; i++) {
            if ((sum - abc[i]) % 2) good = false;
            else to[i] = (sum - abc[i]) / 2;
        }
        if (!good) break;
        bool same = true;
        for (int i = 0; i < 3; i++) if (abc[i] != to[i]) same = false;
        if (same) {
            cout << -1 << endl;
            return 0;
        }
        abc = to;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}






















































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

int main() {
	int K, mod = 0, res = 0;
	cin >> K;
    while (true){
        mod = (mod*10 + 7) % K;
        res++;
        if (mod == 0) {
            break;
    }
        if (res > K) {
            res = -1;
            break;
        }
    }
    cout << res << endl; 
	return 0;
}

Measured memory_bytes: 3508
// (c) 2020, redotter
// The grass was greener...

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:200000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i64 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

i64 n;

void Problem::solve() {
	i64 x = n;
	i64 ans = 0;
	for (i64 i = 2; i * i <= n; i++) {
		if (x % i == 0) {
			i64 cnt = 0;
			while (x % i == 0) {
				++cnt;
				x /= i;
			}
			i64 cur = 0;
			i64 j = 0;
			while (cur <= cnt) {
				++j;
				cur += j;
			}
			cur -= j;
			ans += (j - 1);
		}
	}
	if (x != 1) ++ans;
	println(ans);
}

void Problem::input() {
	read(n);
}


Measured memory_bytes: 3632
def calc(H,W,property):
    visit=[[False for i in range(W+2)] for j in range(H+2)]
    retval=0

    _property=[['.' for i in range(W+2)]]
    for p in property:
        _property.append(['.']+p+['.'])
    _property.append(['.' for i in range(W+2)])
    property=_property
    for i in range(1,H+1):
        for j in range(1,W+1):
            if visit[i][j]:
                continue
            visit[i][j]=True
            retval+=1
            next=[(i,j)]
            while len(next)>0:
                _next=[]
                for p in next:
                    if visit[p[0]-1][p[1]]==False and property[p[0]][p[1]]==property[p[0]-1][p[1]]:
                        _next.append((p[0]-1,p[1]))
                        visit[p[0]-1][p[1]]=True
                    if visit[p[0]+1][p[1]]==False and property[p[0]][p[1]]==property[p[0]+1][p[1]]:
                        _next.append((p[0]+1,p[1]))
                        visit[p[0]+1][p[1]]=True
                    if visit[p[0]][p[1]-1]==False and property[p[0]][p[1]]==property[p[0]][p[1]-1]:
                        _next.append((p[0],p[1]-1))
                        visit[p[0]][p[1]-1]=True
                    if visit[p[0]][p[1]+1]==False and property[p[0]][p[1]]==property[p[0]][p[1]+1]:
                        _next.append((p[0],p[1]+1))
                        visit[p[0]][p[1]+1]=True
                next=_next
    return retval




while True:
    H,W=[int(i) for i in input().split(" ")]
    if H==0 and W==0:
        break
    property=[[s for s in input()] for i in range(H)]
    print(calc(H,W,property))



Measured memory_bytes: 5892
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;


int N, M;
int A[1001];

signed main()
{
	cin >> N >> M;
	REP(i, N) cin >> A[i];

	int all = 0;
	for (int i = 0; i < N; i++)
	{
		all += A[i];
	}

	double lim = all / (double)(4 * M);
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (A[i] >= lim)
		{
			cnt++;
		}
	}
	cout << ((cnt >= M) ? "Yes" : "No") << endl;
}



//signed main()
//{
//	int x, y, z;
//	cin >> x >> y >> z;
//	cout << z << " " << x << " " << y << endl;
//}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    ll n,m;
    cin>>n>>m;
    vll c(m+1);
    rep(i,m)cin>>c.at(i+1);
    vvll dp(m+1,vll(n+1));
    dp.at(0).at(0)=0;
    rep(i,n)dp.at(0).at(i+1)=1000000000;
    rep(i,m){
        rep(j,n+1){
            if(j-c.at(i+1)>=0){
                dp.at(i+1).at(j)=min(dp.at(i).at(j),1+dp.at(i+1).at(j-c.at(i+1)));
            }else{
                dp.at(i+1).at(j)=dp.at(i).at(j);
            }
        }
    }
  cout<<dp.at(m).at(n)<<endl;
}



Measured memory_bytes: 11604
#include<stdio.h>
int main (){
	int a,b;
	int c,d;
	for(;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)break;
			for(c=0;c<a;c++){
				for(d=0;d<b;d++){
				if((c+d)%2==0){
				printf("#");
				}else{
				printf(".");
			}
		}printf("\n");
	}printf("\n");
	}
	return 0;
}

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

using namespace std;

const int N = 100005;

int n,v[N],dp[N];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&v[i]);
	dp[n-1] = 0;
	if(n-2 >= 0) dp[n-2] = abs(v[n-1]-v[n-2]);
	for(int i=n-3;i>=0;i--) dp[i] = min(abs(v[i+1]-v[i])+dp[i+1],abs(v[i+2]-v[i])+dp[i+2]);
	printf("%d\n",dp[0]);
	return 0;
}

Measured memory_bytes: 1024
import kotlin.math.max

fun main() {
    val s = next()
    val t = next()

    var m = 0
    (0..(s.length - t.length)).forEach {
        var count = 0
        t.forEachIndexed { index, c ->
            if (c == s[index + it]) count++
        }
        m = max(m, count)
    }
    println(t.length - m)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 36248
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

long steps[100001];

long count_steps(const vector<int>& as, int n) {
  int j = 0;
  steps[0] = 1;
  steps[1] = 1;
  if (j < as.size() && as[j] == 1) {
    steps[1] = 0;
    ++j;
  }
  for (int i = 2; i <= n; ++i) {
    if (j < as.size() && i == as[j]) {
      steps[i] = 0;
      ++j;
      continue;
    }
    steps[i] = (steps[i - 1] + steps[i - 2]) % 1000000007;
  }
  return steps[n];
}

int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;
  std::vector<int> as(m);
  for (int i = 0; i < m; ++i) {
    cin >> as[i];
  }
  cout << count_steps(as, n);
  return 0;
}


Measured memory_bytes: 1408
n, m = map(int, input().split())
dic_ = {}
for _ in range(n):
    a = list(map(int, input().split()))
    a = a[1:]
    for i in a:
        if i in dic_:
            dic_[i] += 1
        else:
            dic_[i] = 1

ans = 0
for i in dic_.keys():
    if dic_[i] == n:
        ans += 1

print(ans)


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

deque<long long>res;

void push(int d, long long x)
{
	if (d == 0)res.push_front(x);
	else if (d == 1)res.push_back(x);
}

void pop(int d)
{
	if (d == 0)res.pop_front();
	else if (d == 1)res.pop_back();
}


int main(void)
{

	long long T;
	cin >> T;
	while (T--)
	{
		int op,d;
		cin >> op;
		switch (op)
		{
		case 0:
			long long x;
			cin >> d >> x;
			push(d, x);
			break;
		case 1:
			long long rank;
			cin >> rank;
			cout << res[rank] << endl;
			break;
		case 2:
			cin >> d;
			pop(d);
			break;
		default:
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 6168
o = list(input())
e = list(input())

ans = ""
i = 0
while 1:
    if len(o) > i:
        ans = ans + o[i]
    else:
        break
    if len(e) > i:
        ans = ans + e[i]
    else:
        break
    i += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int xmax=x,ymin=y;
    rep(i,n){
        int x0;
        cin>>x0;
        xmax=max(xmax,x0);
    }
    rep(i,m){
        int y0;
        cin>>y0;
        ymin=min(ymin,y0);
    }
    if(xmax<ymin) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll a, b, c; cin >> a >> b >> c;
  if (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b)) Yes();
  else No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(16);

  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B; 
  char op;
  cin >> A >> op >> B;
  
  if ( op == '+') {
    cout << A+B << endl;
  }
  if ( op == '-' ) {
    cout << A-B << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
nf = n
ans = []
while n > 1:
    tmp = n
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            ans.append(i)
            n = n // i
            break
    if tmp == n:
        ans.append(n)
        n = n // n

print(str(nf) + ': ', end='')
print(*ans)


Measured memory_bytes: 5644
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll a[200100];
int main(){
	ll n;
	scanf("%lld",&n);
	ll i,j;
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	ll m=n-2;
	ll t=m/2,p=m%2,s=0;
	for(i=n-2;i>n-2-t;i--)
		s+=a[i];
	s*=2;
	if(p==1)
		s+=a[i];
	s+=a[n-1];
	cout<<s<<endl;
}


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

class UnionFind {
public:
    vector<int> par, rank;
    UnionFind(int n) {
        par.resize(n), rank.resize(n);
        for (int i = 0; i < n; i++) par[i] = i;
    }
    int root(int a) {
        if (par[a] == a) return a;
        else return par[a] = root(par[a]);
    }
    bool isConnect(int a, int b) { return root(a) == root(b); }
    void connect(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] < rank[b]) {
            par[a] = b;
        } else {
            par[b] = a;
            if (rank[a] == rank[b]) rank[a]++;
        }
    }
};

struct Edge {
    int from, to;
    int64_t cost;
    Edge(int _to, int64_t _cost) : from(-1), to(_to), cost(_cost) {}
    Edge(int _from, int _to, int64_t _cost) : from(_from), to(_to), cost(_cost) {}
};

template<class T = int>
T kruskal(vector<Edge> &edges, int V) {
    sort(edges.begin(), edges.end(), [](const Edge &a, const Edge &b) {
        return a.cost < b.cost;
    });
    UnionFind uf(V);
    T res = 0;
    for(auto &e : edges) {
        if(uf.isConnect(e.from, e.to)) continue;
        uf.connect(e.from, e.to);
        res += e.cost;
    }
    return res;
}

int main() {
    int N; cin >> N;
    vector<pair<pair<int64_t, int64_t>, int>> P(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        P[i] = {{x, y}, i};
    }
    sort(P.begin(), P.end());
    vector<Edge> edges;
    for(int i = 0; i < N - 1; ++i) {
        int64_t cost_x = abs(P[i].first.first - P[i + 1].first.first);
        int64_t cost_y = abs(P[i].first.second - P[i + 1].first.second);
        edges.emplace_back(P[i].second, P[i + 1].second, cost_x);
        edges.emplace_back(P[i].second, P[i + 1].second, cost_y);
    }
    for(auto &e : P) swap(e.first.first, e.first.second);
    sort(P.begin(), P.end());
    for(int i = 0; i < N - 1; ++i) {
        int64_t cost_x = abs(P[i].first.first - P[i + 1].first.first);
        int64_t cost_y = abs(P[i].first.second - P[i + 1].first.second);
        edges.emplace_back(P[i].second, P[i + 1].second, cost_x);
        edges.emplace_back(P[i].second, P[i + 1].second, cost_y);
    }
    auto k = kruskal<int64_t>(edges, N);
    cout << k << '\n';
    return 0;
}


Measured memory_bytes: 12908
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
ll h,w,a[510][510];
vector<int> p,q,r,s;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>h>>w;
    for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	    cin>>a[i][j];
	}
	for(int j=0;j<w-1;j++){
	    if(a[i][j]%2==1){
		p.push_back(i);
		q.push_back(j);
		r.push_back(i);
		s.push_back(j+1);
		a[i][j+1]++;
	    }
	}
    }
    for(int i=0;i<h-1;i++){
	if(a[i][w-1]%2==1){
	    p.push_back(i);
	    q.push_back(w-1);
	    r.push_back(i+1);
	    s.push_back(w-1);
	    a[i+1][w-1]++;
	}
    }
    cout<<p.size()<<endl;
    for(int i=0;i<p.size();i++){
	cout<<p[i]+1<<" "<<q[i]+1<<" "<<r[i]+1<<" "<<s[i]+1<<endl;
    }
}




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

int main(void){
  string s;
  cin >> s;
  bool flag1 = false;
  bool flag2 = false;
  bool flag3 = true;
  bool flag4 = true;

  for (int i = 0; i < s.size(); i++) {
    if (i == 0 && s[i] == 'A') {
      flag1 = true;
    }else if (i>=2&&i<=s.size()-2&&s[i] == 'C') {
      if (flag4) {
        flag2 = true;
        flag4 = false;
      }else{
        printf("WA");
        return 0;
      }
    }else{
      if( islower( s[i] ) == 0 ){
        printf("WA");
        return 0;
      }
    }
  }
  if (flag1 == true && flag2 == true && flag3 == true) {
    printf("AC");
  }else{
    printf("WA");
  }
  return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	string s=readString(),t=readString();
	vi pos(100,0);
	int ans=0,cur=0;
	int n=s.size(),m=t.size();
	REP(i,n){
		if(s[i]==t[pos[cur]]){
			pos[cur]++;
			if(cur==0){
				while(pos[cur]==m){
					pos[cur]=0;
					cur++;
				}
				chmax(ans,cur);
			}else{
				REP(j,cur)pos[j]=0;
				cur=0;
			}
		}
	}
	print(ans);
}



Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5+5;
const int mod = 1e9+7;

ll dp[87];

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//#ifndef ONLINE_JUDGE
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//#endif

	dp[0] = 2;
	dp[1] = 1;

	for (int i = 2; i < 87; i++)
		dp[i] = dp[i-1] + dp[i-2];

	
	int n;
	cin >> n;

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 256
import fractions
A, B, C, D = map(int, input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
print((B-A+1)-(B//C-(A-1)//C)-(B//D-(A-1)//D)+(B//lcm(C,D)-(A-1)//lcm(C,D)))



Measured memory_bytes: 5048