akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> x(n + 1), y(n + 1), t(n + 1);
    x[0] = y[0] = t[0] = 0;

    rep(i, n)
    {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    rep(i, n)
    {
        int dx = x[i + 1] - x[i], dy = y[i + 1] - y[i], dt = t[i + 1] - t[i];

        if (abs(dx + dy) % 2 != dt % 2 || abs(dx) + abs(dy) > dt) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
int compare( const void *a,const void *b){
    return *(int*)a - *(int*)b;
}
int main()
{
    int i,n,x[200001],mirror[200001];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
        mirror[i]=x[i];
    }
    
    qsort(mirror,n,sizeof(int),compare);
    int med=mirror[n/2-1];
    for(i=0;i<n;i++){
    if(x[i]>med){
        printf("%d\n",med);
    }else{
        printf("%d\n",mirror[n/2]);
    }        
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	string S,result="";
	cin>>S;
	REP(i,(int)S.length()){
		switch(S[i]){
			case '0':
				result+="0";
				break;
			case '1':
				result+="1";
				break;
			case 'B':
				if(!result.empty())
					result.erase(result.end()-1);
				break;
		}
	}
	cout<<result<<endl;
	return 0; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
typedef long long int ll;
typedef unsigned long long int llt;
#define vector<int> vi
#define pair<int, int> pii
using namespace std;
int main()
{
    int n;
	cin>>n;
	int arr[n];
	int sat[n];
	int c[n-1];
	for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int i=0;i<n;i++)
        cin>>sat[i];
    for(int i=0;i<n-1;i++)
        cin>>c[i];
    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        int e = arr[i];
        ans += sat[e-1];
        if(i == n-1 || e == n) continue;
        else if(arr[i] == arr[i+1] - 1)
            ans += c[e-1];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	map<int,int> m;
	ll sum=0;
	for(int i=0;i<n;i++){
		m[a[i]]++;
		sum+=a[i];
	}
	ll x,y;
	int q;cin>>q;
	while(q--){
		cin>>x>>y;
		if(m.find(x)!=m.end()){
		
		ll k=m[x];
		sum-=k*x;
		sum+=y*k;
		
		m.erase(x);
		m[y]+=k;}
		cout<<sum<<"\n";
	}
}


Measured memory_bytes: 6904
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	map<char,char> m;
	m['A']='T';m['T']='A';m['C']='G';m['G']='C';
	char a;
	cin>>a;
	cout<<m[a];
	
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
  int64_t N, K;
  cin >> N >> K;

  int64_t ans=0;

  while(N>=1){
    N = N/K;
    ans++;
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int D,n,m,d[100010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>D && D){
		cin>>n>>m;
		d[0]=0;
		rep(i,n-1){
			cin>>d[i];
		}
		sort(d,d+n);
		d[n++]=D;
		ll ans=0;
		int k;
		rep(i,m){
			cin>>k;
			int ub=lower_bound(d,d+n,k)-d;
			ans+=min(d[ub]-k,k-d[ub-1]);
		}
		cout<<ans<<endl;
	}
}

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

int main()
{
	int a[1000];
	int i, j, k, n = 0,t;
	int m1, m2;
	int mm1, mm2;
	int temp;

	while (1){
		int x, y, s;//x???????¨????,y??´??°???????¨????,z??????????¨?

		cin >> x >> y >> s;

		if (x == 0 && y == 0 && s == 0) break;

		int max=0;

		for (m1 = 1; m1 < s; m1++){
			for (m2 = 1; m2 < s; m2++){
				if (m1 >= m2){
					//			mm1 = (m1 * (100 + x)) / 100;
					//			mm2 = s - mm1;

					//			m2 = (100 * (mm2 + 0.5)) / (100 + x);
					temp = 0;
					if ((((m1 * (100 + x)) / 100) + ((m2 * (100 + x)) / 100)) == s){
						//			cout << m1 << ' ' << m2 << endl;

						temp = (m1 * (100 + y)) / 100;
						temp += (m2*(100 + y)) / 100;
						if (temp > max){
							max = temp;
							//cout << max << endl;
						}
					}
				}
			}
		}
//		cout << max << endl;
		a[n++] = max;
	}

	for (i = 0; i < n; i++)
		cout << a[i] << endl;

	return(0);
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
int n,m,dir[8][2]={{1,0},{0,1},{-1,0},{0,-1},{-1,-1},{1,-1},{1,1},{-1,1}};
char mp[101][101];
void dfs()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int num=0;
            if(mp[i][j]=='#')cout<<'#';
            if(mp[i][j]=='.')
            {
                for(int k=0;k<8;k++)
                {
                    int x0=i+dir[k][0];
                    int y0=j+dir[k][1];
                    if(mp[x0][y0]=='#')num++;
                }
            cout<<num;
            }

        }
        cout<<endl;
    }

}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>mp[i][j];
    dfs();
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
X = list(map(int, input().split()))
XR = [x if x > 0 else x * 2 for x in X]
XL = [x * 2 if x > 0 else x for x in X]

ans = 10**9
for i in range(k-1, n):
  dist_R = XR[i] - min(0, XR[i-k+1])
  dist_L = max(0, XL[i]) - XL[i-k+1]
  #print(i, dist_R, dist_L)
  ans = min(ans, dist_R, dist_L)
print(ans)

Measured memory_bytes: 14384
N = int(input())
ct = []

for i in range(N):
  ct.append([int(i) for i in input().split()])

dist = 0
for a in ct:
  for b in ct:
    dist += (abs(a[0] - b[0])**2 +abs(a[1] - b[1])**2)**0.5
print(dist/N)

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

int main() {
  int N;
  cin >> N;
  vector<char> color(N);
  for(int i = 0; i < N; i++) {
    cin >> color.at(i);
  }

  bool yellow = false;
  for(int i = 0; i < N; i++) {
    if(color.at(i) == 'Y') {
      yellow = true;
    }
  }

  if(yellow) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    cout << arr[n/2] - arr[n/2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	INF int = 1<<62
	MOD int = 1000000007
)

var N , M int
var A []int
var ans int

func Input(){
	N = NextInt()
	M = NextInt()
	A = NextInts(M)
}

func Solve(){
	broken := Bools(N)
	for _, a := range(A){
		broken[a] = true
	}

	dp := Ints(N+10)
	dp[0] = 1
	for i := 0; i<N; i++ {
		if broken[i] {
			continue
		}
		dp[i+1] += dp[i]
		dp[i+1] %= MOD

		dp[i+2] += dp[i]
		dp[i+2] %= MOD
	}
	ans = dp[N]
}

func Output(){
	fmt.Println(ans)
}

func main() {
	Initialize()
	for {
		Input()
		Solve()
		Output()
	}
}

// Initilize ===================
var io *IO;
func Initialize(){
	io = NewIO()
}
// IO ====================

type IO struct{
	sc *bufio.Scanner
}
func NewIO() *IO {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &IO{
		sc: sc,
	}
}
func Next() string{
	ok := io.sc.Scan()
	if !ok {
		os.Exit(0)
	}
	return io.sc.Text()
}
func NextInt() int {
	s := Next()
	a, err:= strconv.Atoi(s)
	if err != nil {
		print(err)
	}
	return a
}
func NextInts(N int) []int{
	ret := make([]int, N)
	for i := range ret {
		ret[i] = NextInt()
	}
	return ret
}

// =============
func Sort( a[]int){
	sort.Ints(a)
}
func Min(nums ...int) int {
	ret := int(nums[0])
	for _, n := range nums {
		if n < ret {
			ret = n
		}
	}
	return ret
}
func Max(nums ...int) int {
	ret := int(nums[0])
	for _, n := range nums {
		if n > ret {
			ret = n
		}
	}
	return ret
}
func Abs(n int)int{
	if n < 0{
		return -n
	}
	return n
}
func Ints(n int) []int{
	return make([]int, n)
}
func Bools(n int) []bool{
	return make([]bool, n)
}


Measured memory_bytes: 2432
// atcoder/abc153/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "("; each (i, s) os << i << ","; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "("; each (i, m) os << i << ","; os << ")"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> swap(pair<P, Q> p) { return make_pair(p.second, p.first); }

constexpr lli mod = 1e9 + 7;

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

  int n, k;
  while (cin >> n >> k) {
    vector<lli> v(n);
    cin >> v;
    sort(v.begin(), v.end());
    for (int i = 0; i < k; ++i) {
      if (v.empty()) break;
      v.pop_back();
    }
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
  }

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;
	cin >> N;

	if(N%2==0){
		N--;
	}
	cout << N/2 << "\n";

return 0;
}

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

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

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() { 
    int N;
    cin >> N;
    string S;
    cin >> S;
    long long ans = 0;
    REP(i, 10) {
        REP(j, 10) {
            REP(k, 10) {
                int flag = 0;
                REP(n, N) {
                    if (i == S[n] - '0' && flag == 0) {
                            flag |= (1 << 0); 
                    } else if (j == S[n] - '0' && flag == 1) {
                            flag |= (1 << 1);
                    } else if (k == S[n] - '0' && flag == 3) {
                            flag |= (1 << 2);
                    }

                    if (flag == 7) {
                        ans += 1;
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
// 最大値最小値を逐次更新すればよい.
#include<iostream>
using namespace std;
int main(){
  int n,m; cin >> n >> m;
  int min=0,max=100000000;
  for(int i=0;i<m;++i){
    int l,r; cin >> l >> r;
    if(min<=l)min=l;
    if(max>=r)max=r;
  }
  if(max<min) cout << 0 << endl;
  else cout << max-min+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    string s;cin>>s;
    int n=s.length();
    bool flag=true;
    for(int i=n-2;i>=0;i-=2)
    {
        for(int j=0;j<i/2;j++)
        {
            if(s[j]!=s[i/2 + j])
            {
                flag=false;
                break;
            }
        }
        if(flag)
        return cout<<i,0;
        flag=true;
    }
  }  
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int A, B;
		A = scan.nextInt();
		B = scan.nextInt();

		if (A >= 13) {
			System.out.println(B);
		} else if (A >= 6) {
			System.out.println(B / 2);
		} else {
			System.out.println(0);
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 23124
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll cnt[200005];
int main(){
 ll n;
 cin>>n;
 V<ll> a(n);
 for(int i=0;i<n;i++){
     cin>>a[i];
     cnt[a[i]]++;
 }
 ll ans=0;
 for(int i=1;i<=n;i++){
     ans+=cnt[i]*(cnt[i]-1)/2;
 }
 for(int i=0;i<n;i++){
     ll d=cnt[a[i]]*(cnt[a[i]]-1)/2-(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
     cout<<ans-d<<"\n";
 }
}


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

const int N = 1e5 + 10;
int n, ans, u, d, ar[2][N], tmp[N];
map <int, bool> mp;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		if (i & 1)
			cin >> ar[1][d], tmp[i] = ar[1][d++];
		else
			cin >> ar[0][u], tmp[i] = ar[0][u++];
	}
	sort(ar[0], ar[0] + u);
	sort(ar[1], ar[1] + d);
	sort(tmp, tmp + n);
	for (int i = 0; i < n; i++)
		mp[tmp[i]] = (i & 1);
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			if (mp[ar[1][i / 2]] != (i & 1))
				ans++;
		}
		else {
			if (mp[ar[0][i / 2]] != (i & 1))
				ans++;
		}
	}
	cout << (ans + 1) / 2;
}

Measured memory_bytes: 5760
const fs = require('fs')
const reader = (s: string) => s.split(' ').map(t => parseInt(t, 10))

function Main(input: string) {
  const [...N] = reader(input)
  const sorting = N.sort((a, b) => a - b)

  if (sorting[0] === 5 && sorting[1] === 5 && sorting[2] === 7) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 1400

int dp[MAX][MAX], G[MAX][MAX];

int getLargestSquare(int H, int W){
    int maxWidth = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            dp[i][j] = (G[i][j] + 1) % 2; //ビット反転 つまり、汚れ０、きれい１
            maxWidth |= dp[i][j]; //maxWidth = maxWidth | dp[i][j] (ビット和代入)
        }
    }

    for(int i=1; i<H; i++){
        for(int j=0; j<W; j++){
            if( G[i][j] ){
                dp[i][j] = 0;
            }else{
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                maxWidth = max(maxWidth, dp[i][j]);
            }
        }
    }

    return maxWidth * maxWidth;
}

int main(void){
    int H, W;
    scanf("%d %d", &H, &W);

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++) scanf("%d", &G[i][j]);
    }

    printf("%d\n", getLargestSquare(H, W));

    return 0;
}


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

int insertionSort(vector<ll> a, int n) {
  rep(i, n) {
    if (i != n-1) cout << a[i] << " ";
    else cout << a[i];
  }
  cout << endl;

  for(int i = 1; i < n; i ++) {
    int v = a[i];
    int j = i-1;
    while (0 <= j && v < a[j]) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    rep(i, n) {
      if (i != n-1) cout << a[i] << " ";
      else cout << a[i];
    }
    cout<<endl;
  }
  return 0;
}

int main()
{
  ll n;cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  insertionSort(a, n);
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

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

int main()
{
    ll a, b ;
    cin >> a >> b ;

    cout << lcm(a,b) << endl ;
}

Measured memory_bytes: 3632
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).sbegin()) it = (a).begin(); it != (a).end(); it++)  
void solve()
{
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}

int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;

  vector<string> pic(H); // H列のpixel

  // データを受け取る
  for (int i = 0; i < H; i++) {
    cin >> pic.at(i);
  }

  // #出力 1
  for (int i = 0; i < W+2; i++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    cout << "#";
    cout << pic.at(i);
    cout << "#" << endl;
  }
  
  for (int i = 0; i < W+2; i++) {
    cout << "#";
  }
  cout << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    string s, t;
    cin >> n;
    cin >> s;
    for(i = 0; i < n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            sum++;
        }
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> g(n);
    vector<ll> ans(n - 1, -1);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(make_pair(b, i));
        g[b].push_back(make_pair(a, i));
    }
    set<ll> color;
    rep(i, n) color.insert(i + 1);
    vector<bool> seen(n, false);
    queue<ll> q;
    q.push(0);
    ll mc = 0;
    while(!q.empty()) {
        ll from = q.front(); q.pop();
        set<ll> vc;
        if (seen[from]) continue;
        seen[from] = true;
        rep(i, sz(g[from])) {
            if (ans[g[from][i].second] == -1) continue;
            color.erase(ans[g[from][i].second]);
            vc.insert(ans[g[from][i].second]);
        }
        rep(i, sz(g[from])) {
            ll idx = g[from][i].second;
            ll to = g[from][i].first;
            q.push(to);
            if (ans[idx] != -1) continue;
            auto it = color.begin();
            vc.insert(*it);
            ans[idx] = *it;
            mc = max(mc, *it);
            color.erase(it);
        }
        for(auto x : vc) color.insert(x);
    }
    cout << mc << endl;
    rep(i, n - 1) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 13696
K,A,B = input().split()
K = int(K)
A = int(A)
B = int(B)
bi = 1

if(B-A<=2):
    bi+=K
else:
    bi=A
    K1=K-(A-1)
    bi+=((K1)//2)*(B-A)
    bi+=((K1)%2)
print(bi)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
const ll INF = 1e18;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    ll dp[n][n];
    rep(i,n)rep(j,n)dp[i][j]=INF;
    rep(i,n) dp[i][i]=0;
    ll c[n],r[n];
    rep(i,n){
        cin  >> r[i] >> c[i];
    }
    for(int num=2;num<=n;num++){
        for(int i=0;i<n;i++){
            int j=i+num-1;
            if(j<0||n<=j) continue;
            for(int k=i;k<j;k++){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+r[i]*c[k]*c[j]);
            }
        }
    }
    cout<< dp[0][n-1]  << endl;
}



Measured memory_bytes: 3204
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Text.Printf
import Data.Fixed
import Debug.Trace

solve total = [(x,y,z,w) | x <- [0..9], y <- [0..9], z <- [0..9], w <- [0..9], x + y + z + w == total ]

main :: IO ()
main = do
    ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    -- ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> (return "35\n1\n")
    forM_ [0..length ns - 1] $ \i -> do
      putStrLn $ show $ length $ solve (ns!!i!!0)

Measured memory_bytes: 4140
using System;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;


namespace aizu
{
	public class EntryPoint
	{
		public static void Main()
		{
			var line = Console.ReadLine();
			
//			var v = Regex.Split(line, " ").Select(x => int.Parse(x)).ToArray();

			var v = int.Parse(line);
			
			var m = v / 60;
			var s = v % 60;
			var h = m / 60;
			m = m % 60;
			
			Console.WriteLine("{0}:{1}:{2}", h, m, s);
			
		}
	}


}

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

int main(){
string S,T,U;
  int A,B;
  cin>>S>>T;
  cin>>A>>B;
  cin>>U;
 if(U==S){
 cout<<A-1<<" "<<B;
 }
  else{
  cout<<A<<" "<<B-1;
  }

}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

i = 0
res = 0
tmp = 0
while True:
    if i == n-1:
        print(max(res, tmp))
        break
    if h[i] < h[i+1]:
        res = max(res, tmp)
        tmp = 0
    else:
        tmp += 1
    i += 1


Measured memory_bytes: 15020
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
   char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;

}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void getSuffixArray(vector<int> &res, const string &str){
	int n = str.size();
	vector< pair<int, int> > vp(n);
	vector<int> rank(n), cnt(256, 0);
	for(int i=0;i<n;i++) cnt[str[i]]++;
	for(int i=1;i<256;i++) cnt[i] += cnt[i-1];
	for(int i=0;i<n;i++){
		rank[i] = cnt[str[i]];
		vp[i] = make_pair(cnt[str[i]], i);
	}
	sort(vp.begin(), vp.end());
	for(int h=1;h<n;h*=2){
		vector< pair<int,int> >::iterator cur = vp.begin();
		while(cur != vp.end()){
			vector< pair<int,int> >::iterator end = cur;
			int key = rank[cur->second];
			while(end!=vp.end() && rank[end->second] == key){
				end->first = end->second + h < n ? rank[end->second + h] : -1;
				end++;
			}
			int s = distance(vp.begin(), cur), e = distance(vp.begin(), end);
			if(e-s>1){
				sort(cur, end);
				rank[vp[e-1].second] = key;
				for(int i=e-2;i>=s;i--){
					if(vp[i].first == vp[i+1].first) rank[vp[i].second] = rank[vp[i+1].second];
					else rank[vp[i].second] = key-(e-1-i);
				}
			}
			cur = end;
		}
	}
	res.assign(n,0);
	for(int i=0;i<n;i++) res[i] = vp[i].second;
}

int main(){
	string s;
	while(cin >> s){
		vector<int> SA;
		getSuffixArray(SA, s);
		int res = s.size();
		int n = SA.size();
		vector<int> rev(n);
		for(int i=0;i<n;i++) rev[SA[i]] = i;
		int prev = 0;
		for(int i=0;i<n;i++){
			int idx = rev[i];
			if(idx == n-1){ prev = 0; continue; }
			idx = SA[idx+1];
			int t = prev;
			while(i+t < n && idx+t < n && s[i+t] == s[idx+t]) t++;
			res = min(res, (int)s.size() - t);
			prev = max(0, t-1);
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 2048
using System;

namespace aoj7a
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string[] line = (Console.ReadLine()).Split(' ');
            int r = int.Parse(line[0]);
            int c = int.Parse(line[1]);
            int[,] sheet = new int[r+1,c+1];

            for(int i = 0; i < r; i++)
            {
                string[] line2 = (Console.ReadLine()).Split(' ');

                for(int j = 0; j < c; j++)
                {
                    sheet[i, j] = int.Parse(line2[j]);
                    Console.Write(sheet[i,j] + " ");
                    sheet[i,c] += sheet[i,j];
                    sheet[r,j] += sheet[i,j];
                }
                Console.WriteLine(sheet[i,c]);

            }

            for (int j = 0; j < c; j++)
            {
                Console.Write(sheet[r, j] + " ");
                sheet[r, c] += sheet[r, j];
            }
            Console.WriteLine(sheet[r, c]);




        }
    }
}

Measured memory_bytes: 9276
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
t = [int(input()) for i in range(D)]
tmp = 0
last = [0]*(26)
v = [0]*(D+1) #満足度これだけi=日付他のはi-1=日付


for i in range(D):
	tmp = 0
	tmp += v[i] + s[i][(t[i]-1)]
	last[t[i]-1] = (i+1)
	for j in range(26):
		tmp -= c[j] * (i+1 - last[j]) 
	v[i+1]=tmp
#print(v)
for i in range(1,D+1):
	print(v[i])

Measured memory_bytes: 9280
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    //
    ll L = 1, R = N;
    rep(i, M)
    {
        ll nL, nR;
        cin >> nL >> nR;
        chmax(L, nL);
        chmin(R, nR);
    }
    cout << max(R - L+1, 0LL);
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,x,y;
    cin>>n>>x>>y;
    vector <vector<lli> >adj(n+1);
    for(lli i=0;i<n-1;i++){
    	adj[i+1].pb(i+2);
    	adj[i+2].pb(i+1);
	}
	adj[x].pb(y);
	adj[y].pb(x);
		//cout<<"got here\n";
	lli dis[n+1][n+1];
	for(lli i=0;i<=n;i++){
		for(lli j=0;j<=n;j++)
		dis[i][j]=INT_MAX;
	}
	for(lli i=1;i<=n;i++){
		queue <lli> q;
		q.push(i);
		dis[i][i]=0;
		bool vis[n+1];
		rep(0,n+1)
		vis[i]=0;
		while(!q.empty()){
			lli x=q.front();
			q.pop();
			vis[x]=1;
			for(lli j=0;j<adj[x].size();j++){
				if(vis[adj[x][j]]==0){
					q.push(adj[x][j]);
					if(dis[i][adj[x][j]]>dis[i][x]+1){
						dis[i][adj[x][j]]=dis[i][x]+1;
					}
				}
			}
		}
	}
	lli ans[n+1];
	rep(0,n+1)
	ans[i]=0;
	for(lli i=1;i<=n;i++){
		for(lli j=i+1;j<=n;j++){
			ans[dis[i][j]]++;
		}
	}
	for(lli i=1;i<=n-1;i++)
	cout<<ans[i]<<"\n";
	return 0;
}


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

#define vi vector<int>
#define pb push_back

int main(){

    string n;
    cin >> n;
    cout << "ABC"+n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

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


int n, m, s, t;
vector<int> v[101010];
bool used[101010][3];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	cin >> s >> t;
	
	i64 ans = LINF;
	queue<P> q;
	q.push(P(s,0));
	while(!q.empty()){
		P p = q.front();
		q.pop();
		i64 now = p.first, cnt = p.second;
		if(used[now][cnt%3]) continue;
		used[now][cnt%3] = 1;
		if(now == t && cnt % 3 == 0){
			ans = min(ans, cnt/3);
		}
		for(int i = 0; i < v[now].size(); i++){
			q.push(P(v[now][i], cnt+1));
		}
	}
	
	if(ans == LINF) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}

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

const int maxN = 1e6 + 10;

int n, a[maxN + 1], t0, t2;
int t[maxN + 1];
char s[maxN + 1];

int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++) a[i] = s[i] - '0';

	for(int i = 1; i <= n - 1; i++) a[i] = abs(a[i] - a[i + 1]);
	n --;

	for(int i = 1; i <= n; i++)
	{
		int x = i;
		while(x) t[i] += x / 2, x /= 2;
	}

	bool fk = false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0) t0 ++;
		else if(a[i] == 2) t2 ++;
	if(t0 + t2 == n)
	{
		for(int i = 1; i <= n; i++) a[i] >>= 1;
		fk = true;
	}

	for(int i = 1; i <= n; i++) a[i] = (a[i] & 1);	

	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int x = t[n - 1] - t[i - 1] - t[n - i];
		if(!x) ans ^= (a[i] & 1);
	}

	if(fk) printf("%d", ans * 2);
	else printf("%d", ans);
	return 0;
}


Measured memory_bytes: 9088
n = int(input())
a_list = list(map(int,input().split()))
a_plus = {}
a_minus = {}
for i in range(1,n):
  a_minus[i] = 0
  
for i in range(n):
  minus = (i+1) - a_list[i]
  if 2 <= minus:
    a_minus[minus] += 1
  
count = 0

for j in range(n):
  plus = (j+1) + a_list[j]
  if plus <= n - 1:
    count += a_minus[plus]

    
print(count)

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

const int N = 1e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

int main()
{
	int q, h, s, d;
	scanf("%d%d%d%d", &q, &h, &s, &d);
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, 2 * s);
	int n;
	scanf("%d", &n);
	printf("%lld\n", n/2 * (long long)d + (n % 2) * s);
}


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

const ll mod = 1e9 + 7;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	map<char, int> dic;
	for (int i = 0; i < N; i++) {
		dic[S[i]] += 1;
	}
	ll res = 1;
	for (auto p : dic) {
		res = res * (p.second + 1) % mod;
	}
	cout << (res + mod - 1) % mod << endl;
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n,i,h,w;
  while(cin>>n&&n){
    vector<pair<double,int>> v(n);
    rep(j,n){
      cin >> i >> h >> w;
      v[j].fi = abs (22.0 - w / (h * h / 10000));
      v[j].se = i;
    }
    sort(all(v),[](const pair<double,int> &a,const pair<double,int> &b){
        if(a.fi == b.fi) return a.se < b.se;
        return a.fi < b.fi;
        });
    cout << v[0].se <<endl;
  }
  return 0;
}

Measured memory_bytes: 3232
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count=0;
		
		for(int i=1;i<10;i++) {
			for(int j=1;j<10;j++) {
				if(i*j==N) {
					count++;
				}
			}
		}
		
		if(count==0) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
		
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        if ( (i*a) % b == c ) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e9;

struct Vertex {
    vector<pll> node;
};

Vertex V[100005];
pll D[100005];
ll T[100005];
ll C[200005];
ll S[100005];

int main() {
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        cin >> D[i].first;
        D[i].second = i;
        T[i] = D[i].first;
    }
    sort(D, D + N, [](pll a, pll b) { return a.first < b.first; });
    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(pll(b, i));
        V[b].node.push_back(pll(a, i));
    }

    memset(C, 0, sizeof(C));
    memset(S, -1, sizeof(S));
    REP(i, N) {
        ll c = D[i].first;
        ll v = D[i].second;

        if (S[v] >= 0)
            continue;

        bool exist = false;
        REP(j, V[v].node.size()) {
            //! すでに色付けされている or 同じ最小コストで色付けされていないものを見つける
            ll n = V[v].node[j].first;
            if (S[n] >= 0) {
                exist = true;
                C[V[v].node[j].second] = c;
                S[v] = (S[n] + 1) % 2;
                break;
            }

            if (S[n] == -1 && T[n] == c) {
                exist = true;
                C[V[v].node[j].second] = c;
                S[v] = 0;
                S[n] = 1;
                break;
            }
        }

        if (!exist) {
            cout << -1 << endl;
            return 0;
        }
    }

    REP(i, M) {
        if (C[i] == 0)
            C[i] = INF;
    }

    REP(i, N) {
        if (S[i] == 0)
            cout << "B";
        else
            cout << "W";
    }
    cout << endl;
    REP(i, M) {
        cout << C[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 1000003
#define INF 1e9
void lcs(int m, int n, char *s , char *d){
    int i,j;
	int dp[m+1][n+1];
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			if(i==0 or j==0)
			dp[i][j]=0;
			else if(s[i-1]==d[j-1])
			dp[i][j] = dp[i-1][j-1] +1;
			else
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int index = dp[m][n];
	i =m;
	j=n;
	char ans[index+1];
	ans[index] = '\0';
	while(i>0 or j>0){
		if(s[i-1] == d[j-1]){
			ans[index-1]=s[i-1];
			i--;
			j--;
			index--;
		}else{
			if(dp[i-1][j]>dp[i][j-1]) i--;
			else j--;
		}
	}	
	cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,w,i,j,t,k,l,r;
   	char s[3001],d[3001];
   	scanf("%s",s);
   	scanf("%s",d);
   	lcs(strlen(s),strlen(d),s,d);
   	
 }

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin>>N;
  vector<ll> ans(N+1);
  ans[0]=2;
  ans[1]=1;
  for(int i=2;i<=N;i++){
    ans[i]=ans[i-1]+ans[i-2];
  }
  cout<<ans[N]<<endl;
}   

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
ll n,a,b;
cin>>n>>a>>b;
ll mi = a*(n-1)+b;
ll ma = b*(n-1)+a;
ll z=0;
cout<<max(ma-mi+1,z)<<endl;
}

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

int str[60][26];
int as[26];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < s.size(); j++) {
			str[i][s[j] - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++) {
		as[i] = 100000;
		for (int j = 0; j < n; j++) {
			as[i] = min(as[i], str[j][i]);
		}
	}
	string ans = "";
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < as[i]; j++) {
			ans.push_back(i + 'a');
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = int(input())
mod = 10**9+7
dp = [0 for i in range(s+1)]
dp[0]=1
x=0
for i in range(s+1):
    for j in range(i-3+1):
        dp[i]+=dp[j]
        dp[i]%=mod
"""
    if i>=3:
        x+=dp[i-3]
        x%=mod
"""
print(dp[s])

Measured memory_bytes: 65704
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    noX = S.replace('x','')
    if list(noX) == list(reversed(noX)):
        l = 0
        r = len(S)-1
        count = 0
        while l<r:
            if S[l] == S[r]:
                l += 1
                r -= 1
            else:
                if S[l] == 'x':
                    count += 1
                    l += 1
                else:
                    count += 1
                    r -= 1
        print(count)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10448