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

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

    int h[n+1];
    for(int i=0; i<n; ++i) cin >> h[i];

    int dp[n+1];

    dp[0] = 0;              
    dp[1] = abs(h[1] - h[0]);    //1から2

    for(int 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;
}

Measured memory_bytes: 1024
n,a,b=gets.split.map(&:to_i)
s=gets.chomp
ab=a+b
n.times do |i|
  if s[i] == "a"
    if ab>0
      puts "Yes"
      ab-=1
    else
      puts "No"
    end
  elsif s[i] == "b"
    if b>0 && ab>0
      puts "Yes"
      b-=1
      ab-=1
    else
      puts "No"
    end
  else
    puts "No"
  end
end


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

int main() {
  int N,M;
  cin >> N>>M;
  vector<int>a(N);
  vector<int>b(N);
  for(int i = 0; i<N; i++) {
    cin>>a.at(i)>>b.at(i);
  }
  vector<int>c(M);
  vector<int>d(M);
  for(int i = 0; i<M; i++) {
    cin>>c.at(i)>>d.at(i);
  }
  
  for(int i = 0; i<N; i++) {
    int e=1000000000;
    int ans;
    for(int j = 0; j<M; j++) {
      if(e>abs(c.at(j)-a.at(i))+abs(d.at(j)-b.at(i))){
        ans=j;
        e=abs(c.at(j)-a.at(i))+abs(d.at(j)-b.at(i));
      }
    }
    cout<<ans+1<<endl;
  }
  
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> d = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            d.add(sc.nextInt());
        }
        List<Integer> steps = d.stream().distinct().collect(Collectors.toList());
        System.out.println(steps.size());
    }
}


Measured memory_bytes: 27092
#include <stdio.h>

int main(void){
    int i,n,k,x,y,sum=0;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(n<k){
        for(i=1;i<=n;i++){
            sum+=x;
        }
    }else{
        for(i=1;i<=k;i++){
            sum+=x;
        }
        for(i=k+1;i<=n;i++){
            sum+=y;
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

ll n, m, cnt, sz[N], col[N];
bool u[N], bad[N];
vector < ll > g[N];

void dfs(ll v) {
    u[v] = 1;
    sz[cnt]++;
    for (auto to : g[v]) {
        if (!u[to]) {
            col[to] = col[v] ^ 1;
            dfs(to);
        }
        if (col[to] == col[v]) bad[cnt] = 1;
    }
}

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

    cin >> n >> m;
    forn(i, 1, m) {
        ll x, y;
        cin >> x >> y;
        g[x].eb(y);
        g[y].eb(x);
    }

    forn(i, 1, n) {
        if (!u[i]) {
            ++cnt;
            dfs(i);
        }
    }

    ll ans = 1ll * n * n, sum = 0, c = 0, b = 1;
    forn(i, 1, cnt) {
        if (sz[i] == 1) continue;
        ans -= 1ll * sz[i] * sum * 2 + 1ll * sz[i] * sz[i];
        sum += sz[i];
        if (bad[i]) {
            ans += 1ll * 2 * (b - 1) + 1;
        }
        else {
            ans += 1ll * (b - c - 1) * 2 + 1ll * c * 4 + 2;
            ++c;
        }
        ++b;
    }

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 64512
#include <iostream>
#include <cstdio>
#include <utility>

using namespace std;
int main (void){
    int N, M, tmp1, tmp2, result;
    scanf("%d%d", &N, &M);
    pair <int, int> res(-1, 100000);
    for(int i = 0; i < M; i++){
        scanf("%d%d", &tmp1, &tmp2);
        res.first = max(res.first, tmp1);
        res.second = min(res.second, tmp2);
    }

    result = max(0, res.second - res.first + 1);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
int n, k;
signed main() {
	cin >> n >> k;
	if (k > (n + 1) / 2) {
		cout << -1 << endl;
		return 0;
	}
	set<int>se;
	for (int i = k + 2 * n; i < k + 3 * n; i++) se.insert(i);
	vector<P>ans;
	int a = n, b = k + 2 * n - 1, c = k + 3 * n - 1;
	ans.push_back(Q(a, b, c));
	while (--a >= k) {
		--b;
		c = *se.lower_bound(a + b);
		ans.push_back(Q(a, b, c));
		se.erase(c);
	}
	a = k + n - 1;
	--b;
	while (a > n) {
		c = *se.lower_bound(a + b);
		ans.push_back(Q(a, b, c));
		se.erase(c);
		--a; --b;
	}
	for (auto t : ans) {
		cout << t.xx <<" "<< t.yy <<" "<< t.zz << endl;
	}
}

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

ll mod = 1000000007;
ll ncr[2005][2005]; // 0
void init_ncr() {
  for(int i=0;i<2000;i++){
    ncr[i][0]=1;
    for(int j=1;j<i+1;j++){
      ncr[i][j]=ncr[i-1][j-1]+ncr[i-1][j];
      ncr[i][j]%=mod;
    }
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  init_ncr();
  ll n,k;cin>>n>>k;
  ll blue=k;
  ll red=n-k;
  ll res=0;
  res = red+1;
  cout<<res<<endl;
  for(ll i=2;i<=k;i++){
    if(red + 1 < i){
      cout<<0<<endl;
      continue;
    }
    res = ncr[blue-1][i-1]*ncr[red+1][i] % mod;
    cout<<res<<endl;
  }

  return 0;
}


Measured memory_bytes: 30080
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN = 5e5 + 5;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

char S[MAXN];
int nxt1[MAXN], nxt2[MAXN];
int N;

void calc( int *ret )
{
	ret[1] = 0;
	for( int i = 2, j = ret[1] ; i <= N ; i ++ )
	{
		while( j && S[i] ^ S[j + 1] ) j = ret[j];
		if( S[j + 1] == S[i] ) j ++;
		ret[i] = j;
	}
}

bool chkPre( const int p ) { return nxt1[p] && p % ( p - nxt1[p] ) == 0; }
bool chkSuf( const int p ) { return nxt2[p] && p % ( p - nxt2[p] ) == 0; }
bool chk( const int p ) { return chkPre( p ) == 0 && chkSuf( N - p ) == 0; }

int main()
{
	scanf( "%s", S + 1 );
	N = strlen( S + 1 );
	calc( nxt1 ), std :: reverse( S + 1, S + 1 + N ), calc( nxt2 );
	if( nxt1[N] && N % ( N - nxt1[N] ) == 0 )
	{
		if( nxt1[N] == N - 1 ) { printf( "%d\n%d\n", N, 1 ); return 0; }
		puts( "2" ); int ans = 0;
		for( int i = 1 ; i < N ; i ++ ) 
			ans += chk( i );
		write( ans ), putchar( '\n' );
	}
	else puts( "1\n1" );
	return 0;
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int,int>
#define mii map<int,int>
#define mci map<char,int>
#define fir first
#define sec second
#define eline "\n"

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	set<int> s;
	for(int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		for(int i = 0; i < d; ++i) {
			int t;
			cin >> t;
			s.insert(t);
		}
	}
	
	cout << n - s.size() << eline;
	
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.length() / 2, r = (int)s.length() + 1;
    while (l + 1 < r) {
        int m = (l + r) >> 1, y = 0;
        for (int i = (int)s.length() - m + 1; i < m; i++) if (s[i] != s[i - 1]) y = 1;
        if (y) r = m;
        else l = m;
    }
    cout << l;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "Yes"
#define no cout << "No"
#define NAME ""
bool isFile = 0;
 
typedef long long ll;
typedef long double ld;
 
const ll INF=1e9+1234;                                                   
const int N = 4e5 + 5; 
const ll MOD=998244353;
const ll mod=1e9+7;                                            
double EPS = 3e-18;
const double PI = acos(-1);  
 
 
void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);        
    cin.tie(NULL);                                         
    cout.tie(NULL);                                
}                                                     

int a[2134];
vll g[2134];
int d[2134][2134];
int used[2134];


void solve() 
{			  			 																	 									 	  	                      
	int n,x,y;
	cin >> n >> x >> y;
	g[x].pb(y);
	g[y].pb(x);
	forn(i,1,n)
	{
		g[i].pb(i+1);
		g[i+1].pb(i);
	}
	forn(i,1,n+1)
	{
		queue<ll>q;
		q.push(i);
		used[i] = i;
		while(!q.empty())
		{
			int u = q.front();
			q.pop();
			for(int to : g[u])
			{
				if(used[to] != i)
				{
					used[to] = i;
					d[i][to] += d[i][u] + 1;
					q.push(to);
				}
			}	
		}
		forn(j,1,n+1)
		{
			a[d[i][j]]++;
		}
	}
	forn(i,1,n)
		cout << a[i]/2 << '\n';	
}                         
                           
int main()                                     
{                            
	faster();                 
	int t = 1;
	//cin >> t;	
	while(t--)
	{               	
		solve();
		ed;
	}
	return 0;
}

Measured memory_bytes: 17024
#include<bits/stdc++.h> //ABC 167_d
#define ll long long
using namespace std;
const int maxn=2e5+5;
ll k,n,len,be;
ll a[maxn],b[maxn],r[maxn];
ll p=1,cnt;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	while(1){
		if(b[a[p]]!=0){
			be=b[a[p]];
			len=cnt-be+1;
			break;
		}
		r[++cnt]=a[p];
		b[a[p]]=cnt;
		p=a[p];
	}
	if(k<=be) cout<<r[k];
	else{
		int s=(k-be)%len;
		cout<<r[be+s];
	}
	return 0;
}

Measured memory_bytes: 8240
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mod 1000000007
#define fst first
#define pb push_back
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; }

//ユークリッドの互除法
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }


int main()
{
	ll r;
	cin >> r;
	cout << r*r << endl;
}

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

#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;
void solve()
{
ll n;
cin>>n;
vi b(n+1);
vi v(n+1);
loop(i,2,n+1)
{

    cin>>v[i];
    b[v[i]]++;
}
v[1]=1;
cout<<count(v.begin(),v.end(),v[1])-1<<line;
loop(i,2,n+1)
{
cout<<b[i]<<line;

}


}

int main()
{fast
//int t;
//cin>>t;
//while(t--)
{
solve();
}

}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

const ll mod = 1000000007LL;

long long extgcd(long long a,long long b,long long& x,long long& y)
{
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m)
{
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}


const int MAXnCk = 400001;
ll fact[MAXnCk+1], fact_inv[MAXnCk+1];
void init_nCk(){
  fact[0] = fact_inv[0] = 1;
  REP(i,1,MAXnCk+1) {
    fact[i] = fact[i-1] * (ll)i % mod;
    fact_inv[i] = mod_inv(fact[i],mod);
  }
}

ll nCk(ll n,ll k){
  if( n < 0 || k < 0 || k > n ) return 0LL;
  if( n-k < k ) k = n-k;
  return fact_inv[k] * fact[n] % mod * fact_inv[n-k] % mod;
}


void solve() {

}

int main() {
  init_nCk();
  ll N, K;
  cin >> N >> K;
  ll B = K;
  ll R = N - K;
  REP(i,1,K+1) {
    ll rem_B = B - i;
    ll rem_R = R - ( i - 1 );
    ll ans = ( nCk(rem_B+i-1,rem_B) * nCk(i+rem_R,rem_R) ) % mod;
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N;
	cin >> N;
	int h_max = INT_MIN, ans = 0;
	for(int i = 0; i < N; i++) {
		int H;
		cin >> H;
		if(h_max <= H)
			ans++;
		h_max = max(h_max, H);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define VMAX 501
#define HMAX 501

void initary( int table[VMAX][HMAX] )
{
	for ( int i = 0 ; i < VMAX ; i++ ) {
		for ( int j = 0 ; j < HMAX ; j++ ) {
			table[i][j] = 0;
		}
	}
}

void numstr( char table[VMAX][HMAX], int map[VMAX][HMAX], int h, int w )
{
	int i = 0, j = 0, k = 1;
	for ( i = 0 ; i < h ; i++ ) {
		k = 0;
		for ( j = w-1 ; j > -1 ; j-- ) {
			if ( table[i][j] == '*' ) {
				map[i][j] = 0;
				k = 0;
			} else if ( table[i][j] == '.' ){
				k++;
				map[i][j] = k;
			}
		}
	}
}

int maximumarea( int map[VMAX][HMAX], int h, int w )
{
	int i = 0, j = 0, k = 0, tmpi = 0;
	int mink = 501, area = 0;

	for ( i = 0 ; i < h ; i++ ) {
		for ( j = 0 ; j < w ; j++ ) {
			tmpi = i, k = 1;
			mink = 501;
			while ( tmpi < h ) {
				// printf( "[%3d][%3d] ", tmpi, j );
				if ( map[tmpi][j] == 0 ) {
					// map[i][j]の値が0の場合はkの値を1にする
					k = 1;
					mink = 501;
				} else if ( map[tmpi][j] > 0 ) {
					// kの値を加算する
					if ( map[tmpi][j] <= mink ) {
						mink = map[tmpi][j];	
					}
					if ( mink * k > area ) {
						area = mink * k;
					}
					// printf( " %3d x %3d = %3d", mink, k, area );
					k++;
				}
				// printf( "\n" );
				tmpi++;
			}
		}
	}
	return area;
}

void printtable( int table[VMAX][HMAX], int h, int w ) 
{
	int i = 0, j = 0;
	for ( i = 0 ; i < h ; i++ ) {
		for ( j = 0 ; j < w ; j++ ) {
			printf( "%3d", table[i][j] );
		}
		printf( "\n" );
	}
}

int main()
{
	char str[VMAX][HMAX];
	int map[VMAX][HMAX];
	int w = 0, h = 0, i = 0, j = 0, k = 0;
	int ans = 0;

	while ( scanf( "%d %d", &h, &w ) == 2 ) {
		if ( h == 0 && w == 0 ) { break; }

		initary( map );
		for ( i = 0 ; i < h ; i++ ) {
			scanf( "%s", str[i] );
		}
		numstr( str, map, h, w );
		// printtable( map, h, w );	
		ans = maximumarea( map, h, w );
		printf( "%d\n", ans );
	}
	return 0;
}



Measured memory_bytes: 2912
#include <cstdio>

using namespace std;

char s[200'009];

int main() {
  scanf("%s", s);
  long long ans = 0;
  int cnt = 0;
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'B') {
      ++cnt;
    } else {
      ans += cnt;
    }
  }
  printf("%lld\n", ans);
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<ll, ll> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

// Z-algorithm: O(n)
// 文字列が与えられた時、各 i について「S と S[i..|S|-1] の最長共通接頭辞の長さ」を記録した配列 A を O(|S|) で構築するアルゴリズム
// https://snuke.hatenablog.com/entry/2014/12/03/214243
vector<int> A(MAX_N, 0);
int m = 0;
int Z_algorithm(string S) {
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i + j < S.size() && S[j] == S[i + j])
            ++j;
        A[i] = j;
        if (j <= i) m = max(A[i], m);
        if (j == 0) {
            ++i;
            continue;
        }
        int k = 1;
        while (i + k < S.size() && k + A[k] < j)
            A[i + k] = A[k], ++k;
        i += k;
        j -= k;
    }
    return m;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> counts;
    rep(i, n) {
        string subst = s.substr(i, n - i);
        int m = Z_algorithm(subst);
        counts.push_back(m);
    }
    sort(counts.begin(), counts.end(), greater<int>());
    out(counts[0]);
}


Measured memory_bytes: 768
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
typedef long long LL;
using namespace std;

struct Node{
    int color;
    vector<int> v;
    vector<LL> w;
};

int dfs(vector<Node> &nodes, int points){
    for(int i=0; i<nodes[points].v.size(); i++){
        if(nodes[nodes[points].v[i]].color!=-1){
            continue;
        }
        if(nodes[points].w[i]%2==0){
            nodes[nodes[points].v[i]].color=nodes[points].color;
        }else{
            if(nodes[points].color==0){
                nodes[nodes[points].v[i]].color=1; 
            }else{
                nodes[nodes[points].v[i]].color=0;                
            } 
        }
        dfs(nodes, nodes[points].v[i]);
    }
    return 0;
}

int main(){
    int n;
    int tmp_u;
    int tmp_v;
    LL tmp_w;

    cin >> n;
    vector<Node> nodes(n);
    for(int i=0; i<n; i++){
        nodes[i].color=-1;
    }
    for(int i=0; i<n-1; i++){
        cin >> tmp_u >> tmp_v >> tmp_w;
        tmp_u--;
        tmp_v--;
        nodes[tmp_u].v.push_back(tmp_v);
        nodes[tmp_u].w.push_back(tmp_w);
        nodes[tmp_v].v.push_back(tmp_u);
        nodes[tmp_v].w.push_back(tmp_w);
    }

    nodes[0].color=0;
    dfs(nodes, 0);

    for(int i=0; i<n; i++){
        cout << nodes[i].color << endl;
    }    
}

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


int main(){
    ll n;
    cin >> n;
    ll res=0;
    for(ll i=1;i<=n-1;i++){
        res+=(n-1)/i;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
A.append(0)
A.insert(0, 0)
sum_val = 0
now = 0
for i in range(N + 1):
    sum_val += abs(A[i] - A[i + 1])

for i in range(1 , N + 1):
    print(sum_val - (abs(A[i-1] - A[i]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1]))


Measured memory_bytes: 14040
import qualified Data.ByteString.Char8 as BSC8
import qualified Control.Monad         as Monad
import qualified Control.Arrow         as Arrow
import qualified Data.Vector.Unboxed   as VU
import qualified Data.List             as List

getStringList :: IO [String]
getStringList = map BSC8.unpack . BSC8.words <$> BSC8.getLine
getMultiLineString :: Int -> IO [[String]]
getMultiLineString n = Monad.replicateM n getStringList

getI :: BSC8.ByteString -> Maybe (Int, BSC8.ByteString)
getI = fmap (Arrow.second BSC8.tail) . BSC8.readInt
getAB :: IO (Int, Int)
getAB = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 getI <$> BSC8.getLine

main :: IO ()
main = do
  (n, l) <- getAB
  xs <- concat <$> getMultiLineString n
  putStrLn $ concat $ List.sort xs


Measured memory_bytes: 4708
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <vector <int>> gr(n, vector <int> (n, 1));
    int ans = n * (n - 1) / 2;
    if (n % 2)
        forn (i, 0, (n - 1) / 2)
            gr[i][n - i - 2] = 0, ans--;
    else
        forn (i, 0, n / 2)
            gr[i][n - i - 1] = 0, ans--;
    cout << ans << "\n";
    forn (i, 0, n)
        forn (j, i + 1, n)
            if (gr[i][j])
                cout << i + 1 << " " << j + 1 << "\n";
    return 0;
}


Measured memory_bytes: 384
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
int determined[200000] = {};
vector<int> vertexs[200000];
pair<int, int> geko[200000];
pair<int,int> solve(int now, int back) {
	pair<int, int> now_ans = make_pair(-10000000, 10000000);
	REP(i, vertexs[now].size()) {
		if (vertexs[now][i] != back) {
			pair<int, int> boa = solve(vertexs[now][i], now);
			now_ans.first = max(now_ans.first, boa.first - 1);
			now_ans.second = min(now_ans.second, boa.second + 1);
		}
	}
	if (determined[now] != -1) {
		now_ans.first = determined[now];
		now_ans.second = determined[now];
	}
	return geko[now] = now_ans;
}
int now_ok = 1;
int final_ans[200000];
int fitting(int now, int back) {
	for (int q = 0; q < vertexs[now].size(); ++q) {
		if (vertexs[now][q] != back) {
			int now_ans = final_ans[now];
			int next_itr = vertexs[now][q];
			if (geko[next_itr].first <= now_ans + 1 && now_ans + 1 <= geko[next_itr].second) {
				final_ans[next_itr] = now_ans + 1;
			}
			else if (geko[next_itr].first <= now_ans - 1 && now_ans - 1 <= geko[next_itr].second) {
				final_ans[next_itr] = now_ans - 1;
			}
			else {
				now_ok = 0;
				return 0;
			}
			fitting(next_itr, now);
		}
	}
	return 0;
}
int main(){
	iostream::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, n-1) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	int k;
	cin >> k;
	int boa = 0;
	REP(i, n) {
		determined[i + 1] = -1;
	}
	REP(i, k) {
		int a, b;
		cin >> a >> b;
		determined[a] = b;
		boa = a;
	}
	solve(boa, -1);
	final_ans[boa] = determined[boa];
	fitting(boa, -1);
	if (now_ok == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		REP(i, n) {
			cout << final_ans[i + 1] << endl;
		}
	}
}

Measured memory_bytes: 18176
#include <iostream>

using namespace std;

int CAKE_PRICE = 4;
int DONUT_PRICE = 7;

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

  if (n % CAKE_PRICE == 0) {
    cout << "Yes" << endl;
    return 0;
  } else {
    for (int i = 0; i < n / CAKE_PRICE; i++) {
      if ((n - CAKE_PRICE * i) % DONUT_PRICE == 0) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
//
//  Insertion Sort
//

#include <iostream>
using namespace std;

/*
 函数模板: CPP 中支持两种模板, 函数模板和类模板, 顾名思义, 此处就是
 生成函数的模板; 它的写法是(class 关键字可以被替换成 typename)
 template <class 类型参数1, class 类型参数2, ...>
 返回值类型 模板名(形参表)
 {
    函数体
 }
 */
template <class T>
void printArray(T Array, int size)
{
    for (int i = 0; i < size; i++) {
        cout << Array[i];
        if (i != size - 1) cout << " ";
    }
    cout << endl;
}

int main() {
    int size;
    cin >> size;
    int array[size];

    int i = 0;
    while(i < size) {
        cin >> array[i];
        i++;
    }
    
    printArray(array, size);
    // Insertion Sort
    for (int i = 1; i < size; i++) {
        int v = array[i];
        int j = i - 1;
        while (j >= 0 && array[j] > v) {
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = v;
        // print out each step result
        printArray(array, size);
    }

    return 0;
}



Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;

public class Main {

    static class D {
        int x;
        int y;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int maxn = 10;
        D[] d = new D[maxn];

        for (int i = 0; i < n; i++) {
            d[i] = new D();
            d[i].x = sc.nextInt();
            d[i].y = sc.nextInt();
        }
        double sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                sum += dis(d[i],d[j]);
            }
        }
        System.out.println(sum*fac(n-1)/fac(n));

    }

    private static int fac(int n) {
        int res = 1;
        for (int i = 2; i <= n; i++) {
            res *= i;
        }
        return res;
    }

    private static double dis(D d, D d1) {
        return Math.sqrt(Math.pow(d.x-d1.x,2)+Math.pow(d.y-d1.y,2));
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll h, w, k; cin >> h >> w >> k;
  vector <vector <char>> v(h, vector <char> (w));
  rep(i, h) {
    rep(j, w) {
      cin >> v.at(i).at(j);
    }
  }
  ll res = 0;
  for (ll bit_h = 0; bit_h < (1 << h); bit_h++) {
    for (ll bit_w = 0; bit_w < (1 << w); bit_w++) {
      ll tmp = 0;
      rep(i, h) {
        if (bit_h&(1<<i)) continue;
        rep(j, w) {
          if (bit_w&(1<<j)) continue;
          if (v.at(i).at(j) == '#') tmp++;
        }
      }
      if (tmp == k) res++;
    }
  }
  cout << res << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


using P = pair<i64, i64>;

int main() {
    i64 N, K; cin >> N >> K;
    map<i64, i64> mp;
    REP(i, N) {
        i64 a; cin >> a;
        mp[a]++;
    }

    vector<P> A;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        i64 num, cnt;
        num = (*it).first, cnt = (*it).second;
        A.emplace_back(cnt, num);
    }

    sort(A.rbegin(), A.rend());

    i64 ans = 0;
    REP(i, A.size()) {
        if (i >= K) ans += A[i].first;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vector<pair<int, int>> ans;
	for (int i = N / 2, j = N-1; i < N; i++, j -= 2) {
		ans.emplace_back(K + i, K + N + j);
	}
	for (int i = 0, j = N - 2; i < N / 2; i++, j -= 2) {
		ans.emplace_back(K + i, K + N + j);
	}
	sort(ans.begin(), ans.end(), [&](pair<int, int> a, pair<int, int> b) {
		return a.first + a.second < b.first + b.second;
	});

	for (int i = 0; i < N; i++) {
		if (ans[i].first + ans[i].second > K + N + N + i) {
			cout << -1 << '\n'; exit(0);
		}
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i].first << ' ' << ans[i].second << ' ' <<  K + N + N + i << '\n';
	}

	return 0;
}

//
// 1,2 3
//
// 1,2,3,4 -> 1,4,5 and 2,3,5 (value 6)
//
// 1,2,3,4,5,6 -> 2,6 = 8, 3,4 = 7, 1,5 = 6
//
//
// 1,2,3,4,5,6,7,8 -> 3,7 = 10, 4,5 = 9, 2,6 = 8, 1,8 = 9
//
// 1,2,3,4,5,6,7,8,9,10 -> 3,10 = 13, 4,8 = 12, 5,6 = 11, 1,9 = 10, 2,7 = 9


Measured memory_bytes: 3188
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, Y;

int main()
{
  scanf( "%d%d", &N, &Y );
  rep( i, Y/10000+1 ) rep( j, (Y-i*10000)/5000+1 ) if( (Y-(i*10000+j*5000)) % 1000 == 0 && i+j+(Y-(i*10000+j*5000))/1000 == N )
  {
    printf( "%d %d %d\n", i, j, (Y-(i*10000+j*5000))/1000 );

    return 0;
  }

  puts( "-1 -1 -1" );
  
  return 0;
}

Measured memory_bytes: 128
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
	const [n, max] = line.split(' ').map(Number);

	if (n === 0 && max === 0) {break;}

	const prices = lines.shift().split(' ').map(Number);

	const allSum = [];

	prices.map((priceA, indexA) => {
			prices.map((priceB, indexB) => {
				if (indexA !== indexB) {
					const sum = priceA + priceB;

					if(sum <= max) {
						allSum.push(sum);
					}
				}
			})
		}
	);

	const answer = allSum.sort((a,b) => b - a)[0];

	if (answer) {
		console.log(answer);
		continue;
	}

	console.log('NONE');
}



Measured memory_bytes: 55864
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    string S;
    cin >> S;
    int ans = 0;
    int i = 0;
    int j = S.size()-1;
    while(i < j) {
        if(S[i] == S[j]) {
            i++;
            j--;
            continue;
        }
        if(S[i] == 'x') {
            ans++;
            i+=1;
        }
        else if(S[j] == 'x') {
            ans++;
            j-=1;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] L = in.ii(N);
        Arrays.sort(L);

        long ans = 0;
        for (int i = 2; i < N; i++) {
            for (int j = 0, k = i - 1; j < i - 1; j++) {
                int t = L[i] - L[j];
                while (j < k && t < L[k]) {
                    k--;
                }
                if (j == k) {
                    ans += (long)(i - j - 1) * (i - j) / 2;
                    break;
                }
                ans += i - k - 1;
            }
        }

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32592
def main(n):
    if n == 1:
        return ['a']
    else:
        ans = []
        for a in main(n-1):
            b = '`'
            while b <= max(a):
                b = chr(ord(b) + 1)
                ans.append(a + str(b))
        return ans
N = int(input())
L = main(N)
for i in L:
    print(i)


Measured memory_bytes: 12996
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
    int A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    cout<<max(A*B,C*D);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;

#include <vector>
#include <functional>

template <typename T,typename E>
struct LazySegmentTree{
   using F=std::function<T(T,T)>;
   using G=std::function<T(T,E,int,int)>;
   using H=std::function<E(E,E)>;

   int n;
   std::vector<T> dat;
   std::vector<E> laz;
   const F f;
   const G g;
   const H h;
   const T d1;
   const E d0;

   LazySegmentTree(int n_,const F f,const G g,const H h,const T d1,const E d0):f(f),g(g),h(h),d1(d1),d0(d0)
   {
      n=1;
      while(n_>n) n<<=1;
      dat.assign(2*n,d1);
      laz.assign(2*n,d0);
   }
   void set(int k,const T &x){
      dat[k+n]=x;
   }
   void build(){
      for(int k=n-1;k>0;--k) dat[k]=f(dat[2*k],dat[2*k+1]);
   }
   void eval(int k,int l,int r){
      if(laz[k]==d0) return;
      dat[k]=g(dat[k],laz[k],l,r);
      if(k<n){
         laz[2*k]=h(laz[2*k],laz[k]);
         laz[2*k+1]=h(laz[2*k+1],laz[k]);
      }
      laz[k]=d0;
   }
   void update(int a,int b,E x,int k=1,int l=0,int r=-1){
      if(r<0) r=n;
      eval(k,l,r);
      if(r<=a||b<=l) return;
      if(a<=l&&r<=b){
         laz[k]=h(laz[k],x);
         eval(k,l,r);
      }
      else{
         update(a,b,x,2*k,l,(l+r)/2);
         update(a,b,x,2*k+1,(l+r)/2,r);
         dat[k]=f(dat[2*k],dat[2*k+1]);
      }
   }
   T query(int a,int b,int k=1,int l=0,int r=-1){
      if(r<0) r=n;
      eval(k,l,r);
      if(r<=a||b<=l) return d1;
      if(a<=l&&r<=b) return dat[k];
      T vl=query(a,b,2*k,l,(l+r)/2);
      T vr=query(a,b,2*k+1,(l+r)/2,r);
      return f(vl,vr);
   }
};

/*

-RMinimumQ and RUpdateQ
f=[](T x,T y){ return min(x,y); };
g=[](T x,E y,int l,int r){ return y; };
h=[](E x,E y){ return y; };

-RSumQ and RAddQ
f=[](T x,T y){ return x+y; };
g=[](T x,E y,int l,int r){ return x+(r-l)*y; };
h=[](E x,E y){ return x+y; };

-RMinimumQ and RAddQ
f=[](T x,T y){ return min(x,y); };
g=[](T x,E y,int l,int r){ return x+y; };
h=[](E x,E y){ return x+y; };

-RSumQ and RUpdateQ
f=[](T x,T y){ return x+y; };
g=[](T x,E y,int l,int r){ return (r-l)*y; };
h=[](E x,E y){ return y; };

*/

int main(){
   int n,q;
   cin>>n>>q;
   using T=ll;
   using E=ll;
   auto f=[](T x,T y){ return x+y; };
   auto g=[](T x,E y,int l,int r){ return (r-l)*y; };
   auto h=[](E x,E y){ return y; };
   LazySegmentTree<ll,ll> seg(n,f,g,h,0,INT_MAX);
   for(int i=0;i<q;++i){
      int com;
      cin>>com;
      int s,t,x;
      cin>>s>>t;
      if(com==0){
         cin>>x;
         seg.update(s,t+1,x);
      }
      else{
         cout<<seg.query(s,t+1)<<endl;
      }
   }
}



Measured memory_bytes: 7088
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [list(map(int, input().split())) for i in range(N)]
input_list = list(map(int, input().split()))

ans_list=[input_list[0]]
for i in range(N-2):
    ans_list.append(min(input_list[i], input_list[i+1]))
ans_list.append(input_list[N-2])
#print(ans_list)
print(sum(ans_list))


Measured memory_bytes: 38256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

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

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

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  cout<<10-n/200<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int H;
  int N;
  vector<int> A;

  cin >> H >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.begin(), A.end(), greater<int>());

  for (int i = 0; i < N; i++) {
    H -= A[i];
    if (H <= 0) {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
 int i, h, m, s;
 scanf("%d", &i);
 h = i / 3600;
 m = i % 3600;
 s = m %60;
 m = m / 60;
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}
 

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

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

typedef long long ll;

using namespace std;
int main(){
    int N;
    int ans;
    cin >> N;
    ans = 800 * N - 200 * (N /15);
    cout << ans << endl;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
sa = sorted(set(a))
if len(sa) ==1 and sa[0] == 0:
  ans = "Yes"
elif len(sa) == 2 and sa[0] == 0 and a.count(sa[0])*2==a.count(sa[1]):
  ans = "Yes"
elif len(sa) == 3 and sa[0]^sa[1]^sa[2] == 0 and a.count(sa[0])==a.count(sa[1])==a.count(sa[2]):
  ans = "Yes"
else:
  ans = "No"
print(ans)

Measured memory_bytes: 14116
using System;
using System.Linq;

namespace ABC082_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var s = AB[0] + AB[1];
            Console.WriteLine(s % 2 == 0 ? s / 2 : (s + 1) / 2);
        }
    }
}


Measured memory_bytes: 11220
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let P: i64 = sc.get();
    let ans = (A * 3 + P) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int w = in.nextInt();
		for(int i=0; i<w; i++){
			list.add(i+1);
		}
		
		int n = in.nextInt();
		for(int i=0; i<n; i++){
			String tmp = in.next();
			StringTokenizer str = new StringTokenizer(tmp, ",");
			int a = Integer.parseInt(str.nextToken());
			int b = Integer.parseInt(str.nextToken());
			int x = list.get(a-1);
			list.set(a-1, list.get(b-1));
			list.set(b-1, x);
		}
		
		for(int i=0; i<list.size(); i++){
			System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 12000