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

using namespace std;

int main() {
    int n; cin >> n;
    double arr[n];
    long double prod = 1;
    for (int i  = 0; i < n; i++) {
        cin >> arr[i];
        prod *= arr[i];
    }
    long double summ = 0;
    for (int i  = 0; i < n; i++) summ += prod/arr[i];
    long double res = prod/summ;
    cout << fixed << setprecision(10) << res;
}

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

int f(vector<int> &p, int index) {
  if (index == p.size()) return 0;
  int s = p.at(index);
  for (int i = 1; i <= p.size() - 1 - index; i++) s *= i;
  for (int i = index + 1; i < p.size(); i++) {
    if (p.at(i) > p.at(index)) p.at(i)--;
  }
  return s + f(p, index + 1);
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
    p.at(i)--;
  }
  for (int i = 0; i < n; i++) {
    cin >> q.at(i);
    q.at(i)--;
  }
  cout << abs(f(p, 0) - f(q, 0)) << endl;
}


Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())

#c,d,lcm(c,d)の倍数がa~bの区間にいくつあるか調べる関数
def check(p):
    if a%p==0:
        e = a//p
    else:
        e = (a//p) +1

    if b%p==0:
        f = b//p
    else:
        f = (b//p)
        
    return(f-e+1)
        

lcm = (c*d)//gcd(c,d)
    
ans = b-a+1 -(check(c)+check(d)) +check(lcm)
print(ans)

Measured memory_bytes: 5052
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int n;
  	cin>>n;
  	vector<int> v(n);
  	for(int i=0;i<n;i++)cin>>v[i];
  	int u  = accumulate(v.begin(),v.end(),0)/n;
  	int ans1=0;
  	for(int i=0;i<n;i++)ans1+=(v[i]-u)*(v[i]-u);
     
  	int ans2=0;
    u  = (accumulate(v.begin(),v.end(),0)+n-1)/n;
    for(int i=0;i<n;i++)ans2+=(v[i]-u)*(v[i]-u);
  	cout<<min(ans1,ans2);
}


Measured memory_bytes: 5980
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b;
	cin>>c>>d;
	int ans =(a*b)-((c*b)+((a-c)*d));
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 3636
x,size=map(int,input().split())
weight=[]
value=[]
for i in range(x):
    a,b=map(int,input().split())
    weight.append(a)
    value.append(b)
dp=[[0 for i in range(size+1)] for j in range(len(weight))]
for i in range(len(weight)):
    dp[i][0]=0
for i in range(len(weight)):
    for j in range(1,size+1):
        if weight[i]>j:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i])
print(dp[len(value)-1][size])
        
    

Measured memory_bytes: 217392
s = sorted(input())
t = sorted(input(), reverse=True)

for item in zip(s,t):
    if ord(item[0]) < ord(item[1]):
        print('Yes')
        exit()
    elif ord(item[0]) > ord(item[1]):
        print('No')
        exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] b = new int[n-1];
        for(int i=0; i<n-1; i++) {
            b[i] = in.nextInt();
        }
        int s = b[0];
        for(int i=1; i<n-1; i++) {
            s += Math.min(b[i-1], b[i]);
        }
        s += b[n-2];
        System.out.println(s);
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> h(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  vector<bool> vc(n);
  for(ll i=0;i<n;i++) vc[i] = true;
  for(ll i=0;i<m;i++){
    ll a,b;
    cin >> a >> b;
    if(h[a-1]==h[b-1]){
      vc[a-1] = false;
      vc[b-1] = false;
    }
    else if(h[a-1]>h[b-1]) vc[b-1] = false;
    else vc[a-1] = false;
  }
  ll ans = 0;
  for(ll i=0;i<n;i++){
    if(vc[i]==true) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k;
char a[200010];
int red=0;

int32_t main(){
INIT
cin>>n;
for(int i=1; i<=n; i++){cin>>a[i]; if(a[i]=='R'){red++;}  }
int cnt=0;
for(int i=1; i<=n; i++){
    if( (a[i]=='R') && (i>red) ){cnt++;}
}
cout<<cnt;

return 0;
}





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

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        printf("%d %d\n", min(x, y), max(x, y));
    }
    
/**
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (x + r > W || y + r > H) {
        printf("No");
    } else if (x - r < 0 || y - r < 0) {
        printf("No");
    } else {
        printf("Yes");
    }
    printf("\n");

    return 0;
    **/
}

Measured memory_bytes: 1144
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ln '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

int32_t main() {
	ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

#ifdef _DEBUG
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int h, a;
	cin >> h >> a;
	cout << cai(ceil((1.0*h)/a)) << ln;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    x = x/a;
    double ans;
    if(x <= a*b/2) {
        double r = (b*b)/(2*x);
        ans = (atan(r) * 180.0) / (atan(1.0) * 4.0);
    } else {
        double c = 2*x/a;
        c = 2*b-c;
        double r = c/a;
        ans = (atan(r) * 180.0) / (atan(1.0) * 4.0);
    }

    printf("%.8f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int s;  //秒単位の時間
    int hour, min;
    
    scanf("%d", &s);
    
    hour = s / 3600;
    s -= hour * 3600;
    min = s / 60;
    s -= min * 60;
    
    
    printf("%d:%d:%d\n", hour, min, s);
    
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(void){
    int x,y;
    int now_x,now_y;
    int tmp;
    int board[22][22];
    int i,j;
    int end_flag = 0;
    int cnt = 0;



    while(1){
        scanf("%d %d", &x, &y);
        
        if(x == 0 && y == 0){
            return 0;
        }

        for(i = 0; i < 22; i++){
            for(j = 0; j < 22; j++){
                board[i][j] = -1;
            }
        }

        for(i = 1; i <= y; i++){
            for(j = 1; j <= x; j++){
                tmp = getchar();
                if(tmp == '\n'){
                    tmp = getchar();
                }
                switch(tmp){
                    case '.': board[i][j] = 1;break;
                    case '#': board[i][j] = 0;break;
                    case '@': board[i][j] = 2;break;
                }
            }
        }

        end_flag = 0;
        while(end_flag == 0){
            end_flag = 1;

            for(i = 1; i <= y; i++){
                for(j = 1; j <= x; j++){
                    if(board[i][j] == 2){
                        if(board[i + 1][j] == 1){
                            end_flag = 0;
                            board[i + 1][j] = 2;
                        }
                        if(board[i - 1][j] == 1){
                            end_flag = 0;
                            board[i - 1][j] = 2;
                        }
                        if(board[i][j + 1] == 1){
                            end_flag = 0;
                            board[i][j + 1] = 2;
                        }
                        if(board[i][j - 1] == 1){
                            end_flag = 0;
                            board[i][j - 1] = 2;
                        }
                    }
                }
            }
        }
        
        cnt = 0;
        for(i = 1; i <= y; i++){
           for(j = 1; j <= x; j++){
               if(board[i][j] == 2){
                   cnt++;
               }
           }
        }
        printf("%d\n", cnt);
    }

}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll A,B,C,K;
  cin >> A >> B >> C >> K;

  ll ans=0;
  ans+=min(A,K);
  K-=A;
  K-=B;
  if(K>0) ans-=min(C,K);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
class DoublyLinkedList
	class Cell
		attr_accessor :data, :prev_data, :next_data
		def initialize(data, prev_data = nil, next_data = nil)
			@data = data
			@prev_data = prev_data
			@next_data = next_data
		end
	end
	
	def initialize
		@top_data = nil
		@last_data = @top_data
	end
	
	def insert(x)
		cell = Cell.new(x)
		if @top_data == nil
			@top_data = cell
			@last_data = cell
		else
			cell.next_data = @top_data
			@top_data.prev_data = cell
			@top_data = cell
		end
	end
	
	def delete(x)
		cell = @top_data
		while cell.data != x
			cell = cell.next_data
			if cell == nil
				return
			end
		end
		if cell.prev_data != nil
			cell.prev_data.next_data = cell.next_data
		elsif cell == @top_data
			cell.next_data.prev_data = nil
			@top_data = cell.next_data
		end
		if cell.next_data!= nil
			cell.next_data.prev_data = cell.prev_data
		elsif cell == @last_data
			cell.prev_data.next_data = nil
			@last_data = cell.prev_data
		end
	end
	
	def delete_first
		if @top_data.next_data != nil
			@top_data.next_data.prev_data = nil
			@top_data = @top_data.next_data
		else
			@top_data = nil
			@last_data = nil
		end
	end
	
	def delete_Last
		if @last_data.prev_data != nil
			@last_data.prev_data.next_data = nil
			@last_data = @last_data.prev_data
		else
			@top_data = nil
			@last_data = nil
		end
	end
	
	def data_print
		cell = @top_data
		print cell.data
		while cell.next_data != nil
			cell = cell.next_data
			print " ",cell.data
		end
		puts
	end
end

n = gets.chomp.to_i

list = DoublyLinkedList.new

n.times {
	cmd = gets.chomp.split(" ")
	case cmd[0]
	when "insert"
		list.insert(cmd[1])
	when "delete"
		list.delete(cmd[1])
	when "deleteFirst"
		list.delete_first
	when "deleteLast"
		list.delete_Last
	end
}
list.data_print

Measured memory_bytes: 143132
a=int(input())
x=[input()]
flag=0
for i in range(1,a):
    s=input()
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
      
        flag=1
    x.append(s)
        
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    if(r < 1200){
      System.out.println("ABC");
    }else if(r < 2800){
      System.out.println("ARC");
    }else{
      System.out.println("AGC");
    }
  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 101010
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m;
ll w[sz];
struct hh{int x,y;ll w;const bool operator < (const hh &a) const {return w<a.w;}}e[sz];

ll sum[sz];int cnt[sz],ok[sz];
int fa[sz];
int getfa(int x){return x==fa[x]?x:fa[x]=getfa(fa[x]);}
void work(hh e)
{
	int x=e.x,y=e.y;ll w=e.w;
	x=getfa(x),y=getfa(y);
	if (x==y) return ++cnt[x],ok[x]+=(sum[x]>=w),void();
	sum[x]+=sum[y],cnt[x]+=cnt[y]+1,ok[x]+=ok[y],fa[y]=x;
	if (sum[x]>=w) ok[x]=cnt[x];
}

int main()
{
	file();
	read(n,m);
	rep(i,1,n) read(w[i]);
	int x,y,z;
	rep(i,1,m) read(x,y,z),e[i]=(hh){x,y,z};
	sort(e+1,e+m+1);
	rep(i,1,n) fa[i]=i,sum[i]=w[i];
	rep(i,1,m) work(e[i]);
	int ans=m;
	rep(i,1,n) if (i==fa[i]) ans-=ok[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6400
/*||>>>> Praveen Ojha <<<<>>>> 09 August 2019 <<<<>>>> 21:01:11 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
bool isod(int x){
    int dig=(int)log10(x)+1;

    return (dig&1);
}
int32_t main(){__
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(isod(i))
            ans++;
    }
    cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
/*namespace std {
	bool operator < (const int& a, const int& b) {
		return 
		//return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
		//return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);  
	}
}*/
bool in[5001][5001];
int main(){
	int n;
	while(cin>>n,n){
		memset(in,0,sizeof(in));
		vector<int>x(n);
		vector<int>y(n);
		rep(i,n){
			cin>>x[i]>>y[i];
			in[x[i]][y[i]]=true;
		}
		rep(i,n)rep(j,n)if(x[i]<x[j]){swap(x[i],x[j]);swap(y[i],y[j]);}
			else if(x[i]==x[j]&&y[i]<y[j])swap(y[i],y[j]);

		int out=0;
		rep(i,n){
			loop(j,i+1,n){
				if(x[i]+y[j]-y[i]<5001&&x[j]+y[j]-y[i]<5001&&
				y[i]+x[i]-x[j]<5001&&y[j]+x[i]-x[j]<5001&&
				x[i]+y[j]-y[i]>=0&&x[j]+y[j]-y[i]>=0&&
				y[i]+x[i]-x[j]>=0&&y[j]+x[i]-x[j]>=0&&				in[x[i]+y[j]-y[i]][y[i]+x[i]-x[j]]&&
				in[x[j]+y[j]-y[i]][y[j]+x[i]-x[j]])
					out=max(out,(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
			}
		}
		cout<<out<<endl;
	}
		//rep(i,n)cout<<x[i]<<" "<<y[i]<<endl;
}

Measured memory_bytes: 25648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code

    int N = inputValue();
    int d[N];
    int i,j;
    int sum = 0;
    d[0] = inputValue();
    for(i=1;i<N;i++){
        d[i] = inputValue();
        for(j=0;j<i;j++){
            sum = sum + d[i]*d[j];
        }
    }
    cout << sum << endl;
    


    return 0;
}

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

void solve(){
  int n; string s; cin >> n >> s;
  if(n % 2 != 0){
    cout << "No\n";
    return;
  }
  int i;
  for(i = 0; i < n / 2; i++){
    if(s[i] != s[n / 2 + i]) break;
  }
  if(i == n / 2) cout << "Yes\n";
  else cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,ans=1;cin >> a;
    const ll p=1000000007;
    vector<ll> v(a,0);
    for (ll i=1;i<=a;i++){
        int cur=i;
        for (int b=2;b<=i;b++){
            while(cur%b==0){
                cur/=b;
                v[b-1]++;
            }
        }
    }
    for (int i=1;i<a;i++){
        ans=ans*(v[i]+1ll);
        ans%=p;
    }
    cout << ans;
    // D:
    // D:
    // D:
    // D:
    // D:
    // D:
    // D:
    // D:
    // D:
    // D:
    // :D
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    ll dp[n][3],a[n][3];
    for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
    cin>>a[i][j];
    for(int j=0;j<3;j++)
    dp[0][j]=a[0][j];
    for(int i=1;i<n;i++)
    {
    	for(int j=0;j<3;j++)
    	dp[i][j]=max(dp[i-1][(j+2)%3],dp[i-1][((j+1)%3)])+a[i][j];
	}
	cout<<(ll)max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
}



Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

long long evalmod(long long a, long long b){
  long long maxval = std::max(a, b);
  long long minval = std::min(a, b);
  if (minval==0){
    return maxval;
  } else {
    return evalmod(minval, maxval%minval);
  }
}

bool isprime(int n){
  if (n==1){
    return false;
  }
  for (int i=2; i*i<n; i++){
    if (n%i==0){
      return false;
    }
  }
  return true;
}
int N, M;
std::map<int, int > mp;

long long ans = 0;
void dfs(std::map<int, int>::iterator itr, long long multiple){
  //printf("dfs %lld called\n", multiple);
  if (itr==mp.end()){
    //printf("M=%lld, multiple=%lld, N=%d\n",M,multiple,N);
    if (M/multiple>=N){
      ans = std::max(ans, multiple);
    }
    return;
  } else {
    for (int i=0; i<=itr->second; i++){
      std::map<int, int>::iterator itr_next = itr;
      itr_next++;
      //printf("pow(%d, %d)\n", )
      dfs(itr_next, multiple*(long long)pow(itr->first, i));
    }
    return;
  }
}

int main(){
  scanf("%d", &N);
  scanf("%d", &M);
  //printf("N=%d, M=%d\n", N, M);
  int temp = M;
  for (int i=2; i*i<=temp; i++){
    if (isprime(i)){
      while(temp%i==0){
        temp = temp/i;
        mp[i]++;
      }
    }
  }
  if(temp!=1){
    mp[temp]++;
  }
  /*for (auto entry: mp){
    std::cout << entry.first << "," << entry.second << std::endl;
    }*/
  dfs(mp.begin(), 1);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		String tmp1 = s;
		String tmp2 = s;
		int red = tmp1.replace("1", "").length();
		int blue = tmp2.replace("0", "").length();
		System.out.println(Math.min(red, blue) * 2);
	}
}

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

using namespace std;



int main() {

    int n;
    cin >> n;

    int a[n];

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

    sort (a, a + n);

    cout << (a[n - 1] - a[0]) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[222222];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	long long ans=0;
	for(int i=1;i<n;i++)
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	cout<<ans<<endl;
	return 0;
 } 

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

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

const int mx=1e5+5;

int h[mx];
ll dp[mx];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n,k;
	cin>>n>>k;
	
	for(int i=1;i<n+1;i++) cin>>h[i];
	for(int i=1;i<n+1;i++) dp[i]=1LL<<50;
	
	dp[1]=0;
	
	for(int i=1;i<n+1;i++)
	{
		for(int j=1;j<k+1;j++)
		{
			if(i+j>n) break;
			dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	
	cout<<dp[n];
	
						
	cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,k;
  cin>>n>>k;
  puts(n+1 >= 2*k ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	cin >> N;
	vector<ll>A(N);
	rep(i, N)cin >> A[i];
	cin >> Q;
	rep(i, Q) {
		ll k;
		cin >> k;
		if (binary_search(A.begin(),A.end(),k)) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

	return 0;
}





Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

#define D 15

using namespace std;

class Solver {
    private:
        int char_num_;
        int alpha_[12][D];
        bool is_top_[10];
        bool has_used_[10];
        int nums_[10];
        void init() {
            int indices[26];
            for (int i = 0; i < 26; ++i) {
                indices[i] = -1;
            }
            for (int i = 0; i < 10; ++i) {
                is_top_[i] = false;
                has_used_[i] = false;
            }
            char_num_ = 0;
            for (int i = 0; i < n; ++i) {
                int len = s[i].length();
                for (int j = 0; j < D - len; ++j) {
                    alpha_[i][j] = -1;
                }
                for (int j = 0; j < len; ++j) {
                    int c = s[i][j] - 'A';
                    if (indices[c] < 0) {
                        indices[c] = char_num_;
                        ++char_num_;
                    }
                    alpha_[i][j + D - len] = indices[c];
                    if (j == 0 && len > 1) {
                        is_top_[indices[c]] = true;
                    }
                }
            }
        }
        bool is_valid() {
            int carry = 0;
            for (int i = D - 1; i >= 0; --i) {
                int d = carry;
                int id = alpha_[n - 1][i];
                for (int j = 0; j < n - 1; ++j) {
                    if (alpha_[j][i] >= 0) {
                        d += nums_[alpha_[j][i]];
                    }
                }
                if (d % 10 != (id < 0? 0: nums_[id])) {
                    return false;
                }
                carry = d / 10;
            }
            return true;
        }
        int search(int k = 0) {
            int count = 0;
            if (k < char_num_) {
                for (int i = 0; i < 10; ++i) {
                    if (has_used_[i] || (i == 0 && is_top_[k])) {
                        continue;
                    }
                    has_used_[i] = true;
                    nums_[k] = i;
                    count += search(k + 1);
                    has_used_[i] = false;
                }
            } else {
                if (is_valid()) {
                    ++count;
                }
            }
            return count;
        }
    public:
        int n;
        string s[12];
        int solve() {
            init();
            return search();
        }
};

int main() {
    Solver s;
    while (true) {
        cin >> s.n;
        if (s.n == 0) {
            return 0;
        }
        for (int i = 0; i < s.n; ++i) {
            cin >> s.s[i];
        }
        cout << s.solve() << endl;
    }
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(){
    
    int a, b, d, r;
    double f;
    
    scanf("%d %d", &a, &b);
    
    d = a/b;
    r = a%b;
    f = (double)a/b;
    printf("%d %d %f\n", d, r, f);
    return 0;
    
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define N 100010
using namespace std;

int main()
{
    char s[11],t[11],u[11];
    cin>>s;
    cin>>t;
    unsigned short n,k;
    cin>>n>>k;
    cin>>u;
    if(strcmp(s,u)==0){n--;}
    else if(strcmp(t,u)==0) {k--;}
    cout<<n<<" "<<k;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
inputs = []
ans = 0
n.times do
    inputs << gets.chomp.split(" ").map(&:to_i)
end
inputs.sort!{|x, y| x[0] <=> y[0]}

inputs.each do |a, b|
    tmp = m > b ? b : m
    ans += a * tmp
    m -= b
    break if m <= 0
end

puts ans

Measured memory_bytes: 10488
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sub = sorted(b[i] - a[i] for i in range(N))
odd = len([x for x in sub if x > 0 and x % 2 == 1])
plus = sum(x for x in sub if x > 0)
minus = sum(x for x in sub if x < 0)
print(('No', 'Yes')[plus + minus * 2 >= odd])


Measured memory_bytes: 4600
#B
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
mod=10**9+7
n=int(input())
C=[int(input()) for _ in range(n)]
A=[0]*(2*10**5+1) #A[i]:色iが最後にあった場所(1-indexed)
B=[1]
for i,c in enumerate(C):
    #print(A[c])
    tmp=B[-1]
    if A[c]!=i and A[c]!=0:
        tmp+=B[A[c]]
    A[c]=i+1
    B.append(tmp%mod)
#print(B)
print(B[-1])

Measured memory_bytes: 64988
N,X=map(int,input().split())
x=list(map(int,input().split()))
diffx=[abs(X-x[i]) for i in range(N)]

def euclid(a,b):
    if b==0:
        return a
    else:
        return euclid(b,a%b)

gcd=diffx[0]
for i in range(1,N):
    gcd=euclid(diffx[i],gcd)
print(gcd)

Measured memory_bytes: 15020
#include "algorithm"
#include "iostream"
#include "numeric"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
using namespace std;
typedef long long ll;

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

  ll X;
  cin >> X;

  ll ct = X / 100;
  ll rest = X % 100;
  if (rest <= 5 * ct) {
    cout << 1 << endl;
    return 0;
  } else {
    cout << 0 << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

ll h[maxn], dp[maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n, k;
    scanf("%d%d", &n, &k);

    for(int i = 1; i <= n; i++)  scanf("%lld", &h[i]);

    memset(dp, 0x3f, sizeof(dp));
    dp[1] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= k; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    printf("%lld\n", dp[n]);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
 
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    IOS
    
    ll h;
    int a;
    cin >> h >> a;
    int tmp;
    for(int i=0; i<a; i++) {
		cin >> tmp;
		h -= tmp;
    }
    cout << ((h <= 0 ? "Yes" : "No")) << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int digit(int n)
{
    int count = 0;
    while (n > 0)
    {
        count++;
        n /= 10;
    }
    return count;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (digit(i) % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,d;
    cin>>n>>d;
    if(n%2==0)d^=127;
    cout<<(n-1)*127+d<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);


		//ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
		final int MAX = 50000;
		boolean [] prime = new boolean[MAX + 1];
		for(int i=2; i < prime.length; i++){
			prime[i] = true;
		}
		for(int i=2; i * i < MAX; i++){
			if(prime[i]){
				for(int j = i + i; j <= MAX; j += i){
					prime[j] = false;
				}
			}
		}

		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int count = 0;
			for(int i=2; i <= n/2; i++){
				if(prime[i] && prime[n-i]){
					count++;
				}
			}
			System.out.println(count);
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

int main() {
        int b, i, r = 0, n, m, a[10000];
        cin >> n;
        for(i = 0; i < n; i++) {
                cin >> a[i];
        }
        cin >> m;
        for(int j = 0; j < m; j++) {
                cin >> b;
                for(int l = 0; l < i; l++) {
                        if(a[l] == b) {
                                r++;
                                break;
                        }
                }
        }
        cout << r << endl;
        return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    uint n{N};
    uint h{0};
    while (n != 0){
        h += n%10;
        n/=10;
    }
    if (N % h == 0){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,r;
  cin >> n >> r;
  if(n>=10) {
    cout << r << endl;
  }
  else {
    cout << r+100*(10-n)<< endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type kv struct {
	Key   string
	Value int
}

type byValue []kv

func (a byValue) Len() int           { return len(a) }
func (a byValue) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byValue) Less(i, j int) bool { return a[i].Value > a[j].Value }
func (a byValue) Up(i, j int) bool   { return a[i].Value > a[j].Value }

func main() {
	var H, N int
	fmt.Scan(&H, &N)
	arr := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&arr[i])
	}

	var sum int
	for _, v := range arr {
		sum += v
	}
	if sum >= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	// sort.Ints(arr)
	// l := len(arr) - 1

	// isDead := false
	// if l == 0 {
	// 	if H < 1 {
	// 		fmt.Println("Yes")
	// 		isDead = true
	// 	}
	// } else if l == 1 {
	// 	H -= arr[1]
	// 	if H < 1 {
	// 		fmt.Println("Yes")
	// 		isDead = true
	// 	}
	// } else {
	// 	for i := 0; i < 2; i++ {
	// 		H -= arr[l-i]
	// 		fmt.Println(arr[l-i])
	// 		if H < 1 {
	// 			fmt.Println("Yes")
	// 			isDead = true
	// 			break
	// 		}
	// 	}
	// }
	// if !isDead {
	// 	fmt.Println("No")
	// }
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N;
llvec A;


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N;
  A = llvec(N, 0);
  rep(i, N)cin >> A[i];
  map<ll, ll>r, l;
  ll ans = 0;
  rep(i, N){
    l[-A[i]-i-1]++;
    ans += l[A[i]-i-1];
  }
  rep(i, N){
    r[A[N-1-i]-i-1]++;
    ans += r[-A[N-1-i]-i-1];
  }
  /*
  ll ans = 0;
  for(auto i: pos){
    ans += i.second * (i.second-1)/2;
  }  
  for(auto i: neg){
    ans += i.second * (i.second-1)/2;
    } 
*/ 
  cout << ans;
  return 0;
}


Measured memory_bytes: 50252
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


int dfs(int n, int s, int k){
	if(n==0 && s==0){
		return 1;
	}
	if(n==0) return 0;
	if(s<0) return 0;			//ココ
	if(k>9 || k>s) return 0;
	int res1 = dfs(n-1, s-k, k+1);
	int res2 = dfs(n, s, k+1);
	return res1 + res2;
}

bool solve(){
	int n,s;
	while(1){
		cin>> n>> s;
		if(n==0 && s==0) break;
		int res = dfs(n,s,0);
		cout<< res<< endl;
	}

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdio.h>
int main(){
        int a,b,n=0;
        scanf("%d %d %d",&n,&a,&b);
        if(n*a<b){
                printf("%d",n*a);
        }else{
                printf("%d",b);
        }
        return 0;
}

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

int a, b;

int main() {
	scanf("%d%d", &a, &b);
	if(a <= 0 && b >= 0) {
		printf("Zero\n");
		return 0;
	}
	if(a < 0) {
		if((b-a+1)&1) printf("Negative\n");
		else printf("Positive\n");
	}
	else printf("Positive\n");
	return 0;
}


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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modt[100002], imodt[100002];

int n, in[100001];
int samel, samer;

ll modpow(ll a, ll b) {
	ll x = 1,times = a;
	while (b > 0) {
		if (b & 1)x *= times;
		times *= times;
		x %= MOD;
		times %= MOD;
		b >>= 1;
	}
	return x;
}

ll comb(ll n, ll r) {
	if (r > n)return 0;
	//cout << n << " " << r << endl;
	ll ans = modt[n];
	ans = (ans * imodt[r]) % MOD;
	ans = (ans * imodt[n - r]) % MOD;
	return ans;
}

int main() {
	modt[0] = 1;
	modt[1] = 1;
	for (int i = 2; i <= 100001; i++) {
		modt[i] = modt[i - 1] * i;
		modt[i] %= MOD;
		//cout << modt[i] << endl;
	}
	
	for (int i = 100001; i >= 0; i--)imodt[i] = modpow(modt[i], 1000000005);

	/* modが小さいときに効率的に逆元を求める
	for (int i = 99999; i >= 0; i--) {
		imodt[i] = imodt[i + 1] * (i + 1);
		imodt[i] %= MOD;
	}
	*/
	cin >> n;
	for (int i = 1; i <= n + 1; i++) {
		int a;
		cin >> a;
		if (in[a - 1] != 0) {
			samel = in[a - 1] - 1, samer = i - 1;
		}
		else {
			in[a - 1] = i;
		}
	}
	for (int i = 1; i <= n + 1; i++) {
		if (i == 1)cout << n << endl;
		else {
			ll ans = comb(n + 1, i);
			ans %= MOD;
			ans -= comb(samel + (n - samer), i - 1);
			ans += MOD;
			ans %= MOD;
			//cout << i << " " << j << " " << comb(samel, j) * comb(n - samer + 1, i - 1 - j) << endl;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<bitset>
#define _GLIBCXX_DEBUG

using namespace std;

int main() {
	string S;
	cin >> S;
	bool ans1 = true;
	bool ans2 = true;
	bool ans3 = true;
	vector<char> v1;
	for (int i = 0; i < S.size(); i++) {
		v1.push_back(S[i]);
	}
	for (int i = 0; i < (S.size() - 1) / 2; i++) {
		if (v1[i] != v1[S.size() - 1 - i]) {
			ans1 = false;
		}
	}
	for (int i = 0; i < (S.size() - 1) / 4; i++) {
		if (S.size() == 3) break;
		if (v1[i] != v1[(S.size() - 1) / 2-i-1]) {
			ans2 = false;
		}
	}
	if (S.size()  == 3) {
		if (v1[0] != v1[2]) ans2 = false;
	}
	for (int i = 0; i < (S.size() - 3) / 4; i++) {
		if (v1[(S.size() + 3) / 2 + i-1] != v1[S.size() - i-1]) {
			ans3 = false;
		}
	}
	if (ans1 == true && ans2 == true && ans3 == true) {
		cout << "Yes"<<endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

const int MAX_N = 3030;

int main() {
    int n;
    cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    double dp[MAX_N][MAX_N] = {};
    dp[0][0] = 1.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i+1][j] += dp[i][j] * (1.00 - p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }
    
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        if (n - i < i) ans += dp[n][i];
    }
    
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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

int kuku(int,int);

int main(void){
    int a,b,r;
    cin >> a >> b;

    if(a<10 && b<10){
        r = kuku(a,b);
    } else {
        r = -1;
    }

    cout << r;
}

int kuku(int x,int y){
    return x*y;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> blue = new HashMap<String, Integer>();
		Map<String, Integer> red = new HashMap<String, Integer>();
		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			String string = sc.next();
			if (blue.containsKey(string)) {
				int count = blue.get(string) + 1;
				blue.put(string, count);
			} else {
				blue.put(string, 1);
			}
		}
		int M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			String string = sc.next();
			if (red.containsKey(string)) {
				int count = red.get(string) - 1;
				red.put(string, count);
			} else {
				red.put(string, -1);
			}
		}
		int ans = 0;
		for (Map.Entry<String, Integer> bm : blue.entrySet()) {
			int count = bm.getValue();
			if (red.containsKey(bm.getKey())) {
				count += red.get(bm.getKey());
			}
			ans = Math.max(ans, count);
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21972
#include<iostream>

int main(){

    int N;
    int wi[100];

    std::cin>>N;

    int lowside=0,highside=0;

    for(int i=0;i<N/2;i++){
        std::cin >> wi[i];
        lowside+=wi[i];
    }
    for(int i=N/2;i<N;i++){
        std::cin >> wi[i];
        highside+=wi[i];
    }
    
    int retnum;
    if(lowside == highside){
        retnum = 0;
    }
    if(lowside < highside){
        for(int i=N/2;i<N;i++){
            int temp = highside -lowside;
            lowside+=wi[i];
            highside-=wi[i];
            if(lowside > highside){
                if(temp < lowside-highside){
                    retnum = temp;
                }
                else{
                    retnum = lowside -highside;
                }
                break;
            }
        }
    }
    else{
        for(int i=N/2-1;i>=0;i--){
            int temp = lowside -highside;
            lowside-=wi[i];
            highside+=wi[i];
            if(lowside < highside){
                if(temp < highside-lowside){
                    retnum = temp;
                }
                else{
                    retnum = highside -lowside;
                }
                break;
            }
        }
    }
    std::cout << retnum <<std::endl;
}


Measured memory_bytes: 256