akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 505;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>

void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, d1, d2, t1 = 0, t2 = 0, col1[N << 1][N << 1], col2[N << 1][N << 1];

int main () {
	read(n), read(d1), read(d2);

	while (d1 & 1 ^ 1) t1++, d1 >>= 1;
	while (d2 & 1 ^ 1) t2++, d2 >>= 1;
	for (int i = 0; i < (n << 1); i++) {
		for (int j = 0; j < (n << 1); j++) {
			if (t1 & 1) col1[i][j] = (i % (1 << (t1 + 1 >> 1)) < (1 << (t1 >> 1)));
			else col1[i][j] = ((i + j) % (1 << (t1 + 2 >> 1)) < (1 << (t1 >> 1)));
			if (t2 & 1) col2[i][j] = (i % (1 << (t2 + 1 >> 1)) < (1 << (t2 >> 1)));
			else col2[i][j] = ((i + j) % (1 << (t2 + 2 >> 1)) < (1 << (t2 >> 1)));

		}
	}

	int mx = 0, posi = -1, posj = -1;
	for (int i = 0; i <= 1; i++) {
		for (int j = 0; j <= 1; j++) {
			int cnt = 0;
			for (int x = 0; x < (n << 1); x++) {
				for (int y = 0; y < (n << 1); y++) {
					if (col1[x][y] == i && col2[x][y] == j) cnt++;
				}
			}

			if (mx < cnt) mx = cnt, posi = i, posj = j;
		}
	}

	vector<pair<int, int> > s;
	for (int i = 0; i < (n << 1); i++) {
		for (int j = 0; j < (n << 1); j++) {
			if (col1[i][j] == posi && col2[i][j] == posj) s.push_back(make_pair(i, j));
		}
	}

	for (int i = 0; i < n * n; i++) {
		write(s[i].first), putchar(' ');
		write(s[i].second), putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 8820
N = gets.chomp.to_i
A = []

max1 = 0
max1_id = 0
max2 = 0

N.times { |i|
    A.push(gets.chomp.to_i)
    v = A[i]
    
    if v > max1
        max1 = v
        max1_id = i
    elsif v <= max1 && v > max2
        max2 = v
    end
}

N.times { |i|
    if i == max1_id
        puts max2
    else
        puts max1
    end
}

Measured memory_bytes: 5116
#include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long K;
    long N;
    long A[200001];

    cin >> K >> N;
    for (int i=0; i<N; i++) cin >> A[i];

    long max_distance = 0;
    for (int i=0; i<(N-1); i++) {
        if ((A[i+1] - A[i]) > max_distance) {
            max_distance = A[i+1] - A[i];
        }
    }
    if ((A[0] + K - A[N-1]) > max_distance) {
            max_distance = A[0] + K - A[N-1];
    }

    long ans = K - max_distance;

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1061109567;
const ll LINF = 4557430888798830399ll;

/* --- */

ll a[100005];

void TestCase() {
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i)
        scanf("%lld", &a[i]);
    ll ans = LINF;
    for(int i = 1; i <= n - k + 1; ++i) {
        int j = i + k - 1;
        if(a[i] <= 0 && a[j] <= 0)
            ans = min(ans, -a[i]);
        else if(a[i] >= 0 && a[j] >= 0)
            ans = min(ans, a[j]);
        else
            ans = min(ans, a[j] - a[i] + min(-a[i], a[j]));
    }
    printf("%lld\n", ans);
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
    //freopen("KisekiPurin.out", "w", stdout);
#endif // KisekiPurin
    //InitCase();
    int t = 1;
    //scanf("%d", &t);
    for(int i = 1; i <= t; ++i) {
        //printf("Case #%d: ", i);
        TestCase();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
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 keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    vi a(n-1);
    int ans = 0;
    
    rep(i, n-1){
        cin >> a[i];
        if(i==0||i==n-1) continue;
        ans += (min (a[i],a[i-1]));
    }
    // if(n==3) ans = a[0];
    
    cout << ans +a[0] + a[n-2] << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=100100;
const ll MAXK=17;
const ll INF=2e18;
const ll MOD=998244353;

ll N,T,a,b,c,d,e,f;
ll A[MAXN];


int main(){
    cin>>a>>b>>c>>d>>N;
    ll t=(c-a)*60+(d-b);
    t=t-N;
    cout<<max(0LL,t);
}   

Measured memory_bytes: 3640
n, m= input().split()
n, m= int(n), int(m)
eq=0
soma=0
cont=0
lista=[]
for x in input().split():
	x= int(x)
	lista.append(x)
	soma+=x

eq= soma/(4*m)
for x in range(n):
	if lista[x] >= eq:
		cont+=1

if cont < m:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
ll findlcm(ll arr[], ll n) 
{ 
    ll ans = arr[0]; 
    for (int i = 1; i < n; i++) 
    ans = (((arr[i] * ans)) / (__gcd(arr[i], ans))); 
    return ans; 
} 
int main()
{
	boost;
	ll n, m, i;
	cin >> n >> m;
	ll arr[n];
	vector <ll> v;
	fo(i, 0, n){
		cin >> arr[i];
		ll x = arr[i];
		ll cnt = 0;
		while(x % 2 == 0){
			x /= 2;
			cnt++;
		}
		v.pb(cnt);
	}
	ll mx = *max_element(all(v));
	ll mn = *min_element(all(v));
	if(mx != mn)
	cout << 0;
	else{
		ll strt = findlcm(arr, n) / 2;
		if(strt <= 0) cout << 0;
		else if(strt > m) cout << 0;
		else cout << 1 + (m - strt) / (2 * strt);
	}
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];

    if (n % 2 == 0) {
        vvll dp(n, vll(2, -1e15));
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        REP(i, n) {
            if (i < 2) continue;
            dp[i][0] = max(dp[i][0], dp[i - 2][0] + a[i]);
            dp[i][1] = max(dp[i][1], dp[i - 2][1] + a[i]);
            if (i - 3 >= 0) {
                dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
            }
        }
        ll res = max(dp[n - 2][0], dp[n - 1][1]);
        cout << res << endl;
        return 0;
    }

    // dp[i][j] : i 文字目まで見て j 回パスしたときの和の最大値
    vvll dp(n, vll(3, -1e15));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    REP(i, n) {
        if (i < 2) continue;
        REP(j, 3) {
            dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
        }
        if (i - 3 >= 0) {
            dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
            dp[i][2] = max(dp[i][2], dp[i - 3][1] + a[i]);
        }
        if (i - 4 >= 0) {
            dp[i][2] = max(dp[i][2], dp[i - 4][0] + a[i]);
        }
    }
    ll res = max(dp[n - 3][0], max(dp[n - 2][1], dp[n - 1][2]));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>

typedef long long int li;
typedef long double ld;


using namespace std;

int main(){
    int a,b,d,r;
    ld f;
    cin >> a >> b;
    d=a/b;
    r=a%b;
    f=(ld)a/(ld)b;
    cout << fixed << setprecision(5) << d << " " << r << " " << f << endl;
    return 0;
}


Measured memory_bytes: 3284
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  // cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<double> p(n); REP(i, n) cin >> p[i];
  vector<vector<double> > dp(n+1, vector<double>(n+1, 0));
  dp[0][0] = 1;
  REP(i, n) REP(j, n+1) {
    if (j == 0) dp[i+1][j] = dp[i][j] * (1 - p[i]);
    else dp[i+1][j] = dp[i][j] * (1 - p[i]) + dp[i][j-1] * p[i];
  }
  double ans = 0;
  FOR(j, n/2+1, n+1) ans += dp[n][j];
  printf("%.10f\n", ans);
  return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    int h,w,m;
    cin>>h>>w>>m;
    set<pinin> s;
    vin hm(h),wm(w);
    rep(i,m){
        pinin hw;
        cin>>hw.first>>hw.second;
        hw.first--; hw.second--;
        s.insert(hw);
        hm[hw.first]++;
        wm[hw.second]++;
    }
    set<int> hma,wma;
    int hmax=0,wmax=0;
    rep(i,h){
        hmax=max(hmax,hm[i]);
    }
    rep(i,w){
        wmax=max(wmax,wm[i]);
    }
    rep(i,h){
        if(hmax==hm[i]) hma.insert(i);
    }
    rep(i,w){
        if(wmax==wm[i]) wma.insert(i);
    }
    int ans=hmax+wmax-1;
    bool fin=false;
    for(int x:hma){
        for(int y:wma){
            pinin xy;
            xy.first=x;
            xy.second=y;
            if(!s.count(xy)){
                ans=hmax+wmax;
                break;
                fin=true;
            }
        }
        if(fin) break;
    }
    cout<<ans<<endl;
  

}


Measured memory_bytes: 47784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 2e5+5;
int N, q[MM], f, r; ll dp[MM],  h[MM], C;
double fun(int j, int k){
    return ((double)(dp[k] + h[k]*h[k] - dp[j] - h[j]*h[j]))/(2.0*(h[k]-h[j]));
}
int main(){
    scanf("%d %lld %lld", &N, &C, &h[1]);
    f = r = 0; q[0] = 1; dp[1] = 0;
    for(int i=2; i<=N; i++){
        scanf("%lld", &h[i]);
        while(f < r && fun(q[f], q[f+1]) <= h[i]) f++;
        dp[i] = dp[q[f]] + (h[i] - h[q[f]])*(h[i] - h[q[f]]) + C;
        while(f < r && fun(q[r-1], q[r]) >= fun(q[r], i)) r--;
        q[++r] = i;
    }
    printf("%lld\n", dp[N]);
}


Measured memory_bytes: 4096
n, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))

ans = 0
for i, ai in enumerate(a):
    left = 0
    right = 0
    for j in range(i):
        if ai > a[j]:
            left += 1
    for j in range(i + 1, n):
        if ai > a[j]:
            right += 1
    ans += (k * (k + 1) * right // 2) + (k * (k - 1) * left // 2)
print(ans % 1000000007)


Measured memory_bytes: 3188
from sys import stdin

s, t = stdin.readline().rstrip().split()
a, b = [int(x) for x in stdin.readline().rstrip().split()]
u = input()

if (u in s):
    print(str(a - 1) + ' ' + str(b))
elif (u in t):
    print(str(a) + ' ' + str(b - 1))
else:
    print(str(a) + ' ' + str(b))


Measured memory_bytes: 3060
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(2)(Array.fill(n)(sc.nextInt()))
  val ans = for(i <- 0 until n) yield {
    a(0).slice(0,i+1).sum + a(1).slice(i,n).sum
  }
  println(ans.max)
}


Measured memory_bytes: 55868
N, M, R = gets.split.map(&:to_i)
r_list = gets.split.map { |a| a.to_i - 1}
INF = 1 << 60
d = Array.new(N) { Array.new(N, INF) }
N.times { |i| d[i][i] = 0 }
M.times do
  u, v, c = gets.split.map(&:to_i)
  u -= 1
  v -= 1
  d[u][v] = c
  d[v][u] = c
end

def warshal_floyd(d)
  v = d.size
  v.times do |k|
    v.times do |i|
      v.times do |j|
        cost = d[i][j]
        new_cost = d[i][k] + d[k][j]
        d[i][j] = new_cost if new_cost < cost 
      end
    end
  end
end

warshal_floyd(d)
ans = 1 << 60
r_list.permutation.each do |l|
  ret = 0
  u = l[0]
  l.each do |v|
    ret += d[u][v]
    u = v
  end
  ans = ret if ret < ans
end
puts ans

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int i;
  
  cin >> N;
  
  if(N<=111)
    cout << 111;
  else if(N<=222)
    cout << 222;
  else if(N<=333)
    cout << 333;
  else if(N<=444)
    cout << 444;
  else if(N<=555)
    cout << 555;
  else if(N<=666)
    cout << 666;
  else if(N<=777)
    cout << 777;
  else if(N<=888)
    cout << 888;
  else if(N<=999)
    cout << 999;
  else
    cout << 1111;
  
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);

  multiset<ll,greater<ll>> ms;
  
  rep(i,n){
    cin>>a[i];
    //ms.insert(a[i]);
    b[i]=a[i];
  }
  sort(begin(b),end(b));

  

  for(auto x:a){

    if(b[n-1]==x) cout << b[n-2] << endl;
    else cout << b[n-1] << endl;

    /*
    auto itr=lower_bound( begin(ms),end(ms),x );
    ms.erase(itr);
    auto las=begin(ms);
    //las--;
    cout << *las << endl;

    ms.insert(x);
    */
  }


  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 4736
from enum import Enum


class Sssp(object):
    """ single source shortest path """
    INFINITY = 999999999
    class Status(Enum):
        """ ?????????????¨??????¶??? """
        white = 1  # ????¨????
        gray = 2  # ?¨???????
        black = 3  #?¨???????

    def __init__(self, data):
        num_of_nodes = len(data)
        self.color = [Sssp.Status.white] * num_of_nodes  # ????????????????¨??????¶???
        self.M = [[Sssp.INFINITY] * num_of_nodes for _ in range(num_of_nodes)]
        self._make_matrix(data)  # data????????????????????£??\??????(?????\?¶???¨???????????????????????§????????????)
        self.d = [Sssp.INFINITY] * num_of_nodes
        self.p = [-1] * num_of_nodes  # ????????????????????????????¨??????????

    def _make_matrix(self, data):
        for d in data:
            my_id = d[0]
            d = d[2:]
            while len(d) > 1:
                to_node, cost = d[0], d[1]
                self.M[my_id][to_node] = cost
                d = d[2:]

    def dijkstra(self, start):
        self.d[start] = 0
        self.p[start] = -1

        while True:
            mincost = Sssp.INFINITY
            for i in range(len(self.d)):
                if self.color[i] != Sssp.Status.black and self.d[i] < mincost:
                    mincost = self.d[i]
                    u = i

            if mincost == Sssp.INFINITY:
                break

            self.color[u] = Sssp.Status.black

            for v in range(len(self.d)):
                if self.color[v] != Sssp.Status.black and self.M[u][v] != Sssp.INFINITY:
                    if self.d[u] + self.M[u][v] < self.d[v]:
                        self.d[v] = self.d[u] + self.M[u][v]
                        self.p[v] = u
                        self.color[v] = Sssp.Status.gray


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for i in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????¢?´¢
    s = Sssp(data)
    s.dijkstra(0)

    # ???????????¨???
    for i in range(num):
        print('{0} {1}'.format(i, s.d[i]))

Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int > > v1,v2;
int n;
long long a[109],b[109];
long long min1=100000000000,max1=-100000000000;
int idx1,idx2;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    for(int i=1; i<=n; i++)
    {
        if(max1<a[i])
        {
            max1=a[i];
            idx1=i;
        }
        if(min1>a[i])
        {
            min1=a[i];
            idx2=i;
        }
    }
    a[0]=b[0]=-1000000000;
    a[n+1]=b[n+1]=1000000000;
    int is1=0,is2=0;
    if(max1>0)
    {
        is1=1;
        for(int i=1; i<=n; i++)
        {
            if(b[i]>=b[i-1])continue;
            while(b[i]<b[i-1])
            {
                b[i]+=max1;
                v1.push_back(make_pair(idx1,i));
                if(v1.size()>2*n){is1=0;goto ss;}
                if(max1<b[i])
                {
                    max1=b[i];
                    idx1=i;
                }
             }
        }
    }
    ss:;
    if(min1<0)
    {
        is2=1;
        for(int i=n; i>0; i--)
        {
            if(a[i]<=a[i+1])continue;
            while(a[i]>a[i+1])
            {
                a[i]+=min1;
                v2.push_back(make_pair(idx2,i));
                if(v2.size()>=2*n){is2=0;goto nn;}
                if(min1>a[i])
                {
                    min1=a[i];
                    idx2=i;
                }
            }
        }
    }
    nn:;
    if(is1&&v1.size()<=2*n)
    {
        cout<<v1.size()<<endl;
        for(int i=0; i<v1.size(); i++)
            cout<<v1[i].first<<" "<<v1[i].second<<endl;
        return 0;
    }
    else
    {
        cout<<v2.size()<<endl;
        for(int i=0; i<v2.size(); i++)
            cout<<v2[i].first<<" "<<v2[i].second<<endl;
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 998244353;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

    int n, q; cin >> n >> q;
    string s; cin >> s;
    s = '0' + s;
    vector<int> l(q), r(q);
    for(int i=0; i<q; ++i) cin >> l[i] >> r[i];

    vector<int> cum(n+5, 0);
    for(int i=1; i<=n; ++i){
        if(s[i] == 'C' && s[i-1] == 'A') cum[i] = cum[i-1]+1;
        else cum[i] = cum[i-1];
    }

    for(int i=0; i<q; ++i){
        int left=l[i], right=r[i];
        if(s[left] == 'C' && s[left-1] == 'A') cout << cum[right]-cum[left-1]-1 << endl;
        else cout << cum[right]-cum[left-1] << endl;
    }

    

    return 0;
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;

int dp[100010][3], a, v[100010][3], n;

int recur(int pos, int pst) {
	if(pos == n)
		return 0;

	if(pst != -1 and dp[pos][pst] != -1)
		return dp[pos][pst];

	int ret = 0;
	for(int i = 0; i < 3; ++i)
		if(i != pst)
			ret = max(ret, recur(pos+1, i) + v[pos][i]);

	return dp[pos][pst] = ret;
}

int main() {
	cin >> n;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < 3; ++j)
			cin >> v[i][j];

	memset(dp, -1, sizeof dp);
	cout << recur(0, -1) << endl;
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define pii pair<int,int>
#define sz(x) (int) x.size()
#define f first
#define s second
using namespace std;
const int N=1e2+2;
const int M=1e8;
ll dp[N][N][12][12];
int n1,n2,k1,k2;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x,y;
    cin>>x>>y;
    bool ok=0;
    for(int i=0;i<=min(x,y/2);i++){
        ll f=y-i*2;
        if(f%4==0 && f/4==x-i){
            ok=1;
        }
    }
    cout<<(ok ? "Yes" : "No");
    return 0;
}
// abcd


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

void Main() {
    // input
    u_int64_t K;
    cin >> K;

    u_int64_t num = 0;

    for (u_int64_t size = 1; size <= K; size++) {
        num = (num * 10 + 7) % K;
        if (num == 0) {
            cout << size << endl;
            return;
        }
    }
    int64_t size = -1;
    cout << size << endl;

    // process


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n = 0, a = 0;
  int x = 0;
  cin >> n >> a;
  x = n % 500;
  if(a >= x){
    cout << "Yes" << endl;
  }else{
    cout << "No"  << endl;
  }
}
  

Measured memory_bytes: 256
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 5e5+5;

int32_t main(){
   
   speed_cubing

   int n;
   cin>>n;

   um<int,int> m;

   for(int i=1;i<=300;i++){
      for(int j=1;j<=300;j++){
         for(int k=1;k<=300;k++){
            m[i*i+j*j+k*k+i*j+j*k+k*i]++;
         }
      }
   }

   for(int i=1;i<=n;i++)
      cout<<m[i]<<endl;
    
   return 0;
}

Measured memory_bytes: 19636
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
A  = nl()

BUKA = [0]* N
for a in A:
    BUKA[a-1] += 1

for i in BUKA:
    print(i)



Measured memory_bytes: 32096
#include<iostream>
#include <cstdio>
using namespace std;
 
const int n_MAX = 100,x_MAX = 300;
int n[n_MAX], x[x_MAX];
 
int input(){
    int i = 0;
 
    for (;; i++){
        cin >> n[i] >> x[i];
        if (n[i] == 0 && x[i] == 0)break;
    }
 
    return i;
}
 
int combination(int n, int x){
    int count = 0;
    for (int i1 = 0; i1 < n - 2; i1++){
        for (int i2 = i1 + 1; i2 < n - 1; i2++){
            for (int i3 = i2 + 1; i3 < n; i3++){
                if (i1 + i2 + i3 + 3 == x)count++;
            }
        }
    }
    return count;
}
 
int main(){
    int i=
        input();
 
    for (int j = 0; j < i; j++){
        cout << combination(n[j], x[j]) << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3080
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

LL f[2055][2055] = {0};
LL n,m;

void solve(LL x,LL y,LL d){
	if(d == 0){
		f[x][y] = 1;
		return;
	}
	solve(x,y,d - 1);
	solve(x + (1LL << d),y,d - 1);
	solve(x,y + (1LL << d),d - 1);
	solve(x + (1LL << d),y + (1LL << d),d - 1);
	f[x + (1LL << d) - 1][y + (1LL << d) - 1] = 1;
}

int main(){
	cin >> n >> m;
	solve(1,1,10);
	for(LL i = 1;i < (1LL << n);i ++){
		for(LL j = 1;j < (1LL << m);j ++){
			cout << f[i][j];
		}
		cout << endl;
	}
	return 0;
}
//

Measured memory_bytes: 34176
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    h = get_int()
    print((1<<h.bit_length()) - 1)




''' Pythonista fLite 1.1 '''
import sys
#from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 38384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	ll N;
	cin>>N;
	VI ans(N);
	int j=11;
	for(int i=0;i<N;i++){
		bool f=true;
		while(f){
			for(int k=2;k<j;k++){
				f=false;
				if(j%k==0){
					j+=5;
					f=true;
					break;
				}
			}
		}
		ans[i]=j;
		j+=5;
	}
	
	REP(i,N)cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i,N) for(ll i=0;i<N;++i)

int main() {
	string S;
	ll w;
	cin >> S >> w;
	vector<char> res;
	REP(i,S.size()) {
		if ((i % w) == 0) res.push_back(S[i]); 
	}
	REP(i,res.size()) {
		cout << res[i];
	}
	/*
	string s_res(res.data());
	cout << s_res << endl;
	*/
	return 0;
}



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

int main(){
  int A,i;
  bool chk[4]={0};
  
  for(i=0;i<4;i++){
  	cin>>A;
    if(A==1)chk[0]=1;
    if(A==9)chk[1]=1;
    if(A==7)chk[2]=1;
    if(A==4)chk[3]=1;
  }
  if(chk[0]+chk[1]+chk[2]+chk[3]==4)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll l, r;
  cin >> l >> r;
  
  if(r-l+1>=2019) {
    pt(0);
  }else {
    ll ans=2019;
    ll i, j;
    for(i=l; i<r; i++) {
      for(j=i+1; j<=r; j++) {
        chmin(ans, i*j%2019);
      }
    }
    
    pt(ans);
  }
  
  
  
  
}









Measured memory_bytes: 256
#include <cstdio>

int main(){
	int a,b,c,d,e,f,ans1,ans2;
	double ans=-1;
	int ii,jj,kk,ll;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	for(int i=0;100*i*a<=f;++i){
		for(int j=0;100*j*a<=f;++j){
			for(int k=0;k*c<=f;++k){
				for(int l=0;l*d<=f;++l){
					if(100*a*i+100*b*j+k*c+d*l<=f && (double)(k*c+d*l)/(100*a*i+100*b*j)<=(double)e/100){
						if(ans<(double)(k*c+d*l)/(100*a*i+100*b*j+k*c+d*l)){
							ans=(double)(k*c+d*l)/(100*a*i+100*b*j+k*c+d*l);
							ans1=100*a*i+100*b*j+k*c+d*l;
							ans2=k*c+d*l;
							kk=k,ll=l;
							ii=i,jj=j;
						}
					}
				}
			}
		}
	}
	printf("%d %d\n",ans1,ans2);
//	printf("%d %d %d %d",ii,jj,kk,ll);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
struct act{
	int first;
	int second;
	int third;
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n;
	vector <act> v;
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		act r;
		r.first=a;
		r.second=b;
		r.third=c;
		v.push_back(r);
	}
	int dp[n][3];
	for(int i=0;i<n;i++){
		dp[i][0]=0;
		dp[i][1]=0;
		dp[i][2]=0;
	}
	dp[0][0]=v[0].first;
	dp[0][1]=v[0].second;
	dp[0][2]=v[0].third;
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i].first;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i].second;
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+v[i].third;
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
} 

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

using namespace std;

void usain_bolt()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int N = 3e3 + 5;

int dp[N][N];
char s[N], t[N];

int main()
{
    usain_bolt();

    cin >> (s + 1) >> (t + 1);
    int szs = strlen(s + 1), szt = strlen(t + 1);

    for(int i = 1; i <= szs; ++i) {
        for(int j = 1; j <= szt; ++j) {
            if(s[i] == t[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans = "";
    int i = szs, j = szt;
    while(i >= 1 && j >= 1) {
        if(s[i] == t[j]) ans = ans + s[i], --i, --j;
        else if(dp[i][j - 1] >= dp[i - 1][j]) --j;
        else --i;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){

string s;
cin>>s;
rep(i,s.size()){
    if(s[i]==','){
        s[i]=' ';
    }
}
cout<<s;
 return 0;
}
/*
happy,newyear,enjoy

happy newyear enjoy


haiku,atcoder,tasks

haiku atcoder tasks



abcde,fghihgf,edcba

abcde fghihgf edcba
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	string s;
	
	cin>>s;
	if(s=="Sunny")cout<<"Cloudy";
	else if(s=="Cloudy")cout<<"Rainy";
	else cout<<"Sunny";
	
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	long long a=0,v=0,b=0,w=0,t=0;scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	puts(abs(a-b)<=(v-w)*t?"YES":"NO");
}

Measured memory_bytes: 1660
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextToken().toCharArray();
        }
        long cnt = 0;
        out:for (int x = 0; x < n; x++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    int c = (j + x) % n;
                    if(a[i][j] != a[(j + x) % n][(i - x + n) % n]) continue out;
                }
            }
            cnt += n;
        }
        System.out.println(cnt);
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 29760
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n;
	int ans=0;
	
	cin>>n;
	if(n/10==9 || n%10==9)
	{
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll ans=100000000000;
    for(ll i=0;i<n;i++)
    {
        if(i==0)
        {
            ll r=k-(a[1]-a[0]);
            ll r1=a[n-1]-a[0];
            ll z=min(r1,r);
            ans=min(ans,z);
        }
        else if(i==n-1)
        {
            ll r=k-(a[n-1]-a[n-2]);
            ll r1=a[n-1]-a[0];
            ll z=min(r1,r);
            ans=min(ans,z);
        }
        else
        {
            ll r=k-a[i]+a[i-1];
            ll r1=k-a[i+1]+a[i];
            ll z=min(r1,r);
            ans=min(ans,z);
        }
        
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
///*二進数割り算*/div2(ll x,ll y){}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 char s[5];
 sc(s);
 if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])pn;
 else if((s[0]==s[1]&&s[2]==s[3])||(s[0]==s[2]&&s[1]==s[3])||(s[0]==s[3]&&s[1]==s[2]))py;
 else pn;
 return 0;
return 0;}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var N string
	fmt.Scan(&N)
	if (N[0] == N[1] && N[0] == N[2]) || (N[1] == N[2] && N[1] == N[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const int mod = 1e9+7;

void bfs(vvi &v,int h,int w)
{
    queue<pii>q;
    q.push(mp(1,1));
    while(!q.empty())
    {
        pii trenutni=q.front();
        q.pop();

        int x[2]={0,1};
        int y[2]={1,0};

        for(int i=0;i<2;i++)
        {
            //v[i][j] i oznacava y osu, j x osu
            if(trenutni.fi+y[i]<=h && trenutni.se+x[i]<=w)
            {
                //cout<<v[trenutni.fi+x[i]][trenutni.se+y[i]]<<'\n';
                if(v[trenutni.fi+y[i]][trenutni.se+x[i]]==INT_MAX)
                {
                    pii zaDodavanje = mp(trenutni.fi+y[i],trenutni.se+x[i]);
                    q.push(zaDodavanje);
                    int suma1=0,suma2=0;
                    if(v[zaDodavanje.fi-1][zaDodavanje.se]!=-1 && v[zaDodavanje.fi-1][zaDodavanje.se]!=INT_MAX)suma1=v[zaDodavanje.fi-1][zaDodavanje.se];
                    if(v[zaDodavanje.fi][zaDodavanje.se-1]!=-1 && v[zaDodavanje.fi][zaDodavanje.se-1]!=INT_MAX)suma2=v[zaDodavanje.fi][zaDodavanje.se-1];
                    v[zaDodavanje.fi][zaDodavanje.se]=(suma1%mod+suma2%mod)%mod;
                }
            }
        }
    }
}

int main()
{
    int h, w;
    cin >>h>>w;
    vvi v(h+1, vi(w+1, INT_MAX));
    for(int i=0;i<=h;i++)v[i][0]=0;
    for(int i=0;i<=w;i++)v[0][i]=0;

    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            char c;
            cin >> c;
            if(c=='#')
            {
                v[i][j]=-1;
            }
        }
    }

    //cout<<v[1][4]<<'\n';

//    for(int i=0;i<=h;i++)
//    {
//        for(int j=0;j<=w;j++)
//        {
//            cout<<v[i][j]<<' ';
//        }
//        cout<<'\n';
//    }

    //-1 je za crno polje, a INT_MAX za neposeceno

    v[1][1]=1;
    bfs(v,h,w);
    int resenje=v[h][w];
    if(resenje==INT_MAX)resenje=0;
    cout<<resenje%mod<<'\n';

    return 0;
}


Measured memory_bytes: 4224
//#include<bits/stdc++.h>
#include <sstream>
#include <stdio.h>
#include <map>
#include <vector>
#define rep(x,y) for(int x = 0; x < (y); x++)
#define REP(x,z,y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(),x.end()
#define length(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str,sp_word) istringstream stream(str); string res; while(getline(stream,res,sp_word))
#define rm_space(x) x.erase(remove(all(x),' '),x.end())

using namespace std;

int N,M;
map<int,vector<int>> ab; 

void dsp(int now, int cnt){
  if(cnt > 2) return;

  for(auto i:ab[now]){
    if(i == N){
      printf("POSSIBLE\n");
      exit(0);
    }
    dsp(i,cnt + 1);
  }
};

int main(){
  scanf("%d%d",&N,&M);
  rep(i,M){
    int tmp,tmp2;
    scanf("%d%d",&tmp,&tmp2);
    ab[tmp].push_back(tmp2);
  }

  dsp(1,1);
  printf("IMPOSSIBLE\n");
  return 0;
}

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

MOD=10**9+7
sumA=0
for i in range(N):
    sumA=(sumA+A[i])%MOD

ans=0
for i in range(N-1):
    sumA=(sumA-A[i])%MOD
    ans=(ans+(A[i]*sumA)%MOD)%MOD

print(ans)

Measured memory_bytes: 31612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int  a;
    cin>>a;
    int max=0;
    for(int i=0;i<=a;i++){
        int b=0,j=i;
        while(j){
        if(j%2==0) b++;
        j=j/2;
        }
        if(max<b) max=b;
    }
    cout<<pow(2,max)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
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;};

int V, E;
vector<vector<int>> dist(1001, vector<int>(1001, MOD));
vector<vector<int>> dp((1<<16), vector<int>(16, MOD));

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	cin >> V >> E;
	rep(i, E) {
		int s, t, d;
		cin >> s >> t >> d;
		dist[s][t] = d;
	}

	dp[0][0] = 0;
	for(int S = 0; S < (1 << V); S++) {
		rep(prev, V) {
			rep(now, V) {
				if((S & (1 << now)) == 0) {
					chmin(dp[S|(1<<now)][now], dp[S][prev] + dist[prev][now]);
				}
			}
		}
	}
	int ans = dp[(1<<V)-1][0];
	if(ans == MOD) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21516
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;
int flipped[200000];
int flipped_cumsum[200000];
int P[200000];
bool sorted[200000];
int main(){
  int N;
  int K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }
  for(int i = 0; i < N - 1; i++){
    if(P[i] > P[i + 1]){
      flipped[i] = 1;
    }
  }
  flipped_cumsum[0] = flipped[0];
  for(int i = 1; i < N - 1; i++){
    flipped_cumsum[i] = flipped[i] + flipped_cumsum[i - 1];
  }

  for(int i = K - 1; i < N; i++){
    int flipped_no;
    if(i == K - 1){
      flipped_no = flipped_cumsum[i - 1];
    } else {
      flipped_no = flipped_cumsum[i - 1] - flipped_cumsum[i - K];
    }
    if(flipped_no == 0){
      sorted[i - (K - 1)] = true;
    }
  }

  int ans = 0;
  set <int> occurence;
  bool counted_org = false;
  for(int i = 0; i < K; i++){
    occurence.insert(P[i]);
  }
  ans ++;
  if(sorted[0]){
    counted_org = true;
  }

  for(int i = K; i < N; i++){
    occurence.erase(P[i - K]);

    if(sorted[i - K + 1]){
      if(!counted_org){
        ans ++;
        counted_org = true;
      }
    } else {
      if(P[i - K] > *(occurence.begin()) || P[i] < *(occurence.rbegin())){
        ans++;
      }
    }
    occurence.insert(P[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11904
/**
 *   created: 25 January 2019  00:27:23
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007

void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector<int> dp(100000,-1),v(100000);
int n;
int frog(int cs)
{
	if(cs<=0)
		return 0;
	if(cs==1)
		return abs(v[cs]-v[0]);
	if(dp[cs]!=-1)
		return dp[cs];
	return dp[cs]=min((abs(v[cs]-v[cs-1])+frog(cs-1)), (abs(v[cs]-v[cs-2])+frog(cs-2)));

}
int main()
{
	optimizeIO();
	cin>>n;
	// v.resize(n);
	// dp.resize(n);
	F(i,0,n-1)
		cin>>v[i];
	cout<<frog(n-1);
	return 0;
}


Measured memory_bytes: 3328