akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define sz size()
#define ff first
#define ss second
#define mp make_pair

const int N = 1e6 + 5;

int dp[N];

int get(string s){

  int n = s.size() - 1;
  int ret = 0;
  for(int r = 0; r <= n; r++){
    int nr = n - r;
    int now = s[r] - '0';
    now %= 2;
    if(now && ((nr & r) == 0))ret ^= 1;
  }
  return ret;
}

int main() {

  int n;
  cin >> n;
  string s;
  cin >> s;

  for(int i = 0; i < n; i++)s[i]--; 

  int w = get(s);
  if(w & 1)cout << 1 << endl;
  else {
    for(int i = 0; i < n; i++){
      if(s[i] == '1'){
        cout << 0 << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++)s[i] = '0' + (s[i] - '0')/2;
    if(get(s))cout << 2 << endl;
    else cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 2308
using System;

namespace C_SccPuzzle {
    class Program {
        static void Main(string[] args) {
            var str = Console.ReadLine().Split(' ');
            var N = long.Parse(str[0]);
            var M = long.Parse(str[1]);
            var ans = Math.Min(N, M / 2);
            ans += Math.Max(0, (M - 2 * ans) / 4);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int rep = 0; rep < n; ++rep) {
        double x; cin >> x;
        //scanf("%lf", &x);
        long long i = llround(x * 1e9);
        int two = 0, five = 0;
        while(i % 2 == 0) {
            two++;
            i /= 2;
        }
        while(i % 5 == 0) {
            five++;
            i /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", answer);
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e16+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n, m, arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n, arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len = v.size();
    for(int i = 0; i < len; ++i) {
        s<<v[i];
        if(i < len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len = vv.size();
    for(int i = 0; i < len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n, m;
    cin>>n>>m;


    VV to(n);
    VV par(n);
    Vi in(n);
    ll a, b;
    rep(i, n-1+m) {
        cin>>a>>b;
        a--;
        b--;
        to[a].pb(b);
        par[b].pb(a);
        in[b]++;
    }

    stack<int> stk;
    rep(i, n)if(in[i] == 0) stk.push(i);

    Vi indtov;
    while (!stk.empty()) {
        int &v = stk.top();
        indtov.pb(v);
        stk.pop();
        Each(nx, to[v]) {
            in[nx]--;
            if(in[nx] == 0)stk.push(nx);
        }
    }

    Vi vtoind(n);
    rep(i, n) {
        vtoind[indtov[i]] = i;
    }


    rep(i, n) {
        int ans = -1;
        int tmp = -1;
        Each(v, par[i]) {
            if(vtoind[v] > tmp) {
                ans = v;
                tmp = vtoind[v];
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}


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

using namespace std;

char a[100010];

int main()
{
    char b;
    int l,i;
    scanf("%s",a);
    l=strlen(a);
    stack<char> p;
    for(i=0; i<l; i++)
    {
        if(p.empty()) p.push(a[i]);
        else
        {
            b=p.top();
            if(b==a[i]) p.push(a[i]);
            else p.pop();
        }
    }
    cout << l-p.size() << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize(3)
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string s;
inline void write(int x){
	if(x>9)write(x/10);
	putchar(x%10^48);
}
int cnt,recL,recR,rec[100001];
int main(){
	cin>>s;
	for(register int i=0;i<s.length();i++){
		if(s[i]=='R')recR=i;
		else {
			if((i-recR)&1)rec[recR+1]++;
			else rec[recR]++;
		}
	}
	for(register int i=s.length()-1;i>=0;i--){
		if(s[i]=='L')recL=i;
		else{
			if((recL-i)&1)rec[recL-1]++;
			else rec[recL]++;
		}
	}
	for(register int i=0;i<s.length();i++){
		write(rec[i]);
		putchar(' ');
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N, 0);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  int ans = A[0];
  int tmp = A[N-1];
  queue<int> q;;
  for(int i = 1; i < N-1; i++){
    q.push(A[i]);
  }
  vector<pair<int, int> > a;
  while(!q.empty()){
    if(q.front() < 0){
      a.push_back({ans, q.front()});
      ans = ans - q.front();
      q.pop();
    }else{
      a.push_back({tmp, q.front()});
      tmp = tmp - q.front();
      q.pop();
    }
  }
  a.push_back({ans, tmp});
  ans = ans - tmp;
  cout << ans << endl;
  REP(i, N-1){
    cout << a[i].first << " " << a[i].second << endl;
  }
}


Measured memory_bytes: 3576
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=998244353;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

vector<int>rv[3];
vector<int>color[3];

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<3*n;i++){
		if(s[i]=='R'){
			rv[0].pb(i);
		}
		else if(s[i]=='G'){
			rv[1].pb(i);
		}
		else{
			rv[2].pb(i);
		}
	}
	int none=n,a=0,b=0,ans=1;
	for(int j=0;j<3*n;j++){
		if(s[j]=='R'){
			int i=lower_bound(all(rv[0]),j)-rv[0].begin();
			if(rv[0][i]==min({rv[0][i],rv[1][i],rv[2][i]})){
				ans=mul(ans,none);
				a++;
				none--;
			}
			else if(rv[0][i]==max({rv[0][i],rv[1][i],rv[2][i]})){
				ans=mul(ans,b);
				b--;
			}
			else{
				ans=mul(ans,a);
				b++;
				a--;
			}
		}
		else if(s[j]=='G'){
			int i=lower_bound(all(rv[1]),j)-rv[1].begin();
			if(rv[1][i]==min({rv[0][i],rv[1][i],rv[2][i]})){
				ans=mul(ans,none);
				a++;
				none--;
			}
			else if(rv[1][i]==max({rv[0][i],rv[1][i],rv[2][i]})){
				ans=mul(ans,b);
				b--;
			}
			else{
				ans=mul(ans,a);
				b++;
				a--;
			}
		}
		else{
			int i=lower_bound(all(rv[2]),j)-rv[2].begin();
			if(rv[2][i]==min({rv[0][i],rv[1][i],rv[2][i]})){
				ans=mul(ans,none);
				a++;
				none--;
			}
			else if(rv[2][i]==max({rv[0][i],rv[1][i],rv[2][i]})){
				ans=mul(ans,b);
				b--;
			}
			else{
				ans=mul(ans,a);
				b++;
				a--;
			}
		}
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 3724
N = int(input())
A = list(map(int, input().split()))

from operator import add
from itertools import accumulate

L = list(accumulate(A, add))

ans = float("inf")
for i in range(N-1):
  x = L[i]
  y = L[N-1] - L[i]
  ans = min(ans, abs(x-y))

print(ans)

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e18
using namespace std;
typedef long long ll;

long double t,x;
int main(){
  std::cin >> t >> x;
  long double res = t/x;
  std::cout << res << '\n';
}


Measured memory_bytes: 256
import java.util.*;
class Main {
public static void main(String[]args) {
	Scanner sc= new Scanner(System.in);
	int n=sc.nextInt();
	int lastD=n%10;
	if(lastD==2||lastD==4||lastD==5||lastD==7||lastD==9)
		System.out.println("hon");
	else if(lastD==0||lastD==1||lastD==6||lastD==8)
		System.out.println("pon");
	else
		System.out.println("bon");
}
}


Measured memory_bytes: 26972
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

#define MAX_N 100000
#define INF INT_MAX / 2

using namespace std;

int main() {
	int n;
	int a[MAX_N];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int dp[MAX_N];
	fill_n(dp, MAX_N, INF);
	dp[0] = a[0];
	int len = 1;
	for (int i = 1; i < n; i++)
		if (dp[len-1] < a[i])
			dp[len++] = a[i];
		else {
			int j = len-1;
			for (; j >= 0; j--)
				if (dp[j] < a[i])
					break;
			dp[j+1] = a[i];
		}
	cout << len << endl;
	return 0;
}

Measured memory_bytes: 1940
n ,s = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
a = a.sort
i = 1
u = []
u << a[0]
uu = 0
if s > 1
while uu < s 
  u << a[i]
uu = u.size
i += 1
end
end
puts u.inject(:+)


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

int main(){
    int N, Y;

    cin >> N >> Y;
    int ans10000 = -1, ans5000 = -1, ans1000 = -1;
    for(int x = 0; x <= N; x++){
        for(int y = 0; y <= N - x; y++){
            int z = N - x - y;
            if(10000 * x + 5000 * y + 1000 * z == Y){
                ans10000 = x;
                ans5000 = y;
                ans1000 = z;
                break;
            }
            }
        }
    cout << ans10000 << ' ' << ans5000 << ' ' << ans1000 << endl;
    return 0;

}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;

  vll h(n);
  rep(i, n) {
    cin >> h[i];
  }

  ll ans = INF;
  sort(all(h));
  rep(i, n - k + 1) {
    chmin(ans, h[i + k - 1] - h[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Lesson5A　たてH cm よこ W cm の長方形を描くプログラム
 * 1 cm × 1cm の長方形を '#'で表します。
 * @author 前島佑介
 * @version 2014/12/1
 */
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		try{
			//キーボードからの入力準備
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			//入力値を格納する場所を初期化
			String strLine = "";

			//入力値をint型で保存する場所
			ArrayList<String> strArray = new ArrayList<String>();

			//入力値の取得にループさせる
			while(true) {

				//1行読み込む
				strLine = insBR.readLine();

				//入力値が"0 0"だったら
				if(strLine.equals("0 0")) {

					//ループから抜ける
					break;
				}

				//入力値を保存
				strArray.add(strLine);
			}

			//ループさせる
			for(int i = 0; i < strArray.size(); i++) {

				//文字列の分割:入力値を" "で分ける
				//分けた文字列はstrLineAry[0]とstrLineAry[1]に分けられる
				String[] strLineAry = strArray.get(i).split(" ");

				//左の値
				int intNum1 = Integer.parseInt(strLineAry[0]);

				//右の値
				int intNum2 = Integer.parseInt(strLineAry[1]);

				//出力させるメソッド
				SharpPaint(intNum1, intNum2);
			}

		//例外処理
		}catch(IOException e) {

			//例外時の出力
			System.out.println(e);
		}catch(NumberFormatException e) {


			//数値以外の入力値で出力
			System.out.println("数値で入力して下さい");
		}
	}

	public static void SharpPaint(int intNum1, int intNum2) {

		for(int i = 0; i < intNum1; i++) {
			for(int j = 0; j < intNum2; j++) {
				System.out.print("#");
			}
			System.out.println();
		}

		System.out.println();

	}
}

Measured memory_bytes: 25692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll asum = accumulate(a.begin(), a.end(), 0LL);
    ll bsum = accumulate(b.begin(), b.end(), 0LL);
    
    ll cnt2 = 0, cnt1 = 0;
    rep(i, n) {
        if (a[i] > b[i]) {
            cnt1 += a[i]-b[i];
        } else if (a[i] < b[i]) {
            if ((b[i]-a[i])&1) {
                cnt2 += (b[i]-a[i]+1)/2;
                cnt1 += 1;
            } else {
                cnt2 += (b[i]-a[i])/2;
            }
        }
    }
    if (cnt2 <= bsum-asum && cnt1 <= bsum-asum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>

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).bigin(), (c).end())

int main()
{
    int n;
    cin >> n;
    if (n % 2 == 0)
        cout << n << endl;
    else
        cout << 2 * n << endl;

    return 0;
}

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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld n;
  cin>>n;
  lld k = ceil(n/1000.0);
  lld ans = k*1000 - n;
  cout<<ans<<endl;

}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin >> n;
    int64_t a[200001];
    long long int L=0;
    rep(i,n){
        cin >> a[i];
        L += a[i];
    }
    int money = 0;
    int64_t l=0,R;
    int left,r;
    rep(i,n){
        l += a[i];
        if(l>=L/2){
            R = L-l;
            r=i;
            left = i-1;
            break;
        }
    }

    cout << min(abs(L-2*l),abs(L-2*l+2*a[r]))<<endl;;
    return 0;
}

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

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

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

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

    int n;
    cin >> n;

    ll ans = 1;

    rep(i, n) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>

using namespace std;

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

  int applyNumList[] = { 111, 222, 333, 444, 555, 666, 777, 888, 999 };

  for (int id = 0; id < 9; id++) {
    if (n <= applyNumList[id]) {
      cout << applyNumList[id];
      break;
    }
  }
}
      

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());

        int i = 0;
        for (i = 1; ; i++)
        {
            if (360 * i % x == 0)
            {
                break;
            }
        }
        Console.WriteLine(360 * i / x);
    }
}


Measured memory_bytes: 27524
#include<bits/stdc++.h>
 
using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f                     first                 
#define  s                     second                
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  1e5+8;
const ll   mod   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
 
ll t=1,n,k,a[N],dp[N];
 
void solve(){
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}
 
int main(){
    fastio;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b; cin >> a >> b;
    cout << a*b-a-b+1 << endl;
    return 0;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

const Int MAX = 510000;
const Int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (Int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(Int n, Int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    Int n, m, k;
    cin >> n >> m >> k;
    Int res = 0;
    Int add = 0;
    for (Int i = 1; i <= n - 1; i++) {
       add += m * m * i * (n - i);
       add %= mod;
    }
    res = (res + add) % mod;
    add = 0;
    for (Int i = 1; i <= m - 1; i++) {
        add += n * n * i * (m - i);
        add %= mod;
    }
    res = (res + add) % mod;
    res *= COM(n * m - 2, k - 2);
    res %= mod;
 /*    dump(res);
    for (Int i = 1; i <= k - 1; i++) {
        res *= i;
        res %= mod;
    } */
    dump(res);
    return 0;
}

Measured memory_bytes: 12288
// C++ (GCC 9.2.1)
// 解き直し.
// https://img.atcoder.jp/abc171/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
const int LIMIT = 2020202;
LL FAC[LIMIT], INV[LIMIT], C[LIMIT], mPow25[LIMIT], mPow26[LIMIT];

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 組み合わせ(nCk)計算用(mod版).
// ※配列FAC, INV は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果(mod版).
LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0LL;
    if(n == k || k == 0LL) return 1LL;
    LL ret = FAC[n] * INV[k] % MOD * INV[n - k] % MOD;
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int K;
    char c[1010101];
    scanf("%d %s", &K, c);
    int N = strlen(c);
    FAC[0] = 1, mPow25[0] = 1, mPow26[0] = 1;
    repx(i, 1, LIMIT){
        FAC[i] = (LL)i * FAC[i - 1] % MOD;
        mPow25[i] = mPow25[i - 1] * 25LL % MOD;
        mPow26[i] = mPow26[i - 1] * 26LL % MOD;
    }
    rep(i, LIMIT) INV[i] = mPow(FAC[i], MOD - 2);
    
    // 2. S[N] の 位置ごとに集計(解説通り).
    LL ans = 0;
    repx(i, N - 1, N + K){
        // 2-1. S[1] ～ S[N - 1] の 選び方.
        LL a = combination((LL)i, (LL)(N - 1));
        
        // 2-2. S[i]以外の文字の選び方.
        int cnt = (N + K - 1) - i; // S[N]以降の文字数.
        LL b = mPow25[K - cnt] * mPow26[cnt] % MOD;
        
        // 2-3. 集計.
        ans = (ans + a * b) % MOD;
    }
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 67840
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

lis = [a, b, c, d, e]
lis

ans = 4 + n // min(lis)
if n % min(lis) is not 0:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<bool> jud(n+1,true);
	REP(i,m){
		int a;
		cin>>a;
		jud[a]=false;
	}
	
	vector<llong> dp(n+1,0);
	dp[0]=1;
	if(jud[1]) dp[1]=1;
	for(int i=2;i<=n;++i){
		if(jud[i]){
			dp[i]=dp[i-2]+dp[i-1];
			dp[i]%=MOD;
		}
	}
	
	cout<<dp[n]<<endl;
}//復習.

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

int main(){
 int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string S;cin>>S;
    sort(ALL(S));
    cout<<(S[0]!=S[2]?"Yes":"No")<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main() {
	// your code goes here
	int n = 0, a = 0, b = 0, count = 0;
	cin>>n;
	bool equal = false;
	for(int i = 0 ; i < n; i++){
		cin>> a >> b;
		if(a == b){
			count++;
		}
		else{
			count = 0;
		}
		if(count == 3){
			equal = true;
		}
	}
	if(equal)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3552
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int ans = 0;
        if(a == max(a, max(b, c))) ans = a*10+b+c;
        else if(b == max(a, max(b, c))) ans = b*10+a+c;
        else ans = c*10+a+b;
        System.out.println(ans);
    }
    public static int max(int a, int b) {
        if(a <= b) return b;
        else return a;
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	set<string> q;
	string s;
	int K;
	cin >> s >> K;
	for(int i = 0; i < s.size(); i++) {
		for(int j = 1; i+j <= s.size() && j <= K; j++) {
			q.insert(string(s.begin()+i, s.begin()+i+j));
		}
	}
	//cout << K << "," << q.size() << endl;
	rep(i,K-1)
		q.erase(q.begin());
	cout << *q.begin() << endl;
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
#define start_from1 true
typedef long long ll;
using namespace std;

class Graph_func
{
public:
	int N;
	int N_edge;
	vector<pair<int, int> > edgelist;
	vector<vector<int> > adjlist;
	vector<int> adjnum;

	vector<int> xdist;

	void read_edge();
	void adjini();
	void adjsort();
	void xydist(int x, int x_old, int dist_tmp);   // ex. xydist(3, N, 0)
	int diameter();
};

void Graph_func::read_edge()
{
	cin >> N;
	N_edge = N - 1;// graph

	edgelist.resize(N_edge);
	adjnum.resize(N);
	xdist.resize(N);
	adjlist.resize(N);
	//cout << N << " " << N_edge << endl;
	for (int i = 0; i < N_edge; i++)
	{
		cin >> edgelist[i].first >> edgelist[i].second;
		if (start_from1)
		{
			edgelist[i].first--;
			edgelist[i].second--;
		}
	}
	return;
}

void Graph_func::adjini()
{
	for (int i = 0; i < N; i++)
		adjnum[i] = 0;
	for (int i = 0; i < N_edge; i++)
	{
		int x = edgelist[i].first;
		int y = edgelist[i].second;
		adjlist[x].push_back(y);
	    adjlist[y].push_back(x);
		adjnum[x]++;
		adjnum[y]++;
	}
	return;
}

void Graph_func::adjsort()
{
	for (int i = 0; i < N; i++)
		sort(adjlist[i].begin(), adjlist[i].end(), less<int>());
	return;
}

void Graph_func::xydist(int x, int x_old, int dist_tmp)  // ex. xydist(3, N, 0)
{
	if (x_old == N)
		xdist[x] = 0;
	for (int i = 0; i < adjnum[x]; i++)
	{
		int x_new = adjlist[x][i];
		if (x_new != x_old)
		{
			xdist[x_new] = dist_tmp + 1;
			xydist(x_new, x, dist_tmp + 1);
		}
	}
	return;
}

int Graph_func::diameter()
{
	int anstmp = 0, anstmp_i = 0;
	pair<int, int> longest;
	xydist(0, N, 0);
	//for (int i = 0; i < N; i++)
		//cout << xdist[i] << endl;
	for (int i = 0; i < N; i++)
	{
		if (xdist[i] > anstmp)
		{
			anstmp = xdist[i];
			anstmp_i = i;
		}
	}
	longest.first = anstmp_i;
	anstmp = 0, anstmp_i = 0;
	xydist(longest.first, N, 0);
	for (int i = 0; i < N; i++)
	{
		if (xdist[i] > anstmp)
		{
			anstmp = xdist[i];
			anstmp_i = i;
		}
	}
	longest.second = anstmp_i;
	return anstmp;
}

int main(void)
{
	Graph_func graph;
	int ans;
	graph.read_edge();
	graph.adjini();
	ans = graph.diameter();
	//cout << ans << endl;
	if (ans % 3 != 1)
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}

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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n;
	n+=1;
	ll a[n];
	rep(i,0,n,1) cin >> a[i];
	if(n==1 && a[0]==0){
		cout << -1 << endl;
		return 0;
	}
	if(n==1 && a[0]==1){
		cout << 1 << endl;
		return 0;
	}
	if(a[0]!=0){
		cout << -1 << endl;
		return 0;
	}
	ll b[n];
	rep(i,0,n,1) b[i]=a[i];
	reverse(a, a+n);
	rep(i,1,n,1) a[i]+=a[i-1];
	reverse(a, a+n);
	ll start = 1;

	//now the main logic begins -->
	vector<ll> ans;
	ans.push_back(1ll);
	rep(i,1,n,1){
		ll max_nodes = (start*2);
		ll rem_nodes = max_nodes - b[i];
		ans.push_back(min(max_nodes, a[i]));
		if(rem_nodes<0){
			cout << -1 << endl;
			return 0;
		}
		start = min(rem_nodes, a[i]);
		//cout << max_nodes << " " << rem_nodes << " " << start << endl;
	}

	cout << accumulate(all(ans), 0ll) << endl;
	return 0;
}


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

const int mod = 1e9+7;

int n;

const int maxn = 100010;
int p[maxn];
int ind[maxn];
bool vis[maxn];
int pos[maxn];
int feet[maxn];

map<int, int> cir;

int dp[maxn];
int DP(int m,int n) {
	long long s = 1 + ((m > 1) & (m & 1));
	long long p = m;
	dp[0] = 1;
	dp[1] = s;
	for(int i = 2; i <= n; ++i) {
		dp[i] = (s * dp[i-1] + p * (i-1) % mod * dp[i-2]) % mod;
	}
	return dp[n];
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) { scanf("%d", &p[i]); ind[p[i]] += 1; }
	for(int i = 1; i <= n; ++i) if(ind[i] > 2) { puts("0"); return 0; }
	for(int i = 1; i <= n; ++i) if(ind[i] == 0) {
		int j, l = 0;
		for(j = i; ind[j] < 2; j = p[j]) vis[j] = true, l += 1;
		feet[j] = l;
	}
	int ans = 1;
	for(int i = 1; i <= n; ++i) if(!vis[i]) {
		int l = 0, j;
		for(j = i; !vis[j]; j = p[j]) vis[j] = true, pos[l++] = j;
		if(i!=j) ans = 0;
		int last = 0;
		for(int j = 0; j < l; ++j) if(feet[pos[j]] > 0) last = j - l;
		if(last == 0) { cir[l]++; continue; }
		for(int j = 0; j < l; ++j) if(feet[pos[j]] > 0) {
			if(j - last > feet[pos[j]]) ans = (ans << 1) % mod;
			else if(j - last < feet[pos[j]]) ans = 0;
			last = j;
		}
	}
	for(auto e: cir) ans = 1ll * ans * DP(e.first, e.second) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import Numeric
showF :: RealFloat a => a -> String
showF = flip (showFFloat Nothing) ""
main = do
  [a, b] <- fmap (map read . words) getLine :: IO [Int]
  print $ div a b
  print $ mod a b
  putStrLn $ showF $ (fromIntegral a) / (fromIntegral b)

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define add push_back
#define endl "\n"
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using ll = long long;
using namespace std;

int a;
string s;
int main() {
    IOS
    cin >> a >> s;
    cout << (a >= 3200 ? s : "red") << endl;
    
    return 0;
}





Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Subscribers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);

  printf("%d %d\n", min(a, b), max(0, a + b - n));
  return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	int cnt=0;
	for(int i=a;i<=b;++i){
		string s=to_string(i);
		string r=s;
		reverse(r.begin(),r.end());
		if(s==r){
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

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

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    double l;
    cin >> l;
    cout << setprecision(12) << (l/3)*(l/3)*(l/3) << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Calc calc=new Calc();

		calc.abc125_C();

	}

}

class Calc{

	int N;
	int[] box;
	int[] L;
	int[] R;

	public void abc125_C() {

		Scanner sc=new Scanner(System.in);

		N=sc.nextInt();

		box=new int[N];
		L=new int[N+1];
		R=new int[N+1];

		L[0]=R[N]=0;

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

		for(int i=0;i<N;i++) L[i+1]=gcd(L[i],box[i]);

		for(int i=N-1;i>=0;i--) R[i]=gcd(R[i+1],box[i]);

		int max=0;

		for(int i=0;i<N;i++) max=Math.max(max, gcd(L[i],R[i+1]));

		System.out.println(max);

		sc.close();

	}

	// O(log MAX_X)
	public int gcd(int a,int b) {
		if(a<b){
			int w=a;
			a=b;
			b=w;
		}
		if(b==0) return a;
		return gcd(a%b,b);
	}

}


Measured memory_bytes: 56712
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(int s=1;s<=1000;s++)
    {
        if((a*s)%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int H,W,K; cin >> H >> W >> K;
    vector<string> s(H);
    rep(i,H) cin >> s[i];
    vector<vector<int>> sum(H+1,vector<int>(W+1));
    rep(i,H)rep(j,W){
        sum[i+1][j+1] = sum[i+1][j]+sum[i][j+1]-sum[i][j]+(s[i][j] == '1');
    }
    int ans = INF;
    rep(i,1<<(H-1)){
        vector<int> v;
        v.push_back(0);
        rep(j,H-1){
            if(i>>j&1) v.push_back(j+1);
        }
        v.push_back(H);
        int tmp = 0;
        int m = v.size();
        int now = __builtin_popcount(i);
        bool ok2 = true;
        repr(j,1,W+1){
            bool ok = false;
            repr(k,1,m){
                if(sum[v[k]][j]-sum[v[k]][tmp]-sum[v[k-1]][j]+sum[v[k-1]][tmp] > K){
                    ok = true;
                }
            }
            if(ok){
                if(j == tmp+1){
                    ok2 = false;
                }
                now++;
                tmp = j-1;
            }
        }
        if(!ok2) continue;
        ans = min(ans,now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int ans[26];

int min(int x,int y){
	if(x<y)return x;
	return y;
}

int main(){
	int n;
	scanf("%d",&n);
	
	char s[51];
	scanf("%s",s);
	for(int j=0;s[j]!='\0';j++)ans[s[j]-'a']++;
	
	for(int i=1;i<n;i++){
		char S[51];
		scanf("%s",S);
		int tmp[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		for(int j=0;S[j]!='\0';j++)tmp[S[j]-'a']++;
		for(int k=0;k<26;k++)ans[k]=min(ans[k],tmp[k]);
	}
	
	for(int k=0;k<26;k++)for(int i=0;i<ans[k];i++)printf("%c",'a'+k);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCountingRoads solver = new BCountingRoads();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCountingRoads {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            int[] count = new int[n];
            for (int i = 0; i < m; i++) {
                count[in.nextInt() - 1]++;
                count[in.nextInt() - 1]++;
            }
            Arrays.stream(count).forEach(out::println);
        }

    }
}



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

int N;
string S[100];
int p;

int cnt(int i) {
  REP(j, 0, S[i].size()) if(S[i][j] != '.') return j;
  return 0;
}

int dfs(int l) {
  if('0' <= S[p][l] && S[p][l] <= '9') return S[p++][l] - '0';
  char op = S[p++][l];
  int ret = op == '+' ? 0 : 1;
  while(p < N && cnt(p) > l) {
    if(op == '+') ret += dfs(l + 1);
    else ret *= dfs(l + 1);
  }
  return ret;
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) cin >> S[i];
    p = 0;
    cout << dfs(0) << endl;
  }
}

Measured memory_bytes: 3136
from collections import deque
import sys

sys.setrecursionlimit(10 ** 9)

N = int(input())

G = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    G[a].append((b, c))
    G[b].append((a, c))
Q, K = [int(_) for _ in input().split()]

# make tree
G2 = [10 ** 12] * (N + 1)

G2[K] = 0


def f():
    que = deque()
    que.append((K, 0))
    while que:
        v, p = que.pop()
        for nv, nc in G[v]:
            if nv == p: continue
            G2[nv] = G2[v] + nc
            que.append((nv, v))


f()

for i in range(Q):
    x, y = [int(_) for _ in input().split()]
    print(G2[x] + G2[y])


Measured memory_bytes: 83488
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" ";
	if(a+b<n){
		cout<<0<<endl;
	}
	else{
		cout<<a+b-n<<endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n = int(input())
    X = list(map(int,input().split()))

    ans = 0
    p = round(sum(X)/n)
    for i in range(n):
        ans += (X[i]-p)**2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <complex>

using namespace std;

typedef complex<double> point;
#define X real()
#define Y imag()
typedef point vec;

double cross(vec a, vec b)
{ return a.X * b.Y - b.X * a.Y; }

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

point center(point A, point B, point C) // Circumcenter
{
	B -= A; C -= A;
	double b = norm(B), c = norm(C), d = 2 * cross(B, C);
	return A + point(C.Y * b - B.Y * c, B.X * c - C.X * b) / d;
}

int main()
{
	int dat;
	scanf("%d", &dat);
	while (dat--) {
		point p[3], c;
		for (int i = 0; i < 3; ++i) {
			double x, y;
			scanf("%lf%lf", &x, &y);
			p[i] = point(x, y);
		}
		c = center(p[0], p[1], p[2]);
		printf("%.3lf %.3lf %.3lf\n", c.X, c.Y, dis(c, p[0]));
	}
}

Measured memory_bytes: 1108
#include <iostream>
    #include <sstream>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <cctype>
    #include <string>
    #include <vector>
    #include <list>
    #include <set>
    #include <map>
    #include <bitset>
    #include <queue>
    #include <stack>
    #include <algorithm>
    #include <functional>
    using namespace std;
    typedef long long ll;
     
    #define mem(dp,a)           memset(dp,a,sizeof dp)
    #define rep(i,a,b)          for(ll i=a;i<b;i++)
    #define pb(x)               push_back(x)
    #define mp(x,y)             make_pair(x,y)
    #define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define F                   first
    #define S                   second
    #define all(v)              (v).begin(),(v).end()
    #define pi                  3.14159265359
    ll INF=1e18+10;
    ll MOD=1000000009;
     
    const int N=2*1e5+10;
    bool vis[N];
     
    int main()
    {
        fastio;
        int n;cin>>n;
        int a[n+1];
        for(int i=0;i<n;i++)
        cin>>a[i+1];
     
        for(int i=n;i>0;i--)
        {
            int last=(n/i)*i;
            int c=0;
            for(int j=last;j>0;j-=i)
                if(vis[j]==1)c++;
            if((c%2==0 && a[i]==0) || (c%2==1 && a[i]==1))
                continue;
            else
                vis[i]=1;
        }
        vector<int> v;
        for(int i=1;i<=n;i++)
            if(vis[i])
            v.push_back(i);
     
        int siz=v.size();
        cout<<siz<<endl;
        for(int i=0;i<siz;i++)
            cout<<v[i]<<" ";
    }

Measured memory_bytes: 2552
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
using namespace std;

int n, q, a[210000], b[210000], c[210000], fa[210000], d[210000];
long long ans;
vector <int> now, now1;
int co;
int tx[210000];
set <pair<int, int> > used;

bool cmp(int x, int y) {
	return c[x] < c[y];
}

int gf(int x) {
	if (fa[x] != x)
		fa[x] = gf(fa[x]);
	return fa[x];
}

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= q; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	for (int i = 1; i <= q; i++)
		tx[i] = i;
	sort(tx + 1, tx + q + 1, cmp);
	for  (int i = 1; i <= n; i++)
		fa[i] = i;
	co = n;
	c[tx[q + 1] = q + 1] = 2000000000;
	int h;
	for (int i = 1; i <= q; i = h + 1) {
		h = i;
		while (h < q && c[tx[h + 1]] == c[tx[i]])
			h ++;
		for (int j = i; j <= h; j++)
			now.push_back(tx[j]);
		while (now.size() > 0 && c[now[0]] < c[tx[h + 1]] && co > 1) {
			now1.clear();
			for (int j = 0; j < (int) now.size(); j++) {
				if (gf(a[now[j]]) != gf(b[now[j]])) {
					fa[gf(a[now[j]])] = gf(b[now[j]]);
					co -= 1;
					ans += c[now[j]];
				}else {
					d[now[j]] |= (1 << (c[now[j]] % 2));
				}
			}
			for (int j = 0; j < (int) now.size(); j++)
				if (d[now[j]] != 3)
					now1.push_back(now[j]);
			now.clear();
			for (int j = 0; j < (int) now1.size(); j++)
				now.push_back(now1[j]);
			for (int j = 0; j < (int) now.size(); j++) {
				swap(a[now[j]], b[now[j]]);
				b[now[j]] = (b[now[j]] + 1) % n;
				c[now[j]] += 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7284
h, w = [int(item) for item in input().split()]
shw = ["." * (w+2)] + ["." + input() + "." for _ in range(h)] + ["." * (w+2)]

ans = True
for i in range(1,w+1):
  for j in range(1,h+1):
    if shw[j][i] == ".":
      continue
    if shw[j][i+1] == "." and shw[j][i-1] == "." and shw[j+1][i] == "." and shw[j-1][i] == ".":
      ans = False
      break

if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
if __name__ == '__main__':
	N, M = map(int, input().split())
	lmax = 0
	rmin = N
	for _ in range(M):
		L,R = map(int, input().split())
		if L > lmax:
			lmax = L
		if R < rmin:
			rmin = R
	ans = rmin - lmax + 1
	if ans < 0:
		ans = 0

	print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, b[200005] = {}, c[200005] = {}, d[200005] = {}, x = 0;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		c[a]++;
	}
	rep(i, n) {
		cin >> b[i];
		d[b[i]]++;
		if (c[b[i]] + d[b[i]] > n) {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, n) {
		c[i + 1] = c[i] + c[i + 1];
		d[i + 1] = d[i] + d[i + 1];
	}
	rep(i, n)chmax(x, c[i + 1] - d[i]);
	cout << "Yes" << endl;
	rep(i, n)cout << b[(n + i - x) % n] << endl;
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int N;
    ll x;
    cin >> N >> x;
    ll a[100050];
    a[0] = 0;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        if(a[i - 1] + a[i] <= x) continue;
        ll delta = a[i - 1] + a[i] - x;
        a[i] -= delta;
        ans += delta;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024