akhauriyash/Code-Regression huggingface dataset:
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  if (N === 1) {
    return "Hello World";
  } else {
    const A = Number(input[1][0]);
    const B = Number(input[2][0]);

    return A + B;
  }
};

console.log(main(read()));


Measured memory_bytes: 29696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DUMP(x) cout << #x << " = " << (x) << endl
using VI = vector<int>;
using VVI = vector<VI>;

vector<bool> prime(50000, true);

bool isPrime(int x) {
  if (x == 2) {
    return true;
  } else if (x % 2 == 0) {
    return false;
  } else {
    return prime[(x - 1) / 2];
  }
}

int main() {
  prime[0] = false;
  for (int i = 1; i < 50000; ++i) {
    if (not prime[i]) continue;
    int p = i * 2 + 1;
    for (int j = i + p; j < 50000; j += p) {
      prime[j] = false;
    }
  }
  VI a(100001, 0);
  FOR(i, 1, 100001) {
    a[i] += a[i - 1];
    if (isPrime(i) and isPrime((i + 1) / 2)) a[i]++;
  }
  int q; cin >> q;
  VI ans(q);
  REP(i, q) {
    int l, r; cin >> l >> r;
    ans[i] = a[r] - a[l - 1];
  }
  REP(i, q) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define fi first
//#define endl "\n"
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define initialize(array,size,value) for(ll i=0;i<size;i++) array[i]=value
#define couta(array,size) for(ll i=0;i<size;i++) cout<<array[i]<<" "
#define debug(x) cout<<"x: "<<x<<endl
#define dbug(x,y) cout<<"x: "<<x<<"    "<<"y: "<<y<<endl
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
#define mod 1000000007
#define MAXN 100001
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);
vector<ll> prefix_function(string s);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
        
    ll a, b;
    cin>>a>>b;
    cout<<max(a+b, max(a+a-1, b+b-1))<<endl;
}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


Measured memory_bytes: 256
n,a,b,c,d=map(int,input().split())
a,b=min(a,b),max(a,b)
pl1=b-d
pr1=b-c
pl2=b+c
pr2=b+d
flag=False
for i in range((n-2)//2+1):
  j=(n-2)-i*2
  al=a+j*c+i*(c-d)
  ar=a+j*d+i*(d-c)
  if (al<pl1 and pl1<=ar) or pl1<=al<=pr1:
    flag=True
    break
  if (al<pl2 and pl2<=ar) or pl2<=al<=pr2:
    flag=True
    break
if flag==True:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
#define int long long

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
#define TIMES_PER_SEC (CLOCKS_PER_SEC)



double get_absolute_time()
{
	return (double)clock()/TIMES_PER_SEC;
}
double starttime_acrush;
void starttime()
{
	starttime_acrush=get_absolute_time();
}
double gettime()
{
	return get_absolute_time()-starttime_acrush;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define MOD   1000000007
#define maxn 100002
#define inf 1e18


int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n,x;
  cin >> n >>x;
  int c=0;
  while(n>0){
    n-=x;
    c++;
  }
  cout<<c;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k,ans = 0;
    int count = 0;
    cin >> a >> b >> k;
    for(int i=100;i>=1;--i){
        if(a % i ==  0 && b % i == 0 ){
            count++;
            if(count == k) {
                ans = i;
                break;
            }
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000
const double PI = 3.14159265358979323846;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll A, B, H, M;
  cin >> A >> B >> H >> M;

  ld Ax = A * cosl(((ld)H + (ld)M / 60) / 12 * 2 * PI);
  ld Ay = A * sinl(((ld)H + (ld)M / 60) / 12 * 2 * PI);
  ld Bx = B * cosl((ld)M / 60 * 2 * PI);
  ld By = B * sinl((ld)M / 60 * 2 * PI);

  ld ans = sqrt(pow(Ax - Bx, 2) + pow(Ay - By, 2));

  cout << setprecision(20) << ans << endl;

  return 0;
}

Measured memory_bytes: 4164
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double S = r * r * Math.PI;
        double L = 2 * r * Math.PI;
        System.out.printf("%.6f %.6f\n", S, L);
    }
}


Measured memory_bytes: 28232
#include<bits/stdc++.h>
#define x first
#define pb push_back
#define y second
#define all(a) a.begin(), a.end()

using namespace std;

typedef long long LL;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL INF=1e14;


map<LL, set<PLL> > sum, dif;
map<LL, vector<LL> > fsum, fdif;
queue<PLL> q;
vector<PLL> comp;
PLL p[100555];
LL d, a, b;
LL rs;

int n;

void nb(LL left, LL right, set<PLL> &ptr)
{
    vector<PLL> cur;

    for(set<PLL>::iterator it = ptr.lower_bound({left, -INF}); it!=ptr.end() && *it <= make_pair(right, INF); it++)
    {
        cur.pb(*it);
        q.push(*it);
        comp.pb(*it); 
    }
    for(auto el: cur)
        ptr.erase(el);
}

void bfs(int v)
{
    PLL el = p[v];
    comp.pb(el);
    q.push(el);

    while(!q.empty())
    {
        LL x =q.front().x;
        LL y =q.front().y;
        q.pop();
        nb(x, x+d, sum[x+y+d]); // I cadran
        nb(x-d, x, dif[x-y-d]); // II cadran
        nb(x-d, x, sum[x+y-d]); // III cadran
        nb(x, x+d, dif[x-y+d]); // IV cadran
    }
}



int solve()
{
    cin>>n>>a>>b;

    for(int i=1; i<=n; ++i)
    {
        cin>>p[i].x>>p[i].y;
        sum[p[i].x+p[i].y].insert(p[i]);
        dif[p[i].x-p[i].y].insert(p[i]);
    }

    d=abs(p[a].x - p[b].x) + abs(p[a].y - p[b].y);

    bfs(a);
    sort(all(comp));
    comp.resize(unique(all(comp)) - comp.begin());
    for(auto el: comp)
    {
        fsum[el.x + el.y].pb(el.x);
        fdif[el.x - el.y].pb(el.x);
    }
    for(auto el: fsum)
        sort(all(el.y));
    for(auto el: fdif)
        sort(all(el.y));
    
    for(auto el: comp)
    {
        LL x=el.x;
        LL y=el.y;
        rs+=lower_bound(all(fsum[x+y+d]), x+d) - lower_bound(all(fsum[x+y+d]), x);
        rs+=upper_bound(all(fsum[x+y-d]), x) - upper_bound(all(fsum[x+y-d]), x-d);
        rs+=upper_bound(all(fdif[x-y+d]), x+d) - upper_bound(all(fdif[x-y+d]), x);
        rs+=lower_bound(all(fdif[x-y-d]), x) - lower_bound(all(fdif[x-y-d]), x-d);
    }
    cout<<rs/2;

}


int main()
{
    time_t tic = clock();

    solve();

    time_t toc = clock(); 
    cout<<"\n";
    cout<<setprecision(3)<<fixed;
    //cout<<"It took "<<(double)(toc-tic)/CLOCKS_PER_SEC<<" s.";
    return 0;
}



Measured memory_bytes: 80364
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[7];
    for(int i=1;i<=6;i++){
        cin>>a[i];
    }
    if(a[5]-a[1]<=a[6]) cout<<"Yay!"<<endl;
    if(a[5]-a[1]>a[6]) cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#'init(a)': 配列aで初期化。O(N)
#'update(k,x)': a[k]をxに変更 O(logN)
#'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
#'ide_ele' : 単位元。単位元(ide_ele)は、区間外の値などに設定する値です。

def gcd(x,y):
    if x==0:
        return y
    if y==0:
        return x
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y

#####segfunc######
def segfunc(x,y):
    return gcd(x,y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k+1:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
#単位元。単位元(ide_ele)は、区間外の値などに設定する値です。
#            ex) 最小値のセグ木 → +inf
#             　　和のセグ木 → 0
#　　             積のセグ木 → 1
#　　             gcdのセグ木 → 0
ide_ele = 0

n=int(input())
a=list(map(int,input().split()))

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(a)
ans=0
for i in range(n):
    ans=max(ans,gcd(query(0,i),query(i+1,n)))

print(ans)


Measured memory_bytes: 81388
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        double r = fs.nextDouble();
        double g = fs.nextDouble();

        System.out.println((int) (2 * g - r));
    }

}


Measured memory_bytes: 80848
k,a,b = map(int,input().split())
ans = 1
if b-a<2:
    ans += k
else:
    if k-(a-1)>0:
        k = k-(a-1)
        if k%2==0:ans = k//2*(b-a)+a
        else: ans = k//2*(b-a)+a+1
    else:
        ans += k
print(ans)

Measured memory_bytes: 38496
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int c[26];

signed main()
{
    string s; cin>>s;
    REP(i,s.size()) c[s[i]-'a']++;

    REP(i,26){
        if(c[i]==0){
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
 
}


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

int main() {
	ll h=0;
	ll res=0;
	int count=0;
	cin >> h ;
	
	while (h != 1){
		h = floor(h/2);
		count++;
	}
	
	rep(i,count+1) res += pow(2,i);
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
//#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+ 5;
#define ll long long
#define inf 0x3f3f
#define mod 1000000007
#define endl '\n'
int fa[maxn];
int find(int x)
{
    if(x==fa[x])
        return x;
    else
        return fa[x]=find(fa[x]);
}
void Union(int x, int y)
{
	int fx = find(x), fy = find(y);
	fa[fx] = fy;
}
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	for (int i = 1; i < maxn; i++)fa[i] = i;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int x, y; cin >> x >> y;
		Union(x, y);
	}
	map<int, int>mp;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int t = find(i);
		mp[t]++;
		ans = max(ans, mp[t]);
	}cout << ans << endl;

}
	 


Measured memory_bytes: 13756
import sys

sys.setrecursionlimit(10000000)

#ボールの数、青いボールの数を書く
n,k=[int(i) for i in input().split()]

#modnum 定義
modnum=1000000007

#dp用のコンビネーションリスト
Cnklist=[None for i in range(2001)]
def Cnk(i):
    if Cnklist[i]!=None:
        return Cnklist[i]
    if i==0:
        Cnklist[0]=1
        return 1
    Cnklist[i]=(n-k+2-i)*Cnk(i-1)//i
    return Cnklist[i]

#dp用のコンビネーションリスト
Cklist=[None for i in range(2001)]
def Ck(i):
    if Cklist[i]!=None:
        return Cklist[i]
    if i==0:
        Cklist[0]=1
        return 1
    Cklist[i]=(k-i)*Ck(i-1)//i
    return Cklist[i]


for i in range(1,k+1):
    print((Cnk(i)*Ck(i-1))%modnum)

Measured memory_bytes: 43760
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

// Longest (Strictly) Increasing Sequence
class LIS{
public:
    vector<ll> S, L;
    LIS(vector<ll> S) : S(S) {}
    
    vector<ll> calc(){
        int len = 1; // length of LIS
        L.push_back(S[0]);
        rep(i, 1, S.size()){
            if (L[len - 1] < S[i]) {
                L.push_back(S[i]);
                len++;
            }
            else{
                int l = -1, r = len - 1;
                while (r - l > 1) {
                    int mid = (r + l) / 2;
                    if (L[mid] >= S[i]) {
                        r = mid;
                    }
                    else{
                        l = mid;
                    }
                }
                if(L[r] > S[i]) L[r] = S[i];
            }
        }
        return L;
    }
};
double pi = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    pair<ll, ll> S, G;
    cin >> S.first >> S.second >> G.first >> G.second;
    int N;
    cin >> N;
    vector<pair<ll, ll>> R(N);
    rep(i, N){
        cin >> R[i].first >> R[i].second;
    }
    
    if(S.first > G.first) {
        S.first *= -1, G.first *= -1;
        rep(i, N) R[i].first *= -1;
    }
    if(S.second > G.second){
        S.second *= -1, G.second *= -1;
        rep(i, N) R[i].second *= -1;
    }
    
    vector<ll> A;
    sort(all(R));
    for(auto r: R){
        if((r.first - S.first) * (r.first - G.first) <= 0 && (r.second - S.second) * (r.second - G.second) <= 0) {
            A.pb(r.second);
        }
    }
    
    vector<ll> L;
    if(A.size() > 0){
        LIS lis(A);
        L = lis.calc();
    }
    
    double ans = 0.0;
    int sz = (int)L.size();
    if(sz == min(abs(S.first - G.first), abs(S.second - G.second)) + 1) {
        sz--;
        ans = 10.0 * pi - 20.0;
    }
    ans += (5.0 * pi - 20.0) * sz;
    ans += 100.0 * (abs(S.first - G.first) + abs(S.second - G.second));
    
    output(ans, 15);
    
    return 0;
}

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

int main() {
  int A, B; cin >> A >> B;
  int ans = -1;

  int taxA, taxB;
  for (int i = 0; i < 100000; i++) {
    taxA = i * 0.08;
    taxB = i * 0.1;
    if (taxA == A && taxB == B) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int w,a,b;
    cin>>w>>a>>b;
    bool connected=false;
    if(a>=b&&a<=b+w){
        connected=true;
    }
    if(a+w>=b&&a+w<=b+w){
        connected=true;
    }
    if(b>=a&&b<=a+w){
        connected=true;
    }
    if(b+w>=a&&b+w<=a+w){
        connected=true;
    }
    if(connected){
        cout<<"0";
    }
    else{
        if(b<a){
            int temp=a;
            a=b;
            b=temp;
            
        }
        cout<<b-w-a;
    }
}

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

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

  int n;
  cin >> n;
  vi l(n);
  rep(i, n)cin >> l[i];

  int cnt=0;
  rep(i, n-1){
    for(int j=i+1; j<n; j++)
      for(int k=j+1; k<n; k++){
        if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
          if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i])cnt++;
        }
      }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
int main() {
  ll a, ans;
  cin >> a;
  ans = a + a * a + a * a * a;
  cout << ans;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
	int N, K, S;
	int i;
	if (scanf("%d%d%d", &N, &K, &S) != 3) return 1;
	for (i = 0; i < N; i++) {
		if (i > 0) putchar(' ');
		printf("%d", i < K ? S : (S == 1000000000 ? 1 : (S + 1)));
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a<b) return gcd(b,a);
  int r;
  while(r=a%b){
    a=b;
    b=r;
  }
  return b;
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n,0);
  for(auto& i:a) cin >> i;
  int ans = a[0];
  for(int i=0;i<n;i++) ans = gcd(ans,a[i]);
  cout << ans << endl;
  return 0;
}


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

static const int N = 1000;
int dp[N + 1][N + 1];

int lcs(string x, string y)
{
    int m = x.length();
    int n = y.length();
    x = ' ' + x;
    y = ' ' + y;

    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
        dp[i][0] = 0;
    for (int j = 1; j <= n; j++)
        dp[0][j] = 0;

    int res = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (x[i] == y[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    return dp[m][n];
}

int main()
{
    int n;
    cin >> n;
    string x1, x2;
    for (int i = 0; i < n; i++)
    {
        cin >> x1 >> x2;
        cout << lcs(x1, x2) << endl;
    }
    return 0;
}


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

#define MAX_W 100005
#define MAX_H 100005
int W,H;
ll p[MAX_W];
ll q[MAX_H];
P t[MAX_W+MAX_H];

int main(){
  scanf("%d %d",&W,&H);
  for(int i=0;i<W;i++){
    scanf("%lld",&p[i]);
    t[i]=P(p[i],0);
  }
  for(int i=0;i<H;i++){
    scanf("%lld",&q[i]);
    t[i+W]=P(q[i],1);
  }
  sort(t,t+W+H);
  ll hc=0,wc=0,ans=0;
  for(int i=0;i<W+H;i++){
    //    cout<<t[i].first<<' '<<t[i].second<<' '<<ans<<endl;
    if(t[i].second==0){
      wc++;
      ans+=(H+1-hc)*t[i].first;
    }else{
      hc++;
      ans+=(W+1-wc)*t[i].first;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int check(char x){
  if(x=='A' || x=='T' || x=='C' || x=='G'){
    return 1;
  }
  else{
  return 0;
  }
}

int main(){
  string S;
  cin>>S;
  int count_inside=0,count_outside=0,j=0;
  for(int i=0;i<S.size();i++){
    j=i;
    count_inside=0;
    while(check(S.at(j))==1){
      count_inside++;
      j++;
      if(j==S.size()){
      break;
      }
    }
    count_outside=max(count_inside,count_outside);
  }
  cout<<count_outside<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>

#define ll long long int
#define MAX 1000000

using namespace std;

int main(void)
{
	string s;

	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ',') {
			cout << " ";
		}
		else {
			cout << s[i];
		}


	}

	cout << endl;

	return (0);
}




Measured memory_bytes: 256
s = [i for i in input()]

ans = [0] * len(s)
c = 0
for i in range(len(s)):
    if s[i] == "R":
        c += 1
    if s[i] == "L":
        if c % 2 == 0:
            ans[i-1] += c // 2
            ans[i] += c // 2
        else:
            ans[i - 1] += c // 2 + 1
            ans[i] += c // 2
        c = 0


c = 0
for i in range(len(s) - 1, -1, -1):
    if s[i] == "L":
        c += 1
    if s[i] == "R":
        if c % 2 == 0:
            ans[i] += c // 2
            ans[i + 1] += c // 2
        else:
            ans[i] += c // 2
            ans[i + 1] += c // 2 + 1
        c = 0
a = [str(i) for i in ans]
print(" ".join(a))


Measured memory_bytes: 11548
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

n=int(input())
a=0
for i in range(55555):
  if primes(2000)[i]%5==1:
    print(primes(55555)[i],end=" ")
    a=a+1
  if a==n:
    break
print()

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


main(){
  char ST[10];
  int X[100],s,i=0;
  
  while(scanf("%s",ST) != EOF){
    if(ST[0] == '+'){
      X[i-2] = X[i-2] + X[i-1];
      i--;
    }
    else if(ST[0] == '-'){
      X[i-2] = X[i-2] - X[i-1];
      i--;
    }
    else if(ST[0] == '*'){
      X[i-2] = X[i-2] * X[i-1];
      i--;
    }
    else{
      s = atoi(ST);
      X[i] = s;
      i++;
    }
  }
  printf("%d\n",X[0]);
  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 101010
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
	string s,t;
	cin>>s>>t;
	string p=t.substr(0,s.length());
	if(p==s){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}	
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	

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

a = [0 for _ in range(n)]
a = [int(s) for s in input().split()]


st_num = 0
mny = 1000

for i in range(n-1):
    now_mn = a[i]
    next_mn = a[i+1]
    
    #print(st_num,mny)
    if(next_mn > now_mn):
        st_num += mny//now_mn
        mny = mny%now_mn
    else:
        mny += st_num*now_mn
        st_num = 0

if(a[n-1] > a[n-2] and st_num > 0):
    mny += st_num*a[n-1]
    st_num = 0

print(mny)

Measured memory_bytes: 9192
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s;
	cin>>n;
	for(int u=0;u<n;u++){
		cin>>s;
		cout<<"Case "<<u+1<<":"<<endl;
		for(int o=0;o<10;o++){
			s=s*s%1000000/100;
			cout<<s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int f (int n);

int main (void)
{
  int n;

  scanf("%d", &n);

  printf((n % f(n) == 0)? "Yes": "No");

  return 0;
}

int f (int n)
{
  int tmp = 0;
  while (n != 0) {
    tmp += n % 10;
    n /= 10;
  }

  return tmp;
}

Measured memory_bytes: 128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n,m,t;
	cin>>n>>m>>t;
	vvi in(m+1,{n});
	rep(i,t){
		int a,b;
		cin>>b>>a;
		a--;b--;
		in[a].pb(b);
	}
	rep(i,m)sort(all(in[i]));
	int out=inf;
	t=0;
	rep(i,m){
		cmin(out,*lower_bound(all(in[i]),t));
		t++;
		while(t<n&&*lower_bound(all(in[i+1]),t)==t)t++;
		if(t==n)break;
	}
	
	cout<<out<<endl;
}






Measured memory_bytes: 13440
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        List<Pair> list = new ArrayList<Pair>();
        for (int i = 0; i < n; i++) {
            int x = Integer.parseInt(scan.next());
            int y = Integer.parseInt(scan.next());
            list.add(new Pair(x, y));
        }
        scan.close();

        list.sort(new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                return o1.x + o1.y - (o2.x + o2.y);
            }
        });
        int ans = calc(list.get(0), list.get(n - 1));

        list.sort(new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                return (o1.x - o1.y) - (o2.x - o2.y);
            }
        });
        ans = Math.max(ans, calc(list.get(0), list.get(n - 1)));
        System.out.println(ans);
    }

    private static int calc(Pair a, Pair b) {
        return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
    }

    static class Pair {
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

    }

}


Measured memory_bytes: 67808
#include<stdio.h>
int main(void){
	int a,b,i;
	scanf("%d %d",&a,&b);
	if(a<b){
		for(i=1;i<=b;i++){
			printf("%d",a);
		}
	}else{
		for(i=1;i<=a;i++){
			printf("%d",b);
		}	}
	return 0;
}

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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (k <= a) {
    cout << a - k << " ";
    cout << b << endl;
  } else if (a + b <= k) {
    cout << 0 << " ";
    cout << 0 << endl;
  } else {
    cout << 0 << " ";
    cout << b - (k - a) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

struct Node
{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = x;

    if(y==NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;

}

void preOrder(Node *u){
    if(u == NIL) return;
    cout << " " << u->key;
    preOrder(u->left);
    preOrder(u->right);
}

void inOrder(Node *u){
    if(u == NIL) return;
    inOrder(u->left);
    cout << " " << u->key;
    inOrder(u->right);
}

int main(){
    int n,i,x;
    string com;

    cin >> n;
    
    for(int i=0;i<n;++i){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        } else if( com == "print"){
            inOrder(root);
            cout << endl;
            preOrder(root);
            cout << endl;
        }
    }
}


Measured memory_bytes: 26588
def solve():
    k = int(input())
    curr_num = 7
    for count in range(1, 10 ** 6 + 100):
        if curr_num % k == 0:
            print(count)
            return
        curr_num *= 10
        curr_num += 7
        curr_num %= k
    print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9156
import sys
sys.setrecursionlimit(10 ** 5 + 100)

def dfs(i, type_):
    if i >= N:
        return 0
    if dp[i][type_] != -1:
        return dp[i][type_]
    ret = 0
    for t in range(3):
        if t == type_:
            continue
        ret = max(ret, dfs(i + K, t))
    dp[i][type_] = ret + ((type_ + 1) % 3 == T[i]) * score[type_]
    return dp[i][type_]


N, K = map(int, input().split())
score = [int(x) for x in input().split()]
dic = {"r": 0, "s": 1, "p": 2}
T = [dic[x] for x in input()]
dp = [[-1] * 3 for _ in range(N)]
ans = 0
for i in range(K):
    ans += max(dfs(i, t) for t in range(3))
print(ans)


Measured memory_bytes: 103788
#import numpy as np
Q = int(1e9 + 7)

N, K = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)

if K == N:
    ans = 1
    for a in A:
        ans *= a
        ans %= Q
    print(ans)
    exit()
elif K == 1:
    ans = A[-1] % Q
    print(ans)
    exit()

A_mi, A_0, A_pl = [], [], []
for a in A:
    if a > 0:
        A_pl.append(a)
    elif a < 0:
        A_mi.append(a)
    else:
        A_0.append(a)

#答えが必ず0
if len(A_mi) + len(A_pl) < K:
    print(0)
    exit()

#全て正
if N == len(A_pl):
    ans, c = 1, 0
    for a in reversed(A_pl):
        ans *= a
        ans %= Q
        c += 1
        if c == K:
            break
    print(ans)
    exit()

#全て負or0
if N == len(A_mi) + len(A_0):
    if K % 2 == 0:
        ans, c = 1, 0
        for a in A_mi:
            ans *= a
            ans %= Q
            c += 1
            if c == K:
                break
        print(ans)
        exit()
    else:
        if len(A_0) > 0:
            print(0)
            exit()
        else:
            ans, c = 1, 0
            for a in reversed(A_mi):
                ans *= a
                ans %= Q
                c += 1
                if c == K:
                    break
            print(ans)
            exit()


cost_2 = []
if len(A_mi) > 1:
    for i in range(0, len(A_mi)-1, 2):
        cost_2.append(A_mi[i] * A_mi[i + 1])

c = 0
ans = 1

if K % 2 == 0:
    while True:
        if len(cost_2) > 0:
            c2 = cost_2[0]
        else:
            c2 = 0
        if len(A_pl) > 1:
            pl2 = A_pl[-1] * A_pl[-2]
        else:
            pl2 = 0
        if c2 > pl2:
            ans *= c2
            cost_2.pop(0)
        else:
            ans *= pl2
            A_pl.pop(-1)
            A_pl.pop(-1)
        ans %= Q
        c += 2
        if c == K:
            break
    print(ans)
else:
    while True:
        if (K - c > 1) and (len(cost_2) > 0):
            c2 = cost_2[0]
            if len(A_pl) > 2:
                pl2 = A_pl[-1] * A_pl[-2]
            else:
                pl2 = 0
            if c2 >= pl2:
                ans *= c2
                cost_2.pop(0)
            else:
                ans *= pl2
                A_pl.pop(-1)
                A_pl.pop(-1)
            ans %= Q
            c += 2
        else:
            ans *= A_pl[-1]
            ans %= Q
            c += 1
            A_pl.pop(-1)
        if K == c:
            break

    print(ans)


Measured memory_bytes: 31836
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,i,a[100005],count=1,k=1,flag=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{	scanf("%d",&a[i]);
	
	
	}
	i=1;
	
	while(a[i]!=2)
	{
		i=a[i];
		count++;
		k++;
		if(k==n)
			break;
		
		
	}
	
	if(k!=n)
	{
		printf("%d",count);
	}
	else
		printf("-1");

	

	return 0;
}


Measured memory_bytes: 512
package main

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

var r = bufio.NewReader(os.Stdin)

func main(){
    var a, b int
    fmt.Fscan(r, &a)
    fmt.Fscan(r, &b)
    if a > b {
        fmt.Println("a > b")
    } else if a < b {
        fmt.Println("a < b")
    } else {
        fmt.Println("a == b")
    }
}


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

using namespace std;

void B() {
    string S;
    cin >> S;
    bool ok = (S[0] == 'A' && islower(S[1]) && islower(S.back()));
    int cnt = 0;
    for (int i = 2; i < (int)S.size() - 1; i++) {
        cnt += S[i] == 'C';
        if (S[i] != 'C' && isupper(S[i])) {
            ok = false;
        }
    }
    ok &= (cnt == 1);
    cout << (ok ? "AC" : "WA") << endl;
}

int main() {
    B();
}


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

class Program
{
    static bool CanOnce(int index, int n, bool[] chk, bool[][] node)
    {
        chk[index] = true;
        if(chk.All(x => x))
            return true;
        else
            foreach(int i in Enumerable.Range(0, n).Where(x => !chk[x] && node[index][x]))
            {
                if(CanOnce(i, n, chk, node))
                    return true;
            }
        chk[index] = false;
        return false;
    }
    public void Slove()
    {   
        int n = 4;
        bool[][] connect =
            Enumerable.Range(0, n)
            .Select(x => new bool[n])
            .ToArray();
        foreach(int i in Enumerable.Range(0, 3))
        {
            var inputs = Console.ReadLine().Split();
            int a = int.Parse(inputs[0]) - 1;
            int b = int.Parse(inputs[1]) - 1;
            connect[a][b] = true;
            connect[b][a] = true;
        }
        bool result = Enumerable.Range(0, n).Any(x => CanOnce(x, n, new bool[n], connect));
        Console.WriteLine(result ? "YES": "NO");

    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 13652
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
vector<int> adj[1000002];
int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;
// }

void solve()
{
    int n;cin>>n;
    int a[n+1];
    a[0]=0;
    forf(i,1,n+1)
        cin>>a[i];
    
    unordered_map<int,int> m;
    forf(i,1,n+1)
        m[i+a[i]]++;
        
    int ans=0;
    forf(i,1,n+1)
    {
        ans+=m[(i-a[i])];
    }
    cout<<ans;
    
    
}

signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 43616
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp = 0;
	int n, d, x;
	cin >> n >> d >> x;
	ans = x;
	vector<int> a(n);
	REP(i, n){
		cin >> a[i];
		REP1(j, d) if(j %a[i] == 1 || a[i] == 1) ans ++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,k,q;
    cin >> n >> k >> q;
    int A[n] = {};
    int tmp;
    REP(i,q){
        cin >> tmp;
        tmp --;
        A[tmp] ++;
    }

    REP(i,n){
        if(A[i] <= q - k){
            cout << "No" << endl;
        }
        else cout << "Yes" << endl;
    }


}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#define max(a,b) ((a)>(b)?(a):(b))

int compare_int(const void *a,const void *b){
	return *(long long*)a-*(long long*)b;
}

int main(){
	int n,k,i,j;
	int v[50];
	long long ans=-2000000000000000000;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%d",&v[i]);
	if(k>=n*2){
		long long anss=0;
		for(i=0;i<n;i++){
			if(v[i]>0)anss+=v[i];
		}
		printf("%lld\n",anss);
		return 0;
	}
	long long tmp[50],c=0;
	for(i=0;i<=k;i++){
		for(j=0;j<=k-i;j++){
			c=0;
			if(i+j>n)continue;
			for(int l=0;l<i;l++)tmp[c++]=v[l];
			for(int r=0;r<j;r++)tmp[c++]=v[n-1-r];
			qsort(tmp,c,sizeof(long long),compare_int);
			int no=k-i-j;
			long long t=0;
			for(int l=0;l<c;l++){
				if(tmp[l]<0&&no>0)no--;
				else t+=tmp[l];
			}
			ans=max(ans,t);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

LL C[51][51];

void comb_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1;
			}
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<LL> V;
	LL v;
	for (int i = 0; i < n; i++) {
		cin >> v;
		V.emplace_back(v);
	}
	comb_table(n);
	sort(V.begin(), V.end(), greater<LL>());
	long double ans = 0.0;
	for (int i = 0; i < a; i++) {
		ans += V[i];
	}
	ans /= a;
	int anum = 0, apos = 0;
	for (int i = 0; i < n; i++) {
		if (V[i] == V[a - 1]) {
			anum++;
			if (i < a) {
				apos++;
			}
		}
	}

	LL count = 0;
	if (apos == a) {
		for (apos = a; apos <= b; apos++) {
			count += C[anum][apos];
		}
	}
	else {
		count += C[anum][apos];
	}
	cout << fixed << setprecision(7) << ans << endl;
	cout << count << endl;
}

Measured memory_bytes: 256
n=int(input())
x=[]
g=0
if n==0:
    print(0)
    exit()

if n<0:
    g=1
    n=abs(n)

if n>0:
    while n>0:
        x.insert(0,n%2)
        n=n//2
    m=len(x)
    for i in range(2*m):
        x.insert(0,0)
    m=len(x)
    for i in range(m):
        if i%2==1 and x[-i-1]==1:
            x[-i-2]+=1
        if x[-i-1]==2:
            x[-i-1]=0
            x[-i-2]+=1
    if g==1:
        for i in range(m):
            x[i]*=-1
        for i in range(m):
            if x[-i-1]==-1:
                x[-i-1]=1
                x[-i-2]+=1

    a=[]
    f=0
    for i in range(m):
        if x[i]!=0:
            f=1
        if f==1:
            a.append(x[i])
    m=len(a)
    for i in range(m):
        a[i]=str(a[i])
    print("".join(a))


Measured memory_bytes: 62100