akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ll a, b;
    while(cin >> a >> b){
        if(a <= 0 && 0 <= b){
            puts("Zero");
        } else if(a > 0){
            puts("Positive");
        } else{
            ll c = b - a + 1;
            if(c % 2 == 1){
                puts("Negative");
            } else{
                puts("Positive");
                
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)
int main() {
    
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n; cin>>n;
    ll h[n+1],dp[n+1];
    for(ll i=1;i<=n;i++) cin >> h[i];
    dp[1]=0; dp[2]=abs(h[2]-h[1]);
    for(ll i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    cout<<dp[n];
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}

Measured memory_bytes: 1792
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p.at(i);  // 0-index

    int ans;
    int larger = X;
    int smaller = X;
    bool found;
    while (larger != 1000 && smaller != -1000) {
        
        found = false;
        rep(i, N) {
            if (smaller == p.at(i)) found = true;
        }
        if (!found) {
            ans = smaller;
            break;
        }
        smaller--;

        found = false;
        rep(i, N) {
            if (larger == p.at(i)) found = true;
        }
        if (!found) {
            ans = larger;
            break;
        }
        larger++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
  int l,j,N,flag,a,k,i,b;
  int A[100];
  scanf("%d",&N);
  if(N>=1 && N<=100)
    {
      for(l=0;l<N;l++)
	{
	  scanf("%d",&A[l]);
	}
      flag=1;
      i=0;
      while(flag)
	{
	  flag=0;
	  for(j=N-1;j>=i+1;j--)
	    {
	      if(A[j]<A[j-1])
		{
		  a=A[j];
		  A[j]=A[j-1];
		  A[j-1]=a;
		  b++;
		  flag=1;
        
	        }
	    }
	  i++;
	}
		  for(k=0;k<N;k++)
		    {
		      printf("%d",A[k]);
		      if(k<N-1)
			printf(" ");
		    }
		  
    }
		  
  printf("\n");
  printf("%d",b);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2144
n = int(input())
s,t = list(),list()

for i in range(n):
    s.append(input())

m = int(input())

for i in range(m):
    t.append(input())

s.sort()
t.sort()

s_ = set(s)
t_ = set(t)

s_,t_ = list(s_),list(t_)
st_ = s_ + t_
st = set(st_)

res_list = list(st)
lo = len(res_list)
res_co = [0]*lo

for i in range(lo):
    res_co[i] += s.count(res_list[i])
    res_co[i] -= t.count(res_list[i])

#point = res_co.index(max(res_co))
#print(res_list)
#print(res_co)
if max(res_co) >= 0:
    print(max(res_co))
else:
    print(0)



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

int main() {
long a,b,c,d=0;
  cin>>a>>b>>c>>d;
      if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))	cout<< "Yes" <<endl;
        else cout<< "No" <<endl;
}


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

#define ll long long

int main()
{
    ll N;
    std::string str = "";

    std::cin >> N;

    int count = 0;
    while(true) {
        bool flag = false;
        uint8_t c = 'a' + (N % 26) - 1;
        if((N % 26) == 0) {
            str += 'z';
            flag = true;
        }
        else {
            str += c;
        }
        N = N / 26;
        if(flag == true) {
            N = N-1;
        }

        if(N <= 0) {
            break;
        }
        if(N == 1 and (N % 26) == 0) {
            break;
        }
    }
    
    int size = str.size();
    for(int i=0; i < size; i++) {
        std::cout << str[size-1-i];
    }
    std::cout << std::endl;
    
}

Measured memory_bytes: 3636
n,x,y=map(int,input().split())
ans=[0]*(n-1)
t=[]
for i in range(1,n):
	for j in range(i+1,n+1):
		ans[min(j-i,abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)-1]+=1
for _ in ans:
	print(_)

Measured memory_bytes: 3444
import numpy as np
import math


H, W = map(int, input().split())

A = np.zeros((H, W), dtype=int)

for h in range(H):
    ah = input()
    for w in range(W):
        if ah[w] == '.':
            A[h][w] = 0
        else:
            A[h][w] = 1

# print(A)
remH = []
remW = []
            
for h in range(H):
    if all(A[h] == 0):
        remH.append(h)
for w in range(W):
    if all(A[:,w] == 0):
        remW.append(w)

# print(remH, remW)
        
ret = []

for h in range(H):
    if h in remH:
        continue
    hlist = []
    for w in range(W):
        if w in remW:
            continue
        # print(h)
        # print(w)
        # print(A[h][w])
        hlist.append(A[h][w])
    ret.append(hlist)

# print(ret)

retH = H - len(remH)
retW = W - len(remW)

# print(retH, retW)
for x in range(retH):
    for y in range(retW):
        if ret[x][y] == 0:
            print('.', end='')
        else:
            print('#', end='')            
    print()


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

const int N = 200 * 1000 + 20;
int p[N], n, ans = 1, mn;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	cin >> n;
  	for (int i = 0; i < n; i++)
      	cin >> p[i];
 	mn = p[0];
  	for (int i = 1; i < n; i++) {
		ans += (p[i] <= mn);
      	mn = min(mn, p[i]);
    }
  	return cout << ans << "\n", 0;
}


Measured memory_bytes: 1024
n = int(input())

A = [int(s) for s in input().split()]

cnt = 0
for i in range(n):
    mini = i
    for j in range(i, n):
        if A[j] < A[mini]:
            mini = j
    if i != mini:
        A[i], A[mini] = A[mini], A[i]
        cnt += 1

print(*A)
print(cnt)


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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  int sum = A+B;
  int sub = B-A;
  
  if(B%A==0) {
    
    cout << sum << endl;
    
  } else {
    
    cout << sub << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, W, w[110], v[110], dp[110][100100];

signed main()
{
    cin >> N >> W;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j - w[i] >= 0)dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            else dp[i + 1][j] = dp[i][j];
            ans = max(ans, dp[i + 1][j]);
        }
    }
    cout << ans << endl;

    return 0;
}
/*



*/



Measured memory_bytes: 79360
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define swap(Type, X, Y) {Type _tmp = (X); (X) = (Y); (Y) = _tmp;}
typedef long long ll;

ll gcd(ll x, ll y);
ll lcm(ll x, ll y);

int main()
{
    ll a, b, c, d;
    ll l;

    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    l = lcm(c, d);

    printf("%lld\n", (b - a + 1) -
           ((b / c) + (b / d) - (b / lcm(c, d))) +
           (((a - 1) / c) + ((a - 1) / d) - ((a - 1) / lcm(c, d))));

    return 0;
}

ll gcd(ll x, ll y)
{
    if (x < y) {
        swap(ll, x, y);
    }

    ll r;

    while (y) {
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

using namespace std;
#define int ll
using ll = long long;

signed main() {
	int N;
	cin >> N;

	int ans = -1;
	for (int i = 1; i*i <= N; i++) {
		if (N%i == 0) ans = i + N / i - 2;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;

public class Test
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        var b = a.OrderBy(x => x).ToArray();

        int pos = 0;
        long lastHeight = 0;

        for (int i = 0; i < N; i++)
        {
            long temp = 0;
            long height = Math.Max(lastHeight, a[i]);

            while (pos < N && b[pos] <= height)
            {
                temp += (b[pos] - lastHeight);
                pos++;
            }

            temp += (N - pos) * (height - lastHeight);

            lastHeight += (height - lastHeight);
            
            Console.WriteLine(temp);
        }
    }
}

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

int main() {
	int N, M;
  	cin >> N >> M;
  	vector<int> A(50);
  	vector<int> B(50);
  	for(int i = 0; i < M; i++){
      cin >> A[i] >> B[i];
    }
  	vector<int> road(50);
  	for(int i = 0; i < M; i ++){
      road[i] = 0;
    }
  	for(int i = 0; i < M; i ++ ){
      road[A[i] - 1 ] += 1;
      road[B[i] - 1 ] += 1;
    }
  	for(int i = 0; i < N; i++){
      cout << road[i] << endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }
    else if(abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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, m;
    cin >> n >> m;
    vector<vector<ll>> g(n), r(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        r[b].push_back(a);
    }
    vector<ll> ans(n + 1);
    rep(i, n) {
        queue<ll> q;
        vector<ll> dist(n, LONG_LONG_MAX);
        vector<ll> prev(n, LONG_LONG_MAX);
        q.push(i);
        dist[i] = 0;
        while(!q.empty()) {
            ll now = q.front(); q.pop();
            rep(ii, sz(g[now])) {
                ll next = g[now][ii];
                if (dist[next] <= (dist[now] + 1)) continue;
                dist[next] = dist[now] + 1;
                prev[next] = now;
                q.push(next);
            }
        }
        vector<ll> tmp;
        q.push(i);
        tmp.push_back(i);
        while(!q.empty()) {
            ll now = q.front(); q.pop();
            ll mi = -1, mv = LONG_LONG_MAX;
            rep(ii, sz(r[now])) {
                ll next = r[now][ii];
                if (mv <= dist[next]) continue;
                mv = dist[next];
                mi = next;
            }
            if ((mv == LONG_LONG_MAX) || (mi == i)) break;
            tmp.push_back(mi);
            q.push(mi);
        }
        if ((sz(tmp) == 1) || (sz(tmp) >= sz(ans))) continue;
        reverse(tmp.begin() + 1, tmp.end());
        ans = tmp;
    }
    if (sz(ans) == (n + 1)) {
        cout << -1 << endl;
    }
    else {
        cout << sz(ans) << endl;
        rep(i, sz(ans)) cout << (ans[i] + 1) << endl;
    }
    return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    int ans = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x >= k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = long.Parse(spl[0]);
        var b     = long.Parse(spl[1]);

        for(int i=0; i<=2000; i++) {
            if ((int)((double)i * 0.080) == a
                && (int)((double)i * 0.100) == b)
                return i;
        }

        return -1;
    }
}

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

int main(){
	double x,y;
	while(cin>>x){
		cin>>y;
		if(x<35.5 && y<71.0)cout<<"AAA"<<endl;
		else if(x<37.5 && y<77.0)cout<<"AA"<<endl;
		else if(x<40.0 && y<83.0)cout<<"A"<<endl;
		else if(x<43.0 && y<89.0)cout<<"B"<<endl;
		else if(x<50.0 && y<105.0)cout<<"C"<<endl;
		else if(x<55.0 && y<116.0)cout<<"D"<<endl;
		else if(x<70.0 && y<148.0)cout<<"E"<<endl;
		else cout<<"NA"<<endl;
		}
	return 0;
}

Measured memory_bytes: 1220
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;



	return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S == "A" || S == "B" || S == "C" || S == "D" || S == "E"){
    cout << 'A' << endl; }
  else if(S == "F" || S == "G" || S == "H" || S == "I" || S == "J"){
    cout << 'A' << endl; }
  else if(S == "K" || S == "L" || S == "M" || S == "N" || S == "O"){
    cout << 'A' << endl; }
  else if(S == "P" || S == "Q" || S == "R" || S == "S" || S == "T"){
    cout << 'A' << endl; }
  else if(S == "U" || S == "V" || S == "W" || S == "X" || S == "Y" || S == "Z"){
    cout << 'A' << endl; }
  else{
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3528
import java.util.Scanner;

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

        int N = sc.nextInt();

        System.out.println(solve(N) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int N) {
        return N % String.valueOf(N).chars().map(ch -> ch - '0').sum() == 0;
    }
}

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


void solve(long long N, std::string S){
  for (auto &&c : S) {
    c += N;
    if (c > 'Z') 
      c = (c - 'A') % 26 + 'A';
  }
  std::cout << S << std::endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
def bellman_ford(s):
    '''
    始点sから各頂点への最短距離を求める (重み付き有向グラフ)
    '''
    dist = [float('inf')] * v
    dist[s] = 0
    neg = [False] * v

    for i in range(v):
        for p, q, cost in edge:
            if dist[p] != float('inf') and dist[q] > dist[p] + cost:
                dist[q] = dist[p] + cost
    
    for i in range(v):
        for p, q, cost in edge:
            if dist[p] != float('inf') and dist[q] > dist[p] + cost:
                dist[q] = dist[p] + cost
                neg[q] = True
            if neg[p]:
                neg[q] = True

    if neg[v-1]:
        return False
    else:
        return -dist[v-1]


v, e = map(int, input().split())

edge = []
for _ in range(e):
    s, t, d = map(int, input().split())
    edge.append([s-1, t-1, -d])

res = bellman_ford(0)

if not res:
    print('inf')
else:
    print(res)

Measured memory_bytes: 75864
n = int(input())
a_list = list(map(int, input().split()))

count = 0
l = 0
r = 0

sum_num = a_list[0]
xor_num = a_list[0]

while l < n and r < n:
    if sum_num == xor_num:
        count += r - l + 1
        r += 1
        if r < n:
            sum_num += a_list[r]
            xor_num ^= a_list[r]
    else:
        if l < n :
            sum_num -= a_list[l]
            xor_num ^= a_list[l]
        l += 1


print(count)

Measured memory_bytes: 24424
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
    string s;
    int ans=0;
	cin >> n>>s;
    int trmax = n/2;
    int hajime=0;
    for(int i = 1;i<=trmax;i++){
      bool end = true;
      bool tugi = false;
      for(int j = hajime;j<=n-2*i;j++){
        for(int k=j+i;k<=n-i;k++){
          if(s.substr(j, i)==s.substr(k, i)){
            if(hajime<j)hajime=j;
            ans = i;
            tugi = true;
            end = false;
            trmax = min(trmax,max(k-j,n-k));
            break;
          }
        }
      if(tugi)break;
      }
    if(end)break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
       #define int long long
        #define inf  100000000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

 
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int dis[105][105];
int a[105][105];
signed main(){
	int V,E;
cin>>V>>E;
	for(int i=0;i<V;i++)for(int j=0;j<V;j++) dis[i][j]=inf,a[i][j]=inf;
	for(int i=0;i<V;i++) dis[i][i]=0;
	for(int i=0;i<E;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		dis[y][yy]=yyy;
		a[y][yy]=yyy;
	}
	
	
	for(int i=0;i<V;i++)for(int j=0;j<V;j++)for(int k=0;k<V;k++){
		if(dis[j][i]!=inf && dis[i][k]!=inf)dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k]);
	}
	
	for(int i=0;i<V;i++){
		if(dis[i][i]<0) {
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
	}
	
	
	for(int i=0;i<V;i++){
		if(dis[i][0]<inf )cout<<dis[i][0];
		else cout<<"INF";
		for(int j=1;j<V;j++){
			if(dis[i][j]<inf) cout<<" "<<dis[i][j];
			else cout<<" INF";
		}
		cout<<endl;
	}
	return 0;
	
        }

Measured memory_bytes: 1332
from collections import Counter

N = int(input())
nums = list(map(int, input().split()))

A = [i + n for i, n in enumerate(nums, start=1)]
B = [j - n for j, n in enumerate(nums, start=1)]
BC = Counter(B)
answer = 0
for a in A:
  answer += BC[a]
print(answer)

Measured memory_bytes: 146496
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll bestsat = -1;

    srand(time(NULL));
    vector<ll> best(d,0);
    ll times = 100000;
    while(times--){
        ll sat = 0;
        vector<ll> ans(d,0);
        rep(i,d){
            ans.at(i) = (rand() % 26) + 1;
        }
            for(int i=1;i<=d;i++){
                ll t = ans.at(i-1);
                t--;
                last.at(t) = i;
                sat += s.at(i-1).at(t);
                for(int j=0;j<26;j++){
                    sat -= c.at(j) * (i - last.at(j));
                }
                //cout << sat << endl;
                if(sat>bestsat){
                    bestsat = sat;
                    best = ans;
                }
            }
    }

    rep(i,d){
        cout << best.at(i);
        if(i<d-1) cout << endl;
    }
  
    //cout << bestsat << endl;

    /*
    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
using namespace std;
 
int main(){
	long long s;
	cin>>s;
	
	const int v=1000000000;
	
	int x=(v-s%v)%v;
	int y=(s+x)/v;
	
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "6 2 4" ].solve == 2 );
	assert( [ "7 4 3" ].solve == 1 );
	assert( [ "10 1 2" ].solve == 8 );
	assert( [ "1000000000000000 1000000000000000 1000000000000000" ].solve == 1000000000000000 );
}



import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = 0L;
	auto k = 0L;
	auto d = 0L;
	input.front.formattedRead!"%s %s %s"( x, k, d );
	
	auto c = abs( x / d );
	if( k <= c )
	{
		if( 0 < x ) return abs( x - d * k );
		else        return abs( x + d * k );
	}
	else
	{
		k -= c;
		if( 0 < x ) return abs( x - d * ( c + ( k % 2 ) ) );
		else        return abs( x + d * ( c + ( k % 2 ) ) );
	}
}


Measured memory_bytes: 2928
#include<iostream>
#include<string>

using namespace std;

int main() {
  int h, w;
  bool res=true;
  cin >> h >> w;
  string board[50];
  int dx[4] = {0,-1,1,0};
  int dy[4] = {1,0,0,-1};
  for(int i=0;i<h;i++) cin >> board[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j] == '#'){
        bool can=false;
        for(int k=0;k<4;k++){
          int nj = j + dx[k];
          int ni = i + dy[k];
          if((ni >= 0 && ni < h) && (nj >= 0 && nj < w) && (board[ni][nj] == '#')) can=true;
        }
        if(!can) res=false;
      }
    }
  }
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
class Main{
  public static void main(String[] args)throws IOException{
      
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
  
    String[] strAry = str.split(" ");
    int a = Integer.parseInt(strAry[0]);
  	int b = Integer.parseInt(strAry[1]);
  	
  	if (a > b) {
  		System.out.println( "a > b");
  	}
  	else if( a == b) {
  		System.out.println( "a == b");
  	}
  	else System.out.println( "a < b");
  	
  } 
}

Measured memory_bytes: 24160
s = input()
s1 = s[::2]
s2 = s[1::2]
s1 = s1.replace('R','')
s1 = s1.replace('U','')
s1 = s1.replace('D','')
s2 = s2.replace('L','')
s2 = s2.replace('U','')
s2 = s2.replace('D','')
if s1 == '' and s2 == '':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
/*
  Task: I. Kevin and Grid
  Link: http://codeforces.com/contest/1392/problem/I
  Lang: cpp17
*/
#include <bits/stdc++.h>
using namespace std;

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)


using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T>& val) {
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T>& val) {
  return val.first + val.second;
}


template <typename T>
T min(T a, T b, T c) {
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c) {
  return max(max(a, b), c);
}


template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
sort(a.begin(), a.end(), [ ](ll& lhs, ll& rhs) {return abs(lhs) < abs(rhs);});
*/


class mytask {
public:

  mytask() { }

  
  int solve() {

    string s, t;
    cin >> s >> t;

    ll min_changes = t.size();
    for (ll i = 0; i <= s.size() - t.size(); i++) {
      ll cur_changes = 0;
      for (ll j = 0; j < t.size(); j++) {
        if (s[i + j] != t[j]) cur_changes++;
      }
      min_changes = min(min_changes, cur_changes);

    }

    cout << min_changes;
    
    return 0;
  }

   

};


int main() {

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

  auto task = mytask();
  task.solve();


  //cout << endl;

  return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題160

            string[] line = Console.ReadLine().Split(' ');

            long k = int.Parse(line[0]);
            long n = int.Parse(line[1]);

            string[] line2 = Console.ReadLine().Split(' ');

            long[] a = new long[n];
            for (long i = 0; i < n; i++)
            {
                a[i] = long.Parse(line2[i]);
            }

            long longest = Math.Min(k - a[n-1] + a[0], a[n-1] - a[0]);

            //Console.WriteLine(longest);

            //最長の組み合わせ
            //long[,] kumi = new long[n, 2];

            for (int i = 0; i < n - 1; i++)
            {
                //if (longest < )
                longest = Math.Max(longest, a[i + 1] - a[i]);
            }

            Console.WriteLine((k - longest));
        }

    }





    
}


Measured memory_bytes: 43860
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;
typedef long long LL;
 
LL A, B, C, D;
map<LL, LL> memo;
LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;
 
    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));
 
    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));
 
    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));
 
    memo[N] = res;
 
    return res;
}
 
int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}

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

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int score=0;
  rep(i,n-1){
    if(s[i] == s[i+1]) score++;
  }
  int ans = min (score+2*k,n-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for(int i=1;i<=n;i++)
		if(i % 3 != 0 && i % 5 != 0)
			sum += i;
	cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 3636
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    
	ll h,n;
	cin>>h>>n;
	ll ar[n];
	ll sum=0;
	rep(i,0,n)
	{
		cin>>ar[i];
		sum+=ar[i];
	}
	if(sum>=h)
		cout<<"Yes";
	else
		cout<<"No";
}
//Goodbye...

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct UF{
    int n;
    //正だったらその頂点の親,負だったら根で連結成分の個数
    vector<int> d;
    UF() {}
    UF(int N):n(N), d(N,-1){}
    int root(int v){
        if(d[v]<0) return v;
        return d[v]=root(d[v]);
    }
    bool unite(int X,int Y){
        X=root(X); Y=root(Y);
        if(X==Y) return false;
        if(size(X) < size(Y)) swap(X,Y);
        d[X]+=d[Y];
        d[Y]=X;
        return true;
    }
    int size(int v){ return -d[root(v)]; }
    bool same(int X,int Y){ return root(X)==root(Y); }
};

vector<int> f(int x){
    vector<int> ret;
    int t = x;
    for(int i=2; i*i<=x; ++i){
        if(t%i==0){
            ret.pb(i);
            while(t%i==0) t/=i;
        }
    }
    if(t>1) ret.pb(t);
    return ret;
}

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

    map<int,vector<int>> m;
    rep(i,n){
        vector<int> d = f(a[i]);
        for(int j:d) m[j].pb(i);
    }

    UF uf(n);
    for(const auto &p:m){
        int k = p.fi;
        vector<int> v = p.se;
        int V = v.size();
        rep(i,V) uf.unite(v[0],v[i]);
    }

    vector<int> sa(a);
    sort(all(sa));
    map<int,int> pos;
    for(int i=n-1; i>=0; --i) pos[sa[i]] = i;

    int ans = 1;
    rep(i,n){
        int v = a[i];
        int p = pos[v];
        if(!uf.same(i,p)){
            ans = 0;
            break;
        }
        ++pos[v];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10940
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int main(){
    int N, M;
    std::cin >> N >> M;

    int max_M = M;
    REP(i, N){
        int in, out;
        std::cin >> in >> out;

        M += in - out;
        if(M < 0){
            max_M = -1;
        }else if(max_M != -1){
            max_M = std::max(max_M, M);
        }
    }

    if(max_M == -1){
        std::cout << 0 << std::endl;
    }else{
        std::cout << max_M << std::endl;
    }
}

Measured memory_bytes: 1160
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int N;
  cin >> N;
  vector<vector<bool>> d(N + 1, vector<bool>(N + 1, false));
  vector<int> cnt(N + 1, 0);
  for (int i = 1; i <= N; i += 2) {
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        d[i][j] = true;
        d[i][i / j] = true;
      }
    }
    cnt[i] = count(d[i].begin(), d[i].end(), true);
  }

  cout << count(cnt.begin(), cnt.end(), 8) << endl;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define REP(N) for(int i = 0; i < N; i++)
using namespace std;

int main(){
  int N, A, B; cin >>N >>A >>B;
  int a = N * A, b = B;
  cout <<(a > b ? b : a) <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cerr<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

const double pi = acos(-1);
int main(){
    double a,b;cin >> a >> b;
    int h,m;cin >> h >> m;
    double big = (double)(h*60+m) / (12*60);
    double small = (double)m/60;

    call(big);
    call(small);
    call(pi);
    big *= pi*2;
    small *= pi*2;
    call(big);
    call(small);
    double theta = big - small;
    call(theta);


    double ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
    cout << fixed << setprecision(12) << ans << endl;
}

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

int main(){
    const int w[10]={1,2,4,8,16,32,64,128,256,512};
    int n;
    
    while(cin >> n){
        int nw[10]={0};
        int cnt=0;
        
        for(int i = 0 ; w[i] <= n ; i++){
            nw[i] = w[i];
            cnt++;
        }
        
        int sum = 0;
        int nnw[10]={0};
        int k = 0;
        int m = n;
        for(int i = 0 ; i < cnt ; i++){
            for(int j = cnt-1 ; j >= 0 ; j--){
                
                if(sum == n) break;
                
                if(nw[j] <= m){
                    nnw[k++] = nw[j];
                    sum += nw[j];
                    m -= nw[j];
                }
            }
            if(sum == n) break;
        }
        sort(nnw,nnw+k);
        
        for(int i = 0 ; i < k ; i++){
            if(i == 0) cout << nnw[i];
            else cout << ' ' << nnw[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#define MAX_R (1000000000)

int main(void)
{
    int N;
    std::cin >> N;
    long *arr;
    arr = new long[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> arr[i];
    }

    long max_diff = -MAX_R;
    long min = arr[0];

    for (int i = 1; i < N; ++i) {
        max_diff = std::max(max_diff, arr[i] - min);
        min = std::min(min, arr[i]);
    }

    std::cout << max_diff << std::endl;
    return 0;
}





Measured memory_bytes: 4644
#include<iostream>

using namespace std;

int main(){
	long long h,w;
  	cin >> h >> w;
  	if(h == 1 || w ==1)
      cout << 1;
  	else if((h * w) % 2L == 0L){
    	cout << (h * w) / 2L;
    }else if((h*w)%2L==1L){
    	cout <<  ((h * w) / 2L) + 1L;
    }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& s) {
	for (auto i : s) os << i << ' ';
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, map<T, S>& m) {
	for (auto i : m) os << i << ' ';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

int getPow(int a) {
	for (int i = 1; i < 1e18; i *= 2) {
		if (a < i) { return i; }
	}
	return -1;
}

void decElement(map<int, int>& m, int a) {
	m[a]--;
	if (m[a] == 0) m.erase(a);
}

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

	map<int, int> m;
	rep(i, n) {
		int a;
		cin >> a;
		m[a]++;
	}

	int ans = 0;
	while (not m.empty()) {
		int a = (--m.end())->first;
		decElement(m, a);

		auto b = getPow(a) - a;
		if (m.count(b)) {
			decElement(m, b);
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int a[202020];
int pos[202020];

signed main()
{
    cin >> N;

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

    set<int> s;
    s.insert(-1);
    s.insert(N);
    int ans = 0;

    for (int i=1; i<=N; i++) {
        s.insert(pos[i]);
        auto it = s.find(pos[i]);
        --it;
        int left = *it;
        ++it;
        ++it;
        int right = *it;
        //cout << "pos[" << i << "] = " << pos[i] << endl;
        //cout << "left = " << left << endl;
        //cout << "right = " << right << endl;
        ans += i * (pos[i] - left) * (right - pos[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 12800
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int get_bit(int x,int v){return (x>>v)&1;}
int tr[8][8];
LL dp[101][8];
int main(){
    int h,w,k;
    R(h,w,k);
    REP(i,1<<(w-1)){
        bool err=0;
        REPP(j,1,w-1){
            if(get_bit(i,j)&&get_bit(i,j-1))err=1;
        }
        if(err)continue;
        REP(j,w){
            if(get_bit(i,j))tr[j][j+1]++;
            else if(j&&get_bit(i,j-1))tr[j][j-1]++;
            else tr[j][j]++;
        }
    }
    dp[0][0]=1;
    FOR(i,1,h){
        REP(j,w)REP(r,w){
            ADD(dp[i][r],dp[i-1][j]*tr[j][r]);
        }
    }
    W(dp[h][k-1]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mincostrecursion(int A[],int i,int N,int k)
{
  if(i==N-1)
  {
    return 0;
  }
  long long c,mi = INT_MAX;

  //cout<<i<<"\n";
  //cout<<"\n";
  for(int j=1;j<=k;j++)
  {
    if((i+j)<N)
    {
      c= abs(A[i]-A[i+j])+mincostrecursion(A,i+j,N,k);
    //  cout<<i<<" "<<i+j<<" "<<c<<" ;\n";
      if(mi>c)
      {
        mi = c;
      }

    }
  }
//cout<<"\n Choice of "<<i<<" "<<mi<<" \n";
  return mi;

}

long long mincostdp(int A[],int N,int k)
{
  long long mi,c;

  long long *Dp = new long long[N];
  for(int i=N-1;i>=0;i--)
  {
    if(i==N-1)
    {
      Dp[i]=0;
    }
    else
    {
      mi = INT_MAX;
      for(int j=1;j<=k;j++)
      {
        if((i+j)<N)
        {
          if(mi>(Dp[i+j]+abs(A[i]-A[i+j])))
          {
            mi = (Dp[i+j]+abs(A[i]-A[i+j]));
          }
        }
        Dp[i] = mi;
      }

    }


  }


  return Dp[0];
}

main()
{
  int N,k;
  cin>>N>>k;
  int *A = new int[N];
  for(int i=0;i<N;i++)
  {
    cin>>A[i];

  }

  cout<<mincostdp(A,N,k);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100010];
int n,sg[100010],u,v;

void dfs(int u,int fa)
{
    for(auto v : edge[u])
    {
        if(v==fa)continue;
        dfs(v,u);
        sg[u]^=sg[v]+1;
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;++i)
    {
        scanf("%d%d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,0);
    puts(sg[1]?"Alice":"Bob");
}

Measured memory_bytes: 12416
S = list(str(input()))
Q = int(input())

state = 0
start = []
end = []

for i in range(Q):
    x = list(input().split())
    if x[0] == "1":
        state = (state+1)%2
    else:
        x[1] = int(x[1])
        if (state + x[1]) % 2 == 1:
            start.append(x[2])
        else:
            end.append(x[2])

if state == 0:
    start.reverse()
    ans = start + S + end
    
else:
    end.reverse()
    S.reverse()
    ans = end + S + start

print("".join(ans))


Measured memory_bytes: 9888