akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    long long N;
    string ans = "";
    cin >> N;
    while (N)
    {
        if (N % 26 != 0)
            ans = char('a' + N % 26 - 1) + ans;
        else
            ans = 'z' + ans;
        N = (N - 1) / 26;
    }
    cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  
  int d[n];
  rep(i,n) cin >> d[i];
  
  sort(d,d+n);
  
  int ans = 1;
  rep(i,n-1){
    if(d[i] != d[i+1]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#if defined(LOCAL)
#include "C:\includes.hpp"
#include "C:\debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
  	cin.tie(0);
	int k, n;
	cin >> k >> n;
	vi a(n);
	forn(i, n)cin >> a[i];
	a.pb(a[0] + k);
	int ans = 0;
	forn(i, n)uax(ans, a[i + 1] - a[i]);
	deb(a);
	cout << k - ans << '\n';
    return 0;
}
    

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

int main(){
  int n;
  scanf("%d",&n);
  int a[n][3],b[n][3];
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
  }
  b[n-1][0]=a[n-1][0];
  b[n-1][1]=a[n-1][1];
  b[n-1][2]=a[n-1][2];
  for(int i=n-2;i>=0;i--){
    b[i][0]=max(b[i+1][1],b[i+1][2])+a[i][0];
    b[i][1]=max(b[i+1][0],b[i+1][2])+a[i][1];
    b[i][2]=max(b[i+1][1],b[i+1][0])+a[i][2];
  }
  printf("%d\n",max(b[0][0],max(b[0][1],b[0][2])));
}
    


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy";
	else if (s == "Cloudy") cout << "Rainy";
	else cout << "Sunny";
}

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

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

ll n, a, b;
std::vector<std::pair<int, int>> vec;
std::priority_queue<pii, std::vector<pii>, std::greater<pii>> q;

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a >> b;
        q.push(std::make_pair(b, a));
    }
    ll t = 0;
    while (!q.empty()) {
        auto e = q.top();
        t += e.second;
        if (t > e.first) {
            std::cout << "No" << std::endl;
            return 0;
        }
        q.pop();
    }
    std::cout << "Yes" << std::endl;

}


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int n, x = 0, y = 0;
	cin >> n;
	x = n*800;
	y = n / 15*200;
	cout << x - y << endl;
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

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

using namespace std;

const int N = 200010;

int a[N];
bool st[N];
int ans[N];

int main(){
	int n;
	long long k;
	scanf("%d%lld",&n,&k);
	for (int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
	}
	st[1] = true;
	int x = 1;
	int num = 0;
	ans[1] = 0;
	int kk = 0;
	for (int i = 1; i <= k ; i++){
		x = a[x];
		num++;
		if (st[x]){
			kk = num - ans[x];
			break;
		}
		else{
			ans[x] = num;
			st[x] = true;
		}
	}

	if (num >= k){
		int p = 1;
		for (int i = 1; i <= k; i++){
			p = a[p];

		}
		printf("%d\n",p);
		return 0;
	}

	long long  res = k - num;

	
	res = res  % kk;
	if (res == 0){
		printf("%d\n",x);
		return 0;
	}
	int y = x;

	for (int i = 1; i <= res; i++){
		y = a[y];
	}
	printf("%d\n",y);
}

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

int main(){
    int n,m;

    while(1){
        cin>>n>>m;
        if(n==0 && m==0){
            return 0;
        }

        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=0;
        int sum=0,sa=0,val=1e9;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=j){
                    sum=a[i]+a[j];
                    sa=m-sum;
                    if(m>=sum && sa<val){
                        ans=sum;
                        val=sa;
                    }
                }
            }
        }
        if(ans==0){
             cout<<"NONE"<<endl;   
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n;
  if(n <= 111) fin(111)
  else if(n <= 222) fin(222)
  else if(n <= 333) fin(333)
  else if(n <= 444) fin(444)
  else if(n <= 555) fin(555)
  else if(n <= 666) fin(666)
  else if(n <= 777) fin(777)
  else if(n <= 888) fin(888)
  else if(n <= 999) fin(999)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

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

    map<int, int> mp;
    ll ans = 0;
    rep(i, n){
        int J = i - a[i];
        int I = i + a[i];
        ans += mp[J];
        mp[I] += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20976
#include <stdio.h>

int main() 
{
    int n, k;
    scanf("%d", &n);
    scanf("%d", &k);
    int temp = n/2;
    int total = 1;
    for(int i = 1; i <= n; i++)
    {
    	if(2 * total <= total + k)
    	{
    		total *= 2;
		} else
		{
			total += k;
		}
	}
	printf("%d", total);
	
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

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

int main()
{
    string S; cin >> S;
    ll K; cin >> K;
    ll oddCount = 0;
    string C = S;
  	ll k = K/2;
  	if (S.size() == 1) {
      cout << k << endl;
      return 0;
    }
  
    for (ll i=0; i<S.size()-1; i++) {
        if (S.at(i) == 'R') continue;
        if (S.at(i) == S.at(i+1)) {
            S[i+1] = 'R';
            oddCount++;
        }
    }

    ll evenCount = 0;

    for (ll i=0; i<C.size()-1; i++) {
        if (i==0) {
            char last = S.at(S.size()-1);
            if (last != 'R' && C.at(0) == last) {
                C[0] = 'R';
                evenCount++;
            }
        }
      	
        if (C.at(i) == 'R') continue;
        
        if (C.at(i) == C.at(i+1)) {
            C[i+1] = 'R';
            evenCount++;
        }
      
      	
     }
	if (C.at(0) == 'R' && C.at(S.size()-1) != 'R') {
      	cout << ((oddCount) + (evenCount*(K-1))) << endl;
    } else {
    	cout << ((oddCount*(K-k)) + (evenCount*k))<< endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;	cin >> s;
  bool ok=true;
  
  for(int i=0;i<s.size();i+=2){
    if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')){
      ok=false;
    }
  }
  
  for(int i=1;i<s.size();i+=2){
    if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')){
      ok=false; 
    }
  }
  
  
  if(ok)	cout << "Yes";
  else cout << "No";
}

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

int P, Q, R;

int eval(string S, int &cur)
{
    // cerr << cur << endl;
    if (S[cur] == '(')
    {
        cur++;
        int val1 = eval(S, cur);
        char op = S[cur];
        cur++;
        int val2 = eval(S, cur);
        int val = 0;
        if (op == '+')
        {
            val = max(val1, val2);
        }
        else if (op == '*')
        {
            val = min(val1, val2);
        }
        // cerr << val1 << ' ' << val2 << ' ' << cur << endl;
        cur++;
        return val;
    }
    else if (S[cur] == '-')
    {
        cur++;
        int val = eval(S, cur);
        if (val == 0)
            return 2;
        else if (val == 1)
            return 1;
        else if (val == 2)
            return 0;
    }
    else
    {
        int val = 0;
        if (S[cur] == 'P')
        {
            val = P;
        }
        else if (S[cur] == 'Q')
            val = Q;
        else if (S[cur] == 'R')
            val = R;
        else
            val = (int)(S[cur] - '0');
        cur++;
        return val;
    }
}

int main()
{
    string S;
    while (cin >> S, S != ".")
    {
        int res = 0;
        for (P = 0; P <= 2; P++)
        {
            for (Q = 0; Q <= 2; Q++)
            {
                for (R = 0; R <= 2; R++)
                {
                    int c = 0;
                    // cerr << P << ' ' << Q << ' ' << R << ':' << eval(S, c) << endl;
                    // cerr << c << endl;
                    c = 0;
                    if (eval(S, c) == 2)
                        res++;
                }
            }
        }
        // int c = 0;
        // cerr << eval(S, c) << endl;
        // cerr << c << endl;

        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
import math, sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

def prime(n):
    p = []
    min_p = [0 for i in range(n - 1)]
    flag = [True] * (n - 1)
    for i in range(n - 1):
        if flag[i] == True:
            p.append(i + 2)
            num = i
            while num <= n - 2:
                if flag[num] == True:
                    min_p[num] = i + 2
                flag[num] = False
                num += i + 2
    return p, min_p

gcd = 0
for i in range(n):
    gcd = math.gcd(gcd, a[i])
if gcd != 1:
    print("not coprime")
else:
    p = prime(max(a))
    p_list = {i:0 for i in p[0]}
    min_p = p[1]
    flag = True
    for i in a:
        temp = set()
        while i != 1:
            temp.add(min_p[i - 2])
            i //= min_p[i - 2]
        for j in temp:
            if p_list[j] == 1:
                flag = False
                break
            else:
                p_list[j] += 1
        if flag == False:
            print("setwise coprime")
            break
    else:
        print("pairwise coprime")

Measured memory_bytes: 207092
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	string S;
	int i, j;
	int num100 = 0;
	int num10 = 0;
	int num1 = 0;
	int num = 0;
	int nummin = 99999;
	cin >> S;


	for (i = 0; i < S.size()-2; ++i) {
		num100 =100*( S[i]-48);
		num10 =10*(S[i + 1] - 48);
		num1 = S[i + 2] - 48;
		num = num100 + num10 + num1;
		if (nummin > abs(753 - num)) {
			nummin = abs(753-num);
		}



		num100 = 0;
		num10 = 0;
		num1 = 0;
		num = 0;
	}

	cout << nummin << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i,m){
        int d,e; cin >> d >> e; d--; e--;
        a[d]++;a[e]++;
    }

    rep(i,n){
        cout << a[i] << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string S,s;
long long K,cnt;
int main(){
    cin>>S>>K;
    string s(S.size(),char(S[0]));
    if(S==s){cout<<(S.size()*K)/2LL<<endl;return 0;}
    for(int i=1;i<S.size();i++)if(S[i-1]==S[i])cnt++,i++;
    if(S[0]!=S.back()){cout<<cnt*K<<endl;return 0;}
    int a=0,b=0;
    while(S[a]==S[0])a++;
    while(S[S.size()-1-b]==S[S.size()-1])b++;
    cout<<cnt*K-(a/2+b/2-(a+b)/2)*(K-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int H,W;
    cin >> H >> W;
    rep(i,0,H){
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
  solve(sc)
}

fun solve(sc: java.util.Scanner) {
  val A = sc.nextInt()
  val B = sc.nextInt()
  val C = sc.nextInt()
  for (x in 1..B) {
    if ((A * x % B) == C) {
      println("YES")
      return
    }
  }
  println("NO")
}


Measured memory_bytes: 31264
#include<bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, N = 3005;

int n, m, f[N][N][2];

void up (int &a, int b) { a += b; if (a >= P) a -= P; }

int main () {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) f[0][i][0] = 1;
	f[0][0][1] = 1;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j <= n; ++j) {
			for (int o = 0; o < 2; ++o) if (f[i][j][o]) {
				if (j) up(f[i + 1][j - 1][(j == 1) | o], f[i][j][o]), up(f[i + 1][j][(j == 1) | o], f[i][j][o]);
				if (j < n) up(f[i + 1][j + 1][o], f[i][j][o]), up(f[i + 1][j][o], f[i][j][o]);
			}
		}
	}
	int ret = 0; for (int i = 0; i <= n; ++i) up(ret, f[m][i][1]); printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 70656
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    let k: i32 = input();

    let mut ans = 0.0;
    for i in 1..n + 1 {
        let mut p = 1.0 / n as f64;
        let mut now = i;
        while now < k {
            now *= 2;
            p *= 0.5;
        }
        ans += p;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    string s;
    cin>>s;
    if(s[0]=='7' or s[1]=='7' or s[2]=='7')
      cout<<"Yes ";
    else
      cout<<"No ";
} 

Measured memory_bytes: 3652
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v,pick[200000];
map<string, vector<LL>>ma;
multiset<LL>st[3];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct vecter {
	double x, y, r, norm;
	vecter() {}
	vecter(double x_, double y_) :x(x_), y(y_) {
		norm = x * x + y * y;
		r = sqrt(x*x + y * y);
	}
	vecter operator+(vecter v) {
		return vecter(x + v.x, y + v.y);
	}
	vecter operator-(vecter v) {
		return vecter(x - v.x, y - v.y);
	}
	vecter operator/(double k) {
		return vecter(x/k, y/k);
	}
	vecter operator*(double k) {
		return vecter(x*k,y*k);
	}
	double operator*(vecter v) { //内積
		return x * v.x + y * v.y;
	}
	double angle(vecter v) { //なす角(Radians)
		if((r * v.r)>0)
		return acos(*this*v / (r * v.r));
		else return 0;
	}
	vecter unit() {
		return (r == 0 ? vecter() : vecter(x, y) / r);
	}
};
int main() {
	double x, y;
	cin >> x >> y;
	vecter p1(x, y);
	cin >> x >> y;
	vecter p2(x, y);
	cin >> n;
	rep(i, n) {
		cin >> x >> y;
		vecter P(x, y);
		vecter cur=p1+(p2-p1).unit()*(P - p1).r*cos(((vecter)(p2 - p1)).angle((vecter)(P - p1)));
		vecter ret = P + (cur - P) * 2;
		printf("%.15f %.15f\n", ret.x,ret.y);
	}
	return 0;
}



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

long long n, m, l, d, c = 0, t = 0;
long long a[100000];
bool f = 0;

long long gcd(long long a, long long b) {
   long long p = a, q = b, r = a % b;

   while (r > 0) {
       p = q;
       q = r;
       r = p % q;
   }

   return q;
}

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

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

    l = a[0];

    for (int i = 0; i < n; i++) {
        d = gcd(l, a[i]);

        if (((l / d) % 2 == 0) || ((a[i] / d) % 2 == 0)) {
            f = 1;
            break;
        }
        else{
            l *= a[i] / d;

            if (l / 2 > m)
                break;
        }
    }

    if(!f)
        c = m / l + (m % l) / (l / 2);

    cout << c << endl;
    
    return 0;
}


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

int main() {
    using namespace std;
    unsigned long N, Q;
    cin >> N >> Q;
    vector<pair<long, long>> s(N), t(N);
    for(unsigned long i = 0, X; i < N; ++i){
        cin >> s[i].first >> t[i].first >> X;
        s[i].second = t[i].second = X;
        s[i].first -= X;
        t[i].first -= X;
    }
    auto cmp = [&s](auto a, auto b){
        return s[a] > s[b];
    };
    auto cmp2 = [&t](auto a, auto b){
        return t[a] > t[b];
    };
    priority_queue<unsigned long, vector<unsigned long>, decltype(cmp)> pq1(cmp);
    priority_queue<unsigned long, vector<unsigned long>, decltype(cmp2)> pq2(cmp2);
    for(unsigned long i = 0; i < N; ++i)pq1.push(i);
    multiset<long> S;
    auto it1 = s.begin(), it2 = t.begin();
    for(long i = 0, D; i < Q; ++i){
        cin >> D;
        while(!pq1.empty() && s[pq1.top()].first <= D){
            pq2.push(pq1.top());
            S.insert(s[pq1.top()].second);
            pq1.pop();
        }
        while(!pq2.empty() && t[pq2.top()].first <= D){
            S.erase(S.find(t[pq2.top()].second));
            pq2.pop();
        }
        cout << (S.empty() ? -1 : *S.begin()) << endl;
    }
    return 0;
}

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

#define ucin ios::sync_with_stdio(0), cin.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;

const int N = 3000 + 10;
const int mod = 998244353;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}
int n, s, a[N];
ll dp[N][N];
int main() {
	scanf("%d%d", &n, &s);
	for(int i = 1; i <= n; i ++) scanf("%d", a + i);
	ll ans = 0;
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= s; j ++) {
			dp[i][j] = (dp[i - 1][j] + (j >= a[i] ? dp[i - 1][j - a[i]] : 0)) % mod;
		}
		if(a[i] <= s) (dp[i][a[i]] += i) %= mod;
		if(s >= a[i]) (ans += dp[i - 1][s - a[i]] * (n - i + 1ll) % mod) %= mod;
		if(a[i] == s) (ans += 1ll * i * (n - i + 1ll) % mod) %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin>>n;
    int s=0;
    int m=n;
    while(m>0){
        s+=m%10;
        m/=10;
    }
    if(n%s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

struct edge {int f, t, c;};
const int MINF = -1e18;

V(edge) E;
vi dis(1050, MINF);
int N, M;
V(bool) T(1050, false);
bool updated;

void update(int &x, int y) {
    if(x < y) {
        x = y;
        updated = true;
    }
}

void bellmanford() {
    dis[0] = 0;
    rep(i, N) {
        rep(j, M) {
            updated = false;
            update(dis[E[j].t], dis[E[j].f]+E[j].c);
            if(updated) T[E[j].t] = true;
            else T[E[j].t] = false;
        }
    }
}

signed main(){
    cin >> N >> M;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        E.pb(edge{a, b, c});
    }

    int res = 0;
    bellmanford();
    if(T[N-1]) cout << "inf" << endl;
    else cout << dis[N-1] << endl;
    
    return 0;
}

Measured memory_bytes: 384
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

//双方向リスト
typedef struct Node {
  int key;
  Node *prev, *next;
} Node;

Node *nil; //番兵
//リストの初期化
void init() {
  nil = (Node *) malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

//値keyを持つノードを番兵の直後に追加
void insert(int key) {
  Node *child = (Node *) malloc(sizeof(Node));
  child->key = key;
  child->next = nil->next;
  nil->next->prev = child; //最初の挿入時はnil->next == nil, nil->prevで最後の要素を指すようになる
  nil->next = child;
  child->prev = nil;
}

//keyを持つノードのポインタを返す
Node* listSearch(int key) {
  Node* cur = nil->next; //番兵の次の要素が最初の要素
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

//ノードtを削除
void deleteNode(Node *t) {
  if (t == nil) { //番兵は削除しない
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t); //ノードtのための領域を解放
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

//keyを持つノードを検索して削除
void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void printList() {
  Node *cur = nil->next;
  bool isFirst = true;
  while (true) {
    if (cur == nil) {
      break;
    }
    if (!isFirst) { //要素間の空白, 初回時だけプリントしない
      printf(" ");
    } else {
      isFirst = false;
    }
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void solve() {
  init();
  int n, key;
  char com[20];
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%s", com);
    if (strlen(com) > 6) { //deleteLast, deleteFirst
      if (com[6] == 'L') {
        deleteLast();
      } else {
        deleteFirst();
      }
    } else {
      scanf("%d", &key);
      if (com[0] == 'i') {
        insert(key);
      } else {
        deleteKey(key);
      }
    }
  }
  printList();
}
int main() {
  solve();
  return 0;
}



Measured memory_bytes: 34432
#include <string>/*{{{*/
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#define FOR(i, b, e) for (typeof(b) i = (b); i != (e); ++i)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;/*}}}*/

int main(int argc, char const* argv[])
{
	int n, m, a;
	int lines[100][1000];
	while (cin >> n >> m >> a, n || m || a) {
		FOR(i, 0, 100) {
			FOR(j, 0, 1000) {
				lines[i][j] = 0;
			}
		}
		FOR(i, 0, m) {
			int h, p, q;
			cin >> h >> p >> q;
			if (p > q) {
				swap(p, q);
			}
			lines[p-1][h-1] = 1;
			lines[q-1][h-1] = -1;
		}
		int pos = a - 1;
		for (int i = 999; i >= 0; --i) {
			pos += lines[pos][i];
		}
		cout << pos + 1 << endl;
	}
	return 0;
}

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

ll mod_pow(ll a, ll b){
    if(b == 0) return 1LL;
    if(b%2){
        ll tmp = mod_pow(a,(b-1)/2);
        return a*tmp%MOD*tmp%MOD;
    }else{
        ll tmp = mod_pow(a,b/2);
        return tmp%MOD*tmp%MOD;
    }
}

ll mod_combination(ll n, ll r){
    if(r > n) return 0;
    if(r == 0) return 1;
    ll fact1 = 1,fact2 = 1;
    for(ll i = 0; i < r; ++i){
        fact1 = fact1*(n-i)%MOD;
        fact2 = fact2*(i+1)%MOD;
    }
    return fact1*mod_pow(fact2,MOD-2)%MOD;
}

bool isPrime(ll n){
    if(n < 2) return false;
    for(ll i = 2; i*i <= n; ++i) if(n%i == 0) return false;
    return true;
}

ll mcnt(ll m, ll i){
    ll cnt = 0;
    while(m%i == 0){
        m /= i;
        cnt++;
    }
    return cnt;
}

int main(){
    ll n,m; cin >> n >> m;
    ll cnt; //mの素因数の数
    ll ans = 1;
    for(ll i = 1; i*i <= m; ++i){
        if(m % i == 0){
            if(isPrime(i)){
                cnt = mcnt(m, i);
                ans = ans*mod_combination(cnt + n - 1, cnt)%MOD;
            }
            if(isPrime(m/i)){
                cnt = mcnt(m, m/i);
                ans = ans*mod_combination(cnt + n - 1, cnt)%MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int x=Integer.parseInt(br.readLine());
		ArrayDeque<Integer> list=new ArrayDeque<Integer>();
		for (int i = 0; i < x; i++) {
			String s=br.readLine();
			if(s.charAt(0)=='i'){
				list.addFirst(Integer.parseInt(s.substring(7)));
			}
			else if(s.charAt(6)==' '){
				list.remove(Integer.parseInt(s.substring(7)));
			}else if(s.charAt(6)=='F'){
				list.removeFirst();
			}else{
				list.removeLast();

			}
		}
		pw.print(list.poll());
		for (Integer integer : list) {
			pw.print(" "+integer);
		}
		pw.println();
		pw.close();
	}

}

Measured memory_bytes: 117824
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  vector<string> a(n);
  vector<string> b(m);
  
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  int times = n-m+1;
  rep(i,times){
    rep(j,times){
      bool ok=true;
      rep(k,m){
        if(!(a[i+k].substr(j,m)==b[k])){
          ok = false;
          break;
        }
      }
      if(ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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

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

int A[10];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	ll all = 1, sub = 1;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		all *= 3;
		if(A[i] % 2) sub *= 1;
		else sub *= 2;
	}
	cout << all - sub << endl;

}


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

int main()
{
    int N, a;
    cin >> N;

    int chk = 1;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a == chk) {
            chk++;
        }
    }

    if (chk == 1) {
        cout << -1 << endl;
    }
    else {
        cout << N - chk + 1 << endl;
    }
}

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

int main() {
    int n,h,preh,ans=0,temp=0;
    cin>>n;
    rep(i,n) {
        preh = h;
        cin>>h;
        if(preh<h) {
            ans=max(temp,ans);
            temp=0;
        }else{
            temp++;
        }
            ans=max(ans,temp);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    else b--;
    cout << a << " " << b << endl;
}

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


Measured memory_bytes: 3584
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD= 998244353;
//Variables End

ll mul(ll a,ll b){return (a*b)%MOD;}
ll sub(ll a,ll b){return (a-b+MOD)%MOD;}

ll modexp(ll pow,ll num){
	ll ret=1;
	while(pow){
		if(pow&1) ret = mul(ret,num);
		num = mul(num,num);
		pow/=2;
	}
	return ret;
}
ll modinv(ll num){
	return modexp(MOD-2,num);
}
void solve(){
	ll n,m,k;cin>>n>>m>>k;
	vector<ll> ans(n+1,0),val(n+1,0);
	val[k+1]=m;
	for(ll i=k+2;i<=n;i++){
		val[i] = mul( mul( val[i-1],mul(i-1,m-1) ) , modinv(i-k-1) );
		//cout<<val[i]<<endl;
	}
	ans[0] = 1;
	for(int i=1;i<=n;i++){
		ans[i] = mul(m,ans[i-1]);
		ans[i] = sub(ans[i],val[i-1]);
		//cout<<ans[i]<<endl;
	}
	
	cout<<ans[n]<<endl;
	 
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a , b , c ;
	cin >> a >> b >> c ;
	if(a + b < c  ) cout <<"NO"<< endl;
	else {
        if(a > c){
            if(b > c) cout <<"NO"<< endl;
            else if (b == c) cout <<"YES"<< endl;
            else cout <<"NO"<< endl;
        }else {
            if(a == c) cout <<"YES"<< endl;
            else {
                if(a + b == c ) cout <<"YES"<< endl;
                else {
                    int k = c - a ;
                    if(k <= b ) cout <<"YES"<< endl;
                    else cout <<"NO"<< endl;
                }
            }
        }

	}
}


Measured memory_bytes: 256
using System;

namespace abc144A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A <= 9 && B <= 9)
            {
                Console.WriteLine(A * B);
            }
            else
                Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13140
#include <stdlib.h>
#include <stdio.h>
                                                            
typedef struct { int id, parent, left, right; } node;                                       
                                                                                  
static int dig(node *nodes, int *depths, int *heights, int id, int depth) {
  int d, d1, d2;
  if (id != -1) {
    depths[id] = depth;   
    d1 = dig(nodes, depths, heights, nodes[id].left, depth + 1);
    d2 = dig(nodes, depths, heights, nodes[id].right, depth + 1);
    d = d1 > d2 ? d1 : d2;                 
    heights[id] = d - depth;
  } else {
    d = depth - 1;
  }
  return d;
}

int main(int argc, char **argv) {
  int n, i, id, sibling, degree, root;
  node *nodes;
  int *depths;
  int *heights;
  char *type;

  scanf("%d", &n);
  nodes = (node *) malloc(sizeof(node) * n);
  for (i = 0; i < n; ++i) {
    nodes[i].id = nodes[i].parent = nodes[i].left = nodes[i].right = -1;
  }
  for (i = 0; i < n; ++i) {
    scanf("%d", &id);
    nodes[id].id = id;
    scanf("%d %d", &nodes[id].left, &nodes[id].right);
    nodes[nodes[id].left].parent = nodes[nodes[id].right].parent = id;
  }
  for (i = 0; i < n; ++i) {
    if (nodes[i].parent == -1) {
      root = i;
      break;
    }
  }
  depths = (int *) malloc(sizeof(int) * n);
  heights = (int *) malloc(sizeof(int) * n);
  dig(nodes, depths, heights, root, 0);
  for (i = 0; i < n; ++i) {
    if (nodes[i].parent == -1) {
      type = "root";
    } else if (nodes[i].left == -1 && nodes[i].right == -1) {
      type = "leaf";
    } else {
      type = "internal node";
    }
    sibling = -1;
    if (nodes[i].parent != -1) {
      if (nodes[nodes[i].parent].left == i) {
        sibling = nodes[nodes[i].parent].right;
      } else {
        sibling = nodes[nodes[i].parent].left;
      }
    }
    degree = (nodes[i].left != -1) + (nodes[i].right != -1);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
      nodes[i].id, nodes[i].parent, sibling, degree, depths[i], heights[i], type);
  }
  free(nodes);
  free(depths);
  // free(heights); // WTF
  exit(0);
}


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

int main() {
  int N ,M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) cin >> t[i];
  int max = 0;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < N; j++) if (s[i] == s[j]) cnt++;
    for (int k = 0; k < M; k++) if (s[i] == t[k]) cnt--;
    if ( cnt > max) max = cnt;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

from collections import defaultdict

def main():
	n=II()
	A=LI()
	
	X=defaultdict(int)
	Y=defaultdict(int)
	
	for i,v in enumerate(A):
		X[i+v]+=1
		Y[i-v]+=1
	
	ans=0
	for k,v in X.items():
		ans+=v*Y[k]
	print(ans)
	
	







if __name__=="__main__":
	main()


Measured memory_bytes: 74168
N, M = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

def is_half_lcm(ary)
  if ary.all?{|a| a.odd?} then
    true
  elsif ary.all?{|a| a.even?} then
    is_half_lcm(ary.map{|a| a / 2})
  else
    false
  end
end

if is_half_lcm(A.map{|a| a / 2}) then
  hlcm = 1
  A.each{|a|
    hlcm = hlcm.lcm(a / 2)
    break if hlcm > M
  }
  puts hlcm > M ? 0 : (((M - hlcm) / (2 * hlcm)) + 1)
else
  puts 0
end


Measured memory_bytes: 32268
N = int(input())
S = input()

original_w = []
prev = 0
for i in range(N):
    if S[i] == 'W':
        prev += 1
    original_w.append(prev)

original_e = []
prev = 0
for i in range(N - 1, -1, -1):
    if S[i] == 'E':
        prev += 1
    original_e.append(prev)

ans = min(original_e[N - 1], original_w[N - 2])
for i in range(1, N - 1):
    ans = min(ans, original_w[i - 1] + original_e[N - (i + 1)])
print(ans)


Measured memory_bytes: 17832
n = int(input())
list = input().split()

for i in range(n // 2):
    list[i], list[n - 1 - i] = list[n - 1 - i], list[i]
    
for i in range(n):
    if i != n - 1:
        print("%s " % list[i], end="")
    else:
        print("%s" % list[i])


Measured memory_bytes: 5612
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int[] a = new int[3];
    for (int i = 0; i < a.length; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);
    int cost = 0;
    for (int i = 1; i < a.length; i++) {
      cost += a[i] - a[i - 1];
    }
    System.out.println(cost);
  }
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		var n = my.GetInt();
		
		for(int i = 0; i < n; i++) {
			var p = my.GetDoubleArray();
			
			var d = Math.Sqrt( (p[0]-p[3])*(p[0]-p[3]) + (p[1]-p[4])*(p[1]-p[4]) );
			
			var rr = Math.Abs(p[2]-p[5]);
			
			if(d > p[2]+p[5])	Console.WriteLine(0);
			else if(d <= p[2]+p[5] && d>= rr)	Console.WriteLine(1);
			else if(d < rr && p[2] > p[5] )	Console.WriteLine(2);
			else if(d < rr && p[2] < p[5] )	Console.WriteLine(-2);
		}
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	private static double[] GetDoubleArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteVector(Vector v)
	{
		Console.WriteLine(string.Format("{0:f8} {1:f8}", v.X, v.Y));
	}
}

public struct Vector
{
	public double X,Y;
}

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

int main()
{
    int n;
    scanf("%d", &n);
    int *a = (int*)malloc(n * sizeof(int));
    int *b = (int*)malloc(n * sizeof(int));
    int i;
    int max = 0;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        b[i] = 0;
    }
    for(i=n-1; i>0; i--) {
        if(a[i-1] >= a[i]) {
            b[i-1] = b[i] + 1;
        }
    }

    for(i=0; i<n; i++) {
        if(b[i] > max) {
            max = b[i];
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
	int a, b,holl ;
	int ans;
	holl = 1;
	cin >> a >> b;
	for (int i = 0; i < 30; i++) {
		if (holl >= b) { ans = i; break; }
		holl += a-1;
		
	}
	cout << ans << endl;

}


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

int main () {
	string s;
	cin >> s;
	int n = s.size(), l = 0, r = n + 1;
	auto f = [&](int k) {
		for (int i = n - k + 1; i < k; i++) {
			if (s[i - 1] != s[i]) {
				return false;
			}
		}
		return true;
	};
	while (1 < r - l) {
		int mid = (l + r) / 2;
		(f(mid) ? l : r) = mid;
	}
	cout << l << endl;
	return 0;
}

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

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int n;
    cin >> n;

    int o;
    if(n<10) o=n;
    else if(n<100) o=9;
    else if(n<1000) o=n-90;
    else if(n<10000) o=909;
    else if(n<100000) o=n-9090;
    else o=90909;

    cout << o << endl;
    return 0;
}


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

int main() {
  int a;
  cin >> a;
  int b[100001];
  long long int c,d,e,f;
  long long int sum=0;
  for(int i = 0;i<100001;i++){
    b[i]=0;
  }
  for(int i = 0;i<a;i++){
    cin >> c;
    b[c]++;
    sum += c;
  }
  cin >> d;
  for(int i=0;i<d;i++){
    cin >> e >> f;
    sum +=(f-e)*b[e];
    cout << sum << endl;
    b[f] += b[e];
    b[e] = 0;
  }
}


Measured memory_bytes: 4000
import fractions
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import functools

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def lcm_base(x,y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

n,m = LI()
a = [int(i)//2 for i in LI()]

def num_of_2(x):
    c = 0
    while x%2==0:
        c+=1
        x//=2
    return c

a0 = num_of_2(a[0])
if any([num_of_2(i) != a0 for i in a]):
    print(0)
else:
    def lcm(x,y):
        return x//fractions.gcd(x,y)*y

    c = 1
    for i in a:
        c = lcm(c,i)
        if c>=inf:
            break
    
    ans = m//c
    print((ans+1)//2)

Measured memory_bytes: 16356
#include <stdio.h>
int main()
{
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
  d = a/b;
  r = a%b;
  f = 1.0*a/b;
  printf("%d %d %.5f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 640
import itertools
S = input()
ans = 'NO'
for i, j, k, l in itertools.product(range(2), repeat = 4):
    if S == i*'A' + 'KIH' + j*'A' + 'B' + k*'A' + 'R' + l*'A':
       ans = 'YES'
print(ans)

Measured memory_bytes: 3060