akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		long arr[] = new long[n];
		int zero = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
			if (arr[i] == 0)
				zero++;
		}
		if (zero > 0) {
			System.out.println(0);
			return;
		}
		long prod = 1;
		boolean flag = false;
		for (int i = 0; i < n; i++) {
			if (arr[i] <= ((long)Math.pow(10, 18)) / prod) {
				prod = prod * arr[i];
			} else {
				System.out.println(-1);
				flag = true;
				break;
			}
		}
		if (!flag) {
			System.out.println(prod);
		}



	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

Measured memory_bytes: 48792
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int x,y;
  cin >> x >> y;

  int gr[] = {1,3,1,2,1,2,1,1,2,1,2,1};

  if (gr[x-1] == gr[y-1]) pr("Yes");
  else pr("No");


  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 1000005;

int see[N], cnt[N], p[N], v[N];

int main(){
	fastio;
	int n, pairwise = 1, setwise = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		setwise = __gcd(setwise, v[i]);
		see[v[i]]++;
	}
	for(int i = 2; i < N; i++){
		if(!p[i]){
			cnt[i] += see[i];
			if(cnt[i] > 1)pairwise = 0;
			for(int j = i+i; j < N; j+=i){
				cnt[i]+=see[j];
				if(cnt[i] > 1) pairwise = 0;
				p[j] = 1;
			}
		}
	}
	if(pairwise){
		cout << "pairwise coprime\n";
	} else if(setwise == 1){
		cout << "setwise coprime\n";
	} else cout << "not coprime\n";
	return 0;
}


Measured memory_bytes: 19040
#include <iostream>

using namespace std;

int main(){
  int N, i, white=0, black=0, min, white2, black2;
  cin >> N;
  char S[N];
  for(i=0; i<N; i++) cin >> S[i];
  for(i=0; i<N; i++){
    if(S[i] == '.') white++;
    else black++;
  }
  min = white;
  black2 = 0;
  white2 = white;
  for(i=0; i<N; i++){
    if(S[i] == '.') white2--;
    if(S[i] == '#') black2++;
    if(min > white2 + black2){
      min = white2 + black2;
    }
  }
  if(min > black) min = black;
  cout << min << endl;
  return 0;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int x,i,j,a,b;
    bool y=false;
    long long int A[120];
    for(i=0;i<120;i++){
        A[i]=i;
        for(j=1;j<5;j++){
            A[i]*=i;
        }
    }
    cin>>x;
    for(i=0;i<120;i++){
        for(j=i+1;j<120;j++){
            if(-A[i]-(-A[j])==x){
                a=j;
                b=i;
                y=true;
                break;
            }
            else if(A[i]-(-A[j])==x){
                a=i;
                b=-j;
                y=true;
            }
        }
        if(y==true)
            break;
    }
    cout<<a<<" "<<b;
    return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  double a;
  while (cin >> a) {
    double ans = a;
    for (int i = 2; i <= 10; i++) {
      if (i & 1) a /= 3;
      else a *= 2;
      ans += a;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for(int i = 0; i < N;i++){
            t.add(sc.nextInt());
        }

        int M = sc.nextInt();
        int sum = 0;
        for(int i = 0;i < N;i++){
            sum += t.get(i);
        }
        for(int i = 0;i < M;i++){
            int p = sc.nextInt();
            int x = sc.nextInt();
            System.out.println(sum + x - t.get(p-1));
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;
 
int state[N];
int dp[5000][1005];
 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    
    
    int n;
    cin>>n;
    bool f=0;
    for(int i=1;i<10;i++) {
        for(int j=1;j<10;j++) {
            if(i*j==n) {
                f=1;
            }
        }
    }

    if(f) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int h,w,K;
vvi field;

void Make(int x,vvi& c){
	vi a;
	for(int i=0;i<h;i++){
		if(c[x][i]) a.push_back(c[x][i]);
	}
	for(int i=0;i<h;i++){
		if(i>=a.size()) c[x][i]=0;
		else c[x][i]=a[i];
	}
}

int main(){
	cin>>h>>w>>K;
	field=vvi(w,vi(h));
	vvc C(w,vc(h));
	for(int i=h-1;i>=0;i--) for(int j=0;j<w;j++) cin>>C[j][i];
	for(int i=h-1;i>=0;i--) for(int j=0;j<w;j++) field[j][i]=C[j][i]-'0';
	int ans=0;
//	cout<<endl;
	for(int i=0;i<w;i++) for(int I=0;I<h;I++){
		int M=0,tmp=1;
		vvi c(w,vi(h));
		for(int j=h-1;j>=0;j--) for(int k=0;k<w;k++) c[k][j]=field[k][j];
		c[i][I]=0;
		Make(i,c);/*
		if(i==2){for(int j=h-1;j>=0;j--){
			for(int k=0;k<w;k++) cout<<c[k][j];
			cout<<endl;
		}cout<<endl;}*/
		while(1){
			int sum=0;
			bool flag=0;
			for(int j=0;j<h;j++){
				vi a(w);
				for(int k=0;k<w;k++) a[k]=c[k][j];
				int s=0;
/*				if(i==2){for(int k=0;k<w;k++) cout<<a[k]<<' ';
				cout<<endl;}*/
				for(int k=1;k<w;k++){
					if(a[k]!=a[k-1]){
						if(k-s>=K){
							sum+=(k-s)*a[s];
							for(int l=s;l<k;l++) a[l]=0;
							flag=1;
						}
						s=k;
						if(!a[k]) s++;
					}
					else if(!a[k]) s=k+1;
				}
				if(a[w-1]&&w-s>=K){
					sum+=(w-s)*a[s];
					for(int k=s;k<w;k++) a[k]=0;
					flag=1;
				}
/*				if(i==2){for(int k=0;k<w;k++) cout<<a[k]<<' ';
				cout<<endl;}*/
				for(int k=0;k<w;k++) c[k][j]=a[k];
			}
//			cout<<'B'<<sum<<endl;
/*			if(i==2){for(int j=h-1;j>=0;j--){
				for(int k=0;k<w;k++) cout<<c[k][j];
				cout<<endl;
			}cout<<endl;}*/
			if(!flag) break;
			for(int j=0;j<w;j++) Make(j,c);
			M+=tmp*sum;
//			if(i==2) cout<<'A'<<M<<endl;
			tmp*=2;
		}
//		cout<<M<<endl;
		ans=max(ans,M);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// split??¢??° (1?????????????????§?????????????????????????????§??????????????????)
vector<string> split(string s, char c) {
    vector<string> ret;
    string temp;
    replace(s.begin(), s.end(), c, ' ');
    stringstream ss(s);
    while(ss >> temp) ret.pb(temp);
    return ret;
}

string s;
int res;
signed main() {
    cin >> s >> res;
    int a = 0, b = 0;
    // multiplication-first rule
    vector<string> cls = split(s, '+');
    rep(i,0,cls.size()) {
        int temp = 1;
        rep(j,0,cls[i].length()) {
            if(cls[i][j] != '*') temp *= (cls[i][j] - '0');
        }
        a += temp;
    }

    // left-to-right rule
    rep(i,0,s.length()) {
        if(i == 0) b += (s[i] - '0');
        else if(s[i] == '+') b += (s[i+1] - '0');
        else if(s[i] == '*') b *= (s[i+1] - '0');
    }

    if(res == a && res == b) cout << "U" << endl;
    if(res != a && res == b) cout << "L" << endl;
    if(res == a && res != b) cout << "M" << endl;
    if(res != a && res != b) cout << "I" << endl;
    return 0;
}

Measured memory_bytes: 3228
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"No";
	else
	cout<<"Yes";
}


void bta_de_yarr(){

	ll n, i, j, m, ans, fl=0;

    cin>>n;

    ans= (n/500)*1000 ;
    n%= 500;

    ans+= ((n/5)*5);

    

	cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t, i;
    t= 1;
	// cin>>t;
    
    rep(i, 1, t+1){

        // cout<<"Case #"<<i<<":"<<" ";
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

const int mxn = 5e5;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

ll iv[mxn + 1], f1[mxn + 1], f2[mxn + 1];
ll nck(int n, int k)
{
	return f1[n] * f2[k] % M * f2[n - k] % M;
}

int main()
{
	fast;
	int n, x, t;
	cin >> n >> x >> t;
	cout << (int)ceil((double)n / x) * t;
}

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

namespace atcoder.abc166.a
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("ABC" == getStringParam() ? "ARC" : "ABC");
        }

        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
        static decimal getDecimalParam()
        {
            return decimal.Parse(Console.ReadLine());
        }
        static decimal[] getDecimalParams()
        {
            return Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
        }
    }
}


Measured memory_bytes: 25884
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

bool cmp(const pii &a, const pii &b) //セカンドキー->ファーストキーの順ソート
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int main(void)
{
    int n;
    cin >> n;
    vll a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];

    ll ans = 0;
    repm(i, n - 1, 0)
    {
        //cout << ans << " " << ((a[i] + ans - 1) / b[i] + 1) * b[i] << endl;
        if ((a[i] + ans) % b[i])
            ans += b[i] - (a[i] + ans) % b[i];
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long> vll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpll;

#define F first
#define S second
#define PB push_back
#define MP make_pair

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


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


int main()
{
    int P, Q, R;
    cin >> P >> Q >> R;
    vector<int> v(3);
    v[0]= P;v[1]=Q;v[2] = R;
    sort(v.begin(),v.end());
    cout << v[0]+v[1];
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


vector<ll> dp;
vector<ll> pre; /// preprocessing
const int nax = 16;
ll cap[nax][nax];

const ll inf = 1e18L + 5;


void rec(int i, vector<int>& not_taken, int mask, ll sum_so_far, int group){
    if(i == (int)not_taken.size()){
        dp[mask] = max(dp[mask], sum_so_far + pre[group]);
        return;
    }

    rec(i + 1, not_taken, mask, sum_so_far, group);
    rec(i + 1, not_taken, mask ^ (1<<not_taken[i]),
        sum_so_far, group ^ (1<<not_taken[i]));
}


void solve(){
    int n;
    cin>>n;
    dp.resize((1<<n), -inf);
    pre.resize((1<<n));
    /// dp[mask] - maximum possible total score with rabbits in mask already being grouped
    /// pre[mask] - total score with all rabbits in the mask in 1 group
    dp[0] = 0;
    fr(i, n){
        fr(j, n){
            cin>>cap[i][j];
        }
    }

    for(int mask = 0; mask < (1<<n); ++mask){
        for(int i=0; i<n; i++){
            if(mask & (1<<i)){
                for(int j=i+1; j<n; j++){
                    if(mask & (1<<j)){
                        pre[mask] += cap[i][j];
                    }
                }
            }
        }
    }

    for(int mask = 0; mask < (1<<n); ++mask){
        vector<int> not_taken;
        for(int i=0; i<n; i++){
            if(!(mask & (1<<i)))
                not_taken.push_back(i);
        }

        /// recurse over different possible combinations of putting elements among not_taken rabbits in 1 group
        rec(0, not_taken, mask, dp[mask], 0);
    }

    cout<<dp[(1<<n) - 1];
}

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

    solve();

    return 0;
}



Measured memory_bytes: 1280
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        if(X < A){
            System.out.println(0);
        }else if(X >= A){
            System.out.println(10);
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int MAX=10;

string S;
int a,b,c,d,H,W,last;
char f[MAX][MAX];

void solve(){
    H=W=0;
    for (char c:S){
        if (c=='/') ++H,W=0;
        else if (c=='b'){
            f[H][W++]='b';
        } else for (int i=0;i<c-'0';++i) f[H][W++]='.';
    }
    f[--a][--b]='.'; f[--c][--d]='b';
    for (int i=0;i<H+1;++i){
        last=-1;
        for (int j=0;j<W;++j) if (f[i][j]=='b'){
            if (j-last-1) cout << j-last-1;
            cout << 'b';
            last=j;
        }
        if (W-last-1) cout << W-last-1;
        if (i!=H) cout << '/';
    }
    cout << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> S,S!="#"){
        cin >> a >> b >> c >> d;
        solve();
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long;

auto main() -> int
{
	int N; cin >> N;
	N %= 100;
    N %= 10;
    
    if(N==3)
  	  cout << "bon" << "\n";
    
    else if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
      cout << "hon" << "\n";
      
    else cout << "pon" << "\n";
       
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	char s[1000006],s2[1000006];
	int n,sum=0,j;
	cin>>n>>s;
	int len=strlen(s);
	strcpy(s2,s);
	sort(s,s+len);
	for(int i=0;i<=len;++i)
	{
		if(s[i]!=s2[i])
		sum++;
	}
	cout<<sum/2<<endl;
} 

Measured memory_bytes: 4056
mod = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

if n == k:
    ans = 1
    for i in a:
        ans *= i
        ans %= mod
    print(ans)
    exit()

m = []
p = []
zero = 0
for i in a:
    if i < 0:
        m.append(-i)
    elif i > 0:
        p.append(i)
    else:
        zero += 1

if n - k < zero:
    print(0)
    exit()

if n - k == zero:
    if len(m) % 2 == 1:
        print(0)
        exit()

if len(p) == 0 and k % 2 == 1:
    if zero >= 1:
        print(0)
    else:
        m.sort()
        ans = 1
        for i in range(k):
            ans *= m[i]
            ans %= mod
        ans = mod - ans
        print(ans % mod)
    exit()

m.sort(reverse=True)
p.sort(reverse=True)
nm = 0
np = 0
ans = 1
if k % 2 == 1:
    ans *= p[0]
    np += 1
lap = k // 2

while nm < len(m) - 1 and np < len(p) - 1 and lap > 0:
    lap -= 1
    i = m[nm] * m[nm + 1]
    j = p[np] * p[np + 1]
    if i > j:
        ans *= i
        ans %= mod
        nm += 2
    else:
        ans *= j
        ans %= mod
        np += 2

if lap > 0:
    if nm < len(m) - 1:
        for i in range(nm, nm + lap * 2):
            ans *= m[i]
            ans %= mod
    else:
        for i in range(np, np + lap * 2):
            ans *= p[i]
            ans %= mod

print(ans % mod)

Measured memory_bytes: 107324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/
/*ll lcs(string a,string b,ll n,ll m){
    ll dp[n+1][m+1];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0|| j==0)
                dp[i][j]=0;
            else if(a[i]==b[j])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    return dp[n][m];

}*/
/*ll editDist(string a,string b,ll n,ll m){
    vector<vector<ll> >dp(n+1,vector<ll>(m+1,-1));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0)
                dp[i][j]=j;
            else if(j==0)
                dp[i][j]=i;
            else if(a[i]==b[j])
                dp[i][j]=dp[i-1][j-1];
            else{
                dp[i][j]=1+min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]));
            }
        }
    }
    return dp[n][m];
}*/

/*ll d1(vector<string>a,ll n,ll m,vector<vector<ll> >dp){
    if(n<0 || m<0 ) return 0;
    if(n==0 && m==0) return 0;
    if(a[n][m]=='#') dp[n][m]=0;
    if((n==0 &&m==1) || (m==0&&n==1)) return 1 ;
    if(dp[n][m]!=-1)
        return dp[n][m];

    dp[n][m]=d(a,n-1,m,dp)+d(a,n,m-1,dp);
    return dp[n][m];
}*/
ll solve(ll a[],ll n){
    ll l=0,r=n-1;
        while(a[l+1]>a[l] && l<n-1){
            l++;
        }
        while(a[r-1]<a[r] && r-1>=0){
            r--;
        }
        if(r==n-1 && l==0){
            cout<<"yes"<<endl;
            cout<<1<<" "<<n;
        }


}
int main() {
    ll a;
    cin>>a;
    ll x=a+pow(a,2)+pow(a,3);
    cout<<x;

}


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

/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    void unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

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

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }

    int q;
    cin >> q;
    vector<int> s(q), t(q);
    for (int i = 0; i < q; i++) {
        cin >> s.at(i) >> t.at(i);
    }

    for (int i = 0; i < q; i++) {
        if (uf.isSame(s[i], t[i])) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}



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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n; cin >> n;

	vector <int> h(n);

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

	h[0]--;

	for(int i = 1; i < n; i++){
		if(h[i] > h[i - 1]){
			h[i]--;
		}else if(h[i] < h[i - 1]){
			cout << "No" << endl; return 0;
		}
	}

	cout << "Yes" << endl;
	



	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, W;
  cin >> N >> W;
  int64_t vec[N][2];
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec[i][j];
    }
  }
  const int64_t val_max = 100*1000 + 10;
  const int64_t INF = 10000000000;
  
  int64_t dp[N][val_max]; //i番目までに価値jを作るのに必要な重さのmin
  for(int i=0; i<N; i++){
    for(int j=0; j<val_max; j++){
      dp[i][j] = INF;
    }
  }
  
  for(int i=0; i<N; i++){
    int64_t x = vec[i][0];
    int64_t y = vec[i][1];
    dp[i][y] = min(dp[i][y],x);
    if(i != 0){
      for(int j=0; j<val_max; j++){
        if(dp[i-1][j] != INF && j+y < val_max){
          dp[i][j+y] = min(dp[i][j+y], dp[i-1][j] + x);
        }
        dp[i][j] = min(dp[i][j], dp[i-1][j]);
      }
    }
  } 
  
  int64_t ans = 0; 
  for(int i=0; i<val_max; i++){
    if(dp[N-1][i] <= W){
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 78336
#include <iostream>

using namespace std;

int main()
{
int A,B;cin>>A>>B;
if(A>=13)
{
    cout<<B;
    return 0;
}
else if(A>=6 && A<=12)
{
    cout<<B/2;
    return 0;
}else{
cout<<0;
return 0;
}

    return 0;
}


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

namespace _6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] a = new int[s[0], s[1]];
            for (int i = 0; i < s[0]; i++)
            {
                int[] kj = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for(int k = 0; k < s[1]; k++)
                {
                    a[i, k] = kj[k];
                }
            }
            int[] b = new int[s[1]];
            for (int i = 0; i < s[1]; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }
            for(int i = 0; i < s[0]; i++)
            {
                int ans = 0;
                for(int k = 0; k < s[1]; k++)
                {
                    ans += a[i, k] * b[k];
                }
                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 9644
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
#include <atcoder/all>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}

int main(void)
{
    int N, Q;
    cin >> N >> Q;
    int a, b, c;
    dsu d(N);
    for (int i = 0; i < Q; i++)
    {

        cin >> c >> a >> b;
        if (c == 0)
        {
            d.merge(a, b);
        }
        else
        {
            if (d.same(a, b))
            {
                cout << 1 << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4052
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, m, x[100000];
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d", x + i);
	sort(x, x + m);
	for (int i = 0; i + 1 < m; i++)
		x[i] = x[i + 1] - x[i];
	sort(x, x + m - 1);
	int cost = 0;
	for (int i = 0; n + i < m; i++)
		cost += x[i];
	printf("%d\n", cost);
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        s += a[i];
        if (a[i] == 0) {
            ans += s / 2;
            s = 0;
        }
    }
    ans += s / 2;
    cout << ans;
    return 0;
}

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

int main(){
	long long a, n;
	cin >> n >> a;
	
	long long max = a;
	long long min = a;
	
	for( int i = 0; i < n-1; i++){
	long long b;
	cin >> b;
	if( b > max ) max = b;
	if( b < min ) min = b;
	a += b;
	}
	
	cout << min << " " << max << " " << a <<endl;
	
	return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e3 + 5;
int a[maxn] , b[maxn] , n;
bool check(int a , int b , vector<int> & val){
    vector<int> now = {a};
    vector<bool> vis(51 , 0);
    while(now.size()){
        vector<int> tmp;
        for(int c : now){
            vis[c] = 1;
            if(c == b)return 1;
        }
        for(int c : now){
            for(int d : val){
                if(vis[c % d] == 0){
                    tmp.pb(c % d);
                    vis[c % d] = 1;
                }
            }
        }
        now = tmp;
    }
    return 0;
}
bool check(vector<int> & val){
    for(int i = 1 ; i <= n ; ++i){
        if(check(a[i] , b[i] , val) == 0)return 0;
    }
    return 1;
}
int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    for(int i = 1 ; i <= n ; ++i)cin >> b[i];
    vector<int> val;
    ll res = 0;
    for(int i = 50 ; i >= 1 ; --i){
        vector<int> tmp = val;
        for(int j = 1 ; j < i ; ++j)tmp.pb(j);
        if(check(tmp))continue;
        val.pb(i);
        res += (1ll << i);
    }
    if(check(val))cout << res;
    else cout << -1;
}



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

int H;
int W;
string fie[50];
int main(){
    cin >> H >> W;
    for(int i = 0;i < H;i++){
        cin >> fie[i];
    }

    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(fie[i][j] == '.') continue;
            int sum = 0;
            if(i - 1 >= 0){
                sum += (fie[i - 1][j] == '#');
            }
            if(i + 1 < H){
                sum += (fie[i + 1][j] == '#');
            }
            if(j - 1 >= 0){
                sum += (fie[i][j - 1] == '#');
            }
            if(j + 1 < W){
                sum += (fie[i][j + 1] == '#');
            }
            if(sum == 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

let inputData = '';

process.stdin.on('data', inputStdin => {
  inputData += inputStdin;
});

process.stdin.on('end', _ => {
  // data parse
  inputData = inputData.replace(/\s*$/g, '')
    .split('\n')
    .map(str => str.split(' '));
  main();
});

function solve(n, a) {
  const limit = 10n ** 18n;
  let result = 1n;

  if (a.indexOf('0') >= 0) {
    return 0;
  }

  for (let i = 0; i < n; i++) {
    result *= BigInt(a[i]);

    if (result > limit) {
      return -1;
    }
  }
  return result;
}

function main() {
  const n = inputData[0][0];
  const a = inputData[1];

  process.stdout.write(solve(n, a).toString());
}


Measured memory_bytes: 37296
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;

int sum(int N, int *A){
	int s = 0;
	for(int i=0 ; i < N ; i++ ){
		s += A[i];
	}
	return s;
}

int main(){
	int n, m, a[101], b[101];
	
	while( cin >> n >> m, n || m ){
		for(int i = 0 ; i < n ; i++ ){
			cin >> a[i];
		}
		for(int i = 0 ; i < m ; i++ ){
			cin >> b[i];
		}

		vector<P> ans;
		for(int i=0 ; i < n ; i++ ){
			for(int j=0 ; j < m ; j++ ){
				swap( a[i] , b[j] );
				int s1 = sum( n , a );
				int s2 = sum( m , b );
				if( s1 == s2 ){
					ans.push_back( P(a[i],b[j]) );
				}
				swap( a[i] , b[j] );
			}
		}
		bool flag = false;
		int m = 100000;
		for(int i=0 ; i < ans.size() ; i++ ){
			m = min( m , ans[i].first + ans[i].second );
		}
		for(int i=0 ; i < ans.size() ; i++ ){
			if( m == ans[i].first + ans[i].second ){
				flag = true;
				cout << ans[i].second << " " << ans[i].first << endl;
				break;
			}
		}
		if( !flag )
			cout << -1 << endl;
	}
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int s,w;
    cin >> s >> w;
    if(w >= s)
    {
        cout << "unsafe\n";
    }
    else
    {
        cout << "safe\n";
    }
    
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){

  int x,y,i,d;

  /* Using loop to check input numbers are in constrants or not */
  while(1){
    scanf("%d %d", &x,&y);
    if(x>=1 && y<=1000000000)break;
    else printf("error!\n");
  }

  /* make three situations x>y, x<y and x=y */
  if(x>y){
    d=x%y;
    for(i=d ; i>0 ; i--){
      if(y%i==0 && d%i==0)break;
    }
  }
  else if(x<y){
    d=y%x;
    for(i=d ; i>0 ; i--){
      if(x%i==0 && d%i==0) break;
    }
  }
  else i=x;

  /* output the greatest common divisor */
  printf("%d\n", i);

  return 0;
}

Measured memory_bytes: 592
n=int(input())
a=list(map(int,input().split()))
a0=a[0]
a1=a[0]
money=1000
stock=0
for i in range(n):
  if a[i]>a1:
    #if a[i]>a1:
    a1=a[i]
    #print(a1)
  else:
    stock=money//a0
    #print(stock)
    money=money%a0
    money+=stock*a1
    stock=0
    a0=a[i]
    a1=a[i]
stock=money//a0
money=money%a0
money+=stock*a1
print(int(money))

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

// typedef long long ll;
int main() {
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  for (int i = 1; i < N; i++) {
    if (H[i-1] > H[i]) {
      cout << "No" << endl;
      return 0;
    } else {
      if (H[i] != H[i-1]) {
        H[i] = H[i]-1;
      }
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){

    long long sum=0,i,n;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3==0 && i%5==0){
            sum=sum+0;
        }
        else if(i%3==0){
            sum=sum+0;
        }

        else if(i%5==0){
            sum=sum+0;
        }
        else{
                sum=sum+i;

        }
    }
    cout<<sum<<endl;



}


Measured memory_bytes: 3620
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
cnt=[0]*(n+1)
for i in range(m):
  cnt[ab[i][0]]+=1
  cnt[ab[i][1]]+=1
flag=True
for i in range(1,n+1):
  if cnt[i]%2!=0:flag=False
print('YES' if flag else 'NO')

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> mp;
  ll ans = 0;
  rep(i,n) {
    int sa = i-a[i];
    //i<j  j-i==Ai+Aj  Ai+i==j-Aj  Ai+iはmpに入れていくと計算時間を減らせる
    ans += mp[sa];
    int wa = a[i]+i;
    mp[wa]++;
  }
  cout << ans << endl;
  return 0;
}

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

num_list = []
for i in range(n):
    a = int(input())
    num_list.append(a)

num_list.sort()
num_list2 = []
i = 0
while i < n:
    if i == n-1:
        num_list2.append(num_list[i])
        break
    elif num_list[i] == num_list[i+1]:
        i += 2
    else:
        num_list2.append(num_list[i])
        i += 1


print(len(num_list2))

Measured memory_bytes: 8012
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int a, b, k;
    cin >> k;
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            break;
        }
        if(i == b){
            cout << "NG" << endl;
        }
    }
    solve();
    return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x=0;
	string s;
	int max=0;
	int l;
	cin>>l;
	cin>>s;
	for(int i=0;i<l;i++)
	{
		if(s[i]=='I')
		{
			x++;
			if(x>max)
			max=x;
		}
		
		if(s[i]=='D')
		{
			x--;
		}
		if(x>max)
		max=x;
		
	}
	cout<<max;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ans=0;
    int pos=n-1;
    while(pos>=1){
        if(a[pos]>a[pos-1]+1){
            cout<<-1<<endl;
            return 0;
        }
        pos--;
    }
    if(a[0]!=0){
        cout<<-1<<endl;
        return 0;
    }
    pos=n-1;
    for(int i=n-1;i>=1;i--){
        if(i!=n-1&&a[i]+1==a[i+1]){
            
        }else{
            ans+=a[i];
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let s: String = read();
    if s == "AAA" || s == "BBB" {
        println!("{}", "No")
    } else {
        println!("{}", "Yes")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

class Cell
{
public:
    int i, j;
    Cell(int i, int j) : i(i), j(j) {}
};

void solve(int N, int M, vector<string> S)
{
    auto to_id = [&](int i, int j) {
        return i * M + j;
    };
    auto to_ij = [&](int id) {
        return Cell(id / M, id % M);
    };
    int s = N * M, t = N * M + 1;
    auto is_valid = [&](int i, int j) {
        return 0 <= i && i < N && 0 <= j && j < M && S.at(i).at(j) == '.';
    };

    mf_graph<int> graph(N * M + 2);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (!is_valid(i, j))
                continue;
            int id = to_id(i, j);

            if ((i + j) % 2 == 0)
            {
                // s -> even
                graph.add_edge(s, id, 1);

                // even -> odd
                for (int v = 0; v < (int)di.size(); v++)
                {
                    if (!is_valid(i + di.at(v), j + dj.at(v)))
                        continue;
                    int id_o = to_id(i + di.at(v), j + dj.at(v));
                    graph.add_edge(id, id_o, 1);
                }
            }
            else
            {
                // odd -> t
                graph.add_edge(id, t, 1);
            }
        }
    }

    cout << graph.flow(s, t) << endl;

    for (auto &&e : graph.edges())
    {
        if (e.from == s || e.to == t || e.flow == 0)
            continue;
        Cell even = to_ij(e.from);
        Cell odd = to_ij(e.to);
        if (even.i == odd.i)
        {
            if (even.j < odd.j)
            {
                S.at(even.i).at(even.j) = '>';
                S.at(odd.i).at(odd.j) = '<';
            }
            else
            {
                S.at(odd.i).at(odd.j) = '>';
                S.at(even.i).at(even.j) = '<';
            }
        }
        else
        {
            if (even.i < odd.i)
            {
                S.at(even.i).at(even.j) = 'v';
                S.at(odd.i).at(odd.j) = '^';
            }
            else
            {
                S.at(odd.i).at(odd.j) = 'v';
                S.at(even.i).at(even.j) = '^';
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << S.at(i) << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    int M;
    cin >> M;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    solve(N, M, move(S));
    return 0;
}


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

vector<vector<pair<int, int>>> v;
vector<int> d, color;

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

void dijkstra(){
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, 0));
  d[0] = 0;

  while(!q.empty()){
    auto next = q.top(); q.pop();
    if(color[next.second] == BLACK) continue;

    color[next.second] = BLACK;

    for(auto ve : v[next.second]){
      if(color[ve.first] != BLACK && d[ve.first] > d[next.second] + ve.second){
        d[ve.first] = d[next.second] + ve.second;
        color[ve.first] = GRAY;
        q.push(make_pair(d[ve.first], ve.first));
      }
    }
  }
}

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

  v.resize(n);
  d.resize(n);
  color.resize(n);

  for(int i=0; i<n; ++i){
    d[i] = numeric_limits<int>::max();

    int u, k, ve, c; cin >> u >> k;
    for(int l=0; l<k; ++l){
      cin >> ve >> c;
      v[u].push_back(make_pair(ve, c));
    }
  }

  dijkstra();

  for(int i=0; i<n; ++i){
    cout << i << " " << d[i] << endl;
  }
}



Measured memory_bytes: 3148