akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	string s;
	cin >> s;
	
	int cnt = 1;
	int prev = 1;
	int n = s.size();
	
	for(int i = 1; i < n; i++){	
		if(prev == 2){
			cnt++;
			prev = 1;
		}
		else if(s[i] == s[i-1] && i+1 < n){
			cnt++;
			i++;
			prev = 2;
		}
		else if(s[i] != s[i-1]){
			cnt++;
		}
	}
	cout << cnt;

	return 0;
}



Measured memory_bytes: 640
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr+3);
    if(arr[0] == arr[1] && arr[0] != arr[2]){
        cout << "Yes";
    }else if(arr[0] != arr[1] && arr[1] == arr[2]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
B1 = [0,0,0]
B2 = [0,0,0]
B3 = [0,0,0]
N = int(input())
for i in range(N):
  x = int(input())
  if(x in A1):
    tmp = A1.index(x)
    B1[tmp] = 1
  if(x in A2):
    tmp = A2.index(x)
    B2[tmp] = 1
  if(x in A3):
    tmp = A3.index(x)
    B3[tmp] = 1
if(B1[0]==1 and B1[1]==1 and B1[2]==1):
  print("Yes")
  exit()
if(B2[0]==1 and B2[1]==1 and B2[2]==1):
  print("Yes")
  exit()
if(B3[0]==1 and B3[1]==1 and B3[2]==1):
  print("Yes")
  exit()
if(B1[0]==1 and B2[0]==1 and B3[0]==1):
  print("Yes")
  exit()
if(B1[1]==1 and B2[1]==1 and B3[1]==1):
  print("Yes")
  exit()
if(B1[2]==1 and B2[2]==1 and B3[2]==1):
  print("Yes")
  exit()
if(B1[0]==1 and B2[1]==1 and B3[2]==1):
  print("Yes")
  exit()
if(B1[2]==1 and B2[1]==1 and B3[0]==1):
  print("Yes")
  exit()
print("No")

Measured memory_bytes: 3192
N = int(input())
bar = list(map(int, input().split()))
triangles = []
for i in range(N-2):
    for j in range(i + 1, N - 1):
        if bar[i] == bar[j]:
            continue
        for k in range(j + 1, N):
            if bar[j] == bar[k] or bar[i] == bar[k]:
                continue
            if (bar[i] + bar[j] > bar[k]) and (bar[j] + bar[k] > bar[i]) and (bar[i] + bar[k] > bar[j]):# and (len(set([bar[i], bar[j], bar[k]])) == 3):
                triangles.append([bar[i], bar[j], bar[k]])
print(len(triangles))


Measured memory_bytes: 25360
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int l[200010], r[200010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin>>N;
    cin>>S;
    rep(i,0,N) l[i+1]=l[i]+(S[i]=='.'?1:0);
    rer(i,N,0) r[i]=r[i+1]+(S[i]=='#'?1:0);
    ll ans=2000000;
    rep(i,0,N+1){
        ans=min(ans, i-l[i]+N-i-r[i]);
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> PII;
 
const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;
 
int n, m;
 
void prework(){
 
}
 
void read(){
 
}
 
int K;
ll C[2222][2222];
ll pw[2222];
ll f[2222][2222];
ll sum[2222][2222];
 
void solve(int casi){
	cin>>n>>K;
	C[0][0] = C[1][0] = C[1][1] = 1;
	for(int i = 2; i <= 2000; i++){
		C[i][0] = C[i][i] = 1;
		for(int j = 1; j < i; j++)
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	}
	pw[0] = 1;
	for(int i = 1; i <= 2000; i++){
		pw[i] = (2 * pw[i-1]) % MM;
	}
	ll ans = 0;//pw[n-K-1];
	f[0][0] = 1;
	for(int i = 0; i <= n; i++)
		sum[0][i] = 1;
	for(int i = 1; i < K; i++){
		for(int j = 0; j <= n - i; j++){
			f[i][j] = sum[i-1][j+1];
		}
		sum[i][0] = f[i][0];
		for(int j = 1; j <= n - i; j++)
			sum[i][j] = (sum[i][j-1] + f[i][j]) % MM;
	}
	for(int i = 0; i <= n - K; i++)
		ans = sum[K - 1][n - K];
	cout<<((K!=n)?(ans * pw[n-K-1] % MM):ans)<<endl;
}
 
void printans(){
	/*?????????*/
}
 
 
int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}
// ??????????

Measured memory_bytes: 70144
n, k = map(int, input().split())
l = list(map(int, input().split()))

dp = [float('inf') for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j <= n-1:
            temp = dp[i] + abs(l[i+j] - l[i])
            if temp < dp[i+j]:
                dp[i+j] = temp

print(dp[-1])

Measured memory_bytes: 56800
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    ld d,s,t; cin>>d>>t>>s;
    bool is;
    if(d/s<=t)is=true;
    else is=false;
    cout<<(is?"Yes":"No")<<endl;
    return 0;
}


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

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  string s;
  cin >> s;
  bool yes = true;
  if(s[a] == '#' || s[c] == '#') yes = false;
  for(int i=a+1;i<=c;i++) {
    if(s[i] == '#' && s[i-1] == '#') {
      yes = false;
      break;
    }
  }
  if(s[b] == '#' || s[d] == '#') yes = false;
  for(int i=b+1;i<=d;i++) {
    if(s[i] == '#' && s[i-1] == '#') {
      yes = false;
      break;
    }
  }
  if(c > d) {
    bool can = false;
    for(int i=b;i<=d;i++) {
      if(s[i] == '.' && s[i-1] == '.' && s[i+1] == '.') {
        can = true;
      }
    }
    if(!can) yes = false;
  }

  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import Counter
    n = input_int()
    A = input_int_list()
    A_cnt = Counter(A).most_common()
    A_cnt = [list(a) for a in A_cnt]
    cnt = 0
    for i in range(len(A_cnt)):
        if A_cnt[i][1] > 2:
            if A_cnt[i][1] % 2 == 1:
                cnt += A_cnt[i][1] // 2
                A_cnt[i][1] = 1
            elif A_cnt[i][1] % 2 == 0:
                cnt += (A_cnt[i][1] // 2) - 1
                A_cnt[i][1] = 2
        if A_cnt[i][1] == 2:
            if i + 1 < len(A_cnt):
                A_cnt[i + 1][1] -= 1
            A_cnt[i][1] = 1
            cnt += 1
    print(n - cnt * 2)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 103532
main = readAndDo

readAndDo = do
  line <- getLine
  if line == "0 0" then return ()
  else do
    let [a, b] = map (read :: String -> Int) $ words line
    let s | a <= b = fmt [a, b]
          | otherwise = fmt [b, a]
    putStrLn s
    readAndDo
    where fmt = unwords . map show



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

const int N = 1e5 + 10;

int par[N];
int cnt;

int find_parent(int x) {
  par[x] = (par[x] == x ? x : find_parent(par[x]));
  return par[x];
}

void merge(int x, int y) {
  x = find_parent(x);
  y = find_parent(y);
  if (x == y) {
    return;
  }
  cnt--;
  if (rand() & 1) {
    par[x] = y;
  } else {
    par[y] = x;
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  cnt = n;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    merge(x, y);
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



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

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
			String W=reader.readLine().toLowerCase();
			String text="";

		while(true){
		String p=reader.readLine();
		if(p.equals("END_OF_TEXT"))break;
		text+=" "+p.toLowerCase();
		}


		text=text.replaceAll("\\.", " ");
		text=text.replaceAll("\\n", " ");

		String[] array_text=text.split(" ");
		int count=0;
		for(int i=0;i<array_text.length;i++){
			if(array_text[i].equals(W)){
				count++;
			}
		}

		System.out.println(count);
		//split??§??????.???????????????????????¨?????????????????????????????????


		}catch(IOException e){
			System.out.print(e);
		}
	}

}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}


vector <ll> ve;
void get(ll cnt,ll val){
    if(cnt == 0)
    {
        ve.pb(val);
        return;
    }
    ll last = val%10;
    for(ll j=0;j<=9;j++){
        if(abs(j-last) <= 1)
            get(cnt-1,val*10 + j);
    }
}
void solve(ll x){
    ll re = 0;
    for(ll i=1;i<=9;i++){
        get(x-1,re*10+i);
    }
}
void solve(){
    for(ll i=1;i<=10;i++)
        solve(i);
    ll k;
    cin >> k;
    sort(all(ve));

    g(ve[k-1]);
}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
   // cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 5304
#region memo
/* 
 * 偶奇が大切な問題では、偶数番目と奇数番目を分けて配列に入れる
 * 文字列の処理は遅い。char[]で計算して、最後にstringにする
 * (char)0 は、0'\0'となる
 * (char)0は48
 */
#endregion

using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        double L = (double)ReadInt();

      

        WriteLine(Pow((L/3),3));
        ReadLine();
    }


    #region Reader
    static string ReadStr()
    {
        return Console.ReadLine();
    }
    static string[] ReadStrN()
    {
        return Console.ReadLine().Split(' ');
    }
    static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }
    static int[] ReadIntN()
    {
        return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    }
    static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }
    static long[] ReadLongN()
    {
        return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    }
    static long[,] ReadLongMatrix(int r, int c)
    {
        var mat = new long[r, c];
        for (int i = 0; i < r; ++i)
        {
            var x = ReadLongN();
            for (int j = 0; j < c; ++j)
            {
                mat[i, j] = x[j];
            }
        }
        return mat;
    }
    static Tuple<string, string>[] ReadTupleStr(int n)
    {
        List<Tuple<string, string>> list = new List<Tuple<string, string>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadStrN();
            list.Add(new Tuple<string, string>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Tuple<long, long>[] ReadTupleLong(int n)
    {
        List<Tuple<long, long>> list = new List<Tuple<long, long>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadLongN();
            list.Add(new Tuple<long, long>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Tuple<int, int>[] ReadTupleInt(int n)
    {
        List<Tuple<int, int>> list = new List<Tuple<int, int>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadIntN();
            list.Add(new Tuple<int, int>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Tuple<double, double>[] ReadTupleDouble(int n)
    {
        List<Tuple<double, double>> list = new List<Tuple<double, double>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadLongN();
            list.Add(new Tuple<double, double>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Dictionary<int, HashSet<int>> ReadAdjacencyList(int N, int M)
    {
        Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
        for (int i = 0; i <= N; ++i)
        {
            dict.Add(i, new HashSet<int>());
        }
        for (int i = 0; i < M; ++i)
        {
            var ab = ReadIntN();
            dict[ab[0]].Add(ab[1]);
            dict[ab[1]].Add(ab[0]);
        }
        return dict;
    }
    #endregion

}

Measured memory_bytes: 11220
N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

cum_A = [0] * (N + 1)
for i in range(1, N + 1):
    cum_A[i] = cum_A[i - 1] + A[i - 1]
cum_B = [0] * (M + 1)
for i in range(1, M + 1):
    cum_B[i] = cum_B[i - 1] + B[i - 1]

ans = 0
b_ub = M + 1
for i in range(N + 1):
    rest = K - cum_A[i]
    for j in range(b_ub)[::-1]:
        if cum_B[j] <= rest:
            ans = max(i + j, ans)
            b_ub = j + 1
            break

print(ans)


Measured memory_bytes: 48512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

ll _gcd(ll a, ll b) {
    if (b == 0)return a;
    return _gcd(b, a % b);
}
ll _lcm(ll a, ll b) {
    return a * b / _gcd(a, b);
}

int main() {
    init();

    int n; ll m; cin >> n >> m;
    VL a(n); cin >> a;

    each(i, a)i >>= 1;
    bool ng = false;
    int t = 0;
    FOR(i, 0, n) {
        int j = 0;
        for (; !(a[i] & (1LL << j)); ++j);
        if (i == 0)t = j;
        else ng |= t != j;
    }
    if (ng)cout << "0\n";
    else {
        ll x = a[0];
        FOR(i, 1, n) {
            x = _lcm(x, a[i]);
            if (m < x)break;
        }
        if (m < x)cout << "0\n";
        else {
            ll ans = m / (x << 1);
            if ((m % (x << 1)) / x)++ans;
            cout << ans << "\n";
        }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
char s[555][555],a[555][555],b[555][555];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)a[i][j]=b[i][j]='.';
	for(int i=1;i<=m;i++)
	{
		a[1][i]=b[n][i]='#';
		for(int j=2;j<n;j++)
		{
			if(i%2)a[j][i]='#';
			else b[j][i]='#';
		}
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]=='#')a[i][j]=b[i][j]='#';
		}
	}
	for(int i=1;i<=n;i++)
	{
		printf("%s\n",a[i]+1);
	}
	puts("");
	for(int i=1;i<=n;i++)
	{
		printf("%s\n",b[i]+1);
	}
	return 0;
}

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

class history {
public:
    int pc, start, end;
    history(int p, int s, int e) {
        pc = p; start = s; end = e;
    }
};

int main(void){
    vector<history> hist[10010];
    int N, M;
    int r, t, n, m, s, q, ts, te;
    int imos[1265];
    while(cin >> N >> M && N) {
        rep(i, 10010) hist[i].clear();
        cin >> r;
        rep(i, r) {
            cin >> t >> n >> m >> s;
            if(s==1) {
                hist[m].push_back(history(n, t, -1));
            } else {
                rep(j, hist[m].size()) {
                    if(hist[m][j].pc == n && hist[m][j].end == -1) {
                        hist[m][j].end = t;
                        break;
                    }
                }
            }
        }
        cin >> q;
        rep(i, q) {
            cin >> ts >> te >> m;
            rep(j, 1265) imos[j] = 0;
            rep(j, hist[m].size()) {
                if(hist[m][j].start < te && hist[m][j].end > ts) {
                    imos[max(hist[m][j].start, ts)] += 1;
                    imos[min(hist[m][j].end, te)] -= 1;
                }
            }
            int ans = 0;
            int cnt = 0;
            int start;
            rep(j, 1265) {
                if(cnt == 0 && imos[j] > 0) {
                    start = j;
                }
                if(cnt > 0 && cnt+imos[j] == 0) {
                    ans += (j - start);
                }
                cnt += imos[j];
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 1508
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
}

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

using namespace std;

int main()
{
	int n;
	vector<long long> a,ans;
	cin >> n;
	long long sum = 0;
	long long oddsum = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		sum += tmp;
		a.push_back(tmp);
		if (i % 2 == 0) {
			oddsum += tmp;
		}
	}
	sum /= 2;
	ans.push_back(oddsum - sum);
	cout << ans[0] * 2 << " ";
	for (int i = 1; i < a.size(); i++) {
		ans.push_back(a[i-1] - ans[i - 1]);
		cout << ans[i] * 2 << " ";
	}

	return 0;
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main() {

int N;
cin >> N;
vector<double> dp(N+1);
dp[0] = 1;

for(int coin=0; coin<N; coin++) {
   double p_head;
   cin >> p_head;
   for(int i=coin+1; i>=0; i--) {
      dp[i] = ( i==0 ? 0 : dp[i-1]*p_head ) + dp[i] * (1-p_head);
   }
}
double answer = 0;
for(int i=0; i<=N; i++) {
	if(i>N-i) {
		answer+=dp[i];
	}
}
cout<< fixed << setprecision(10) << answer << "\n";
return 0;
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	
	combination comb(200000);
	
	mint ans = 0;
	mint m_mult = 1;
	for(int x = n - 1; x >= 0; --x){
		if(x <= k){
			ans += (mint)m * m_mult * comb(n - 1, x);
		}
		m_mult *= m - 1;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
ll a[maxn],n;
ll dp[maxn];
ll go(ll i){
    if(i==(n-1)) return 0;
    ll &ans=dp[i];
    if(ans!=-1) return ans;
    ans=inf;
    ans=min(ans,abs(a[i]-a[i+1])+go(i+1));
    if((i+2)<n) ans=min(ans,abs(a[i]-a[i+2])+go(i+2));
    return ans;
}
int main()
{
    ll i;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    SET(dp,-1);
    cout<<go(0);
}


Measured memory_bytes: 4864
#include<stdio.h>

int main(void){
    int n,i=0,j=1;
    scanf("%d", &n);
    //printf("%d\n",n);
    int M;
    M=n;
    int N[n];
    char m[n];
    for(i=0;i<M*2;i++){
        //printf("  %d\n\n",i);
        scanf("%c %d", &m[i/2], &N[i/2]);
        //printf("%c %d\n",m[i],N[i]);
        //printf(" /%d\n\n",i);
       // printf("%a %d\n\n",m[i],N[i]);
    }

for(j=1;j<=13;j++){
    i=0;
    while(1){
        if(i==n) {
            printf("S %d\n",j);
            break;
        }
        if(m[i]==83&&N[i]==j) break;
        i++;
    }
}

for(j=1;j<=13;j++){
    i=0;
    while(1){
        if(i==n) {
            printf("H %d\n",j);
            break;
        }
        if(m[i]==72&&N[i]==j) break;
        i++;
    }
}

for(j=1;j<=13;j++){
    i=0;
    while(1){
        if(i==n) {
            printf("C %d\n",j);
            break;
        }
        if(m[i]==67&&N[i]==j) break;
        i++;
    }
}

for(j=1;j<=13;j++){
    i=0;
    while(1){
        if(i==n) {
            printf("D %d\n",j);
            break;
        }
        if(m[i]==68&&N[i]==j) break;
        i++;
    }
}




    return 0;
}


Measured memory_bytes: 2036
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, c = readline().split()

    ans = "A" + b[0] + "C"
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            String T = br.readLine();
            String P = br.readLine();
 
            if(P.length() <= T.length()){
 
                char T_array[] = T.toCharArray();
                char P_array[] = P.toCharArray();
 
                boolean Found = false,FLG;
 
                for(int start = 0; start < T.length(); start++){
                    FLG = true;
                    for(int i = 0; i < P.length(); i++){
                        if(P_array[i] != T_array[(start+i)%T.length()]){
                            FLG = false;
                            break;
                        }
                    }
                    if(FLG){
                        Found = true;
                        break;
                    }
                }
 
                if(Found){
                    System.out.printf("Yes\n");
                }else{
                    System.out.printf("No\n");
                }
 
            }else{
 
                System.out.printf("No\n");
            }
 
        } catch (IOException e) {
            e.printStackTrace();
        }
 
 
    }
}


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

int main(){
    int N,Y;
    cin >> N >> Y;

    int a10000 = -1, b5000 = -1, c1000 = -1;
    for(int a = 0; a <= N; a++){
        for(int b = 0; a + b <= N; b++){
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if(Y == total){
                a10000 = a;
                b5000 = b;
                c1000 = c;
            }
        }
    }
    cout << a10000 << " " << b5000 << " " << c1000 << endl;
}

Measured memory_bytes: 3632
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;


int n;

int get_sum(int x) {
	int res = 0;
	while (x) {
		res += (x % 10);
		x /= 10;
	}
	return res;
}

int main() {	
 
	cin >> n;
	
	int res = inf;
	for (int i = 1; i < n; i++) {
		int j = n - i;
		res = min(res, get_sum(i) + get_sum(j));
	}
	cout << res;
	return 0;
}


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

int main(){
    int n;
    string str;
    vector<string> v;
    
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> str;
        v.push_back(str);
    }
    cin >> n;
    int st = 0; //0 Closed , 1 Opened
    for(int i = 0 ; i < n ; i++){
        int flg = 0;
        cin >> str;
        for(int j = 0 ; j < v.size() ; j++){
            if(str == v[j]){
                if(!st){
                    cout << "Opened by " << str << endl;
                    st = 1;
                }
                else{
                    cout << "Closed by " << str << endl;
                    st = 0;
                }
                flg = 1;
                break;
            }
        }
        if(!flg) cout << "Unknown " << str << endl;
    }
    
    return 0;
}

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

int main() {
  long long n,a,b,c,d,e;
  cin >>n>>a>>b>>c>>d>>e;
  long long k=min({a,b,c,d,e});
  cout<<(n/k)+((n%k)!=0?1:0)+4<<endl;
  }


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

using namespace std;

int N, M;
vector<vector<bool>> rel;
vector<int> visited;

void search(int s){
    visited[s] = 1;
    for(int i=0; i<N; i++){
        if(rel[s][i] && !visited[i]) search(i);
    }
    return;
}


int main() {
    cin >> N >> M;
    vector<int> A(M);
    vector<int> B(M);
    rel.resize(N);
    for(vector<bool> &row:rel) row.resize(N);
    visited.resize(N);
    
    
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        rel[A[i]-1][B[i]-1] = true;
        rel[B[i]-1][A[i]-1] = true;
    }
    
    int ans = 0;
    for(int i=0; i<M; i++){
        rel[A[i]-1][B[i]-1] = false;
        rel[B[i]-1][A[i]-1] = false;

        search(0);
        int cnt = 0;
        for(int &v:visited){
            if(v) cnt++;
            v = 0;
        }
        if(cnt!=N) ans++;
        rel[A[i]-1][B[i]-1] = true;
        rel[B[i]-1][A[i]-1] = true;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string A,B,C;
  cin >> n >> A >> B >> C;
  int answer = 0;
  for(int i = 0;i < n;i++){
    char a,b,c;
    a = A[i];
    b = B[i];
    c = C[i];
    if((a == b && a != c)||(a == c && a != b)||(b == c && a != b)) answer++;
    else if( a != b && b != c && c != a) answer += 2;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
<?php
	$input = trim(fgets(STDIN));
	list($n, $m, $l) = explode(" ", $input);

	$a = $b = array();
	for ($i = 0; $i < $n; $i++) {
		$a[] = explode(" ", trim(fgets(STDIN)));
	}
	for ($i = 0; $i < $m; $i++) {
		$b[]= explode(" ", trim(fgets(STDIN)));
	}

	for ($i = 0; $i < $n; $i++) {
		for ($j = 0; $j < $l; $j++) {
			$c = 0;
			for ($k = 0; $k < $m; $k++) {
				$c += ($a[$i][$k] * $b[$k][$j]);
			}

			echo $c;
			if ($j < $l-1) echo " ";
		}
		echo "\n";
	}

Measured memory_bytes: 10144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()


ll L, R;

const ll MOD = 1e9+7;

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
    return is >> x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
  friend constexpr Fp<MOD> modinv(const Fp<MOD> &a) noexcept {
    return modpow(a, MOD - 2);
  }
};

using mint = Fp<MOD>;

mint dp[61][2][2][2];

int main () {
  cin >> L >> R;

  dp[60][0][0][0] = 1;
  for(int i = 59; i >= 0; i--) {
    int lb = (L >> i) & 1;
    int rb = (R >> i) & 1;

    rep(j,2)rep(k,2)rep(l,2) {
      mint pre = dp[i+1][j][k][l];
      rep(x,2) rep(y,2) {
        if(x && !y) continue;

        int nj = j, nk = k, nl = l;
        if(!l && x != y) continue;
        if(x && y) nl = 1;

        if(!j && !x && lb) continue;
        if(x && !lb) nj = 1;

        if(!k && y && !rb) continue;
        if(!y && rb) nk = 1;

        dp[i][nj][nk][nl] += pre;
      }
    }
  }

  mint ans = 0;
  rep(j,2)rep(k,2)rep(l,2) ans += dp[0][j][k][l];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int N;
    cin >> N;
    string s;
    cin >> s;

    int ans = 0;

    REP(i, N-2){
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
 
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
 
a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)
 
dp = [[0 for j in range(t)] for i in range(n+1)]
 
for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]
 
ans = 0
 
for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])
 
print(ans)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int a,b;
    Scd2(a,b);
    Rep(i,max(a,b)){
        printf ("%d", min(a,b));
    }
    printf ("\n");

    return 0;
}



Measured memory_bytes: 256
def conv(n)
  name = ""
  a = n
  while n > 0 do
    a = ((n - 1) / 26).to_i
    b = (n - 1) % 26
    name = (b + 65).chr + name
    n = a
  end
  name.downcase
end

n = gets.chomp.to_i
puts conv(n)


Measured memory_bytes: 14156
def main():
    X, Y, A, B, C = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))

    P.sort(reverse=True)
    Q.sort(reverse=True)
    PQR = P[:X] + Q[:Y] + R
    PQR.sort(reverse=True)    
    print(sum(PQR[:X+Y]))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 23984
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
int main(){
  string s;
  cin >> s;
  string S = "*KIH*B*R*";
  bool flag = false;
  rep(i,16){
    string SS = S;
    string ss;
    if(i & 1){
      SS.at(0) = 'A';
    }
    if(i & 2){
      SS.at(4) = 'A';
    }
    if(i & 4){
      SS.at(6) = 'A';
    }
    if(i & 8){
      SS.at(8) = 'A';
    }
    rep(j,9){
      if(SS.at(j) != '*'){
        ss.push_back(SS.at(j));
      }
    }
    if(s == ss){
      flag = true;
    }
  }
  if(flag){
    cout << "YES" << endl;
  }else{
      cout << "NO" << endl;
  }
      
        
  
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b) {
	ll r;
	while(b) {
		r = b;
		b = a % b;
		a = r;
	}
	return a;
}
int n;
set<ll> num;
int main() {
	scanf("%d",&n);
	for(int i=0,pos;i<=n;i++)
		scanf("%d",&pos),
		num.insert(1ll*pos);
	ll las=0,ans;
	for(set<ll>::iterator it=num.begin();it!=num.end();it++){
		ll val=*it;
		if(!las) {las=val;continue;}
		if(las==*num.begin()) ans=val-las;
		else ans=GCD(ans,val-las);
		las=val;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
*/

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

int n;
int a[4][4];
bool m[4][4];
int main(){
	for (int i=1;i<=3;i++){
		for (int j=1;j<=3;j++){
			cin >> a[i][j];	
		}
	}
	cin >> n;
	for (int i=1,b;i<=n;i++){
		cin >> b;
		for (int j=1;j<=3;j++){
			for (int k=1;k<=3;k++){
				if (a[j][k]==b){
					m[j][k]=1;
				}
			}
		}
	}
	for (int i=1;i<=3;i++){
		if ((m[i][1]&&m[i][2]&&m[i][3]) || (m[1][i]&&m[2][i]&&m[3][i])){
			cout << "Yes";
			return 0;
		}
	}
	if (m[1][1]&&m[2][2]&&m[3][3]){
		cout << "Yes";
		return 0;	
	}
	if (m[3][1]&&m[2][2]&&m[1][3]){
		cout << "Yes";
		return 0;	
	}
	cout << "No";
	return 0;
}	

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

int main()
{
	int r = 0, c = 0;
	cin >> r >> c;

	int **array = new int*[r + 1];
	for (int i = 0; i < r + 1; i++) array[i] = new int[c + 1];

	for (int j = 0; j < r; j++){
		for (int k = 0; k < c; k++){
			cin >> array[j][k];
		}
	}

	for (int j = 0; j < r; j++){
		array[j][c] = 0;
		for (int k = 0; k < c; k++){
			array[j][c] += array[j][k];
		}
	}

	array[r][c] = 0;
	for (int j = 0; j < r; j++) array[r][c] += array[j][c];

	for (int k = 0; k < c; k++){
		array[r][k] = 0;
		for (int j = 0; j < r; j++){
			array[r][k] += array[j][k];
		}
	}

	for (int j = 0; j < r + 1; j++){
		cout << array[j][0];
		for (int k = 1; k < c + 1; k++){
			cout << " " << array[j][k];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
import sys
sys.setrecursionlimit(100000)
n,k = map(int,input().split())
x = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  x[a].append(b)
  x[b].append(a)
ans = k
def search(i):
  l = len(x[i])
  if l == 0:
    return
  global ans
  for j in range(l):
    ans = (ans*(k-2-j))%1000000007
  for child in x[i]:
    x[child].remove(i)
    search(child)
l1 = len(x[1])
for j in range(l1):
  ans = (ans*(k-1-j))%1000000007
for child1 in x[1]:
  x[child1].remove(1)
  search(child1)
print(ans)

Measured memory_bytes: 87344
#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 main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int max_match = 0;
    for (int i = 1; i < n+1; i++) {
        if (s.substr(n-i, i) == t.substr(0, i)) {
            max_match = max(i, max_match);
        }
    }
    cout << 2 * n - max_match << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
  // cin>>test;

  while(test--)
  {
  
 int n,k;
 cin>>n>>k;
vector<bool> dp(k+1,false);
int a[n];
for(int i=0;i<n;i++)cin>>a[i];

  for(int i=0;i<=k;i++)
    for(int j:a)
    {
      if(i>=j && !dp[i-j])dp[i]=true;
    }

if(dp[k])
  cout<<"First";
else cout<<"Second";
  //while loop ending 
  }



return 0;
}

Measured memory_bytes: 256
mod=10**9+7

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

B=[]
C=[]
B.append([0,T[0],T[0]])
C.append([N-1,A[-1],A[-1]])

if N>1:
  for i in range(1,N):
    B.append([i,T[i],T[i] if T[i]>T[i-1] else 1])
  for i in range(N-2,-1,-1):
    C.append([i,A[i],A[i] if A[i]>A[i+1] else 1])
C.sort()
#print(B)
#print(C)

ans=1
for i in range(N):
  d=min(B[i][1],C[i][1])-max(B[i][2],C[i][2])+1
  ans*=d if d>=0 else 0
  ans%=mod
print(ans)

Measured memory_bytes: 37984
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		long N = Long.parseLong(reader.readLine());
		long res=  0;
		for(long i = 2;i*i<=N;i++){
			if(N%i==0){
				int toadd = 0;
				while(N%i==0){
					N/=i;
					toadd++;
				}
				res += effective(toadd);
			}
		}
		if(N!=1) res++;
		System.out.println(res);
	}
	private static int effective(int a){
		if(a==1) return 1;
		else{
			int res= 0;
			int i = 1;
			while(a>=i){
				res++;
				a-=i;
				i++;
			}
			return res;
		}
	}
}


Measured memory_bytes: 32716
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n;
	cin >> n;
	int ans = (n / 500) * 1000;
	n -= (n / 500) * 500;
	ans += 5 * (n / 5);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int Slen;
    Slen = S.size();

    int i,j,k;

    string f;
    int flen;
    string n;
    string m;
    int a;
    int ans;
    string flag = "OFF";

    for(j=1;j<Slen-1;j++)
    {
        f = S[0];
        for(i=1;i<Slen-j;i++)
        {
            f = f + S[i];  
        }
        flen = f.size();
        if((flen % 2) == 0)
        {
            a = flen / 2;
            n = f[0];
            m = f[a];
            for(k=1;k<a;k++)
            {
                n = n + f[k];
            }
            for(k=a+1;k<flen;k++)
            {
                m = m + f[k];
            }
            if(n == m)
            {
                ans = flen;
                flag = "ON";
            }
        }

        if(flag == "ON")
        {
            break;
        }
    }

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

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

using namespace std;

int main() {
    string s;
    cin >> s;
    bool a = false;
    bool b = false;
    for(int i = 0;i < 3;i++){
        if(s[i] == 'A')
            a = true;
        if(s[i] == 'B')
            b = true;
    }
    if(a && b){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll sn, ans =0;
	cin >>sn;
	VI mt = {3, 5, 7};
	
	auto rec =[&](auto rec, ll c, int usd){
		if(usd == 7 && c <= sn)  ans++;
		if(c > sn) return;
		rep(i, 3){
			rec(rec, c*10 + mt[i], usd | (1<<i));
		}
	};
	rec(rec, 0, 0);
	cout <<ans <<"\n";
	return 0;
}


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

int main(){
	double r,s,l;
	cin >> r;
	
	s = r*r*3.141592653589;
	l = r*2*3.141592653589;
	cout << fixed << s << " " << fixed << l << endl;
	
	return 0;
}

Measured memory_bytes: 3200