akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,cnt[4];string s;
int main(){
	for(scanf("%d",&n);n--;){
		cin>>s;
		if(s=="AC")++cnt[0];
		else if(s=="WA")++cnt[1];
		else if(s=="TLE")++cnt[2];
		else ++cnt[3];
	}
	printf("AC x %d\n",cnt[0]);
	printf("WA x %d\n",cnt[1]);
	printf("TLE x %d\n",cnt[2]);
	printf("RE x %d\n",cnt[3]);
	return 0;
}

Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

vector<int> ps;

void primeTable(int n){
    vector<int> table(n+1, 0);
    for(int i=2; i<=n; i++){
        if(!table[i]){
            ps.push_back(i);
        if(i <= sqrt(n)) table[i*i] = i;
        }
        else{
        int j = i, step = table[i];
            while(j+step<=n){
                if(!table[j+step]) {
                    table[j+step] = step;
                    break;
                }
                else {
                    int tmp = step;
                    step = table[j+step];
                    table[j+tmp] = tmp;
                    j += tmp;
                }
            }
        }
    }
}

#define N 1120

int main(){
    ps.PB(-1);
    primeTable(N);
    static int dp[N+2][190][16];
    int i, j, k, l, n, ans, s = SZ(ps);
    REP(i,N+2)REP(j,190)REP(k,16) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    REP(i,N){
        REP(j,s+1)REP(k,15)if(dp[i][j][k]){
            for(l=j+1; l<s && i + ps[l] <= N; l++){
                dp[i+ps[l]][l][k+1] += dp[i][j][k];
            }
        }
    }

    while(scanf("%d%d",&n,&k)){
        if(!(n||k)) break;
        ans = 0;
        REP(j,190) ans += dp[n][j][k];
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 13000
import java.io.*;
import  java.util.*;

import static java.lang.System.in;

class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        LinkedList<Integer> cur = new LinkedList<>(),next = new LinkedList<>();
        for(int i=0;i<(1<<N);i++) cur.add(sc.nextInt());
        while(cur.size()>1){
            int p = cur.poll(), q = cur.poll();
            if(p==q) next.add(p);
            else next.add(Math.abs(p-q));
            if(cur.size()==0){
                cur=next;
                next = new LinkedList<>();
            }
        }
        int ans = cur.poll();
        System.out.println(ans);
    }
}


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

int main(){

  string s;
  cin>>s;
  
  if(s=="Sunny")cout<<"Cloudy";
  else if(s=="Cloudy")cout<<"Rainy";
  else cout<<"Sunny";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

class Combination_Mod{
    public:
        Combination_Mod(long long MAX, long long MOD) : fact(MAX + 1), inv(MAX + 1), finv(MAX + 1), MAX(MAX + 1), MOD(MOD){
            init();
        }

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

        long long bin(long long n, long long r){
            if(n < r || n < 0 || r < 0) return 0;
            return fact[n] * (finv[r] * finv[n - r] % MOD) % MOD;
        }

        long long perm(long long n, long long r){
            return (bin(n, r) * fact[r]) % MOD;
        }

        long long factorial(long long n){
            return fact[n];
        }

        long long modinv(long long n){
            return inv[n];
        }

        long long modfinv(long long n){
            return finv[n];
        }

    private:
        vector<long long> fact;
        vector<long long> inv;
        vector<long long> finv;
        const long long MAX;
        const long long MOD;
};

long long modpow(long long x, long long n, long long MOD){
    long long ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret * x) % MOD;
        x = (x * x) % MOD;
        n = (n >> 1);
    }
    return ret;
}

ll K;
string S;
Combination_Mod cm(2000010, MOD);

signed main(){
    cin >> K >> S;
    ll ans = 0, N = S.length();
    FOR(i, N - 1, N + K){
        ans = (ans + cm.bin(i, N - 1) * modpow(25, i - N + 1, MOD) % MOD * modpow(26, N + K - 1 - i, MOD) % MOD) % MOD;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 52184
<?php
 	fscanf(STDIN, '%s', $a);
	fscanf(STDIN, '%s', $b);
 
	$arr1 = str_split($a);
	$arr2 = str_split($b);
 
	$r = 0;
	for ($i = 0; $i < count($arr1); $i++) {
    	if ($arr1[$i] == $arr2[$i]) {
        	$r++;
        }
    }
 
	echo $r;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;

//Juan Pablo Betancourt Maldonado

int n;
const int nx = 1e5+5;
int ac[nx][3];
int dp[3][nx];
int go(int a, int i){
	if(i == n) return 0;
	if(dp[a][i] != -1) return dp[a][i];
	int& ans = dp[a][i];
	
	if(a==0){
		ans=max(ans, go(1, i+1)+ac[i][0]);
		ans=max(ans, go(2, i+1)+ac[i][0]);
	}
	if(a==1){
		ans=max(ans, go(0, i+1)+ac[i][1]);
		ans=max(ans, go(2, i+1)+ac[i][1]);
	}
	if(a==2){
		ans=max(ans, go(0, i+1)+ac[i][2]);
		ans=max(ans, go(1, i+1)+ac[i][2]);
	}
	
	return ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
	memset(dp, -1, sizeof dp);
	cout<<max(go(0,0),max(go(1,0),go(2,0)))<<"\n";
	return 0;
}

Measured memory_bytes: 7296
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! debug {
    ( $x:ident [ $i:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}] = {:?}", stringify!($x), $i, $x[$i]);
        }
    };
    ( $x:ident [ $i:expr ][ $j:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}][{}] = {:?}", stringify!($x), $i, $j, $x[$i][$j]);
        }
    };
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    };
}

fn main() {
    use std::io::Write;

    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut stdin = my::io::InputReader::new(stdin.lock());
    let mut stdout = std::io::BufWriter::new(stdout.lock());

    let N: usize = stdin.read();
    let mut n_children = vec![0usize; N];
    for _ in 0..N - 1 {
        let A = stdin.read::<usize>() - 1;
        n_children[A] += 1;
    }
    for i in 0..N {
        writeln!(stdout, "{}", n_children[i]).unwrap();
    }
    stdout.flush().unwrap();
}

#[allow(unused_must_use)]
mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}


Measured memory_bytes: 3576
#include <stdio.h>

typedef struct{
    int label[6];
}dice;

void roll_south( int* );
void roll_north( int* );
void roll_east( int* );
void roll_west( int* );

int main(){
	char direct[101] = {'\0'};
	int times = 0;
	int front = 0;
	int top = 0;
	int roll_cnt = 0;
    int i;
    dice dice1;
    
    for( i = 0; i < 6; i++ ){
        scanf( "%d", &dice1.label[i] );
    }
    
    scanf( "%d", &times );
    
    for( i = 0; i < times; i++){
        scanf( "%d%d", &top, &front );
        
		roll_cnt = 0;
        while( dice1.label[1] != front ){
            if( roll_cnt >= 4 ){
                roll_east( dice1.label );
				roll_cnt = 0;
            }
            
            roll_north( dice1.label );
            
            roll_cnt++;
        }
        
        while( dice1.label[0] != top ){
            roll_east( dice1.label );
        }
        
        printf( "%d\n", dice1.label[2] );
        
    }
    
    return 0;
}

void roll_south( int* label )
{
    int work;
    
    work = label[0];
    label[0] = label[4];
    label[4] = label[5];
    label[5] = label[1];
    label[1] = work;
}
void roll_north( int* label )
{
    int work;
    
    work = label[0];
    label[0] = label[1];
    label[1] = label[5];
    label[5] = label[4];
    label[4] = work;
}
void roll_east( int* label )
{
    int work;
    
    work = label[0];
    label[0] = label[3];
    label[3] = label[5];
    label[5] = label[2];
    label[2] = work;
}
void roll_west( int* label )
{
    int work;
    
    work = label[0];
    label[0] = label[2];
    label[2] = label[5];
    label[5] = label[3];
    label[3] = work;
}


Measured memory_bytes: 2112
/*A - Tenki*/

#include <bits/stdc++.h>
using namespace std;

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

	int ans = 0;
	string pron;
	string cad;

	cin >> cad >> pron;

	for (int i = 0; i < 3; ++i)
	{
		if(cad[i] == pron[i]){
			ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.algorithm;
import std.array, std.conv, std.c.string;
 
long[1001][10] dp;

void init_dp(int comb, int limit) {  
  dp[0][0] = 1;
  for(long i = 0; i <= 100; i++)
    for(long j = limit; j >= 0; j--)
      for(long k = comb; k >= 1; k--)
        if (j - i >= 0) {
          dp[k][j] += dp[k - 1][j - i];
        }
}
 
void main() {
  init_dp(9, 1000);
  while(true) {
    int n, m;
    readf("%d %d\n", &n, &m);
    if ((n + m) == 0) break;
    dp[n][m].writeln;
  }
}

Measured memory_bytes: 1148
#include<stdio.h>
int main(void)
{
  int i,j,k,l,m=0,n;
  
  while(scanf("%d",&n)!=EOF)
    {
      m=0;
      for(i=0;i<10;i++)
	{
	  for(j=0;j<10;j++)
	    {
	      for(k=0;k<10;k++)
		{
		  for(l=0;l<10;l++)
		    {
		      if(i+j+k+l==n)m++;
		    }
		}
	    }
	}
      printf("%d\n",m);
    }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>
#include <unistd.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[300005],y[300005],z[100005];
ll table[500005];
char s[300005],t[300005];

int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	for(i=0;i<n*2;i++){
		table[i] = 2e10;
	}
	for(i=0;i<n;i++){
		num = x[i] * -1 + 1e10;
		ll a = lb(table,table+n,num+1) - table;
		table[a] = num;
		for(j=0;j<10;j++){
			//pe(table[j]);
		}
		//el;
	}
	//el;
	for(i=0;i<2*n;i++){
		if(table[i] != 2e10){
			ans++;
		}else{
			break;
		}
	}
	p(ans);
	return 0;
}



Measured memory_bytes: 19328
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)2e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int par[N];

void solve() {
    int n;
    cin>>n;
    f(i, n - 1) {
        int u;
        cin>>u;
        u--;
        par[u]++;
    }
    f(i, n) cout<<par[i]<<"\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <iomanip>
#include <cmath>
#define NMAX 6
using namespace std;
void mk3(double *L, double *R, int remain) {
    cout << fixed << setprecision(5);
    /*cout << "\t~~~~~~~~~~~~~~~~~~~~" << endl;
    cout << "\tremain: " << remain << endl;*/
    if (remain >= 1) {
        double L2[2] = {(L[0]*2+R[0])/3, (L[1]*2+R[1])/3};
        double R2[2] = {(L[0]+R[0]*2)/3, (L[1]+R[1]*2)/3};
        double C[2];
        double xl = L2[0];
        double yl = L2[1];
        double xr = R2[0];
        double yr = R2[1];
        C[0] = (xr+xl)/2 - sqrt(3) * (yr-yl)/2;
        C[1] = sqrt(3) * (xr-xl)/2 + (yr+yl)/2;
        // test v
        /*cout << "\tl : " << L[0] << " | " << L[1] << endl;
        cout << "\tl2: " << L2[0] << " | " << L2[1] << endl;
        cout << "\tc : " << C[0] << " | " << C[1] << endl;
        cout << "\tr2: " << R2[0] << " | " << R2[1] << endl;
        cout << "\tr : " << R[0] << " | " << R[1] << endl;*/
        // test ^
        mk3(L, L2, remain-1);
        mk3(L2, C, remain-1);
        mk3(C, R2, remain-1);
        mk3(R2, R, remain-1);
    } else cout << L[0] << ' ' << L[1] << endl;
}
void solve(int n) {
    double P[NMAX * 2];
    double L[2] = {0, 0};
    double R[2] = {100, 0};
    mk3(L, R, n);
    cout << R[0] << ' ' << R[1] << endl;
}
int main() {
    int n;
    cin >> n;
    solve(n);
}


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

int main() {
  int N,M;
  cin >> N>>M;
  vector<bool> a(N); // 島１から行ける便
  vector<bool> b(N); // 島Nに行ける便
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x>> y;
    if(x==1) a[y] =1;
    if(y==N) b[x] =1;
  }

  for(int i=0;i<N;i++){
    if(a[i]==1 && b[i]==1){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
 cout << "IMPOSSIBLE" << endl;
}


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

int main()
{
  string S;
  int ans = 700;

  cin >> S;

  for (int i = 0; i < 3; i++) {
    if (S[i] == 'o') {
      ans += 100;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

int main(int argc, const char *argv[])
{
  int n;
  cin >> n;
  vector<int> ws(n);
  for (int i = 0; i < n; i++) {
    cin >> ws[i];
  }

  int ans = 99999999;
  for (int i = 1; i < n; i++) {
    int s1 = 0, s2 = 0;
    for (int j = 0; j < ws.size(); j++) {
      if (j <= i) {
        s1 += ws[j];
      } else {
        s2 += ws[j];
      }
    }

    ans = min(ans, abs(s1 - s2));
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
<?php
  $x = (int)trim(fgets(STDIN));
  $as = explode(" ",fgets(STDIN));
  $sum = 0;
  $min=$max=(int)$as[0];
  foreach($as as $a) {
    $a = (int)$a;
    $sum +=$a;
    if($min > $a) $min = $a;
    if($max < $a) $max = $a;
  }
  printf("%d %d %d\n", $min,$max,$sum);


Measured memory_bytes: 10984
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

long long gcd(long long a, long long b){
    if(!b) return a;
    return gcd(b, a % b);
}


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

    sort(a.begin(), a.end());
    long long nw = gcd(a[0], a[1]), mx = a[0];
    for(int i = 2; i < n; ++i){
        mx = max(gcd(mx, a[i]), nw);
        nw = gcd(nw, a[i]);
    }
    nw = gcd(a[0], a[1]);
    long long mx1 = a[1];
    for(int i = 2; i < n; ++i){
        mx1 = max(gcd(mx1, a[i]), nw);
        nw = gcd(nw, a[i]);
    }
    cout << max(mx, mx1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       int n,m;
       cin>>n>>m;
       if(m<n)
        cout<<"No";
       else
        cout<<"Yes";
    }
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(string S){
  REP(S.size()-1){
    if(S[i]==S[i+1]){
      cout<<"Bad"<<endl;
      return ;
    }
  }
  cout<<"Good"<<endl;
}

int main(){
    string S;
    cin>>S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int B=0;
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i; i<N ;i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for(int j; j<K ;j++)
  {
    B = B+A.at(j);
  }
  cout << B << endl;
}

Measured memory_bytes: 3620
from itertools import accumulate
n,k=map(int, input().split()) 
A=list(map(int, input().split()))
S=[0]+list(accumulate(A))
R=[(S[i]-i)%k for i in range(n+1)]

r_dict={}
ans=0
for i in range(n+1):
    if R[i] in r_dict:
        ans+=r_dict[R[i]]
        r_dict[R[i]]+=1
    else:
        r_dict[R[i]]=1
    if i-k+1>=0:
        r_dict[R[i-k+1]]-=1
    
print(ans)

Measured memory_bytes: 115556
#include <cstdio>
#include <iostream>

char s[110];
int main()
{
	int n; scanf("%d", &n);
	scanf("%s", s);
	int c = 0;
	for(int i = 0; i < n; i++)
	{
		if(s[i] == 'R') c++;
		else c--;
	}
	if(c > 0) puts("Yes");
	else puts("No");
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

#define MAX_N 100010

int N;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    N=s.length();
    ll gcnt = 0;
    ll pcnt = 0;
    ll point = 0;
    REP(i,N) {
        if (i%2==0 && s[i]=='p') {
            point--;
        }
        if (i%2==1 && s[i]=='g') {
            point++;
        }
    }
    
    cout << point << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int h,w,n,x[100000],y[100000],cnt;
int main(){
	cin>>h>>w>>n;for(int i=0;i<n;i++){cin>>x[i]>>y[i];}
	for(int i=1;i<n;i++){
		int p=x[i]-x[i-1],q=y[i]-y[i-1];
		if(p>=0 && q>=0){cnt+=max(p,q);}
		else if(p<=0 && q<=0){cnt+=max(-p,-q);}
		else{cnt+=(abs(p)+abs(q));}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3112
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100004
int N;
VI adj[MAXN];

const int MOD = 1e9 + 7;
inline void mult(int& x, int y) {
   x = (x * 1LL * y) % MOD;
}

int DP[MAXN][2];
void dfs(int u, int p = -1) {
   DP[u][0] = 1;
   DP[u][1] = 1;

   for (int v : adj[u]) {
      if (v == p) continue;
      dfs(v, u);
   // paint white
      mult(DP[u][0], DP[v][0] + DP[v][1]);
   
   // paint black
      mult(DP[u][1], DP[v][0]);
   }

}

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

   cin >> N;
   REP(j, N-1) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }

   dfs(0);

   int res = (DP[0][0] + DP[0][1]) % MOD;
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 13440
X, N = map(int, input().split())
p = list(map(int, input().split()))

ans_enable = [True] * 102

for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;

int main(){
   ll n; cin >> n;
   vector<tuple<ll,ll,ll>> c;
   rep(i,n){
      ll a,b; cin >> a >> b;
      c.emplace_back(a + b, a, b);
   }
   sort(begin(c), end(c), greater<tuple<ll,ll,ll>>());

   ll ans = 0;
   rep(i,n){
      if(i % 2 == 0)ans += get<1>(c[i]);
      else ans -= get<2>(c[i]);
   }
   cout << ans << endl;
}


Measured memory_bytes: 4852
s = input()
t = input()

s_inf = [[] for _ in range(97+26+1)]
t_inf = [[] for _ in range(97+26+1)]

for i in range(len(s)):
    s_inf[ord(s[i])].append(i)
    t_inf[ord(t[i])].append(i)
s_inf.sort()
t_inf.sort()
if s_inf==t_inf:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const mod = 1e9 + 7

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	a := io.NextInts(n)
	s := make([]int, n+1)
	for i := range a {
		s[i+1] = (s[i] + a[i]) % mod
	}
	ans := 0
	for i := range a {
		cs := (s[n] - s[i+1] + mod) % mod
		ans += a[i] * cs % mod
		ans %= mod
	}
	io.Println(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
    stack<int> s;
    s.push(r);
    color[r] = c;

    while( !s.empty() ) {
       int u = s.top(); s.pop();
       rep(i,G[u].size()){
           int v = G[u][i];
           if( color[v] == NIL ){
                color[v] = c;
                s.push(v);
           }
       }
    }
}

void assignColor() {
    int id = 1;
    rep(i,n) color[i] = NIL;
    rep(i,n){
        if( color[i] == NIL ) dfs(i,id++);
    }
}

int main(){
    int s,t,m,q; 
    cin >> n >> m;
    rep(i,m){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;
    rep(i,q){
        cin >> s >> t;
        if( color[s] == color[t] ){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    string s;
    ll k,a = 1,ans = 0;
    vector<ll> cnt;
    cin >> s >> k;
    s += 'A';
    rep0(i, s.size() - 1){
        if (s[i] == s[i + 1]) {
            ++a;
        }else{
            cnt.push_back(a);
            ans += a / 2;
            a = 1;
        }
    }
    ans *= k;
    if (cnt.size() == 1) {
        if (cnt[0] % 2 == 1) {
            ans += k / 2;
        }
        cout << ans << endl;
        return 0;
    }
    if (s[0] == s[s.size() - 2]) {
        if (cnt[0] % 2 == 1 && cnt[cnt.size() - 1] % 2 == 1) {
            ans += k - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* ITP1_8_D */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      String s = br.readLine();
      String p = br.readLine();
      if(s.length() < p.length()) return;

      boolean judge = false;

      char[] s_char = s.toCharArray();

      for(int i = 0; i < s.length(); i++){
        if(s_char[i] == p.charAt(0)){

          for(int j = 0; j < p.length(); j++){
            sb.append( s_char[(i+j) % s.length()] );
          }
          if(p.equals(sb.toString())) judge = true;
          //System.out.println("i:" + i + " p:" + p + " sb:" + sb + " judge:" + judge);
          sb.delete(0, sb.length());
        }
      }

      if(judge)
        System.out.println("Yes");
      else
        System.out.println("No");

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

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

int main() {
    int X; cin >> X;
    int p=X/100;
    X=X%100;
    p=p-X/5; X=X%5;
    p=p-X/4; X=X%4;
    p=p-X/3; X=X%3;
    p=p-X/2; X=X%2;
    if(X==1) p=p-1;
    if(p<0) cout << 0 << endl;
    else cout << 1 << endl;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
const int P = 998244353;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN]; int n;
int dp[MAXN][MAXN][MAXN];
int vis[MAXN][MAXN][MAXN];
bool res[MAXN][MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
bool check(int x, int y, int z) {
	return res[x][y][z];
}
int main() {
	scanf("%s", s + 1), n = strlen(s + 1), dp[n][0][0] = 1;
	for (int i = n; i >= 1; i--)
	for (int j = 0; j + (n - i) <= n - 1; j++)
	for (int k = 0; j + k + (n - i) <= n - 1; k++)
		if (s[i] == '0') {
			update(dp[i - 1][j][k], dp[i][j][k]);
			update(dp[i][j][k + 1], dp[i][j][k]);
		} else {
			update(dp[i - 1][j][k], dp[i][j][k]);
			update(dp[i][j + 1][k], dp[i][j][k]);
		}
	memset(vis, -1, sizeof(vis));
	vis[0][0][0] = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= i / 2; j++)
	for (int k = 0; j + k <= i / 2; k++) {
		if (vis[i][j][k] == -1) continue;
		int tmp = vis[i][j][k];
		if (i + 1 <= n && tmp != 0) {
			if (s[i + 1] == '0') chkmax(vis[i + 1][j + 1][k], tmp - 1);
			if (s[i + 1] == '1') chkmax(vis[i + 1][j][k + 1], tmp - 1);
		}
		if (i + 2 <= n) {
			if (s[i + 1] == '0' || s[i + 2] == '0') chkmax(vis[i + 2][j + 1][k], tmp);
			if (s[i + 1] == '1' || s[i + 2] == '1') chkmax(vis[i + 2][j][k + 1], tmp);
			chkmax(vis[i + 2][j][k], tmp + 1);
		}
	}
	for (int i = 0; i <= n; i++)
	for (int j = n; j >= 0; j--)
	for (int k = n; k >= 0; k--) {
		res[i][j][k] = vis[i][j][k] != -1;
		if (i != 0) res[i][j][k] |= res[i - 1][j][k];
		res[i][j][k] |= res[i][j + 1][k];
		res[i][j][k] |= res[i][j][k + 1];
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j + (n - i) <= n; j++)
	for (int k = 0; j + k + (n - i) <= n; k++)
		if (dp[i][j][k] && (n - i) + j + k != 0) {
			if (check(i, j, k)) {
				update(ans, dp[i][j][k]);
			}
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 196848
/* ~created by Roh@n M@he$hwari~ */

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,i,j;
	cin>>n;
	int dp[n],h[n];
	for(i=0;i<n;i++) cin>>h[i];
	dp[0]=0,dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

#https://atcoder.jp/contests/abc155/tasks/abc155_b
length = int(input())
a = [int(i) for i in input().split()]

Answer = "APPROVED"
for i in set(a):
	if (i%2==1):
		continue
	elif(i%5==0 or i%3==0):
		continue
	else:
		Answer = "DENIED"
		break

print(Answer)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
#include <math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7;

using namespace std;

lol n,x,a[25];
lol power;
void flutes(int i,lol sum){
    if(i==n){
	power=min(abs(x,sum),power);
	return;
    }
    if(sum>=x){
	power=min(abs(x,sum),power);
	return;
    }
    
    for(int j=i+1;j<=n;j++){
	flutes(j,sum+a[j]);
	power=min(abs(x,sum),power);
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    lol a,sum=0;
    rep(i,n){
	cin>>a;
	while(a%2==0){
	    sum++;
	    a/=2;
	}
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<stack>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
int main()
{
	long a,b,x,ans;cin>>a>>b>>x;
	if(a==0)cout<<b/x+1<<endl;
	else if(a%x==0)cout<<b/x-a/x+1<<endl;
	else cout<<b/x-a/x<<endl;
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	s="*" + s;
	int fg=0;
	for(int i=1;i<=s.size();i++){
		if(i%2==0){
			if(s[i]=='R'){
				cout << "No" << endl;
				fg=1;
				break;
			}
		}
		else{
			if(s[i]=='L'){
				cout << "No" << endl;
				fg=1;
				break;
			}
		}
	}if(fg==0)
		cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for (int i=0;i<s.size();i++)
		if (s[i]=='7')
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	int ans[N+1];
	vector<int> S; //金額を記録
	S.push_back(1);
	int h=0;
	for(;;){
		h++;
		int a=pow(6,h);
		if(a > N) break;
		S.push_back(a);
	}
	h=0;
	for(;;){
		h++;
		int a=pow(9,h);
		if(a > N) break;
		S.push_back(a);
	}
	REP(i,N+1) ans[i]=MOD; //ans i円買うときの最低回数
	REP(i,S.size()) ans[S[i]]=1;
	h=0;
	while(h < 500){//DP
		REP(i,S.size())
			FOR(j,S[i],N+1) //配列のindexがマイナスになることを防げる
				ans[j]=min(ans[j], ans[j-S[i]]+1);
		h++;
	}
	cout << ans[N] << endl;
	
	return 0;
}

Measured memory_bytes: 640
from collections import Counter

n = int(input())
h = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(i + h[i])
    b.append(i - h[i])

x = Counter(a)
y = Counter(b)

z = set(a)
ans = 0
for i in z:
    ans += x[i] * y[i]

print(ans)

Measured memory_bytes: 71484
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        for(int i = 1;;i++){
            int x = sc.nextInt();

            if(x==0)
                 break;

        System.out.printf("Case %d: ", i);                
                         
        System.out.printf("%d\n", x);            
        }
    }
}


Measured memory_bytes: 76736
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

template<class T>
struct gufs {
	map<T,T> f;
	//map<T,int> c;
	T find(T v) {
		T r, u;
		for(r=v; f.find(r) != f.end(); r=f[r]);
		for(u=v; u!=r; ) {
			T t = f[u];
			f[u] = r;
			u = t;
		}
		//if (c.find(r)==c.end()) c[r] = 1;
		return r;
	}
	T merge(T a, T b) {
		a = find(a);
		b = find(b);
		if (a!=b) {
			f[a] = b;
			//c[b] += c[a];
		}
		return b;
	}
	void clear() {
		f.clear();
		//c.clear();
	}
	/*
	int count(int v){
		return c[find(v)];
	}
	*/
	void get_sets(map<T,vector<T>> &s) {
		for (auto &x: f) {
			s[find(x.first)].push_back(x.first);
		}
		for (auto &x: s) {
			s[x.first].push_back(x.first);
		}
	}
};

int n, m;
vector<pair<int,int>> g[MAXN];

map<int, gufs<int>> u;
map<int, map<int, vector<int>>> us;

int q[MAXN];
int h, t;
int dist[MAXN];

void adde(int a, int b, int c) {
	g[a].push_back({b,c});
	g[b].push_back({a,c});
	u[c].merge(a, b);
}

int input() {
	if (scanf("%d %d", &n, &m) < 0) return 0;
	for (int i=0; i<m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--, b--, c--;
		adde(a,b,c);
	}
	return 1;
}

void init() {
	for (int i=0; i<n; i++) dist[i] = INT_MAX;
	for (auto &x: u)
		x.second.get_sets(us[x.first]);
}

void push_q(int v, int c, int d) {
	int r = u[c].find(v);
	for (auto &x: us[c][r]) {
		if (d < dist[x]) {
			dist[x] = d;
			q[t++] = x;
		}
	}
	us[c][r].clear();
}

int solve() {
	h=0, t=0;
	dist[0] = 0;
	q[t++] = 0;
	while (h<t) {
		int v = q[h++], d = dist[v];
		//printf("-->v=%d d=%d\n", v, d);
		for(auto &x: g[v]) {
			int u = x.first, c = x.second;
			//need to process when dist[u]==d
			if (dist[u] <= d) continue;
			push_q(u, c, d+1);
		}
	}
	//cout << us << endl; printa(dist,n);
	return dist[n-1];
}

void output(int ans) {
	printf("%d\n", ans==INT_MAX? -1: ans);
}

void cleanup() {
	for (int i=0; i<n; i++) g[i].clear();
	u.clear();
	us.clear();
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 74240
#include <iostream>
#include <vector>

using namespace std;

long solve(long m){
    long min = 1000000;
    for(long x = 0; (x * x * x) <= m; ++x){
        long n = m - (x * x * x);
        for(long y = 0; (y * y) <= n; ++y){
            long z = n - (y * y);
            if( x + y + z < min){
                min = x + y + z;
            }
        }
    }
    return min;
}

int main(){
    while(1){
        int input;
        cin >> input;
        if(input == 0){
            return 0;
        }
        cout << solve(input) << endl;
    }
}



Measured memory_bytes: 3080
#include<stdio.h>
#define sz 200001
int main()
{
    long long int n;

    while(scanf("%lld",&n)!=EOF)
    {
        int a[sz] = {0};
        long long int i,pos=0;
        for(i=1;i<n;i++)
        {
            scanf("%lld",&pos);
            ++a[pos];
        }

        for(i=1;i<=n;i++)
            printf("%d\n",a[i]);
    }
}


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

int main() {
    int d, n;
    cin >> d >> n;
  	int t = 1;
    rep(i, d) t *= 100;
    if(n==100) cout << t * n + t << endl;
  	else cout << t * n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
vector<bool> seen;
vector<vector<int>> graph;

void dfs(int v){
    if(seen[v]) return;
    seen[v]=true;
    for(auto nv: graph[v]) dfs(nv);
}

int main(){
    int n,m;
    cin>>n>>m;
    seen.assign(n,false);
    graph.resize(n);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        --a,--b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int res=0;
    for(int i=0;i<n;++i){
        if(seen[i]) continue;
        dfs(i);
        ++res;
    }

    cout<<res-1<<endl;
}

Measured memory_bytes: 9152
//cwystc <--> 陈威宇是天才  --by cwy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double PI=acos(-1);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
#define travel_set(it,a) for (set<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_map(it,a) for (map<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_vec(it,a) for (vector<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define p(x) cout << x << endl;
#define def cout << "find" << endl;
#define what_is(x) cout << #x << " is " << x << endl;
template <class T>T sqr(T x){return x*x;}
template <class T>T alex(T x){return (x>0)?x:-x;}
template <class T>void read(T&x){
	x=0;T f=1;char ch=getchar();
	while ((ch<48||ch>57)&&ch!=45)ch=getchar();
	if (ch==45)f=-1,ch=getchar();
	while (ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();
	x*=f;
}

//-------------------------------------------------head-------------------------------------------------

int n,m,A,B;
#define maxn 1005
char s[maxn][maxn];
int usedA,usedB;
void push(int x,int y,int ind){
	if (ind==0)s[x][y]='<',s[x][y+1]='>';
	else if (ind==1)s[x][y]='^',s[x+1][y]='v';
}
void clear(int x,int y){
	s[x][y]='.';
}
int main(){
	read(n);read(m);read(A);read(B);
	int fill_num=(A+B)*2;
	if (n*m<fill_num){printf("NO\n");return 0;}
	rep(i,1,n)rep(j,1,m)s[i][j]='.';
	if (m&1){
		rep(i,1,n)rep(j,1,m/2)push(i,2*j-1,0),usedA++;
		rep(i,1,n/2)push(2*i-1,m,1),usedB++;
	}
	else{
		rep(i,1,n)rep(j,1,m/2)push(i,2*j-1,0),usedA++;
	}
	/*
	rep(i,1,n){
		rep(j,1,m)printf("%c",s[i][j]);
		puts("");
	}
	printf("%d %d\n",usedA,usedB);*/
	if ((n*m==fill_num)&&((usedA&1)!=(A&1))){printf("NO\n");return 0;}
	if (usedA<A){printf("NO\n");return 0;}
	{
		if (usedA<=A+1)goto loop;
		rep(i,1,n/2)rep(j,1,m/2){
			// cerr << i << " " << j << endl;
			clear(2*i-1,2*j-1);clear(2*i-1,2*j);
			clear(2*i,2*j-1);clear(2*i,2*j);
			usedA-=2;
			push(2*i-1,2*j-1,1);push(2*i-1,2*j,1);
			usedB+=2;
			// cerr << usedA << " " << usedB << endl;
			if (usedA<=A+1)goto loop;
		}
		loop:;
		// printf("%d %d\n",usedA,usedB);
		if (usedA>A&&usedB+1==B&&n>=3&&m>=3){
			if (s[n][m]=='.'&&s[n-1][m-2]=='<'&&s[n-1][m-1]=='>'&&s[n][m-2]=='<'&&s[n][m-1]=='>'){
				clear(n-1,m-2);clear(n-1,m-1);clear(n,m-2);clear(n,m-1);
				push(n-1,m-2,1);push(n,m-1,0);usedA--;usedB++;
			}
		}
		if (usedB<B){printf("NO\n");return 0;}
		rep(i,1,n)rep(j,1,m){
			if (s[i][j]=='<'&&s[i][j+1]=='>'&&usedA>A)clear(i,j),clear(i,j+1),usedA--;
			if (s[i][j]=='^'&&s[i+1][j]=='v'&&usedB>B)clear(i,j),clear(i+1,j),usedB--;
		}
	}
	printf("YES\n");
	rep(i,1,n){
		rep(j,1,m)printf("%c",s[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstdint>

using namespace std;

template<typename T>
class PriorityQueue {
private:
    vector<T> v;

public:
    PriorityQueue() {}

    void insert(T k) {
        v.push_back(k);

        int32_t i = v.size() - 1;
        int32_t p = (i-1)/2;
        while (p >= 0 && v[p] < v[i]) {
            swap(v[p], v[i]);
            i = p;
            p = (i-1)/2;
        }

        return;
    }

    T extractMax() {
        T maximum = v[0];
        swap(v[0], v[v.size()-1]);
        v.pop_back();

        int32_t i = 0;
        while (true) {
            int32_t l = i*2+1, r = i*2+2, largest = i;
            if (l < v.size() && v[l] > v[largest]) largest = l;
            if (r < v.size() && v[r] > v[largest]) largest = r;

            if (largest != i) {
                swap(v[largest], v[i]);
                i = largest;
            } else {
                break;
            }
        }

        return maximum;
    }
};

int main() {
    PriorityQueue<int32_t> pq;

    while (true) {
        uint8_t command[8];
        scanf("%s", command);

        if (command[0] == 'i') {
            int32_t k;
            scanf("%d", &k);
            pq.insert(k);
        } else if (command[1] == 'x') {
            printf("%d\n", pq.extractMax());
        } else if (command[1] == 'n') {
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 6484
n = int(input())
a = list(map(int, input().split()))
mou = [0]*n
for i in range(1,n):
  mou[i*2%n] =  mou[(i-1)*2%n] + (a[i*2%n-1]-a[(i-1)*2%n])*2
mous = 0
for i in range(n):
  mous += a[i]-mou[i]
p = mous//n
for i in range(n):
  mou[i] += p
print(" ".join(map(str,mou)))

Measured memory_bytes: 19616