akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc166/tasks/abc166_e

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int A_I_MAX = 1e9;

int N;
vector<int> A;

map<int, ll> mp1;
map<int, ll> mp2;

int main() {
  cin >> N;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  REP(i, N) {
    mp1[i + 1 + A[i]]++;
    mp2[i + 1 - A[i]]++;
  }

  ll ans = 0;
  for (auto it = mp1.begin(); it != mp1.end(); it++) {
    int k = it->first;
    ans += mp1[k] * mp2[k];
  }

  cout << ans << endl;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

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

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans++;
    if (A[i] == A[i+1]) {
      while (A[i] == A[i+1]) {
        i++;
        if (i == N - 1) break;
      }
    }
    if (A[i] < A[i+1]) {
      while (A[i] <= A[i+1]) {
        i++;
        if (i == N - 1) break;
      }
      if (i == N - 1) break;
      if (i == N - 2 && A[i] > A[i+1]) ans++;
      continue;
    }
    if (A[i] > A[i+1]) {
      while (A[i] >= A[i+1]) {
        i++;
        if (i == N - 1) break;
      }
      if (i == N -1) break;
      if (i == N - 2 && A[i] < A[i+1]) ans++;
    }
  }
  if (N == 1) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3784
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int N, A, B;
string S;

int main(void)
{
    cin >> N >> A >> B >> S;

    int domes = 0;
    int abroad = 0;
    int pass = 0;
    rep(i, S.size()) {
        switch (S[i]) {
            case 'a':
                domes++;
                if (A + B > pass) {
                    debug("Yes");
                    pass++;
                }
                else
                    debug("No");
                break;
            case 'b':
                abroad++;
                if (A + B > pass && B >= abroad) {
                    debug("Yes");
                    pass++;
                }
                else
                    debug("No");
                break;
            case 'c':
                debug("No");
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 1336
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,x,r;
    string s;
    cin >> n  >> m ;
    if(m>=n) cout << "unsafe" ;
    else cout << "safe" ;
    
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, ma, mb; cin >> n >> ma >> mb;
    vector<tuple<int, int, int>> v(n);
    for (int i = 0; i < n; i++) {
        int a, b, c; cin >> a >> b >> c;
        v[i] = make_tuple(a, b, c);
    }

    int nx = (n + 1) / 2, ny = n / 2;
    vector<pair<int, int>> x(1 << nx), y(1 << ny);
    for (int bits = 0; bits < (1 << nx); bits++) {
        for (int i = 0; i < nx; i++) {
            if ((bits >> i) & 1) {
                x[bits].first += mb * get<0>(v[i]) - ma * get<1>(v[i]);
                x[bits].second += get<2>(v[i]);
            }
        }
    }
    for (int bits = 0; bits < (1 << ny); bits++) {
        for (int i = 0; i < ny; i++) {
            if ((bits >> i) & 1) {
                y[bits].first += ma * get<1>(v[i + nx]) - mb * get<0>(v[i + nx]);
                y[bits].second += get<2>(v[i + nx]);
            }
        }
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int ans = inf;
    for (int i = 0; i < (1 << nx); i++) {
        auto it = lower_bound(y.begin(), y.end(), make_pair(x[i].first, (int)(x[i].second == 0)));
        if (it != y.end() && x[i].first == (*it).first) {
            int res = x[i].second + (*it).second;
            ans = min(ans, res);
        }
    }
    cout << (ans < inf ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){
    long long mn, mx, sum, n, N;

    mn = 1000001;
    mx = -1000001;
    sum = 0;

    cin >> N;

    for(int i=0; i < N; i++){
        cin >> n;
        sum += n;
        mn = min(mn, n);
        mx = max(mx, n);
    }

    printf("%d %d %lld\n", mn, mx, sum);
}


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

pair<int, int> about(long long int n) {
  int times = 0;
  while(n >= 10) {
    times++;
    n /= 10;
  }

  pair<int, int> result = make_pair(n, times);

  return result;
}
int main() {
  long long int n;
  cin >> n;

  pair<int, int> lower = about(n);

  if(n == (lower.first + 1) * pow(10, lower.second) - 1) cout << lower.first + 9 * lower.second << endl;
  else cout << lower.first + 9 * lower.second - 1 << endl;
}

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

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) (x.size())
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7


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


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("test cases\\in.txt", "r", stdin);
    //freopen("test cases\\in.txt", "w", stdout);

    char a; cin >> a;
    if(islower(a))cout<<"a";
        else cout<<"A";
    return 0;
}


Measured memory_bytes: 3648
X = int(input())
ans = 0
if X < 600:
    ans = 8
elif X < 800:
    ans = 7
elif X < 1000:
    ans = 6
elif X < 1200:
    ans = 5
elif X < 1400:
    ans = 4
elif X < 1600:
    ans = 3
elif X < 1800:
    ans = 2
else:
    ans = 1
print(ans)


Measured memory_bytes: 9172
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer,Integer> numCanPass = new HashMap<>();
        for(int i=1; i<=N; i++){
            numCanPass.put(i, 0);
        }
        int minCard = 1;
        int maxCard = N;
        for(int i=0; i<M; i++){
            int L = scanner.nextInt();
            int R = scanner.nextInt();
            
            minCard = Math.max(minCard,L);
            maxCard = Math.min(maxCard,R);
        }
        if(minCard>maxCard){
            System.out.println(String.valueOf(0));
        }else{
            System.out.println(String.valueOf(maxCard - minCard + 1));
        }
    }
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;


void pre(){



}

int n;
long k;
int a[maxs];

bool check(ll MAX){
    ll c=0;
    for(int i=1;i<=n;i++){
        

        if(a[i] > 0){
            int l = i+1,r=n;
            int res=i;
            while(l<=r){
                int mid = (l+r)/2;
                if(a[i]*1ll*a[mid] <= MAX){
                    res = mid;
                    l = mid+1;
                }else r = mid-1;
            }
            c += res-i;
        }else if(a[i] < 0){
            int l=i+1,r=n;
            int res=n+1;
            while(l<=r){
                int mid = (l+r)/2;
                if(a[i]*1ll*a[mid] <= MAX){
                    res = mid;
                    r = mid-1;
                }else l = mid+1;
            }
            c += n-res+1;
        }else{
            if(MAX >= 0){
                c += n-i;
            }
        }
    }
    return c >= k;
} 

void solve(){

    cin >> n >> k;
    for(int i=1;i<n+1;i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    ll l = -1e18 , r = 1e18;
    ll ans=1e18;
    while(l <= r){
        ll mid = (l+r)/2;
        bool res = check(mid);
        if(res){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    cout << ans << endl;


}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

class PG{
    static void Main(string[] args){
        while(true){
            int[] nums=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if(nums[0]==0&&nums[1]==0){
                break;
            }
            for(int i=0;i<nums[0];i++){
                for(int j=0;j<nums[1];j++){
                    if((i+j)%2==0){
                        Console.Write("#");
                    }else{
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            } 
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 18296
#include<cstdlib>
#include<cstdio>
using namespace std;
#define re register
#define cmax(a,b) ((a)>(b)?(a):(b))
int a[300100],c[300100],n;
bool check(re int x)
{
	int x1=0;
	for(re int i=2;i<=n;i+=2)
	{
		x1+=a[i-1];
		if(x1>=x&&x1<a[i])x1=0;
		else x1-=a[i];
	}x1+=a[n];
	return (x1>=x);
}
int main()
{
	re int w=0;
	scanf("%d",&n);
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);w+=a[i];c[i]=a[i];
		if(i>2)c[i]+=c[i-2];
	}if(n&1)
	{
		re int l=0,r=w;
		for(re int mid=(l+r+1)>>1;l<r;mid=(l+r+1)>>1)
		{
			if(check(mid))l=mid;else r=mid-1;
		}printf("%d %d\n",l+c[n-1],w-l-c[n-1]);
	}
	else 
	{
		if(c[n-1]>c[n])printf("%d %d",c[n-1],c[n]);
		else printf("%d %d",c[n],c[n-1]);
	}
}

Measured memory_bytes: 2560
k,n=map(int,input().split())
x=list(map(int,input().split()))

if k>=n or n==1:
	res=0
else:
	y=sorted(x)
	z=[0]*(n-1)
	for i in range(n-1):
		z[i]=y[i+1]-y[i]
	v=sorted(z,reverse=True)
	w=0
	if k>1:
		for i in range(k-1):
			w+=v[i]
		res=y[n-1]-y[0]-w
	else:
		res=y[n-1]-y[0] 

print(res)

Measured memory_bytes: 13960
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
   
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    ll n;
    cin>>n;
    if(n%2!=0){
        cout<<0;
    }
    else{
        n/=2;
        ll ans;
        while(n>0){
            ans+=n/5;
            n/=5;
        }
        cout<<ans;
    }

    return 0;
             
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

using namespace std;
int main(){
    int k,n,a;std::cin >> k;
    n=k/2;
    a=n+k%2;
    std::cout << n*a << std::endl;
    
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	long long wsum;
	int l,n,i,j,x,w,xx[50000],ww[50000];
	scanf("%d",&l);
	scanf("%d",&n);
	wsum=0;
	for(i=0;i<n;i++)	{
		scanf("%d %d",&x,&w);
		wsum+=x*w;
	}
//	printf("%lld\n",wsum);
	if(wsum==0)	{
		j=0;
	}
	else if(wsum>0)	{
		j=0;
		for(i=l;i>0;i--)	{
			w=wsum/i;
			if(w>0)	{
				xx[j]=-i;	ww[j]=w;
				j++;
				wsum=wsum%i;
			}
		}
	}
	else {
		wsum=-wsum;
		j=0;
		for(i=l;i>0;i--)	{
			w=wsum/i;
			if(w>0)	{
				xx[j]=i;	ww[j]=w;
				j++;
				wsum=wsum%i;
			}
		}
	}
	printf("%d\n",j);
	for(i=0;i<j;i++)	{
		printf("%d %d\n",xx[i],ww[i]);
	}
	return 0;
}


Measured memory_bytes: 2756
#include <iostream>
using namespace std;
typedef long long ll;
 
int main() {
    int Q;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        ll A, B;
        cin >> A >> B;
        if (A >= B) {
            swap(A, B);
        }  // A < B
 
        ll ok = A, ng = B + 1;
        while (ng - ok > 1) {
            ll mid = (ok + ng) / 2;
 
            ll m = (mid + A) / 2;
            if (mid == A) --m;
            if (m * (A + mid - m) < A * B) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << ok + A - 2 << endl;
    }
    return 0;
}

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

int m, n, v[1005], w[1005], ans, f[200005];
int main() {
	scanf("%d%d", &m, &n);
    ans = 1e8;
    for (register int i=1; i<=n; ++i) {
        scanf("%d%d", &v[i], &w[i]);
        if (v[i] >= m) ans = min(ans, w[i]);
    }
    memset(f, 0x3f, sizeof(f));
    f[0] = 0;
    for (register int i=1; i<=n; ++i) {
        for (register int j=0; j<=m; ++j)
            f[j] = min(f[j], f[max(j-v[i], 0)] + w[i]);
    }
    //for (register int i=m; i<=m*2; ++i)
      //  ans = min(ans, f[m]);
	cout << f[m];
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N,Q = list(map(int,input().split()))
s = input().rstrip()
lis=[0]*N
 
count = 0
for i in range(1,len(s)):
    if s[i-1] == 'A' and s[i] == 'C':
        count +=1
    lis[i]+=count
for i in range(Q):
    l,r = list(map(int,input().split()))
    print(lis[r-1]-lis[l-1])


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

using namespace std;

int n,i,mini,j,k,v[100010],d[100010];

int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)cin>>v[i];

    d[1]=0;
    for(i=2;i<=n;i++)
    {
        mini=INT_MAX;
        for(j=i-1;j>=max(i-k,1);j--)
            mini=min(mini,d[j]+abs(v[j]-v[i]));

        d[i]=mini;
    }

    cout<<d[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

template< class T >
struct UnionFind
{
    vector<T> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool connected(T x, T y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return true;
        else
            return false;
    }

    bool unite(T x, T y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return false;
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(T k)
    {
        if (data[k] < 0)
            return k;
        return (data[k] = find(data[k]));
    }

    T size(T k)
    {
        return (-data[find(k)]);
    }
};

ll a[100010], b[100010];
ll c[100010];

int main()
{
    ll n, m;
    cin >> n >> m;
    UnionFind<ll>uf(n);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    c[m] = n * (n - 1) / 2;
    for (int i = m - 1; i > 0; i--)
    {
        if (uf.connected(a[i], b[i]))
        {
            c[i] = c[i + 1];
        }
        else
        {
            c[i] = c[i + 1] - uf.size(a[i]) * uf.size(b[i]);
            uf.unite(a[i], b[i]);
        }
    }
    for (int i = 1; i <= m; i++)
    {
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 4480
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

typedef long long ll;

using namespace std;

map<int, int> am, bm;

int main(){
    int n;

    cin >> n;

    rep(i, n){
        int in;
        cin >> in;
        if(i % 2 == 0) am[in]++;
        else bm[in]++;
    }
    int max1 = n;
    int max2 = n;
    int a = 0, b = 0;

    for(auto e : am){
        if(n/2 - e.second < max1){
            max1 = min(max1, n/2 - e.second);
            a = e.first;
        }
    }
    for(auto e : bm){
        if(n/2 - e.second < max2){
            max2 = min(max2, n/2 - e.second);
            b = e.first;
        }
    }
    if(a != b){
        cout << max1 + max2 << endl;
        return 0;
    }

    int ans = n;
    for(auto e : am){
        if(e.first != a) ans = min(ans, max2 + n/2 - e.second);
    }
    if(am.size() == 1) ans = min(ans, max2 + n/2);

    for(auto e : bm){
        if(e.first != b) ans = min(ans, max1 + n/2 - e.second);
    }
    if(bm.size() == 1) ans = min(ans, max1 + n/2);
        
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
 #define mod 1000000007

const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;

int main(){
           lli n,m;
           cin >> n>>m;
           lli ans = 0;
           if(n*2 <= m){
                ans = n;
                m -= n*2;
           } else {
                ans = m / 2;
                n -= m/2;
                m=0;
           }
           //cout<<ans<<endl;
            ans+=m/4;
           cout<<ans;
}


Measured memory_bytes: 256
N = int(input())
A_arr = list(map(int, input().split()))

dif = []
for i in range(1,N):
    if A_arr[i] > A_arr[i-1]:
        dif.append(1)
    elif A_arr[i] < A_arr[i-1]:
        dif.append(-1)
    else:
        dif.append(0)

tmp = 0
count = 0
for i in range(len(dif)):
    if tmp * dif[i] == -1:
        count += 1
        tmp = 0
    elif dif[i] != 0:
        tmp = dif[i]
    else:
        pass

print(count+1)

Measured memory_bytes: 14252
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if(n==0)
				break;
			Pair[] pairs = new Pair[n];
			for(int i = 0;i<n;i++){
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = scanner.nextInt();
				pairs[i] = new Pair(a, b+c);
			}
			Arrays.sort(pairs);
			System.out.println(pairs[0].id+" " + pairs[0].cost);
		}
	}
	class Pair implements Comparable<Pair>{
		int id;
		int cost;
		
		public Pair(int id, int cost) {
			super();
			this.id = id;
			this.cost = cost;
		}

		@Override
		public int compareTo(Pair o) {
			return o.cost-this.cost;
		}
		
	}
}

Measured memory_bytes: 165180
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0,l=s.size();i<l;i++){
		if(i==3) cout<<8;
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <string>
using namespace std;


int main() {
  string S;
  cin >> S;
  
  string ans = "Good";
  for (int i = 0; i < 3; i++) {
    if(S[i]==S[i+1]) ans = "Bad";
  }
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

struct dat {
	int x, y;
	bool operator < (const dat& T) const {
		return y < T.y;
	}
}a[200005];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d%d", &a[i].x, &a[i].y);
	
	sort(a, a + n);
	int cur = 0;
		
	for (int i = 0; i < n; i++) {
		cur += a[i].x;	
		if (cur > a[i].y) return 0 * printf("No\n");
	
	}
	
	printf("Yes\n");
}


Measured memory_bytes: 1792
#include <iostream>

int main() {
    int a, b, c;    

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;

    for (int i = 0; i < 101*50; i++) {
        if ( (i * b + c) % a == 0 ) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 888
#!/usr/bin/env ruby
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i
K = Q.times.map { gets.split.map(&:to_i) }

ah = Hash.new
(0...N).each do |i|
  k = a[i]
  if ah.has_key?(k)
    ah[k] += 1
  else
    ah[k] = 1
  end
end

sum = 0
ah.each { |k,v|
  sum += k * v
}

(0...Q).each do |i|
  if ah.has_key?(K[i][0])
    sum -= ah[K[i][0]] * K[i][0]
    sum += ah[K[i][0]] * K[i][1]
    if ah.has_key?(K[i][1])
      ah[K[i][1]] += ah[K[i][0]]
    else
      ah[K[i][1]] = ah[K[i][0]]
    end
    ah.delete(K[i][0])
  end
  puts sum
end


Measured memory_bytes: 27696
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int a[] = new int[N];
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
			
			if(map.containsKey(a[i] - 1)) {
				map.put(a[i] - 1, map.get(a[i] - 1) + 1);
			} else {
				map.put(a[i] - 1, 1);
			}
			
			
			if(map.containsKey(a[i] + 1)) {
				map.put(a[i] + 1, map.get(a[i] + 1) + 1);
			} else {
				map.put(a[i] + 1, 1);
			}
		}
		
		int ans = 0;
		for(int key : map.keySet()) {
			ans = Math.max(ans, map.get(key));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 64400
while 1 :
    x,y,z=[int(i) for i in input().split()]
    if x==y==z==-1:
        break
    if x==-1 or y==-1:
        print('F')
    elif x+y>=80:
        print('A')
    elif x+y>=65:
        print('B')
    elif x+y>=50:
        print('C')
    elif x+y>=30:
        if z>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Measured memory_bytes: 7604
#include <stdio.h>
int main()
{
	double S;
	int h,s,m;
	scanf("%lf",&S);
	h = (int)(S/3600);
	m = (int)((S-3600*h)/60);
	s =	(int)(S-3600*h-60*m);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=200010;
int n,a[maxn],MAX=0;
LL cnt;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)
	{
		MAX=max(MAX,a[i]);
		if(a[i]<MAX)cnt+=MAX-a[i];
	}
	printf("%lld\n",cnt);
	return 0;
}
/*

*/

Measured memory_bytes: 3972
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int INF = 1 << 30;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
int a, b, c, d;
int main() {
	int nn;
	cin >> nn;
	a = nn / 1000;
	b = (nn % 1000) / 100;
	c = (nn % 100) / 10;
	d = nn % 10;
	TFOR(i, 2) {
		TFOR(j, 2) {
			TFOR(k, 2) {
					int n = a;
					if (i == 0)n += b;
					else n -= b;
					if (j == 0)n += c;
					else n -= c;
					if (k == 0)n += d;
					else n -= d;
					if (n == 7) {
						cout <<a<< (i == 0 ? "+" : "-")<<b<<(j==0?"+":"-")<<c<<(k==0?"+":"-")<<d<<"=7"<<endl;
						return 0;
					}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    string n; cin >> n;

    ll sum = 0;
    rep(i, n.size()){
        sum += n[i] - '0';
        sum %= 9;
    }

    if(sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>

bool isEven(const int &_n)
{
    return _n % 2 == 0;
}

int main(void)
{
    while(true) {
        int h, w;
        std::cin >> h >> w;
        if(h == 0 && w == 0) { break; }
        for(int i_h = 0; i_h < h; i_h++) {
            for(int i_w = 0; i_w < w; i_w++) {
                if((isEven(i_h) && isEven(i_w)) || (!isEven(i_h) && !isEven(i_w))) {
                    std::cout << "#";
                } else {
                    std::cout << ".";
                }
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
}

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

using namespace std;
typedef long long ll;

bool stable_check(int _N, vector<string> _a, vector<string> _c){
    //stable
    vector<int> _minv(0);
    bool _stable = true;
    vector<string> _d(0);

    _minv.push_back(_a[0][1]);
    
    for (int i = 1; i < _N; i++)
    {
        if (_a[i][1] != _a[i-1][1])
        {
            _minv.push_back(int(_a[i][1]));
        }
    }
    
    for (int i = 0; i < _minv.size(); i++)
    {   
        for (int j = 0; j < _N; j++)
        {
            if (_minv[i] == int(_c[j][1]))
            {
                _d.push_back(_c[j]);
            }
        }
    }
    
    for (int i = 0; i < _N; i++)
    {
        if (_a[i] != _d[i])
        {
            _stable = false;
        }
    }

    return _stable;

}


int main(){
    int N; cin >> N;
    vector<string> a(N);
    vector<string> b(N);
    vector<string> c(N);
    bool stable;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        b[i] = a[i];
        c[i] = a[i];
    }

    //bubble
    for (int i = 0; i < N; i++)
    {
        for (int j = N-1; j > i; j--)
        {
            if (a[j][1] < a[j-1][1])
            {
                string tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
            }
        }
    }

    cout << a[0];
    for (int i = 1; i < N; i++)
    {
        cout << " " << a[i];
    }
    cout << endl;

    stable = stable_check(N, a, c);

    if (stable)
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }

    //selection
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (b[j][1] < b[minj][1]) minj = j; 
        }

        string tmp = b[i];
        b[i] = b[minj];
        b[minj] = tmp;        
    }

    cout << b[0];
    for (int i = 1; i < N; i++)
    {
        cout << " " << b[i];
    }
    cout << endl;

    stable = stable_check(N, b, c);

    if (stable)
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }

}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int64_t X, Y;
  cin >> X >> Y;
  if (abs(X - Y) <= 1) {
    cout << "Brown" << '\n';
  } else {
    cout << "Alice" << '\n';
  }
  return 0;
}


Measured memory_bytes: 3628
import heapq
n = int(input())
a = [int(i) for i in input().split()]
k = 0
a_front = []
a_center = []
a_back = []
front_sum = 0
back_sum = 0

for i in a:
    k += 1
    if k <= n:
        a_front += [i]
        front_sum += i
    elif k <= 2 * n:
        a_center += [i]
    else:
        a_back += [-i]
        back_sum += i

heapq.heapify(a_front)
heapq.heapify(a_back)

front_sums = [front_sum]
back_sums = [back_sum]

for i in range(n):
        front_sum += a_center[i] - heapq.heappushpop(a_front, a_center[i])
        front_sums += [front_sum]
        back_sum += a_center[-i-1] + heapq.heappushpop(a_back, -a_center[-i-1])
        back_sums += [back_sum]

print(max([front_sums[i] - back_sums[-i-1] for i in range(n+1)]))
#print(front_sums, back_sums)


Measured memory_bytes: 38292
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;
ll k;
pll tab[nax];

ll dp[nax];

int main()
{
	scanf("%d%lld", &n, &k);
	for (int i=1; i<=n; i++)
	{
		scanf("%lld%lld", &tab[i].first, &tab[i].second);
	}
	for (int i=1; i<=n; i++)
	{
		for (int j=k; j>=tab[i].first; j--)
		{
			dp[j]=max(dp[j], dp[j-tab[i].first]+tab[i].second);
		}
	}
	ll wyn=0;
	for (int i=0; i<=k; i++)
		wyn=max(wyn, dp[i]);
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 3072
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
int n, k;
const int maxn = 1e5+10;
int dp[maxn];
const int md = 1e9 + 7;

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline void add(int &a, int b) {
 a += b;
 if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mdpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  fastio;
  cin >> n >> k;
  for (int i = k; i >= 1; i--) {
    dp[i] = mdpow(k/i, n);
  }

  for (int i = k; i >= 1; i--) {
    for (int j = i + i; j <= k; j += i) {
      sub(dp[i], dp[j]);
    }
  }

  int res = 0;
  for (int i = 1; i <= k; i++) {
    add(res, mul(dp[i], i));
  }

  cout << res << "\n";
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    rep(i,n+1)rep(j,m+1)if((n-i)*j+(m-j)*i==k)yn(1),exit(0);
    yn(0);
    return 0;
}


Measured memory_bytes: 384
import fractions

A, B = map(int, input().split())
g = fractions.gcd(A, B)

def make_divisors(n):
    count = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            # print(i)
            flag = 1
            for j in range(2, int(i**0.5)+1):
                if i%j == 0:
                    flag = 0
                    break
            if flag == 1:
                count += 1
            if i != n // i:
                flag = 1
                for j in range(2, int((n // i)**0.5)+1):
                    if (n // i) %j == 0:
                        flag = 0
                        break
                if flag == 1:
                    count += 1
    return count

print(make_divisors(g))

Measured memory_bytes: 5436
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long LL;
inline void normal(LL &a) { a %= MOD; (a < 0) && (a += MOD); }
inline LL modMul(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline LL modAdd(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline LL modSub(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline LL modPow(LL b, LL p) { LL r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline LL modInverse(LL a) { return modPow(a, MOD-2); }
inline LL modDiv(LL a, LL b) { return modMul(a, modInverse(b)); }
long long int sumXOR(LL arr[], LL n)
{
	long long int sum = 0;
	for (LL i = 0; i < 64LL; i++)
	{

         LL zc = 0, oc = 0;

		LL  idsum = 0;
		for (int j = 0; j < n; j++)
		{
			if (arr[j] % 2 == 0)
				zc++;
			else
				oc++;
			arr[j] /= 2;
		}


		idsum = modMul(modMul(oc , zc ), (1LL << i));


		sum = modAdd(sum,idsum);
	}
	return sum;
}

int main()
{

    LL i,j,k,l,m,n;

    cin>>n;
    LL ar[n+10];

    for(i=0;i<n;i++)cin>>ar[i];

    cout<<sumXOR(ar,n)<<endl;
}


Measured memory_bytes: 2560
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	n := sc.Int()

	happiness := make([][]int, n)
	for i := range happiness {
		happiness[i] = sc.Ints(3)
	}

	m := make([][]int, n)
	for i := range m {
		m[i] = make([]int, 3)
	}
	m[0][0] = happiness[0][0]
	m[0][1] = happiness[0][1]
	m[0][2] = happiness[0][2]

	for i := range happiness[1:] {
		m[i+1][0] = Max(m[i][1], m[i][2]) + happiness[i+1][0]
		m[i+1][1] = Max(m[i][0], m[i][2]) + happiness[i+1][1]
		m[i+1][2] = Max(m[i][0], m[i][1]) + happiness[i+1][2]
	}

	fmt.Println(MaxInts(m[n-1]...))
}

// generated by https://github.com/murosan/gollect

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func MaxInts(n ...int) int {
	max := n[0]
	for _, v := range n[1:] {
		if v > max {
			max = v
		}
	}
	return max
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner(r io.Reader) *Scanner {
	s := &Scanner{sc: bufio.NewScanner(r)}
	s.sc.Split(bufio.ScanWords)
	return s
}

func (s *Scanner) Bytes() []byte {
	s.sc.Scan()
	return s.sc.Bytes()
}

func (s *Scanner) Int() int { return BytesToInt(s.Bytes()) }

func (s *Scanner) Ints(len int) []int {
	a := make([]int, len)
	for i := 0; i < len; i++ {
		a[i] = s.Int()
	}
	return a
}

func BytesToInt(b []byte) (n int) {
	var i int
	negative := b[0] == 45
	if negative {
		i++
	}
	for ; i < len(b); i++ {
		n = n*10 + int(b[i]-'0')
	}
	if negative {
		return -n
	}
	return
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define pi acos(-1)
#define maxn 100001
using namespace std;
typedef long long ll;
const int mx=200005;
//ll a[mx];
//ll tree[mx*4];
//ll n;
//ll solve(ll arr[], ll x, ll n)
//{
//  ll *low = lower_bound(arr, arr+n, x);
//  if (low == (arr + n) || *low != x)
//     return 0;
//  ll *high = upper_bound(low, arr+n, x);
//  return high - low;
//}
//void init(int node, int b, int e)
//{
//    if (b == e)
//    {
//        tree[node] = a[b];
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    init(Left, b, mid);
//    init(Right, mid + 1, e);
//    ll x= max(tree[Left],tree[Right]);
//    tree[node]=solve(a,x,n);
//}
//int query(int node, int b, int e, int i, int j)
//{
//    if (i > e || j < b)
//        return 0;
//    if (b >= i && e <= j)
//        return tree[node];
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    int p1 = query(Left, b, mid, i, j);
//    int p2 = query(Right, mid + 1, e, i, j);
//    ll x= max(p1,p2);
//    return solve(a,x,n);
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    update(Left, b, mid, i, newvalue);
//    update(Right, mid + 1, e, i, newvalue);
//    tree[node] = __gcd(tree[Left] , tree[Right]);
//}
//void euiler()
//{
//    for(int i=1;i<maxn;i++)phi[i]=i;
//    for(int p=2;p<maxn;p++){
//        if(phi[p]==p){
//            phi[p]=p-1;
//            for(int i=2*p;i<maxn;i+=p){
//                phi[i]=(phi[i]/p)*(p-1);
//            }
//        }
//    }
//}
//void update(ll idx,ll val)
//{
//    while(idx<=n){
//        tree[idx]=max(tree[idx],val);
//        idx+=(idx&-idx);
//    }
//}
//ll query(ll idx)
//{
//    ll sum=0;
//    while(idx>0){
//        sum=max(sum,tree[idx]);
//        idx-=(idx&-idx);
//    }
//    return sum;
//}

int main()
{
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5]){
    cout<<"Yes"<<endl;
   }
   else{
    cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, l[20005];
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)    
        l[i] = read();
    sort(l + 1, l + n + 1);
}
void solve(){
    int ans = 0;
    for (int i = 2; i <= n; ++i){
        int cur = i; 
        for (int j = 1; j < i; ++j){
            while (cur <= n && l[j] + l[i] > l[cur])
                ++cur;
            ans += cur - i - 1;
        }
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

public static void main(String[] args)throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine();

int a = Integer.parseInt(str);
int h = a/3600;
a%=3600;
int m = a/60;
a%=60;
int s=a;

System.out.println(h+":"+m+":"+s);
}
}

Measured memory_bytes: 24300
#include <cstdio>
#include <cstring>
using namespace std;

const int sz = 1000010;

char s[sz];
int mp[sz];

int main(){
	fgets(s, sz, stdin);
	int n = strlen(s) - 1;
	
	mp[0] = -1;
	int t = -1;
	for(int i = 0; i < n; ++i){
		while(t >= 0 && s[t] != s[i]){
			t = mp[t];
		}
		mp[i + 1] = ++t;
	}
	
	int p = n - mp[n];
	if(p > 0){
		p *= n / (3 * p) + 1;
		if(p * 2 < n){
			printf("Love %.*s!\n", p, s);
			return 0;
		}
	}
	puts("mitomerarenaiWA");
}

Measured memory_bytes: 5856
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n, w, h;
  while(cin >> n >> w >> h, w){
      vector<pii> v;
      v.push_back(pii(h, w));

      rep(i,n){
          int p, s;
          cin >> p >> s;
          int a = v[p-1].first;
          int b = v[p-1].second;
          s = s % (a+b);
          if(s < b){
              v.push_back(pii(a, min(s, b-s)));
              v.push_back(pii(a, max(s, b-s)));
          }else{
              s -= b;
              v.push_back(pii(min(s, a-s), b));
              v.push_back(pii(max(s, a-s), b));
          }
          v.erase(v.begin() + p-1);
      }

      vi ans;
      rep(i,v.size())
        if(v[i].first)
            ans.push_back(v[i].first * v[i].second);
      sort(all(ans));
      rep(i,ans.size()){
          cout << ans[i];
          if(i+1 < ans.size())cout << " ";
          else cout << endl;
      }

  }
}



Measured memory_bytes: 3032
N = int(input())
P = (int,input().split())

sortList = []
for i in range(1,N+1):
        sortList.append(i)

count = 0
for i in range(N):
        # print(P[1][i], sortList[i])
        if (int(P[1][i]) != int(sortList[i])):
                count += 1

if(count == 2 or count == 0):
        print('YES')
else:
        print('NO')

Measured memory_bytes: 3064